コード例 #1
0
ファイル: Player.cs プロジェクト: Khoryn/IDJ
        /// <summary>
        /// Equip the player with a piece of armor from the inventory through it's id.
        /// </summary>
        public void EquipArmor(int id, PlayerSlots slot)
        {
            Item item = GetItemById(id);

            if (item != null && inventory.Exists(i => i.Id == id))
            {
                if (item is Armor)
                {
                    Armor armor = (Armor)item;

                    if (armor.armorSlot.ToString() == slot.ToString())
                    {
                        currentArmor = armor;
                        inventory.Remove(currentArmor);
                        Console.WriteLine($"Equipped: {currentArmor.Name}!");
                    }
                    else
                    {
                        Console.WriteLine("Can't equip in this slot");
                    }
                }
            }
            else
            {
                Console.WriteLine("Couldn't find the item in the inventory!");
            }
        }
コード例 #2
0
ファイル: SlotTests.cs プロジェクト: Qazzquimby/Lindholm2
        public void TestPlayerSlots()
        {
            FakeSlotContentObserver observer = new FakeSlotContentObserver();
            SlotContentHistory      history  = new SlotContentHistory(observer);
            PlayerSlots             sut      = new PlayerSlots(history);

            List <SlotContent> blueSlots = new List <SlotContent>()
            {
                SlotContent.Empty, SlotContent.Empty, SlotContent.Bot, SlotContent.Player, SlotContent.Empty,
                SlotContent.Empty
            };
            List <SlotContent> redSlots = new List <SlotContent>()
            {
                SlotContent.Bot, SlotContent.Bot, SlotContent.Bot, SlotContent.Player, SlotContent.Player, SlotContent.Empty
            };

            observer.SetObserve(blueSlots, redSlots);

            history.Update();

            List <int> blueResult = sut.Slots(Team.Blue);
            List <int> redResult  = sut.Slots(Team.Red);

            List <int> blueExpectation = new List <int>()
            {
                3
            };
            List <int> redExpectation = new List <int>()
            {
                9, 10
            };

            Assert.IsTrue(blueResult.SequenceEqual(blueExpectation));
            Assert.IsTrue(redResult.SequenceEqual((redExpectation)));
        }
コード例 #3
0
ファイル: SlotTests.cs プロジェクト: Qazzquimby/Lindholm2
        public void TestPlayersContentInPlayersSlots()
        {
            PlayerSlots sut = new PlayerSlots(new FakeEmptyContentHistory());

            Assert.IsFalse(sut.SlotContentIsInCategory(SlotContent.Empty));
            Assert.IsFalse(sut.SlotContentIsInCategory(SlotContent.Bot));
            Assert.IsTrue(sut.SlotContentIsInCategory(SlotContent.Player));
        }
コード例 #4
0
ファイル: SlotManager.cs プロジェクト: Qazzquimby/Lindholm2
 public SlotManager(ISlotContentHistory history)
 {
     Bots    = new BotSlots(history);
     All     = new AllSlots(history);
     Filled  = new FilledSlots(history);
     Empty   = new EmptySlots(history);
     Players = new PlayerSlots(history);
 }
コード例 #5
0
ファイル: Player.cs プロジェクト: Khoryn/IDJ
        /// <summary>
        /// Equip the player with a weapon from the inventory through it's id.
        /// </summary>
        public void EquipWeapon(int id, PlayerSlots slot)
        {
            Item item = GetItemById(id);

            if (item is Weapon)
            {
                Weapon weapon    = (Weapon)item;
                Weapon newWeapon = (Weapon)item;

                if (item != null && inventory.Exists(i => i.Id == id))
                {
                    if (currentWeapon == null)
                    {
                        if (weapon.weaponSlot.ToString() == slot.ToString())
                        {
                            currentWeapon = weapon;
                            Console.WriteLine($"Equipped: {currentWeapon.Name}!");
                        }
                        else
                        {
                            Console.WriteLine("Can't equip in this slot");
                        }
                    }
                    else
                    {
                        weapon        = (Weapon)currentWeapon;
                        currentWeapon = newWeapon;
                        Console.WriteLine($"Uniquipped {weapon.Name} and equipped {currentWeapon.Name}!");
                    }
                }
                else
                {
                    Console.WriteLine("Couldn't find the item in the inventory!");
                }
            }
            else
            {
                Console.WriteLine("Can't equip this item!");
            }
        }
コード例 #6
0
ファイル: SlotTests.cs プロジェクト: Qazzquimby/Lindholm2
        public void TestWhenPlayerCountSameThenTeamsHaveEqualCountIsTrue()
        {
            FakeSlotContentObserver observer = new FakeSlotContentObserver();
            SlotContentHistory      history  = new SlotContentHistory(observer);
            PlayerSlots             sut      = new PlayerSlots(history);

            List <SlotContent> blueSlots = new List <SlotContent>()
            {
                SlotContent.Empty, SlotContent.Empty, SlotContent.Bot, SlotContent.Player, SlotContent.Empty,
                SlotContent.Empty
            };
            List <SlotContent> redSlots = new List <SlotContent>()
            {
                SlotContent.Bot, SlotContent.Bot, SlotContent.Bot, SlotContent.Player, SlotContent.Bot, SlotContent.Empty
            };

            observer.SetObserve(blueSlots, redSlots);

            history.Update();

            Assert.IsTrue(sut.TeamsHaveEqualCount);
        }