package common.item.block;

import java.util.List;
import java.util.Map;
import common.attributes.Attribute;
import common.attributes.UsageSlot;
import common.block.Block;
import common.block.artificial.BlockMetalBlock;
import common.block.natural.BlockMetalOre;
import common.color.TextColor;
import common.entity.npc.EntityNPC;
import common.init.MetalType;
import common.item.ItemStack;

public class ItemMetalBlock extends ItemBlock {
	private final MetalType metal;
	private final boolean ore;
	
	private ItemMetalBlock(Block block, MetalType metal, boolean ore) {
		super(block);
		this.metal = metal;
		this.ore = ore;
        if(this.metal.radioactivity > 0.0f)
        	this.setColor(TextColor.GREEN);
	}
	
	public ItemMetalBlock(BlockMetalBlock block) {
		this(block, block.getMetal(), false);
	}
	
	public ItemMetalBlock(BlockMetalOre block) {
		this(block, block.getMetal(), true);
	}
	
	public void addInformation(ItemStack stack, EntityNPC playerIn, List<String> tooltip)
    {
		tooltip.add(this.metal.formatSymbol());
		if(this.metal.radioactivity > 0.0f) {
			tooltip.add(this.metal.formatRadioactivity());
		}
		tooltip.add(this.metal.formatRarity());
    }

    public void getModifiers(Map<Attribute, Float> map, UsageSlot slot)
    {
        if((slot == null || slot == UsageSlot.INVENTORY) && this.metal.radioactivity > 0.0f)
        	map.put(Attribute.RADIATION, this.metal.radioactivity * 4.0f * (this.ore ? 2.0f : 9.0f));
    }
    
    public float getRadiation(ItemStack stack) {
    	return this.metal.radioactivity * (this.ore ? 0.5f : 2.0f) * (float)stack.size;
    }
    
    public boolean isMagnetic() {
    	return this.metal.isMagnetic();
    }
}
