package player;

import hud.Clock;
import interfaces.ItemIDs;

/**  ------------- Nihilne ------------
    *** @author Mitch Weaver - 2016 ***
      ~~~~ All Rights Reserved ~~~~ */

public final class HealthAndDurability implements ItemIDs {

	private static int torchTimer;

	public static final void tick(){
		
		// UPDATE FIRE-BASED DURABILTIES
		switch(Player.equipmentSlots[HAND_SLOT].itemId) {
			
			case TORCH: if(++torchTimer > (Clock.NIGHT_DURATION * 0.75f) / 200){
										Player.equipmentSlots[HAND_SLOT].durability -= 0.5f;
										torchTimer = 0; } break;
		}
		
	}
	
	// SUBTRACT FROM PLAYER HEALTH AND START THE GET-HIT ANIMATION
	private static final int GET_HIT_TIMER_AMOUNT = 20;
	public static final float hurtPlayer(float damage) {
		
		// manipulate damage based on currently worn armour
		
		Player.health -= damage;

		// subtract durabilities from aromurs here
		
		// START GET-HIT ANIMATION
		if(Player.getHitTimer <= 0) Player.getHitTimer = GET_HIT_TIMER_AMOUNT;
		
		// return the player health just for convenience sake
		return Player.health;
	}
	
	public static final void HIT_MOB() { 
		switch(Player.equipmentSlots[HAND_SLOT].itemId) {
			case CRUDE_AXE:     Player.equipmentSlots[HAND_SLOT].durability -= 2.5f; break; 
			case CRUDE_PICKAXE: Player.equipmentSlots[HAND_SLOT].durability -= 2.5f; break; 
			case GOBLIN_SPEAR:  Player.equipmentSlots[HAND_SLOT].durability -= 7.5f; break; 
		}
	}
	
}
