Exemplo n.º 1
0
        // `use(id)` consumes/uses the item `id`
        public void Use(string id, Roar.Callback <Roar.WebObjects.Items.UseResponse> callback)
        {
            var item = dataStore.inventory.Get(id as string);

            if (item == null)
            {
                logger.DebugLog("[roar] -- Failed: no record with id: " + id);
                return;
            }

            // GH#152: Ensure item is consumable first
            logger.DebugLog(Roar.Json.ObjectToJSON(item));

            if (!item.consumable)
            {
                var error = item.ikey + ": Good is not consumable";
                logger.DebugLog("[roar] -- " + error);
                if (callback != null)
                {
                    callback(new Roar.CallbackInfo <Roar.WebObjects.Items.UseResponse> (null, IWebAPI.DISALLOWED, error));
                }
                return;
            }

            WebObjects.Items.UseArguments args = new Roar.WebObjects.Items.UseArguments();
            args.item_id = id;

            itemActions.use(args, new UseCallback(callback, this, id));
        }
Exemplo n.º 2
0
 public void use(Roar.WebObjects.Items.UseArguments args, ZWebAPI.Callback <Roar.WebObjects.Items.UseResponse> cb)
 {
     api.MakeCall("items/use", args.ToHashtable(), new CallbackBridge <Roar.WebObjects.Items.UseResponse>(cb, use_response_parser), true);
 }