Пример #1
0
        /// <summary>
        /// Resolves the IEE and applies it to the PC
        /// </summary>
        /// <param name="eventModifier">Event modifier for item amount</param>
        /// <param name="pcm">The PC model to apply to</param>
        public override void ResolveEffect(double eventModifier, PCModel pcm)
        {
            int amount = item.GetAmount();

            if (amount < 0)
            {
                int remove = Math.Abs(amount);
                pcm.RemoveRandomItemFromInventory(remove);
            }
            else
            {
                pcm.ModifyInventory(item, amount);
            }
        }
Пример #2
0
        /// <summary>
        /// Scavenges a sublocation putting found items into the inventory of this PC
        /// </summary>
        /// <param name="gs">The game state to modify</param>
        /// <returns>List of scavenged items</returns>
        public List <Item> ScavangeSubLocation(GameState gs)
        {
            LocationModel lm             = gs.GetLM();
            PCModel       pcm            = gs.GetPCM();
            ItemCatalogue ic             = pcm.GetItemCatalogue();
            List <Item>   scavengedItems = new List <Item>();

            if (lm.IsScavenged() || pcm.GetInventory().IsInventoryFull())
            {
                return(scavengedItems);
            }
            List <Item> itemSelection = new List <Item>();

            for (int i = 0; i < 100; i++)
            {
                itemSelection.Add(ic.GetRandomItem());
            }
            scavengedItems = lm.Scavenge(itemSelection);
            foreach (Item item in scavengedItems)
            {
                pcm.ModifyInventory(item, item.GetAmount());
            }
            return(scavengedItems);
        }
Пример #3
0
        public void PCModel_ModififyInventory()
        {
            var inventory = pcm.GetInventory();

            Assert.IsTrue(inventory.Contains(items[0]), "Inventory should have item1");
            Assert.IsTrue(inventory.Contains(items[1]), "Inventory should have item2");
            Assert.IsTrue(inventory.Contains(items[2]), "Inventory should have item3");
            Assert.IsFalse(inventory.Contains(items[3]), "Inventory should not have item4");

            Assert.AreEqual(1, inventory.GetAmount(items[0]), "Should have one of item1");
            Assert.AreEqual(1, inventory.GetAmount(items[1]), "Should have one of item2");
            Assert.AreEqual(1, inventory.GetAmount(items[2]), "Should have one of item3");
            Assert.AreEqual(0, inventory.GetAmount(items[3]), "Should have zero of item4");

            pcm.ModifyInventory(items[0], 1);
            Assert.AreEqual(2, inventory.GetAmount(items[0]), "Should have two of item1");
            pcm.ModifyInventory(items[0], -1);
            Assert.AreEqual(1, inventory.GetAmount(items[0]), "Should have one of item1");
            pcm.ModifyInventory(items[0], -1);
            Assert.AreEqual(0, inventory.GetAmount(items[0]), "Should have zero of item1");
            pcm.ModifyInventory(items[0], -1);
            Assert.AreEqual(0, inventory.GetAmount(items[0]), "Should have zero of item1");
            pcm.ModifyInventory(items[0], -1);
            Assert.AreEqual(0, inventory.GetAmount(items[0]), "Should have zero of item1");
            pcm.ModifyInventory(items[0], 4);
            Assert.AreEqual(4, inventory.GetAmount(items[0]), "Should have four of item1");
            pcm.ModifyInventory(items[0], -6);
            Assert.AreEqual(0, inventory.GetAmount(items[0]), "Should have zero of item1");
            pcm.ModifyInventory(items[0], 4);
            Assert.AreEqual(4, inventory.GetAmount(items[0]), "Should have four of item1");

            for (int i = 3; i < items.Count; i++)
            {
                pcm.ModifyInventory(items[i], i);
                if (i < 16)
                {
                    Assert.IsTrue(inventory.Contains(items[i]), "Inventory should have item" + (i + 1));
                    Assert.AreEqual(i, inventory.GetAmount(items[i]), "Should have " + i + " of item" + (i + 1));
                }
                else
                {
                    Assert.IsFalse(inventory.Contains(items[i]), "Inventory should not have item" + (i + 1));
                    Assert.IsTrue(inventory.IsInventoryFull(), "Inventory should be full");
                }
            }
        }