Exemple #1
0
        private bool OnGiveCommand(string userName, string[] pieces)
        {
            var           player        = FrogtownShared.GetPlayerWithName(userName);
            ItemWithCount itemWithCount = null;

            try
            {
                itemWithCount = ParseItemWithCount(pieces);
                if (itemWithCount.index < 0 || itemWithCount.index >= (int)ItemIndex.Count)
                {
                    SendFailedLookupMessage();
                    return(true);
                }
            } catch (ArgumentException e)
            {
                SendFailedLookupMessage();
                return(true);
            }
            itemWithCount.count = Math.Max(itemWithCount.count, 1);

            player.master.inventory.GiveItem((ItemIndex)itemWithCount.index, itemWithCount.count);
            FrogtownShared.SendChat(string.Format("Gave {0} items to {1}.", itemWithCount.count, userName));

            return(true);
        }
Exemple #2
0
        private bool OnRemoveCommand(string userName, string[] pieces)
        {
            var player = FrogtownShared.GetPlayerWithName(userName);

            ItemWithCount itemWithCount = null;

            try
            {
                itemWithCount = ParseItemWithCount(pieces);
            } catch (ArgumentException e)
            {
                SendFailedLookupMessage();
                return(true);
            }

            int countPlayerHas = player.master.inventory.GetItemCount((ItemIndex)itemWithCount.index);

            itemWithCount.count = Math.Min(Math.Max(itemWithCount.count, 1), countPlayerHas);

            FrogtownShared.SendChat(string.Format("countPlayerHas = {0}\r\nitemWithCount.count = {1}", countPlayerHas, itemWithCount.count));

            if (itemWithCount.count > 0)
            {
                player.master.inventory.GiveItem((ItemIndex)itemWithCount.index, -itemWithCount.count);
                FrogtownShared.SendChat(string.Format("Took {0} items from {1}.", itemWithCount.count, userName));
            }

            return(true);
        }
Exemple #3
0
        private bool OnClearItemsCommand(string userName, string[] pieces)
        {
            var player = FrogtownShared.GetPlayerWithName(userName);

            foreach (ItemIndex itemIndex in ItemCatalog.allItems)
            {
                int count = player.master.inventory.GetItemCount(itemIndex);
                OnRemoveCommand(userName, new[] { pieces[0], itemIndex.ToString(), count.ToString() });
            }
            FrogtownShared.SendChat("Took all items from " + userName + ".");

            return(true);
        }