package projectzombie.items;

import projectzombie.items.modifier.ItemModifierDamage;
import projectzombie.util.ItemStack;

public abstract class ItemAbstractTool extends Item implements ItemTool
{
	public ItemAbstractTool() {
		max = 1;
	}
	
	protected abstract int getMaxDamage();
	
	@Override
	public void toolOnUse(ItemStack stack)
	{
		ItemModifierDamage modifier = (ItemModifierDamage) stack.getModifier(ItemModifierDamage.class);
		
		if(modifier == null) {
			modifier = new ItemModifierDamage(0, getMaxDamage());
			stack.addModifier(modifier);
		}
		
		modifier.damage(1);
		
		if(modifier.isBroken()) {
			stack.count = 0;
		}
	}
}
