Esempio n. 1
0
    /**
     * Adds an item to current user
     *
     * @param int id item id
     * @param int amount item quantity
     *
     * @return bool
     */
    public bool addItem(int id, int amount = 1)
    {
        bool          success;
        CharacterItem characterItem = Service.getOne <CharacterItem>("FROM inventory WHERE item == ?", id);

        if (characterItem != null)
        {
            characterItem.quantity += amount;
            characterItem.save();
            success = true;
        }
        else
        {
            CharacterItem item = new CharacterItem {
                item     = id,
                quantity = amount
            };
            success = item.create();
        }
        // reload inventory
        if (success)
        {
            try {
                QuestManager.Instance.sendAction(id, Task.ActorType.Item, Task.ActionType.GetItem, amount);
                Inventory.Instance.reload();
            } catch (Exception) { }
        }

        return(success);
    }
Esempio n. 2
0
    public static void insertTestItems()
    {
        CharacterItem item = new CharacterItem();

        item.item      = 1;
        item.character = 1;
        item.quantity  = 2;
        item.create();
    }
Esempio n. 3
0
 public static void insertTestItems()
 {
     CharacterItem item = new CharacterItem ();
     item.id = 1;
     item.item = 1;
     item.character = 1;
     item.quantity = 2;
     item.create();
 }
Esempio n. 4
0
    /**
    * Adds an item to current user
    *
    * @param int id item id
    * @param int amount item quantity
    *
    * @return bool
     */
    public bool addItem(int id, int amount = 1)
    {
        CharacterItem item = new CharacterItem {
            item = id,
            quantity = amount
        };
        bool success = item.create ();

        // reload inventory
        if (success) {
            try {
                Inventory.Instance.reload();
            } catch (Exception) {}
        }

        return success;
    }
Esempio n. 5
0
    /**
    * Adds an item to current user
    *
    * @param int id item id
    * @param int amount item quantity
    *
    * @return bool
     */
    public bool addItem(int id, int amount = 1)
    {
        bool success;
        CharacterItem characterItem = Service.getOne<CharacterItem>("FROM inventory WHERE item == ?", id);

        if (characterItem != null) {
            characterItem.quantity += amount;
            characterItem.save();
            success = true;
        } else {
            CharacterItem item = new CharacterItem {
                item = id,
                quantity = amount
            };
            success = item.create ();
        }
        Debug.Log(success);
        // reload inventory
        if (success) {
            try {
                Inventory.Instance.reload();
            } catch (Exception) {}
        }

        return success;
    }