public void MainController_IntialiseNewGame() { //FileReadWriter frw = new FileReadWriter(); //frw.WriteSaveDataFile("eventCatalogue", gs.GetEM().ParseCatalogueToString()); //frw.WriteSaveDataFile("itemCatalogue", gs.GetPCM().GetItemCatalogue().ParseToString()); //frw.WriteSaveDataFile("discoveryCatalogue", gs.GetDM().ParseCatalogueToString()); MainController mc = new MainController(); //Assert.IsTrue(mc.InitialiseNewGame(), "New game should be succesfully initialized"); mc.InitialiseNewGame(); GameState workingGS = mc.GetGameState(); PCModel workingPCM = workingGS.GetPCM(); LocationModel workingLM = workingGS.GetLM(); EventModel workingEM = workingGS.GetEM(); DiscoveryModel workingDM = workingGS.GetDM(); EventCatalogue ec = workingEM.GetEventCatalogue(); String workingEventCat = workingEM.ParseCatalogueToString(); String workingDiscCat = workingDM.ParseCatalogueToString(); String workingItemCat = workingPCM.GetItemCatalogue().ParseToString(); Assert.AreEqual(eventCatalogue, workingEventCat, "Event catalogues should match"); Assert.AreEqual(discoveryCatalogue, workingDiscCat, "Discovery catalogues should match"); Assert.AreEqual(itemCatalogue, workingItemCat, "Item catalogues should match"); Assert.AreEqual(512, workingLM.GetUnvisited().Count, "Should be 1024 unvisited nodes"); }
/// <summary> /// Updates the item catalogue /// </summary> public void DrawItemCatalogue() { GameState gs = mc.GetGameState(); PCModel pcm = gs.GetPCM(); List <Item> items = pcm.GetItemCatalogue().GetItems(); List <string> temp = new List <string>(); foreach (Item item in items) { temp.Add(item.ToPrettyString()); } itemCatalogueLB.ItemsSource = temp; //itemCatalogue.DataSource = temp; }
public void PCModel_FullConstructor() { var pc = pcm.GetPC(); var inv = pcm.GetInventory(); var ic = pcm.GetItemCatalogue(); Assert.AreEqual(80, pc.GetResource(PlayerCharacter.HEALTH), "Health Value Incorrect"); Assert.AreEqual(50, pc.GetResource(PlayerCharacter.HUNGER), "Hunger Value Incorrect"); Assert.AreEqual(60, pc.GetResource(PlayerCharacter.THIRST), "Sanity Value Incorrect"); Assert.AreEqual(70, pc.GetResource(PlayerCharacter.SANITY), "Thirst Value Incorrect"); Assert.IsTrue(inv.Contains(items[0]), "Inventory should have item1"); Assert.IsTrue(inv.Contains(items[1]), "Inventory should have item2"); Assert.IsTrue(inv.Contains(items[2]), "Inventory should have item3"); Assert.IsFalse(inv.Contains(items[3]), "Inventory should not have item4"); Assert.AreEqual(invStr, inv.ParseToString(), "Parsed Inventory should match"); }
public void PCModel_StandardConstructor() { var pc = std_pcm.GetPC(); var inv = std_pcm.GetInventory(); var ic = std_pcm.GetItemCatalogue(); Assert.AreEqual(100, pc.GetResource(PlayerCharacter.HEALTH), "Health Value Incorrect"); Assert.AreEqual(100, pc.GetResource(PlayerCharacter.HUNGER), "Hunger Value Incorrect"); Assert.AreEqual(100, pc.GetResource(PlayerCharacter.THIRST), "Sanity Value Incorrect"); Assert.AreEqual(100, pc.GetResource(PlayerCharacter.SANITY), "Thirst Value Incorrect"); Assert.AreEqual(itemStr1, ic.GetItem(1).ParseToString(), "Item 1 should be in the catalogue"); Assert.AreEqual(itemStr2, ic.GetItem(2).ParseToString(), "Item 2 should be in the catalogue"); Assert.AreEqual(itemStr3, ic.GetItem(3).ParseToString(), "Item 3 should be in the catalogue"); Assert.AreEqual(itemStr4, ic.GetItem(4).ParseToString(), "Item 4 should be in the catalogue"); Assert.AreEqual(null, ic.GetItem(5), "Item 5 should not be in the catalogue"); }
/// <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); }