function Hammer() {
	this.hammerType = Hammer.TYPE_PPYONG;
	this.upgradeCountdown = Hammer.UPGRADE_COUNT_PPYONG;

	this.hammer = game.add.image(game.world.centerX + 125, 220, "hammer_ppyong");
	this.hammer.anchor.x = 0.5;
	this.hammer.anchor.y = 1;
	this.hammer.scale.set(1.5);

	this.upgradeCountdownText = game.add.text(game.world.centerX + 140, 170, this.upgradeCountdown);
}

Hammer.prototype.smash = function() {
	this.tween = game.add.tween(this.hammer)
		.from( { angle: -90 }, 10 )
		.to( { angle: 0 }, BigMole.SHOW_UP_TIME_MS, "Quart.easeOut");
	this.tween.start();

	this.showParticle();

	var scoreText = new ScoreText(
		game.world.centerX,
		BigMole.START_POS_Y - Hammer.OFFSET_SCORE_POS_Y,
		this.getScore()
	);

	this.cleanHit();
}

Hammer.prototype.showParticle = function() {
	var particleCount = 0;
	var particleTint = 0xffffff;
	var particleScale = 1;
	switch(this.getType()) {
		case Hammer.TYPE_PPYONG:
		particleCount = Hammer.SCORE_PPYONG;
		particleTint = Hammer.COLOR_PPYONG;
		particleScale = 3;
		break;

		case Hammer.TYPE_WOOD:
		particleCount = Hammer.SCORE_WOOD;
		particleTint = Hammer.COLOR_WOOD;
		particleScale = 2;
		break;

		case Hammer.TYPE_BRONZE:
		particleCount = Hammer.SCORE_BRONZE;
		particleTint = Hammer.COLOR_BRONZE;
		particleScale = 1;
		break;

		case Hammer.TYPE_SILVER:
		particleCount = Hammer.SCORE_SILVER;
		particleTint = Hammer.COLOR_SILVER;
		particleScale = 0.8;
		break;

		case Hammer.TYPE_GOLD:
		particleCount = Hammer.SCORE_GOLD;
		particleTint = Hammer.COLOR_GOLD;
		particleScale = 0.5;
		break;
	}

	var hitStarEmitter = game.add.emitter(
		game.world.centerX,
		BigMole.START_POS_Y - Hammer.OFFSET_SCORE_POS_Y,
		particleCount
	);
	hitStarEmitter.makeParticles('star');
	hitStarEmitter.forEach(
		function(particle) {
			particle.tint = particleTint;
			particle.scale.set(particleScale);
		}
	);
	hitStarEmitter.gravity = 0;
	hitStarEmitter.start(true, 1000, null, 100);
}

Hammer.prototype.getType = function() {
	return this.hammerType;
}

Hammer.prototype.cleanHit = function() {
	if(this.hammerType == Hammer.TYPE_GOLD)
		return;

	this.upgradeCountdown--;
	this.upgradeCountdownText.text = this.upgradeCountdown;

	if(this.upgradeCountdown > 0)
		return;

	if(this.hammerType == Hammer.TYPE_PPYONG)
		this.changeType(Hammer.TYPE_WOOD);
	else if(this.hammerType == Hammer.TYPE_WOOD)
		this.changeType(Hammer.TYPE_BRONZE);
	else if(this.hammerType == Hammer.TYPE_BRONZE)
		this.changeType(Hammer.TYPE_SILVER);
	else if(this.hammerType == Hammer.TYPE_SILVER)
		this.changeType(Hammer.TYPE_GOLD);
}

Hammer.prototype.changeType = function(hammerType) {
	switch(hammerType) {
		case Hammer.TYPE_PPYONG:
		this.hammerType = Hammer.TYPE_PPYONG;
		this.upgradeCountdown = Hammer.UPGRADE_COUNT_PPYONG;
		this.hammer.loadTexture("hammer_ppyong");
		break;

		case Hammer.TYPE_WOOD:
		this.hammerType = Hammer.TYPE_WOOD;
		this.upgradeCountdown = Hammer.UPGRADE_COUNT_WOOD;
		this.hammer.loadTexture("hammer_wood");
		break;

		case Hammer.TYPE_BRONZE:
		this.hammerType = Hammer.TYPE_BRONZE;
		this.upgradeCountdown = Hammer.UPGRADE_COUNT_BRONZE;
		this.hammer.loadTexture("hammer_bronze");
		break;

		case Hammer.TYPE_SILVER:
		this.hammerType = Hammer.TYPE_SILVER;
		this.upgradeCountdown = Hammer.UPGRADE_COUNT_SILVER;
		this.hammer.loadTexture("hammer_silver");
		break;

		case Hammer.TYPE_GOLD:
		this.hammerType = Hammer.TYPE_GOLD;
		this.upgradeCountdown = Hammer.UPGRADE_COUNT_GOLD;
		this.hammer.loadTexture("hammer_gold");
		break;
	}

	if(this.hammerType == Hammer.TYPE_GOLD)
		this.upgradeCountdownText.text = "";
	else
		this.upgradeCountdownText.text = this.upgradeCountdown;
}

Hammer.prototype.getScore = function(hammerType) {
	var score = 0;
	switch(this.hammerType) {
		case Hammer.TYPE_PPYONG:
		score = Hammer.SCORE_PPYONG;
		break;

		case Hammer.TYPE_WOOD:
		score = Hammer.SCORE_WOOD;
		break;

		case Hammer.TYPE_BRONZE:
		score = Hammer.SCORE_BRONZE;
		break;

		case Hammer.TYPE_SILVER:
		score = Hammer.SCORE_SILVER;
		break;

		case Hammer.TYPE_GOLD:
		score = Hammer.SCORE_GOLD;
		break;
	}

	return score;
}

Hammer.loadResources = function() {
	game.load.image('hammer_ppyong',	'../../../resources/image/weapon/hammer_ppyong.png');
	game.load.image('hammer_wood',		'../../../resources/image/weapon/hammer_wood.png');
	game.load.image('hammer_bronze',	'../../../resources/image/weapon/hammer_bronze.png');
	game.load.image('hammer_silver',	'../../../resources/image/weapon/hammer_silver.png');
	game.load.image('hammer_gold',		'../../../resources/image/weapon/hammer_gold.png');
}


Hammer.TYPE_PPYONG	= 1;
Hammer.TYPE_WOOD	= 2;
Hammer.TYPE_BRONZE	= 3;
Hammer.TYPE_SILVER	= 4;
Hammer.TYPE_GOLD	= 5;

Hammer.UPGRADE_COUNT_PPYONG		= 5;
Hammer.UPGRADE_COUNT_WOOD		= 10;
Hammer.UPGRADE_COUNT_BRONZE		= 15;
Hammer.UPGRADE_COUNT_SILVER		= 20;
Hammer.UPGRADE_COUNT_GOLD		= 25;

Hammer.SCORE_PPYONG		= 1;
Hammer.SCORE_WOOD		= 3;
Hammer.SCORE_BRONZE		= 5;
Hammer.SCORE_SILVER		= 7;
Hammer.SCORE_GOLD		= 9;

Hammer.COLOR_PPYONG		= 0x6633FF;
Hammer.COLOR_WOOD		= 0xFF0066;
Hammer.COLOR_BRONZE		= 0xcd7f32;
Hammer.COLOR_SILVER		= 0xC0C0C0;
Hammer.COLOR_GOLD		= 0xFFd700;

Hammer.OFFSET_SCORE_POS_Y			= 100;