示例#1
0
        public override void Push(IWorld world, IUserinterface ui, ActionStack stack, IActor actor)
        {
            if (actor.Decide(ui, "Equipment Action", null, out EquipmentActionToPerform toPerform,
                             GetValues <EquipmentActionToPerform>(), 0))
            {
                switch (toPerform)
                {
                case EquipmentActionToPerform.None:
                    break;

                case EquipmentActionToPerform.PutOn:
                    if (actor.Decide(ui, "Item", "Pick an item to put on", out IItem equip, actor.Items.Where(i => i.Slot != null && !i.IsEquipped).ToArray(), 0))
                    {
                        if (actor.CanEquip(equip, out string s))
                        {
                            stack.Push(new EquipmentFrame(actor, this, toPerform, equip));
                        }
                        else
                        {
                            ShowNarrative(ui, actor, "Cannot Equip", s, $"{actor} tried to equip {equip} but failed ({s})", stack.Round);
                        }
                    }

                    break;

                case EquipmentActionToPerform.TakeOff:
                    if (actor.Decide(ui, "Item", "Pick an item to take off", out IItem remove, actor.Items.Where(i => i.IsEquipped).ToArray(), 0))
                    {
                        stack.Push(new EquipmentFrame(actor, this, toPerform, remove));
                    }

                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
        }