package electrosphere.entity.types.creature;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * Data on what a creature has equipped currently
 */
public class CreatureEquipData {
    
    //Map of equip slot -> item definition
    Map<String,EquippedItem> slotToItemMap = new HashMap<String,EquippedItem>();

    /**
     * Gets the slots in the equip data
     * @return The set of equip slot ids
     */
    public Set<String> getSlots(){
        return slotToItemMap.keySet();
    }

    /**
     * Gets the item occupying a given slot
     * @param slotId The id of the slot
     * @return The item definition
     */
    public EquippedItem getSlotItem(String slotId){
        return slotToItemMap.get(slotId);
    }

    /**
     * Sets a slot as containing an item type
     * @param slotId The slot
     * @param itemType The item definition
     */
    public void setSlotItem(String slotId, EquippedItem itemType){
        slotToItemMap.put(slotId, itemType);
    }

    /**
     * Clears the equip data
     */
    public void clear(){
        slotToItemMap.clear();
    }

    /**
     * An item that is equipped
     */
    public static class EquippedItem {

        /**
         * The type of the item
         */
        String itemType;

        /**
         * The entity id of the item
         */
        int entityId;

        /**
         * Constructor
         * @param entityId The id of the item entity
         * @param itemType The type of the item
         */
        public EquippedItem(int entityId, String itemType){
            this.entityId = entityId;
            this.itemType = itemType;
        }

        /**
         * The type of the item
         * @return The type
         */
        public String getItemType(){
            return itemType;
        }

        /**
         * The id of the entity that is this item
         * @return The id
         */
        public int getEntityId(){
            return entityId;
        }

    }

}
