diff options
| author | Syndamia <kamen.d.mladenov@protonmail.com> | 2020-04-06 09:52:40 +0300 |
|---|---|---|
| committer | Syndamia <kamen.d.mladenov@protonmail.com> | 2020-04-06 09:52:40 +0300 |
| commit | b4807b0e99df2e58731ec4057f8575cca10dbaeb (patch) | |
| tree | 08c43ece5fe0408e1889e48ea8a9fc905c0d8dcc | |
| parent | 4bfcde013d722cba417b7ac0e1adff9886de2ec6 (diff) | |
| download | Mundus-b4807b0e99df2e58731ec4057f8575cca10dbaeb.tar Mundus-b4807b0e99df2e58731ec4057f8575cca10dbaeb.tar.gz Mundus-b4807b0e99df2e58731ec4057f8575cca10dbaeb.zip | |
Did minor bug fixes. After crafting an item, the inventory is redrawn. It doesnt matter where items are in inventory (items inventory), you can craft. Tools that are better class than the structure requirments can break these structures now.
| -rw-r--r-- | Mundus/Service/Crafting/CraftingController.cs | 18 | ||||
| -rw-r--r-- | Mundus/Service/Mobs/MobTerraforming.cs | 2 | ||||
| -rw-r--r-- | Mundus/Views/Windows/CraftingWindow.cs | 3 | ||||
| -rw-r--r-- | Mundus/Views/Windows/IGameWindow.cs | 1 | ||||
| -rw-r--r-- | Mundus/Views/Windows/LargeGameWindow.cs | 4 | ||||
| -rw-r--r-- | Mundus/Views/Windows/MediumGameWindow.cs | 4 |
6 files changed, 27 insertions, 5 deletions
diff --git a/Mundus/Service/Crafting/CraftingController.cs b/Mundus/Service/Crafting/CraftingController.cs index 74172bd..b1ca35c 100644 --- a/Mundus/Service/Crafting/CraftingController.cs +++ b/Mundus/Service/Crafting/CraftingController.cs @@ -9,8 +9,10 @@ namespace Mundus.Service.Crafting { public static class CraftingController { private static Dictionary<ItemTile, int> avalableItems; + /// <summary> + /// Gets all different items and their quantaties in the inventory. Stores that in memory. + /// </summary> public static void FindAvalableItems() { - var tmp = LMI.Player.Inventory.Items.Where(x => x != null); avalableItems = LMI.Player.Inventory.Items.Where(x => x != null) //Can't use distinct on non primative types, beause they also hold their memory location info. //This is my way of getting only the "unique" item tiles. @@ -32,12 +34,18 @@ namespace Mundus.Service.Crafting { return recipes.ToArray(); } + /// <summary> + /// Removes items, used for crafting and adds the result item to the inventory + /// </summary> + /// <param name="itemRecipe">CraftingRecipie of the item that will be crafted</param> public static void CraftItem(CraftingRecipe itemRecipe) { foreach (var itemAndCount in itemRecipe.GetRequiredItemsAndCounts()) { for(int i = 0, removedItems = 0; i < LMI.Player.Inventory.Items.Length && removedItems < itemAndCount.Value; i++) { - if (LMI.Player.Inventory.Items[i].stock_id == itemAndCount.Key.stock_id) { - LMI.Player.Inventory.Items[i] = null; - removedItems++; + if (LMI.Player.Inventory.Items[i] != null) { + if (LMI.Player.Inventory.Items[i].stock_id == itemAndCount.Key.stock_id) { + LMI.Player.Inventory.Items[i] = null; + removedItems++; + } } } } @@ -56,6 +64,8 @@ namespace Mundus.Service.Crafting { tmp = new Structure((Structure)itemRecipe.ResultItem); } LMI.Player.Inventory.AppendToItems(tmp); + + Data.Windows.WI.SelWin.PrintInventory(); } } }
\ No newline at end of file diff --git a/Mundus/Service/Mobs/MobTerraforming.cs b/Mundus/Service/Mobs/MobTerraforming.cs index 93854de..c05e645 100644 --- a/Mundus/Service/Mobs/MobTerraforming.cs +++ b/Mundus/Service/Mobs/MobTerraforming.cs @@ -11,7 +11,7 @@ namespace Mundus.Service.Mobs { var selTool = (Tool)LMI.Player.Inventory.GetTile(place, index);
var selStructure = LMI.Player.CurrSuperLayer.GetStructureLayerTile(mapYPos, mapXPos);
- if (selStructure.ReqToolType == selTool.Type && selStructure.ReqToolClass == selTool.Class) {
+ if (selStructure.ReqToolType == selTool.Type && selStructure.ReqToolClass <= selTool.Class) {
if (LMI.Player.Inventory.Items.Any(x => x == null)) { LMI.Player.Inventory.AppendToItems(new Material(selStructure.DroppedMaterial.stock_id));
diff --git a/Mundus/Views/Windows/CraftingWindow.cs b/Mundus/Views/Windows/CraftingWindow.cs index 1e1b47c..5037226 100644 --- a/Mundus/Views/Windows/CraftingWindow.cs +++ b/Mundus/Views/Windows/CraftingWindow.cs @@ -17,6 +17,9 @@ namespace Mundus.Views.Windows { this.Hide(); } + /// <summary> + /// Resets visuals and prepares avalable recipes for current items in inventory + /// </summary> public void Initialize() { Reset(); CraftingController.FindAvalableItems(); diff --git a/Mundus/Views/Windows/IGameWindow.cs b/Mundus/Views/Windows/IGameWindow.cs index aefdfc7..95f8636 100644 --- a/Mundus/Views/Windows/IGameWindow.cs +++ b/Mundus/Views/Windows/IGameWindow.cs @@ -10,6 +10,7 @@ namespace Mundus.Views.Windows { void PrintScreen(); void PrintMap(); void PrintMainMenu(); + void PrintInventory(); void PrintSelectedItemInfo(ItemTile itemTile); //Stuff that are in Gtk.Window class diff --git a/Mundus/Views/Windows/LargeGameWindow.cs b/Mundus/Views/Windows/LargeGameWindow.cs index 5d20421..5d10c73 100644 --- a/Mundus/Views/Windows/LargeGameWindow.cs +++ b/Mundus/Views/Windows/LargeGameWindow.cs @@ -37,5 +37,9 @@ namespace Mundus.Views.Windows { public void PrintSelectedItemInfo(ItemTile itemTile) { throw new NotImplementedException(); } + + public void PrintInventory() { + throw new NotImplementedException(); + } } } diff --git a/Mundus/Views/Windows/MediumGameWindow.cs b/Mundus/Views/Windows/MediumGameWindow.cs index 29f75a6..a0d49f3 100644 --- a/Mundus/Views/Windows/MediumGameWindow.cs +++ b/Mundus/Views/Windows/MediumGameWindow.cs @@ -37,5 +37,9 @@ namespace Mundus.Views.Windows { public void PrintSelectedItemInfo(ItemTile itemTile) { throw new NotImplementedException(); } + + public void PrintInventory() { + throw new NotImplementedException(); + } } } |
