コード例 #1
0
        void HandleHold(User sender, string e)
        {
            var target = sender.Inventory.Items.FirstOrDefault(t => CommandUtils.FuzzyEquals(t.Name, e));

            if (target == null)
            {
                sender.Connection.SendMessage("You must have the object in your inventory.");
                return;
            }

            if (target.Commands.Contains("hold"))
            {
                if (sender.Player.Held.Count == 2)
                {
                    sender.Connection.SendMessage("You have no free hands.");
                    return;
                }

                sender.Inventory.RemoveFromInventory(target);
                sender.Inventory.setCurrentLoweredCapacity(target.Weight);
                CommandUtils.ChangeStats(target, sender);
                sender.Player.Hold(target);
                return;
            }

            sender.Connection.SendMessage("You cannot hold that.");
        }
コード例 #2
0
        void HandleDrink(User sender, string e)
        {
            if (sender.Player.IsDead)
            {
                sender.Connection.SendMessage("You cannot do that while defeated!");
                return;
            }
            var target = sender.Inventory.Items.FirstOrDefault(t => CommandUtils.FuzzyEquals(t.Name, e));

            if (!target.IsConsumable)
            {
                sender.Connection.SendMessage("You cannot drink that.");
                return;
            }
            if (!CommandUtils.FuzzyEquals(target.ConsumableType, "drink"))
            {
                sender.Connection.SendMessage("You cannot drink that.");
                return;
            }
            if (target == null)
            {
                sender.Connection.SendMessage("You must have the object in your inventory.");
                return;
            }

            sender.Inventory.RemoveFromInventory(target);
            CommandUtils.ChangeStats(target, sender);
            sender.Inventory.setCurrentLoweredCapacity(target.Weight);
            return;
        }
コード例 #3
0
        void HandleEquip(User sender, string e)
        {
            if (sender.Player.IsDead)
            {
                sender.Connection.SendMessage("You cannot do that while defeated!");
                return;
            }
            var  target    = sender.Inventory.Items.FirstOrDefault(t => CommandUtils.FuzzyEquals(t.Name, e));
            bool isWearing = false;

            if (!target.IsWearable)
            {
                sender.Connection.SendMessage("You cannot wear that.");
                return;
            }

            if (target == null)
            {
                sender.Connection.SendMessage("You must have the object in your inventory.");
                return;
            }

            if (target.IsWearable)
            {
                if (sender.Player.Equipped.Count == 6)
                {
                    sender.Connection.SendMessage("You have no other room to wear that.");
                    return;
                }

                foreach (Item item in sender.Player.Equipped)
                {
                    if (target.Slot == item.Slot)
                    {
                        sender.Connection.SendMessage($"You are already wearing a {target.Slot} item.");
                        isWearing = true;
                        break;
                    }
                }

                if (!isWearing)
                {
                    sender.Inventory.RemoveFromInventory(target);
                    sender.Player.Equip(target);
                    CommandUtils.ChangeStats(target, sender);
                    sender.Inventory.setCurrentLoweredCapacity(target.Weight);
                    return;
                }
            }
        }