package electrosphere.client.item;

import electrosphere.engine.Globals;
import electrosphere.net.parser.net.message.InventoryMessage;

/**
 * Utilities for telling the server to perform actions with an item that the player has equipped
 */
public class ItemActions {

    //the item action code for left clicking
    public static final int ITEM_ACTION_CODE_PRIMARY = 0;
    //the item action code for right clicking
    public static final int ITEM_ACTION_CODE_SECONDARY = 1;

    //the state for performing the item action code
    public static final int ITEM_ACTION_CODE_STATE_ON = 1;

    //the state for releasing the item action code
    public static final int ITEM_ACTION_CODE_STATE_OFF = 0;
    
    /**
     * Attempts to perform the secondary item action
     */
    public static void attemptSecondaryItemAction(){
        //tell the server we want the secondary hand item to START doing something
        Globals.clientConnection.queueOutgoingMessage(InventoryMessage.constructclientRequestPerformItemActionMessage("handRight", ITEM_ACTION_CODE_SECONDARY, ITEM_ACTION_CODE_STATE_ON));
        //TODO: do any immediate client side calculations here (ie start playing an animation until we get response from server)
    }

    /**
     * Releases the secondary item action
     */
    public static void releaseSecondaryItemAction(){
        //tell the server we want the secondary hand item to STOP doing something
        Globals.clientConnection.queueOutgoingMessage(InventoryMessage.constructclientRequestPerformItemActionMessage("handRight", ITEM_ACTION_CODE_SECONDARY, ITEM_ACTION_CODE_STATE_OFF));
        //TODO: do any immediate client side calculations here (ie start playing an animation until we get response from server)
    }

}
