From f0b74ed2874e44e821e03dfcd554346bc4a3df62 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 23 May 2020 18:43:26 +0300 Subject: Finished with refactoring. This version is now officially finished. --- Mundus/Data/Crafting/CraftingRecipe.cs | 114 +++++++++++++++ Mundus/Data/Crafting/CraftingTableContext.cs | 49 +------ Mundus/Data/Dialogues/DI.cs | 36 ----- Mundus/Data/GameEventLogs/GameEventLogContext.cs | 2 +- Mundus/Data/SuperLayers/DBTables/PlacedTile.cs | 2 +- Mundus/Data/SuperLayers/ISuperLayerContext.cs | 4 +- Mundus/Data/SuperLayers/LandContext.cs | 11 +- Mundus/Data/SuperLayers/SkyContext.cs | 13 +- Mundus/Data/SuperLayers/UndergroundContext.cs | 13 +- Mundus/Data/Tiles/Mobs/LandMobsPresets.cs | 42 ------ Mundus/Data/Tiles/Mobs/MI.cs | 27 ---- Mundus/Data/Tiles/Presets/GroundPresets.cs | 36 ----- Mundus/Data/Tiles/Presets/MaterialPresets.cs | 38 ----- Mundus/Data/Tiles/Presets/StructurePresets.cs | 45 ------ Mundus/Data/Tiles/Presets/ToolPresets.cs | 64 --------- Mundus/Data/Windows/WI.cs | 111 --------------- Mundus/Mundus.csproj | 43 +++--- Mundus/Program.cs | 6 +- Mundus/Service/Dialogs/DI.cs | 36 +++++ Mundus/Service/GameEventLogController.cs | 2 +- Mundus/Service/GameGenerator.cs | 6 +- .../Generators/LandSuperLayerGenerator.cs | 5 +- .../Generators/SkySuperLayerGenerator.cs | 2 +- .../Generators/UndergroundSuperLayerGenerator.cs | 2 +- Mundus/Service/SuperLayers/ImageController.cs | 2 +- .../Service/Tiles/Crafting/CraftingController.cs | 64 --------- Mundus/Service/Tiles/Crafting/CraftingRecipe.cs | 156 --------------------- Mundus/Service/Tiles/Items/ItemController.cs | 4 +- Mundus/Service/Tiles/Items/ItemTile.cs | 2 +- .../Service/Tiles/Items/Presets/GroundPresets.cs | 36 +++++ .../Service/Tiles/Items/Presets/MaterialPresets.cs | 38 +++++ .../Tiles/Items/Presets/StructurePresets.cs | 45 ++++++ Mundus/Service/Tiles/Items/Presets/ToolPresets.cs | 64 +++++++++ .../Service/Tiles/Mobs/Controllers/MobFighting.cs | 3 +- .../Service/Tiles/Mobs/Controllers/MobMovement.cs | 4 +- .../Tiles/Mobs/Controllers/MobStatsController.cs | 4 +- .../Tiles/Mobs/Controllers/MobTerraforming.cs | 4 +- Mundus/Service/Tiles/Mobs/Inventory.cs | 2 +- .../Service/Tiles/Mobs/LandMobs/LandMobsPresets.cs | 42 ++++++ Mundus/Service/Tiles/Mobs/LandMobs/Player.cs | 2 +- Mundus/Service/Tiles/Mobs/MI.cs | 28 ++++ Mundus/Service/Tiles/Mobs/MobTile.cs | 2 +- Mundus/Service/Tiles/RecipeController.cs | 124 ++++++++++++++++ Mundus/Service/Windows/Calculate.cs | 2 +- Mundus/Service/Windows/WI.cs | 111 +++++++++++++++ Mundus/Service/Windows/WindowController.cs | 1 - Mundus/Views/Windows/CraftingWindow.cs | 9 +- .../Views/Windows/GameWindows/Large/LargeLogic.cs | 2 +- .../Windows/GameWindows/Medium/MediumLogic.cs | 2 +- .../Views/Windows/GameWindows/Small/SmallLogic.cs | 2 +- Mundus/Views/Windows/LogWindow.cs | 2 +- Mundus/Views/Windows/MainWindow.cs | 2 +- Mundus/Views/Windows/PauseWindow.cs | 2 +- Mundus/gtk-gui/Mundus.Views.Windows.MainWindow.cs | 2 +- Mundus/gtk-gui/Mundus.Views.Windows.MusicWindow.cs | 3 + .../gtk-gui/Mundus.Views.Windows.NewGameWindow.cs | 4 + .../gtk-gui/Mundus.Views.Windows.SettingsWindow.cs | 2 +- Mundus/gtk-gui/gui.stetic | 7 +- Mundus/packages.config | 1 + MundusTests/ApplicationSetup.cs | 6 +- MundusTests/DataTests/Mobs/MITests.cs | 2 +- .../SuperLayers/ImageControllerTests.cs | 2 +- .../Tiles/Crafting/CraftingControllerTests.cs | 8 +- .../ServiceTests/Tiles/Mobs/MobTileTests.cs | 2 +- 64 files changed, 756 insertions(+), 753 deletions(-) create mode 100644 Mundus/Data/Crafting/CraftingRecipe.cs delete mode 100644 Mundus/Data/Dialogues/DI.cs delete mode 100644 Mundus/Data/Tiles/Mobs/LandMobsPresets.cs delete mode 100644 Mundus/Data/Tiles/Mobs/MI.cs delete mode 100644 Mundus/Data/Tiles/Presets/GroundPresets.cs delete mode 100644 Mundus/Data/Tiles/Presets/MaterialPresets.cs delete mode 100644 Mundus/Data/Tiles/Presets/StructurePresets.cs delete mode 100644 Mundus/Data/Tiles/Presets/ToolPresets.cs delete mode 100644 Mundus/Data/Windows/WI.cs create mode 100644 Mundus/Service/Dialogs/DI.cs delete mode 100644 Mundus/Service/Tiles/Crafting/CraftingController.cs delete mode 100644 Mundus/Service/Tiles/Crafting/CraftingRecipe.cs create mode 100644 Mundus/Service/Tiles/Items/Presets/GroundPresets.cs create mode 100644 Mundus/Service/Tiles/Items/Presets/MaterialPresets.cs create mode 100644 Mundus/Service/Tiles/Items/Presets/StructurePresets.cs create mode 100644 Mundus/Service/Tiles/Items/Presets/ToolPresets.cs create mode 100644 Mundus/Service/Tiles/Mobs/LandMobs/LandMobsPresets.cs create mode 100644 Mundus/Service/Tiles/Mobs/MI.cs create mode 100644 Mundus/Service/Tiles/RecipeController.cs create mode 100644 Mundus/Service/Windows/WI.cs diff --git a/Mundus/Data/Crafting/CraftingRecipe.cs b/Mundus/Data/Crafting/CraftingRecipe.cs new file mode 100644 index 0000000..d9a3e0b --- /dev/null +++ b/Mundus/Data/Crafting/CraftingRecipe.cs @@ -0,0 +1,114 @@ +namespace Mundus.Data.Crafting +{ + using System.ComponentModel.DataAnnotations; + using System.ComponentModel.DataAnnotations.Schema; + + [Table("CraftingRecipes", Schema = "Mundus")] + public class CraftingRecipe + { + public CraftingRecipe(string resultItem, int count1, string reqItem1) : this(resultItem, count1, reqItem1, 0, null, 0, null, 0, null, 0, null) + { + } + + public CraftingRecipe(string resultItem, int count1, string reqItem1, int count2, string reqItem2) : this(resultItem, count1, reqItem1, count2, reqItem2, 0, null, 0, null, 0, null) + { + } + + public CraftingRecipe(string resultItem, int count1, string reqItem1, int count2, string reqItem2, int count3, string reqItem3) : this(resultItem, count1, reqItem1, count2, reqItem2, count3, reqItem3, 0, null, 0, null) + { + } + + public CraftingRecipe(string resultItem, int count1, string reqItem1, int count2, string reqItem2, int count3, string reqItem3, int count4, string reqItem4) : this(resultItem, count1, reqItem1, count2, reqItem2, count3, reqItem3, count4, reqItem4, 0, null) + { + } + + public CraftingRecipe(string resultItem, int count1, string reqItem1, int count2, string reqItem2, int count3, string reqItem3, int count4, string reqItem4, int count5, string reqItem5) + { + this.ResultItem = resultItem; + + this.Count1 = count1; + this.ReqItem1 = reqItem1; + + this.Count2 = count2; + this.ReqItem2 = reqItem2; + + this.Count3 = count3; + this.ReqItem3 = reqItem3; + + this.Count4 = count4; + this.ReqItem4 = reqItem4; + + this.Count5 = count5; + this.ReqItem5 = reqItem5; + } + + [Key] + public int ID { get; set; } + + /// + /// Gets the item that will be added to the inventory after crafting + /// + /// The result item. + public string ResultItem { get; private set; } + + /// + /// Gets the required amount of the first item + /// + public int Count1 { get; private set; } + + /// + /// Gets the required first item + /// + public string ReqItem1 { get; private set; } + + /// + /// Gets the required amount of the second item + /// + public int Count2 { get; private set; } + + /// + /// Gets the required second item + /// + public string ReqItem2 { get; private set; } + + /// + /// Gets the required amount of the third item + /// + public int Count3 { get; private set; } + + /// + /// Gets the required third item + /// + public string ReqItem3 { get; private set; } + + /// + /// Gets the required amount of the fourth item + /// + public int Count4 { get; private set; } + + /// + /// Gets the required fourth item + /// + public string ReqItem4 { get; private set; } + + /// + /// Gets the required amount of the fifth item + /// + public int Count5 { get; private set; } + + /// + /// Gets the required fifth item + /// + public string ReqItem5 { get; private set; } + + public string[] GetAllRequiredItems() + { + return new string[] { this.ReqItem1, this.ReqItem2, this.ReqItem3, this.ReqItem4, this.ReqItem5 }; + } + + public int[] GetAllCounts() + { + return new int[] { this.Count1, this.Count2, this.Count3, this.Count4, this.Count5 }; + } + } +} diff --git a/Mundus/Data/Crafting/CraftingTableContext.cs b/Mundus/Data/Crafting/CraftingTableContext.cs index 820c018..47b302c 100644 --- a/Mundus/Data/Crafting/CraftingTableContext.cs +++ b/Mundus/Data/Crafting/CraftingTableContext.cs @@ -1,24 +1,12 @@ namespace Mundus.Data.Crafting { - using System.Linq; using Microsoft.EntityFrameworkCore; - using Mundus.Data.Tiles.Mobs; - using Mundus.Data.Tiles.Presets; - using Mundus.Service.Tiles.Crafting; /// /// Context for getting the crafting recipes /// public class CraftingTableContext : DbContext { - /// - /// Initializes a new instance of the class and adds all the recipes to the table - /// - public CraftingTableContext() : base() - { - this.AddRecipes(); - } - /// /// Gets DBSet of the CraftingRecipes table /// @@ -26,12 +14,11 @@ public DbSet CraftingRecipes { get; private set; } /// - /// Returns an array with all the recipes that can be crafted with the items the player has + /// Truncates the table CraftingRecipes (doesn't save the changes) /// - public CraftingRecipe[] GetAvalableRecipes() + public void TruncateTable() { - var recipes = this.CraftingRecipes.ToArray(); - return recipes.Where(cr => cr.HasEnoughItems(MI.Player.Inventory.Items)).ToArray(); + this.Database.ExecuteSqlRaw("TRUNCATE TABLE CraftingRecipes"); } /// @@ -41,35 +28,5 @@ { optionsBuilder.UseMySQL(DataBaseContexts.ConnectionStringMySQL); } - - /// - /// Truncates CraftingRecipes table and adds the crafting recipes (and saves changes) - /// - private void AddRecipes() - { - this.TruncateTable(); - - this.CraftingRecipes.Add(new CraftingRecipe(ToolPresets.GetAWoodenShovel().stock_id, 5, MaterialPresets.GetALandStick().stock_id)); - this.CraftingRecipes.Add(new CraftingRecipe(ToolPresets.GetAWoodenPickaxe().stock_id, 4, MaterialPresets.GetALandStick().stock_id)); - this.CraftingRecipes.Add(new CraftingRecipe(ToolPresets.GetAWoodenAxe().stock_id, 3, MaterialPresets.GetALandStick().stock_id)); - this.CraftingRecipes.Add(new CraftingRecipe(ToolPresets.GetAWoodenLongsword().stock_id, 4, MaterialPresets.GetALandStick().stock_id)); - - this.CraftingRecipes.Add(new CraftingRecipe(ToolPresets.GetARockShovel().stock_id, 4, MaterialPresets.GetALandRock().stock_id, 2, MaterialPresets.GetALandStick().stock_id)); - this.CraftingRecipes.Add(new CraftingRecipe(ToolPresets.GetARockPickaxe().stock_id, 4, MaterialPresets.GetALandRock().stock_id, 2, MaterialPresets.GetALandStick().stock_id)); - this.CraftingRecipes.Add(new CraftingRecipe(ToolPresets.GetARockAxe().stock_id, 3, MaterialPresets.GetALandRock().stock_id, 2, MaterialPresets.GetALandStick().stock_id)); - this.CraftingRecipes.Add(new CraftingRecipe(ToolPresets.GetARockLongsword().stock_id, 5, MaterialPresets.GetALandRock().stock_id, 2, MaterialPresets.GetALandStick().stock_id)); - - this.CraftingRecipes.Add(new CraftingRecipe(StructurePresets.GetAWoodenLadder().inventory_stock_id, 6, MaterialPresets.GetALandStick().stock_id)); - - this.SaveChanges(); - } - - /// - /// Truncates the table CraftingRecipes (doesn't save the changes) - /// - private void TruncateTable() - { - this.Database.ExecuteSqlRaw("TRUNCATE TABLE CraftingRecipes"); - } } } diff --git a/Mundus/Data/Dialogues/DI.cs b/Mundus/Data/Dialogues/DI.cs deleted file mode 100644 index 94f9ae7..0000000 --- a/Mundus/Data/Dialogues/DI.cs +++ /dev/null @@ -1,36 +0,0 @@ -namespace Mundus.Data.Dialogues -{ - using Mundus.Views.Dialogs; - - /// - /// Dialog Instances - /// Stores and creates all needed dialogs - /// - public static class DI - { - /// - /// Gets the exit dialoge - /// - public static ExitDialog DExit { get; private set; } - - /// - /// Creates all dialog instances - /// - public static void CreateInstances() - { - DExit = new ExitDialog(); - - HideAll(); - } - - /// - /// Hides all dialogs - /// Gtk opens all dialog (window) instances in the project automatically, - /// so you need to manually hide them - /// - private static void HideAll() - { - DExit.Hide(); - } - } -} \ No newline at end of file diff --git a/Mundus/Data/GameEventLogs/GameEventLogContext.cs b/Mundus/Data/GameEventLogs/GameEventLogContext.cs index 81a7177..7f4cfc9 100644 --- a/Mundus/Data/GameEventLogs/GameEventLogContext.cs +++ b/Mundus/Data/GameEventLogs/GameEventLogContext.cs @@ -11,7 +11,7 @@ /// /// Initializes a new instance of the class and truncates the table /// - public GameEventLogContext() : base() + public GameEventLogContext() { this.ResetTable(); } diff --git a/Mundus/Data/SuperLayers/DBTables/PlacedTile.cs b/Mundus/Data/SuperLayers/DBTables/PlacedTile.cs index 53c7dd2..6e5e0ff 100644 --- a/Mundus/Data/SuperLayers/DBTables/PlacedTile.cs +++ b/Mundus/Data/SuperLayers/DBTables/PlacedTile.cs @@ -5,7 +5,7 @@ /// public abstract class PlacedTile { - public PlacedTile(string stock_id, int yPos, int xPos) + protected PlacedTile(string stock_id, int yPos, int xPos) { this.YPos = yPos; this.XPos = xPos; diff --git a/Mundus/Data/SuperLayers/ISuperLayerContext.cs b/Mundus/Data/SuperLayers/ISuperLayerContext.cs index 78a2d83..3deb036 100644 --- a/Mundus/Data/SuperLayers/ISuperLayerContext.cs +++ b/Mundus/Data/SuperLayers/ISuperLayerContext.cs @@ -1,6 +1,4 @@ -using System; - -namespace Mundus.Data.SuperLayers +namespace Mundus.Data.SuperLayers { /// /// Add, remove and change values in the different superlayers (database tables) diff --git a/Mundus/Data/SuperLayers/LandContext.cs b/Mundus/Data/SuperLayers/LandContext.cs index 9301438..9010956 100644 --- a/Mundus/Data/SuperLayers/LandContext.cs +++ b/Mundus/Data/SuperLayers/LandContext.cs @@ -12,7 +12,7 @@ /// /// Initializes a new instance of the LandContext class and truncates all related tables /// - public LandContext() : base() + public LandContext() { this.Database.ExecuteSqlRaw("TRUNCATE TABLE LMobLayer"); this.Database.ExecuteSqlRaw("TRUNCATE TABLE LStructureLayer"); @@ -158,6 +158,11 @@ this.LGroundLayer.First(x => x.YPos == yPos && x.XPos == xPos).stock_id = null; } + public override string ToString() + { + return "Land"; + } + /// /// Used to set the connection string /// @@ -165,9 +170,5 @@ { optionsBuilder.UseMySQL(DataBaseContexts.ConnectionStringMySQL); } - - public override string ToString() { - return "Land"; - } } } diff --git a/Mundus/Data/SuperLayers/SkyContext.cs b/Mundus/Data/SuperLayers/SkyContext.cs index 25dc216..91c60a2 100644 --- a/Mundus/Data/SuperLayers/SkyContext.cs +++ b/Mundus/Data/SuperLayers/SkyContext.cs @@ -12,7 +12,7 @@ /// /// Initializes a new instance of the SkyContext class and truncates all related tables /// - public SkyContext() : base() + public SkyContext() { this.Database.ExecuteSqlRaw("TRUNCATE TABLE SMobLayer"); this.Database.ExecuteSqlRaw("TRUNCATE TABLE SStructureLayer"); @@ -158,16 +158,17 @@ this.SGroundLayer.First(x => x.YPos == yPos && x.XPos == xPos).stock_id = null; } + public override string ToString() + { + return "Sky"; + } + /// /// Used to set the connection string /// - protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseMySQL(DataBaseContexts.ConnectionStringMySQL); } - - public override string ToString() { - return "Sky"; - } } } diff --git a/Mundus/Data/SuperLayers/UndergroundContext.cs b/Mundus/Data/SuperLayers/UndergroundContext.cs index 641f480..1dcd0a4 100644 --- a/Mundus/Data/SuperLayers/UndergroundContext.cs +++ b/Mundus/Data/SuperLayers/UndergroundContext.cs @@ -12,7 +12,7 @@ /// /// Initializes a new instance of the UndergroundContext class and truncates all related tables /// - public UndergroundContext() : base() + public UndergroundContext() { this.Database.ExecuteSqlRaw("TRUNCATE TABLE UMobLayer"); this.Database.ExecuteSqlRaw("TRUNCATE TABLE UStructureLayer"); @@ -157,16 +157,17 @@ this.UGroundLayer.First(x => x.YPos == yPos && x.XPos == xPos).stock_id = null; } + public override string ToString() + { + return "Underground"; + } + /// /// Used to set the connection string /// - protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseMySQL(DataBaseContexts.ConnectionStringMySQL); } - - public override string ToString() { - return "Underground"; - } } } diff --git a/Mundus/Data/Tiles/Mobs/LandMobsPresets.cs b/Mundus/Data/Tiles/Mobs/LandMobsPresets.cs deleted file mode 100644 index 7f9edfd..0000000 --- a/Mundus/Data/Tiles/Mobs/LandMobsPresets.cs +++ /dev/null @@ -1,42 +0,0 @@ -namespace Mundus.Data.Tiles.Mobs -{ - using Mundus.Data; - using Mundus.Data.Tiles.Presets; - using Mundus.Service.Tiles.Mobs; - - public static class LandMobsPresets - { - private static MobTile cow = new MobTile("L_cow", 10, 1, DataBaseContexts.LContext, 1, MaterialPresets.GetALandBeefSteak()); - - private static MobTile sheep = new MobTile("L_sheep", 8, 1, DataBaseContexts.LContext, 1, MaterialPresets.GetALandMuttonSteak()); - - /// - /// Returns a (static) cow MobTile. - /// Do not modify! - /// - public static MobTile GetCow() - { - return cow; - } - - /// - /// Returns a (static) sheep MobTile. - /// Do not modify! - /// - public static MobTile GetSheep() - { - return sheep; - } - - public static MobTile GetFromStock(string stock_id) - { - switch (stock_id) - { - case "L_cow": return GetCow(); - case "L_sheep": return GetSheep(); - case "player": return MI.Player; - default: return null; - } - } - } -} diff --git a/Mundus/Data/Tiles/Mobs/MI.cs b/Mundus/Data/Tiles/Mobs/MI.cs deleted file mode 100644 index 8bfa50a..0000000 --- a/Mundus/Data/Tiles/Mobs/MI.cs +++ /dev/null @@ -1,27 +0,0 @@ -namespace Mundus.Data.Tiles.Mobs -{ - using Mundus.Data.Tiles.Presets; - using Mundus.Service.Tiles.Mobs.LandMobs; - - /// - /// Used to store universally accessed mob instances (player) - /// - public static class MI - { - /// - /// Gets the mob that is used by the person who plays the game - /// - public static Player Player { get; private set; } - - /// - /// Creates the instances of the universally accessed mobs. - /// Note: player has a health of 4 * inventorySize and gets a wooden axe and a wooden pickaxe - /// - public static void CreateInstances() - { - Player = new Player("player", 5, DataBaseContexts.LContext); - Player.Inventory.AppendToHotbar(ToolPresets.GetAWoodenAxe()); - Player.Inventory.AppendToHotbar(ToolPresets.GetAWoodenPickaxe()); - } - } -} diff --git a/Mundus/Data/Tiles/Presets/GroundPresets.cs b/Mundus/Data/Tiles/Presets/GroundPresets.cs deleted file mode 100644 index ac9f422..0000000 --- a/Mundus/Data/Tiles/Presets/GroundPresets.cs +++ /dev/null @@ -1,36 +0,0 @@ -namespace Mundus.Data.Tiles.Presets -{ - using Mundus.Service.Tiles.Items.Types; - - public static class GroundPresets - { - private static GroundTile sSky = new GroundTile("S_sky", -1, false); - private static GroundTile lGrass = new GroundTile("L_grass", 1); - private static GroundTile uRoche = new GroundTile("U_roche", 10); - - public static GroundTile GetSSky() - { - return sSky; - } - - public static GroundTile GetLGrass() - { - return lGrass; - } - - public static GroundTile GetURoche() { - return uRoche; - } - - public static GroundTile GetFromStock(string stock_id) - { - switch (stock_id) - { - case "S_sky": return GetSSky(); - case "L_grass": return GetLGrass(); - case "U_roche": return GetURoche(); - default: return null; - } - } - } -} diff --git a/Mundus/Data/Tiles/Presets/MaterialPresets.cs b/Mundus/Data/Tiles/Presets/MaterialPresets.cs deleted file mode 100644 index 7298e8f..0000000 --- a/Mundus/Data/Tiles/Presets/MaterialPresets.cs +++ /dev/null @@ -1,38 +0,0 @@ -namespace Mundus.Data.Tiles.Presets -{ - using Mundus.Service.Tiles.Items.Types; - - public static class MaterialPresets - { - /// New instance - public static Material GetALandRock() - { - return new Material("L_rock"); - } - - /// New instance - public static Material GetALandStick() - { - return new Material("L_stick"); - } - - /// New instance - public static Material GetALandBeefSteak() - { - return new Material("L_beef_steak", 5); - } - - // New instance - public static Material GetALandMuttonSteak() - { - return new Material("L_mutton_steak", 4); - } - - /// - /// TEMPORARY - /// - public static Material GetAStone() { - return new Material("U_stone"); - } - } -} diff --git a/Mundus/Data/Tiles/Presets/StructurePresets.cs b/Mundus/Data/Tiles/Presets/StructurePresets.cs deleted file mode 100644 index 28bad22..0000000 --- a/Mundus/Data/Tiles/Presets/StructurePresets.cs +++ /dev/null @@ -1,45 +0,0 @@ -namespace Mundus.Data.Tiles.Presets -{ - using Mundus.Service.Tiles.Items.Types; - using static Mundus.Data.Values; - - public static class StructurePresets - { - private static Structure lBoulder = new Structure("L_boulder", "L_boulder_inventory", 7, ToolType.Pickaxe, 1, false, false, MaterialPresets.GetALandRock()); - private static Structure lTree = new Structure("L_tree", "L_tree_inventory", 5, ToolType.Axe, 1, false, false, MaterialPresets.GetALandStick()); - private static Structure uRock = new Structure("U_rock", "U_rock", 10, ToolType.Pickaxe, 2, false, false, MaterialPresets.GetAStone()); - - public static Structure GetLBoulder() - { - return lBoulder; - } - - public static Structure GetLTree() - { - return lTree; - } - - public static Structure GetURock() - { - return uRock; - } - - public static Structure GetAWoodenLadder() - { - return new Structure("L_wooden_ladder", "L_wooden_ladder_inventory", 1, ToolType.Axe, 1, true, true); - } - - public static Structure GetFromStock(string stock_id) - { - switch (stock_id) - { - case "L_boulder": return GetLBoulder(); - case "L_tree": return GetLTree(); - case "U_rock": return GetURock(); - case "L_wooden_ladder_inventory": - case "L_wooden_ladder": return GetAWoodenLadder(); - default: return null; - } - } - } -} diff --git a/Mundus/Data/Tiles/Presets/ToolPresets.cs b/Mundus/Data/Tiles/Presets/ToolPresets.cs deleted file mode 100644 index 9c62201..0000000 --- a/Mundus/Data/Tiles/Presets/ToolPresets.cs +++ /dev/null @@ -1,64 +0,0 @@ -namespace Mundus.Data.Tiles.Presets -{ - using Mundus.Service.Tiles.Items.Types; - using static Mundus.Data.Values; - - public static class ToolPresets - { - public static Tool GetAWoodenPickaxe() - { - return new Tool("wooden_pickaxe", ToolType.Pickaxe, 1); - } - - public static Tool GetAWoodenAxe() - { - return new Tool("wooden_axe", ToolType.Axe, 1); - } - - public static Tool GetAWoodenShovel() - { - return new Tool("wooden_shovel", ToolType.Shovel, 1); - } - - public static Tool GetAWoodenLongsword() - { - return new Tool("wooden_longsword", ToolType.Sword, 2); - } - - public static Tool GetARockPickaxe() - { - return new Tool("rock_pickaxe", ToolType.Pickaxe, 2); - } - - public static Tool GetARockAxe() - { - return new Tool("rock_axe", ToolType.Axe, 2); - } - - public static Tool GetARockShovel() - { - return new Tool("rock_shovel", ToolType.Shovel, 2); - } - - public static Tool GetARockLongsword() - { - return new Tool("rock_longsword", ToolType.Sword, 4); - } - - public static Tool GetFromStock(string stock_id) - { - switch (stock_id) - { - case "wooden_pickaxe": return GetAWoodenPickaxe(); - case "wooden_axe": return GetAWoodenAxe(); - case "wooden_shovel": return GetAWoodenShovel(); - case "wooden_longsword": return GetAWoodenLongsword(); - case "rock_pickaxe": return GetARockPickaxe(); - case "rock_axe": return GetARockAxe(); - case "rock_shovel": return GetARockShovel(); - case "rock_longsword": return GetARockLongsword(); - default: return null; - } - } - } -} diff --git a/Mundus/Data/Windows/WI.cs b/Mundus/Data/Windows/WI.cs deleted file mode 100644 index 14e5f6e..0000000 --- a/Mundus/Data/Windows/WI.cs +++ /dev/null @@ -1,111 +0,0 @@ -namespace Mundus.Data.Windows -{ - using Mundus.Views.Windows; - using Mundus.Views.Windows.GameWindows.Large; - using Mundus.Views.Windows.GameWindows.Medium; - using Mundus.Views.Windows.GameWindows.Small; - - /// - /// Used to store universally accessed windows - /// - public static class WI - { - /// - /// Full name of the build that is used in MainMenu and Pause windows - /// - public const string BuildName = "Requirements Build"; - - /// - /// Gets or sets the selected game window (should be WSGame, WMGame or WLGame) - /// - /// The sel window. - public static IGameWindow SelWin { get; set; } - - /// - /// Gets the main window - /// - public static MainWindow WMain { get; private set; } - - /// - /// Gets the new game window - /// - public static NewGameWindow WNewGame { get; private set; } - - /// - /// Gets the small (sized) game window - /// - public static SmallGameWindow WSGame { get; private set; } - - /// - /// Gets the medium (sized) window - /// - public static MediumGameWindow WMGame { get; private set; } - - /// - /// Gets the large (sized) window - /// - public static LargeGameWindow WLGame { get; private set; } - - /// - /// Gets the settings window - /// - public static SettingsWindow WSettings { get; private set; } - - /// - /// Gets the pause window - /// - public static PauseWindow WPause { get; private set; } - - /// - /// Gets the music window - /// - public static MusicWindow WMusic { get; private set; } - - /// - /// Gets the crafting window - /// - public static CraftingWindow WCrafting { get; private set; } - - /// - /// Gets the log window - /// - public static LogWindow WLog { get; private set; } - - /// - /// Creates all instances of the windows and hides them - /// Gtk opens all window instances in the project automatically, unless they are hidden - /// - public static void CreateInstances() - { - WMain = new MainWindow(); - WMain.Hide(); - - WNewGame = new NewGameWindow(); - WNewGame.Hide(); - - WSGame = new SmallGameWindow(); - WSGame.Hide(); - - WMGame = new MediumGameWindow(); - WMGame.Hide(); - - WLGame = new LargeGameWindow(); - WLGame.Hide(); - - WSettings = new SettingsWindow(); - WSettings.Hide(); - - WPause = new PauseWindow(); - WPause.Hide(); - - WMusic = new MusicWindow(); - WMusic.Hide(); - - WCrafting = new CraftingWindow(); - WCrafting.Hide(); - - WLog = new LogWindow(); - WLog.Hide(); - } - } -} diff --git a/Mundus/Mundus.csproj b/Mundus/Mundus.csproj index 82c0596..08f5a2a 100644 --- a/Mundus/Mundus.csproj +++ b/Mundus/Mundus.csproj @@ -1,5 +1,6 @@ + Debug x86 @@ -8,6 +9,17 @@ Mundus Mundus v4.7 + Requirements + Requirements + Kamen Mladenov + en + https://github.com/Syndamia/Mundus/blob/requirements/LICENSE + Kamen Mladenov + https://github.com/Syndamia/Mundus/tree/requirements + This is Requirements version of the project. + Mundus + Requirements + false true @@ -265,8 +277,6 @@ - - @@ -282,8 +292,6 @@ - - @@ -326,12 +334,18 @@ - - - - - - + + false + + + + + + + + + + @@ -342,8 +356,6 @@ - - @@ -351,7 +363,6 @@ - @@ -360,10 +371,9 @@ - - - + + @@ -371,4 +381,5 @@ + diff --git a/Mundus/Program.cs b/Mundus/Program.cs index a4cc679..7f102ce 100644 --- a/Mundus/Program.cs +++ b/Mundus/Program.cs @@ -2,14 +2,16 @@ { using Gtk; using Mundus.Data; - using Mundus.Data.Dialogues; - using Mundus.Data.Windows; + using Mundus.Service.Dialogs; + using Mundus.Service.Tiles; + using Mundus.Service.Windows; public static class MainClass { public static void Main(string[] args) { DataBaseContexts.CreateInstances(); + RecipeController.AddAllRecipes(); Application.Init(); // All windows and dialogues that are used by user (instances) are saved and created in WindowInstances.cs diff --git a/Mundus/Service/Dialogs/DI.cs b/Mundus/Service/Dialogs/DI.cs new file mode 100644 index 0000000..5b74a65 --- /dev/null +++ b/Mundus/Service/Dialogs/DI.cs @@ -0,0 +1,36 @@ +namespace Mundus.Service.Dialogs +{ + using Mundus.Views.Dialogs; + + /// + /// Dialog Instances + /// Stores and creates all needed dialogs + /// + public static class DI + { + /// + /// Gets the exit dialoge + /// + public static ExitDialog DExit { get; private set; } + + /// + /// Creates all dialog instances + /// + public static void CreateInstances() + { + DExit = new ExitDialog(); + + HideAll(); + } + + /// + /// Hides all dialogs + /// Gtk opens all dialog (window) instances in the project automatically, + /// so you need to manually hide them + /// + private static void HideAll() + { + DExit.Hide(); + } + } +} \ No newline at end of file diff --git a/Mundus/Service/GameEventLogController.cs b/Mundus/Service/GameEventLogController.cs index 4d11146..7094ca0 100644 --- a/Mundus/Service/GameEventLogController.cs +++ b/Mundus/Service/GameEventLogController.cs @@ -11,7 +11,7 @@ public static string GetMessagage(int index) { - return (0 <= index && index < GetCount()) ? DataBaseContexts.GELContext.GetMessage(index + 1) : null; + return (index >= 0 && index < GetCount()) ? DataBaseContexts.GELContext.GetMessage(index + 1) : null; } public static int GetCount() diff --git a/Mundus/Service/GameGenerator.cs b/Mundus/Service/GameGenerator.cs index e5e30b7..b5da1fe 100644 --- a/Mundus/Service/GameGenerator.cs +++ b/Mundus/Service/GameGenerator.cs @@ -2,9 +2,9 @@ { using System; using Mundus.Data; - using Mundus.Data.Tiles.Mobs; - using Mundus.Data.Windows; using Mundus.Service.SuperLayers.Generators; + using Mundus.Service.Tiles.Mobs; + using Mundus.Service.Windows; public static class GameGenerator { @@ -51,7 +51,7 @@ /// /// Sets the game difficulty (that affects map generation). /// - /// Must be "peaceful", "easy", "normal", "hard" or "insane" + /// Must be "peaceful", "easy", "normal", "hard" or "insane" public static void SetDifficulty(Values.Difficulty difficulty) { Values.CurrDifficulty = difficulty; diff --git a/Mundus/Service/SuperLayers/Generators/LandSuperLayerGenerator.cs b/Mundus/Service/SuperLayers/Generators/LandSuperLayerGenerator.cs index b99cc20..0037e22 100644 --- a/Mundus/Service/SuperLayers/Generators/LandSuperLayerGenerator.cs +++ b/Mundus/Service/SuperLayers/Generators/LandSuperLayerGenerator.cs @@ -3,8 +3,9 @@ using System; using Mundus.Data; using Mundus.Data.SuperLayers; - using Mundus.Data.Tiles.Mobs; - using Mundus.Data.Tiles.Presets; + using Mundus.Service.Tiles.Items.Presets; + using Mundus.Service.Tiles.Mobs; + using Mundus.Service.Tiles.Mobs.LandMobs; using static Mundus.Data.Values; /// diff --git a/Mundus/Service/SuperLayers/Generators/SkySuperLayerGenerator.cs b/Mundus/Service/SuperLayers/Generators/SkySuperLayerGenerator.cs index 790dbfa..c16db26 100644 --- a/Mundus/Service/SuperLayers/Generators/SkySuperLayerGenerator.cs +++ b/Mundus/Service/SuperLayers/Generators/SkySuperLayerGenerator.cs @@ -3,7 +3,7 @@ using System; using Mundus.Data; using Mundus.Data.SuperLayers; - using Mundus.Data.Tiles.Presets; + using Mundus.Service.Tiles.Items.Presets; using static Mundus.Data.Values; /// diff --git a/Mundus/Service/SuperLayers/Generators/UndergroundSuperLayerGenerator.cs b/Mundus/Service/SuperLayers/Generators/UndergroundSuperLayerGenerator.cs index f4eca86..807533f 100644 --- a/Mundus/Service/SuperLayers/Generators/UndergroundSuperLayerGenerator.cs +++ b/Mundus/Service/SuperLayers/Generators/UndergroundSuperLayerGenerator.cs @@ -3,7 +3,7 @@ using System; using Mundus.Data; using Mundus.Data.SuperLayers; - using Mundus.Data.Tiles.Presets; + using Mundus.Service.Tiles.Items.Presets; using static Mundus.Data.Values; /// diff --git a/Mundus/Service/SuperLayers/ImageController.cs b/Mundus/Service/SuperLayers/ImageController.cs index 19b4793..8e57340 100644 --- a/Mundus/Service/SuperLayers/ImageController.cs +++ b/Mundus/Service/SuperLayers/ImageController.cs @@ -3,8 +3,8 @@ using Gtk; using Mundus.Data; using Mundus.Data.SuperLayers; - using Mundus.Data.Tiles.Mobs; using Mundus.Service.Tiles.Items.Types; + using Mundus.Service.Tiles.Mobs; using static Mundus.Service.Tiles.Mobs.Inventory; public static class ImageController diff --git a/Mundus/Service/Tiles/Crafting/CraftingController.cs b/Mundus/Service/Tiles/Crafting/CraftingController.cs deleted file mode 100644 index ffd31db..0000000 --- a/Mundus/Service/Tiles/Crafting/CraftingController.cs +++ /dev/null @@ -1,64 +0,0 @@ -namespace Mundus.Service.Tiles.Crafting -{ - using System.Linq; - using Mundus.Data; - using Mundus.Data.Tiles.Mobs; - using Mundus.Data.Tiles.Presets; - using Mundus.Service.Tiles.Items; - using Mundus.Service.Tiles.Mobs; - - public static class CraftingController - { - /// - /// Removes items and adds the result item to the inventory - /// - public static void CraftItem(CraftingRecipe itemRecipe, MobTile mob) - { - // Removes all items that are used to craft the result item - var reqItems = itemRecipe.GetAllRequiredItems(); - var reqCounts = itemRecipe.GetAllCounts(); - - var allInventoryItems = mob.Inventory.Items.Where(i => i != null).ToArray(); - - for (int item = 0; item < reqItems.Length; item++) - { - for (int i = 0, removed = 0; i < allInventoryItems.Length && removed < reqCounts[item]; i++) - { - if (allInventoryItems[i].stock_id == reqItems[item]) - { - mob.Inventory.DeleteFromItems(i); - removed++; - } - } - } - - ItemTile result = ToolPresets.GetFromStock(itemRecipe.ResultItem); - - if (result == null) - { - result = StructurePresets.GetFromStock(itemRecipe.ResultItem); - } - - MI.Player.Inventory.AppendToItems(result); - - Data.Windows.WI.SelWin.PrintInventory(); - } - - /// - /// Does CraftItem method for the player - /// - /// CraftingRecipie of the item that will be crafted - public static void CraftItemPlayer(CraftingRecipe itemRecipe) - { - CraftItem(itemRecipe, MI.Player); - } - - /// - /// Returns all recipes that can be executed with the current items in the player inventory (Inventory.Items) - /// - public static CraftingRecipe[] GetAvalableRecipes() - { - return DataBaseContexts.CTContext.GetAvalableRecipes(); - } - } -} \ No newline at end of file diff --git a/Mundus/Service/Tiles/Crafting/CraftingRecipe.cs b/Mundus/Service/Tiles/Crafting/CraftingRecipe.cs deleted file mode 100644 index 1bdb625..0000000 --- a/Mundus/Service/Tiles/Crafting/CraftingRecipe.cs +++ /dev/null @@ -1,156 +0,0 @@ -namespace Mundus.Service.Tiles.Crafting -{ - using System.ComponentModel.DataAnnotations; - using System.ComponentModel.DataAnnotations.Schema; - using System.Linq; - using Mundus.Service.Tiles.Items; - - [Table("CraftingRecipes", Schema = "Mundus")] - public class CraftingRecipe - { - public CraftingRecipe(string resultItem, int count1, string reqItem1) : this(resultItem, count1, reqItem1, 0, null, 0, null, 0, null, 0, null) - { - } - - public CraftingRecipe(string resultItem, int count1, string reqItem1, int count2, string reqItem2) : this(resultItem, count1, reqItem1, count2, reqItem2, 0, null, 0, null, 0, null) - { - } - - public CraftingRecipe(string resultItem, int count1, string reqItem1, int count2, string reqItem2, int count3, string reqItem3) : this(resultItem, count1, reqItem1, count2, reqItem2, count3, reqItem3, 0, null, 0, null) - { - } - - public CraftingRecipe(string resultItem, int count1, string reqItem1, int count2, string reqItem2, int count3, string reqItem3, int count4, string reqItem4) : this(resultItem, count1, reqItem1, count2, reqItem2, count3, reqItem3, count4, reqItem4, 0, null) - { - } - - public CraftingRecipe(string resultItem, int count1, string reqItem1, int count2, string reqItem2, int count3, string reqItem3, int count4, string reqItem4, int count5, string reqItem5) - { - this.ResultItem = resultItem; - - this.Count1 = count1; - this.ReqItem1 = reqItem1; - - this.Count2 = count2; - this.ReqItem2 = reqItem2; - - this.Count3 = count3; - this.ReqItem3 = reqItem3; - - this.Count4 = count4; - this.ReqItem4 = reqItem4; - - this.Count5 = count5; - this.ReqItem5 = reqItem5; - } - - [Key] - public int ID { get; set; } - - /// - /// Item that will be added to the inventory after crafting - /// - /// The result item. - public string ResultItem { get; private set; } - - /// - /// Gets the required amount of the first item - /// - public int Count1 { get; private set; } - - /// - /// Gets the required first item - /// - public string ReqItem1 { get; private set; } - - /// - /// Gets the required amount of the second item - /// - public int Count2 { get; private set; } - - /// - /// Gets the required second item - /// - public string ReqItem2 { get; private set; } - - /// - /// Gets the required amount of the third item - /// - public int Count3 { get; private set; } - - /// - /// Gets the required third item - /// - public string ReqItem3 { get; private set; } - - /// - /// Gets the required amount of the fourth item - /// - public int Count4 { get; private set; } - - /// - /// Gets the required fourth item - /// - public string ReqItem4 { get; private set; } - - /// - /// Gets the required amount of the fifth item - /// - public int Count5 { get; private set; } - - /// - /// Gets the required fifth item - /// - public string ReqItem5 { get; private set; } - - /// - /// Checks if the given array of items has enough of every requried item - /// - /// trueIf has enoughfalseotherwise - public bool HasEnoughItems(ItemTile[] items) - { - bool hasEnough = false; - - if (items.Any(item => item != null)) - { - var allItemStocks = items.Where(x => x != null).Select(x => x.stock_id).ToArray(); - - hasEnough = allItemStocks.Contains(ReqItem1) && - allItemStocks.Count(i => i == ReqItem1) >= Count1; - - if (ReqItem2 != null && hasEnough) - { - hasEnough = allItemStocks.Contains(ReqItem2) && - allItemStocks.Count(i => i == ReqItem2) >= Count2; - } - if (ReqItem3 != null && hasEnough) - { - hasEnough = allItemStocks.Contains(ReqItem3) && - allItemStocks.Count(i => i == ReqItem3) >= Count3; - } - if (ReqItem4 != null && hasEnough) - { - hasEnough = allItemStocks.Contains(ReqItem4) && - allItemStocks.Count(i => i == ReqItem4) >= Count4; - } - if (ReqItem5 != null && hasEnough) - { - hasEnough = allItemStocks.Contains(ReqItem5) && - allItemStocks.Count(i => i == ReqItem5) >= Count5; - } - } - - return hasEnough; - } - - public string[] GetAllRequiredItems() - { - return new string[] { ReqItem1, ReqItem2, ReqItem3, ReqItem4, ReqItem5}; - } - - public int[] GetAllCounts() - { - return new int[] { Count1, Count2, Count3, Count4, Count5}; - } - } -} diff --git a/Mundus/Service/Tiles/Items/ItemController.cs b/Mundus/Service/Tiles/Items/ItemController.cs index 17debc9..5600170 100644 --- a/Mundus/Service/Tiles/Items/ItemController.cs +++ b/Mundus/Service/Tiles/Items/ItemController.cs @@ -1,8 +1,8 @@ namespace Mundus.Service.Tiles.Items { - using Mundus.Data.Tiles.Mobs; - using Mundus.Data.Windows; using Mundus.Service.Tiles.Items.Types; + using Mundus.Service.Tiles.Mobs; + using Mundus.Service.Windows; using static Mundus.Service.Tiles.Mobs.Inventory; /// diff --git a/Mundus/Service/Tiles/Items/ItemTile.cs b/Mundus/Service/Tiles/Items/ItemTile.cs index 83c5590..225e360 100644 --- a/Mundus/Service/Tiles/Items/ItemTile.cs +++ b/Mundus/Service/Tiles/Items/ItemTile.cs @@ -4,7 +4,7 @@ { public string stock_id { get; private set; } - public ItemTile(ItemTile item) : this(item.stock_id) + protected ItemTile(ItemTile item) : this(item.stock_id) { } diff --git a/Mundus/Service/Tiles/Items/Presets/GroundPresets.cs b/Mundus/Service/Tiles/Items/Presets/GroundPresets.cs new file mode 100644 index 0000000..705f746 --- /dev/null +++ b/Mundus/Service/Tiles/Items/Presets/GroundPresets.cs @@ -0,0 +1,36 @@ +namespace Mundus.Service.Tiles.Items.Presets +{ + using Mundus.Service.Tiles.Items.Types; + + public static class GroundPresets + { + private static GroundTile sSky = new GroundTile("S_sky", -1, false); + private static GroundTile lGrass = new GroundTile("L_grass", 1); + private static GroundTile uRoche = new GroundTile("U_roche", 10); + + public static GroundTile GetSSky() + { + return sSky; + } + + public static GroundTile GetLGrass() + { + return lGrass; + } + + public static GroundTile GetURoche() { + return uRoche; + } + + public static GroundTile GetFromStock(string stock_id) + { + switch (stock_id) + { + case "S_sky": return GetSSky(); + case "L_grass": return GetLGrass(); + case "U_roche": return GetURoche(); + default: return null; + } + } + } +} diff --git a/Mundus/Service/Tiles/Items/Presets/MaterialPresets.cs b/Mundus/Service/Tiles/Items/Presets/MaterialPresets.cs new file mode 100644 index 0000000..b546394 --- /dev/null +++ b/Mundus/Service/Tiles/Items/Presets/MaterialPresets.cs @@ -0,0 +1,38 @@ +namespace Mundus.Service.Tiles.Items.Presets +{ + using Mundus.Service.Tiles.Items.Types; + + public static class MaterialPresets + { + /// New instance + public static Material GetALandRock() + { + return new Material("L_rock"); + } + + /// New instance + public static Material GetALandStick() + { + return new Material("L_stick"); + } + + /// New instance + public static Material GetALandBeefSteak() + { + return new Material("L_beef_steak", 5); + } + + // New instance + public static Material GetALandMuttonSteak() + { + return new Material("L_mutton_steak", 4); + } + + /// + /// TEMPORARY + /// + public static Material GetAStone() { + return new Material("U_stone"); + } + } +} diff --git a/Mundus/Service/Tiles/Items/Presets/StructurePresets.cs b/Mundus/Service/Tiles/Items/Presets/StructurePresets.cs new file mode 100644 index 0000000..c019c7c --- /dev/null +++ b/Mundus/Service/Tiles/Items/Presets/StructurePresets.cs @@ -0,0 +1,45 @@ +namespace Mundus.Service.Tiles.Items.Presets +{ + using Mundus.Service.Tiles.Items.Types; + using static Mundus.Data.Values; + + public static class StructurePresets + { + private static Structure lBoulder = new Structure("L_boulder", "L_boulder_inventory", 7, ToolType.Pickaxe, 1, false, false, MaterialPresets.GetALandRock()); + private static Structure lTree = new Structure("L_tree", "L_tree_inventory", 5, ToolType.Axe, 1, false, false, MaterialPresets.GetALandStick()); + private static Structure uRock = new Structure("U_rock", "U_rock", 10, ToolType.Pickaxe, 2, false, false, MaterialPresets.GetAStone()); + + public static Structure GetLBoulder() + { + return lBoulder; + } + + public static Structure GetLTree() + { + return lTree; + } + + public static Structure GetURock() + { + return uRock; + } + + public static Structure GetAWoodenLadder() + { + return new Structure("L_wooden_ladder", "L_wooden_ladder_inventory", 1, ToolType.Axe, 1, true, true); + } + + public static Structure GetFromStock(string stock_id) + { + switch (stock_id) + { + case "L_boulder": return GetLBoulder(); + case "L_tree": return GetLTree(); + case "U_rock": return GetURock(); + case "L_wooden_ladder_inventory": + case "L_wooden_ladder": return GetAWoodenLadder(); + default: return null; + } + } + } +} diff --git a/Mundus/Service/Tiles/Items/Presets/ToolPresets.cs b/Mundus/Service/Tiles/Items/Presets/ToolPresets.cs new file mode 100644 index 0000000..a168c3c --- /dev/null +++ b/Mundus/Service/Tiles/Items/Presets/ToolPresets.cs @@ -0,0 +1,64 @@ +namespace Mundus.Service.Tiles.Items.Presets +{ + using Mundus.Service.Tiles.Items.Types; + using static Mundus.Data.Values; + + public static class ToolPresets + { + public static Tool GetAWoodenPickaxe() + { + return new Tool("wooden_pickaxe", ToolType.Pickaxe, 1); + } + + public static Tool GetAWoodenAxe() + { + return new Tool("wooden_axe", ToolType.Axe, 1); + } + + public static Tool GetAWoodenShovel() + { + return new Tool("wooden_shovel", ToolType.Shovel, 1); + } + + public static Tool GetAWoodenLongsword() + { + return new Tool("wooden_longsword", ToolType.Sword, 2); + } + + public static Tool GetARockPickaxe() + { + return new Tool("rock_pickaxe", ToolType.Pickaxe, 2); + } + + public static Tool GetARockAxe() + { + return new Tool("rock_axe", ToolType.Axe, 2); + } + + public static Tool GetARockShovel() + { + return new Tool("rock_shovel", ToolType.Shovel, 2); + } + + public static Tool GetARockLongsword() + { + return new Tool("rock_longsword", ToolType.Sword, 4); + } + + public static Tool GetFromStock(string stock_id) + { + switch (stock_id) + { + case "wooden_pickaxe": return GetAWoodenPickaxe(); + case "wooden_axe": return GetAWoodenAxe(); + case "wooden_shovel": return GetAWoodenShovel(); + case "wooden_longsword": return GetAWoodenLongsword(); + case "rock_pickaxe": return GetARockPickaxe(); + case "rock_axe": return GetARockAxe(); + case "rock_shovel": return GetARockShovel(); + case "rock_longsword": return GetARockLongsword(); + default: return null; + } + } + } +} diff --git a/Mundus/Service/Tiles/Mobs/Controllers/MobFighting.cs b/Mundus/Service/Tiles/Mobs/Controllers/MobFighting.cs index a903218..1ae1496 100644 --- a/Mundus/Service/Tiles/Mobs/Controllers/MobFighting.cs +++ b/Mundus/Service/Tiles/Mobs/Controllers/MobFighting.cs @@ -3,9 +3,10 @@ using System; using System.Linq; using Mundus.Data; - using Mundus.Data.Tiles.Mobs; + using Mundus.Service.Tiles.Mobs; using Mundus.Service.Tiles.Items.Types; using static Mundus.Data.Values; + using Mundus.Service.Tiles.Mobs.LandMobs; public static class MobFighting { diff --git a/Mundus/Service/Tiles/Mobs/Controllers/MobMovement.cs b/Mundus/Service/Tiles/Mobs/Controllers/MobMovement.cs index c5ed2ac..b6ac419 100644 --- a/Mundus/Service/Tiles/Mobs/Controllers/MobMovement.cs +++ b/Mundus/Service/Tiles/Mobs/Controllers/MobMovement.cs @@ -2,8 +2,8 @@ { using System; using Mundus.Data; - using Mundus.Data.Tiles.Mobs; - using Mundus.Data.Tiles.Presets; + using Mundus.Service.Tiles.Mobs; + using Mundus.Service.Tiles.Items.Presets; using Mundus.Service.SuperLayers; using Mundus.Service.Tiles.Mobs.LandMobs; using static Mundus.Data.Values; diff --git a/Mundus/Service/Tiles/Mobs/Controllers/MobStatsController.cs b/Mundus/Service/Tiles/Mobs/Controllers/MobStatsController.cs index d431ba8..679881f 100644 --- a/Mundus/Service/Tiles/Mobs/Controllers/MobStatsController.cs +++ b/Mundus/Service/Tiles/Mobs/Controllers/MobStatsController.cs @@ -1,7 +1,7 @@ namespace Mundus.Service.Tiles.Mobs.Controllers { - using Mundus.Data.Tiles.Mobs; - using Mundus.Data.Tiles.Presets; + using Mundus.Service.Tiles.Mobs; + using Mundus.Service.Tiles.Items.Presets; using Mundus.Service.SuperLayers; public static class MobStatsController diff --git a/Mundus/Service/Tiles/Mobs/Controllers/MobTerraforming.cs b/Mundus/Service/Tiles/Mobs/Controllers/MobTerraforming.cs index fa70f34..2eea1e9 100644 --- a/Mundus/Service/Tiles/Mobs/Controllers/MobTerraforming.cs +++ b/Mundus/Service/Tiles/Mobs/Controllers/MobTerraforming.cs @@ -3,8 +3,8 @@ using System.Linq; using Mundus.Data; using Mundus.Data.SuperLayers; - using Mundus.Data.Tiles.Mobs; - using Mundus.Data.Tiles.Presets; + using Mundus.Service.Tiles.Mobs; + using Mundus.Service.Tiles.Items.Presets; using Mundus.Service.SuperLayers; using Mundus.Service.Tiles.Items.Types; using static Mundus.Data.Values; diff --git a/Mundus/Service/Tiles/Mobs/Inventory.cs b/Mundus/Service/Tiles/Mobs/Inventory.cs index 47b7b91..8fe6617 100644 --- a/Mundus/Service/Tiles/Mobs/Inventory.cs +++ b/Mundus/Service/Tiles/Mobs/Inventory.cs @@ -2,7 +2,7 @@ { using System; using System.Linq; - using Mundus.Data.Tiles.Mobs; + using Mundus.Service.Tiles.Mobs; using Mundus.Service.Tiles.Items; using Mundus.Service.Tiles.Items.Types; diff --git a/Mundus/Service/Tiles/Mobs/LandMobs/LandMobsPresets.cs b/Mundus/Service/Tiles/Mobs/LandMobs/LandMobsPresets.cs new file mode 100644 index 0000000..c3986ae --- /dev/null +++ b/Mundus/Service/Tiles/Mobs/LandMobs/LandMobsPresets.cs @@ -0,0 +1,42 @@ +namespace Mundus.Service.Tiles.Mobs.LandMobs +{ + using Mundus.Data; + using Mundus.Service.Tiles.Items.Presets; + using Mundus.Service.Tiles.Mobs; + + public static class LandMobsPresets + { + private static MobTile cow = new MobTile("L_cow", 10, 1, DataBaseContexts.LContext, 1, MaterialPresets.GetALandBeefSteak()); + + private static MobTile sheep = new MobTile("L_sheep", 8, 1, DataBaseContexts.LContext, 1, MaterialPresets.GetALandMuttonSteak()); + + /// + /// Returns a (static) cow MobTile. + /// Do not modify! + /// + public static MobTile GetCow() + { + return cow; + } + + /// + /// Returns a (static) sheep MobTile. + /// Do not modify! + /// + public static MobTile GetSheep() + { + return sheep; + } + + public static MobTile GetFromStock(string stock_id) + { + switch (stock_id) + { + case "L_cow": return GetCow(); + case "L_sheep": return GetSheep(); + case "player": return MI.Player; + default: return null; + } + } + } +} diff --git a/Mundus/Service/Tiles/Mobs/LandMobs/Player.cs b/Mundus/Service/Tiles/Mobs/LandMobs/Player.cs index 11d6805..ebc3d7c 100644 --- a/Mundus/Service/Tiles/Mobs/LandMobs/Player.cs +++ b/Mundus/Service/Tiles/Mobs/LandMobs/Player.cs @@ -2,7 +2,7 @@ { using System; using Mundus.Data.SuperLayers; - using Mundus.Data.Windows; + using Mundus.Service.Windows; using Mundus.Service.Tiles.Items.Types; public class Player : MobTile diff --git a/Mundus/Service/Tiles/Mobs/MI.cs b/Mundus/Service/Tiles/Mobs/MI.cs new file mode 100644 index 0000000..ddf0df1 --- /dev/null +++ b/Mundus/Service/Tiles/Mobs/MI.cs @@ -0,0 +1,28 @@ +namespace Mundus.Service.Tiles.Mobs +{ + using Mundus.Data; + using Mundus.Service.Tiles.Items.Presets; + using Mundus.Service.Tiles.Mobs.LandMobs; + + /// + /// Used to store universally accessed mob instances (player) + /// + public static class MI + { + /// + /// Gets the mob that is used by the person who plays the game + /// + public static Player Player { get; private set; } + + /// + /// Creates the instances of the universally accessed mobs. + /// Note: player has a health of 4 * inventorySize and gets a wooden axe and a wooden pickaxe + /// + public static void CreateInstances() + { + Player = new Player("player", 5, DataBaseContexts.LContext); + Player.Inventory.AppendToHotbar(ToolPresets.GetAWoodenAxe()); + Player.Inventory.AppendToHotbar(ToolPresets.GetAWoodenPickaxe()); + } + } +} diff --git a/Mundus/Service/Tiles/Mobs/MobTile.cs b/Mundus/Service/Tiles/Mobs/MobTile.cs index c527437..31cbd61 100644 --- a/Mundus/Service/Tiles/Mobs/MobTile.cs +++ b/Mundus/Service/Tiles/Mobs/MobTile.cs @@ -1,8 +1,8 @@ namespace Mundus.Service.Tiles.Mobs { using Mundus.Data.SuperLayers; - using Mundus.Data.Windows; using Mundus.Service.Tiles.Items.Types; + using Mundus.Service.Windows; public class MobTile : ITile { diff --git a/Mundus/Service/Tiles/RecipeController.cs b/Mundus/Service/Tiles/RecipeController.cs new file mode 100644 index 0000000..142903a --- /dev/null +++ b/Mundus/Service/Tiles/RecipeController.cs @@ -0,0 +1,124 @@ +namespace Mundus.Service.Tiles +{ + using System.Linq; + using Mundus.Data; + using Mundus.Data.Crafting; + using Mundus.Service.Tiles.Items; + using Mundus.Service.Tiles.Items.Presets; + using Mundus.Service.Tiles.Mobs; + using Mundus.Service.Windows; + + public static class RecipeController + { + /// + /// Removes items and adds the result item to the inventory + /// + public static void CraftItem(CraftingRecipe itemRecipe, MobTile mob) + { + // Removes all items that are used to craft the result item + var reqItems = itemRecipe.GetAllRequiredItems(); + var reqCounts = itemRecipe.GetAllCounts(); + + var allInventoryItems = mob.Inventory.Items.Where(i => i != null).ToArray(); + + for (int item = 0; item < reqItems.Length; item++) + { + for (int i = 0, removed = 0; i < allInventoryItems.Length && removed < reqCounts[item]; i++) + { + if (allInventoryItems[i].stock_id == reqItems[item]) + { + mob.Inventory.DeleteFromItems(i); + removed++; + } + } + } + + ItemTile result = ToolPresets.GetFromStock(itemRecipe.ResultItem); + + if (result == null) + { + result = StructurePresets.GetFromStock(itemRecipe.ResultItem); + } + + MI.Player.Inventory.AppendToItems(result); + + WI.SelWin.PrintInventory(); + } + + /// + /// Does CraftItem method for the player + /// + /// CraftingRecipie of the item that will be crafted + public static void CraftItemPlayer(CraftingRecipe itemRecipe) + { + CraftItem(itemRecipe, MI.Player); + } + + /// + /// Checks if the given array of items has enough of every requried item + /// + /// trueIf has enoughfalseotherwise + public static bool HasEnoughItems(CraftingRecipe recipe, ItemTile[] items) { + bool hasEnough = false; + + if (items.Any(item => item != null)) { + var allItemStocks = items.Where(x => x != null).Select(x => x.stock_id).ToArray(); + + hasEnough = allItemStocks.Contains(recipe.ReqItem1) && + allItemStocks.Count(i => i == recipe.ReqItem1) >= recipe.Count1; + + if (recipe.ReqItem2 != null && hasEnough) { + hasEnough = allItemStocks.Contains(recipe.ReqItem2) && + allItemStocks.Count(i => i == recipe.ReqItem2) >= recipe.Count2; + } + if (recipe.ReqItem3 != null && hasEnough) { + hasEnough = allItemStocks.Contains(recipe.ReqItem3) && + allItemStocks.Count(i => i == recipe.ReqItem3) >= recipe.Count3; + } + if (recipe.ReqItem4 != null && hasEnough) { + hasEnough = allItemStocks.Contains(recipe.ReqItem4) && + allItemStocks.Count(i => i == recipe.ReqItem4) >= recipe.Count4; + } + if (recipe.ReqItem5 != null && hasEnough) { + hasEnough = allItemStocks.Contains(recipe.ReqItem5) && + allItemStocks.Count(i => i == recipe.ReqItem5) >= recipe.Count5; + } + } + + return hasEnough; + } + + /// + /// Returns an array with all the recipes that can be crafted with the items the player has + /// + public static CraftingRecipe[] GetAvalableRecipes() + { + var recipes = DataBaseContexts.CTContext.CraftingRecipes.ToArray(); + return recipes.Where(cr => HasEnoughItems(cr, MI.Player.Inventory.Items)).ToArray(); + } + + + + /// + /// Truncates CraftingRecipes table and adds the crafting recipes (and saves changes) + /// + public static void AddAllRecipes() { + DataBaseContexts.CTContext.TruncateTable(); + var craftingRecipes = DataBaseContexts.CTContext.CraftingRecipes; + + craftingRecipes.Add(new CraftingRecipe(ToolPresets.GetAWoodenShovel().stock_id, 5, MaterialPresets.GetALandStick().stock_id)); + craftingRecipes.Add(new CraftingRecipe(ToolPresets.GetAWoodenPickaxe().stock_id, 4, MaterialPresets.GetALandStick().stock_id)); + craftingRecipes.Add(new CraftingRecipe(ToolPresets.GetAWoodenAxe().stock_id, 3, MaterialPresets.GetALandStick().stock_id)); + craftingRecipes.Add(new CraftingRecipe(ToolPresets.GetAWoodenLongsword().stock_id, 4, MaterialPresets.GetALandStick().stock_id)); + + craftingRecipes.Add(new CraftingRecipe(ToolPresets.GetARockShovel().stock_id, 4, MaterialPresets.GetALandRock().stock_id, 2, MaterialPresets.GetALandStick().stock_id)); + craftingRecipes.Add(new CraftingRecipe(ToolPresets.GetARockPickaxe().stock_id, 4, MaterialPresets.GetALandRock().stock_id, 2, MaterialPresets.GetALandStick().stock_id)); + craftingRecipes.Add(new CraftingRecipe(ToolPresets.GetARockAxe().stock_id, 3, MaterialPresets.GetALandRock().stock_id, 2, MaterialPresets.GetALandStick().stock_id)); + craftingRecipes.Add(new CraftingRecipe(ToolPresets.GetARockLongsword().stock_id, 5, MaterialPresets.GetALandRock().stock_id, 2, MaterialPresets.GetALandStick().stock_id)); + + craftingRecipes.Add(new CraftingRecipe(StructurePresets.GetAWoodenLadder().inventory_stock_id, 6, MaterialPresets.GetALandStick().stock_id)); + + DataBaseContexts.CTContext.SaveChanges(); + } + } +} \ No newline at end of file diff --git a/Mundus/Service/Windows/Calculate.cs b/Mundus/Service/Windows/Calculate.cs index 8bc1823..7bf92c3 100644 --- a/Mundus/Service/Windows/Calculate.cs +++ b/Mundus/Service/Windows/Calculate.cs @@ -2,7 +2,7 @@ { using System; using Mundus.Data; - using Mundus.Data.Tiles.Mobs; + using Mundus.Service.Tiles.Mobs; /// /// Used to calculate values, related to the buttons on the game windows diff --git a/Mundus/Service/Windows/WI.cs b/Mundus/Service/Windows/WI.cs new file mode 100644 index 0000000..da3065f --- /dev/null +++ b/Mundus/Service/Windows/WI.cs @@ -0,0 +1,111 @@ +namespace Mundus.Service.Windows +{ + using Mundus.Views.Windows; + using Mundus.Views.Windows.GameWindows.Large; + using Mundus.Views.Windows.GameWindows.Medium; + using Mundus.Views.Windows.GameWindows.Small; + + /// + /// Used to store universally accessed windows + /// + public static class WI + { + /// + /// Full name of the build that is used in MainMenu and Pause windows + /// + public const string BuildName = "Requirements Build"; + + /// + /// Gets or sets the selected game window (should be WSGame, WMGame or WLGame) + /// + /// The sel window. + public static IGameWindow SelWin { get; set; } + + /// + /// Gets the main window + /// + public static MainWindow WMain { get; private set; } + + /// + /// Gets the new game window + /// + public static NewGameWindow WNewGame { get; private set; } + + /// + /// Gets the small (sized) game window + /// + public static SmallGameWindow WSGame { get; private set; } + + /// + /// Gets the medium (sized) window + /// + public static MediumGameWindow WMGame { get; private set; } + + /// + /// Gets the large (sized) window + /// + public static LargeGameWindow WLGame { get; private set; } + + /// + /// Gets the settings window + /// + public static SettingsWindow WSettings { get; private set; } + + /// + /// Gets the pause window + /// + public static PauseWindow WPause { get; private set; } + + /// + /// Gets the music window + /// + public static MusicWindow WMusic { get; private set; } + + /// + /// Gets the crafting window + /// + public static CraftingWindow WCrafting { get; private set; } + + /// + /// Gets the log window + /// + public static LogWindow WLog { get; private set; } + + /// + /// Creates all instances of the windows and hides them + /// Gtk opens all window instances in the project automatically, unless they are hidden + /// + public static void CreateInstances() + { + WMain = new MainWindow(); + WMain.Hide(); + + WNewGame = new NewGameWindow(); + WNewGame.Hide(); + + WSGame = new SmallGameWindow(); + WSGame.Hide(); + + WMGame = new MediumGameWindow(); + WMGame.Hide(); + + WLGame = new LargeGameWindow(); + WLGame.Hide(); + + WSettings = new SettingsWindow(); + WSettings.Hide(); + + WPause = new PauseWindow(); + WPause.Hide(); + + WMusic = new MusicWindow(); + WMusic.Hide(); + + WCrafting = new CraftingWindow(); + WCrafting.Hide(); + + WLog = new LogWindow(); + WLog.Hide(); + } + } +} diff --git a/Mundus/Service/Windows/WindowController.cs b/Mundus/Service/Windows/WindowController.cs index 1c4a4aa..8b089bf 100644 --- a/Mundus/Service/Windows/WindowController.cs +++ b/Mundus/Service/Windows/WindowController.cs @@ -1,7 +1,6 @@ namespace Mundus.Service.Windows { using Gtk; - using Mundus.Data.Windows; using Mundus.Service.Tiles.Items; using Mundus.Service.Tiles.Mobs; using Mundus.Service.Tiles.Mobs.Controllers; diff --git a/Mundus/Views/Windows/CraftingWindow.cs b/Mundus/Views/Windows/CraftingWindow.cs index f05603d..0339327 100644 --- a/Mundus/Views/Windows/CraftingWindow.cs +++ b/Mundus/Views/Windows/CraftingWindow.cs @@ -2,7 +2,8 @@ { using System; using Gtk; - using Mundus.Service.Tiles.Crafting; + using Mundus.Data.Crafting; + using Mundus.Service.Tiles; public partial class CraftingWindow : Gtk.Window { @@ -28,7 +29,7 @@ { this.Reset(); - this.recipes = CraftingController.GetAvalableRecipes(); + this.recipes = RecipeController.GetAvalableRecipes(); this.recipeIndex = 0; this.PrintRecipe(); @@ -71,7 +72,7 @@ /// protected void OnBtnCraftClicked(object sender, EventArgs e) { - CraftingController.CraftItemPlayer(this.recipes[this.recipeIndex]); + RecipeController.CraftItemPlayer(this.recipes[this.recipeIndex]); this.Hide(); } @@ -87,7 +88,7 @@ this.btnCraft.Sensitive = true; this.imgItem.SetFromStock(recipe.ResultItem, IconSize.Dnd); - this.lblInfo.Text = recipe.ResultItem.ToString(); + this.lblInfo.Text = recipe.ResultItem; this.lblC1.Text = recipe.Count1 + string.Empty; this.imgI1.SetFromStock(recipe.ReqItem1, IconSize.Dnd); diff --git a/Mundus/Views/Windows/GameWindows/Large/LargeLogic.cs b/Mundus/Views/Windows/GameWindows/Large/LargeLogic.cs index aa456e5..bb095f7 100644 --- a/Mundus/Views/Windows/GameWindows/Large/LargeLogic.cs +++ b/Mundus/Views/Windows/GameWindows/Large/LargeLogic.cs @@ -1,7 +1,7 @@ namespace Mundus.Views.Windows.GameWindows.Large { using Gtk; - using Mundus.Data.Dialogues; + using Mundus.Service.Dialogs; using Mundus.Service.Tiles.Items; using static Mundus.Service.Tiles.Mobs.Inventory; diff --git a/Mundus/Views/Windows/GameWindows/Medium/MediumLogic.cs b/Mundus/Views/Windows/GameWindows/Medium/MediumLogic.cs index 96bdcf3..86920d6 100644 --- a/Mundus/Views/Windows/GameWindows/Medium/MediumLogic.cs +++ b/Mundus/Views/Windows/GameWindows/Medium/MediumLogic.cs @@ -1,7 +1,7 @@ namespace Mundus.Views.Windows.GameWindows.Medium { using Gtk; - using Mundus.Data.Dialogues; + using Mundus.Service.Dialogs; using Mundus.Service.Tiles.Items; using static Mundus.Service.Tiles.Mobs.Inventory; diff --git a/Mundus/Views/Windows/GameWindows/Small/SmallLogic.cs b/Mundus/Views/Windows/GameWindows/Small/SmallLogic.cs index 3948360..e4a3aa4 100644 --- a/Mundus/Views/Windows/GameWindows/Small/SmallLogic.cs +++ b/Mundus/Views/Windows/GameWindows/Small/SmallLogic.cs @@ -1,7 +1,7 @@ namespace Mundus.Views.Windows.GameWindows.Small { using Gtk; - using Mundus.Data.Dialogues; + using Mundus.Service.Dialogs; using Mundus.Service.Tiles.Items; using static Mundus.Service.Tiles.Mobs.Inventory; diff --git a/Mundus/Views/Windows/LogWindow.cs b/Mundus/Views/Windows/LogWindow.cs index e6df1c5..a53d17a 100644 --- a/Mundus/Views/Windows/LogWindow.cs +++ b/Mundus/Views/Windows/LogWindow.cs @@ -8,7 +8,7 @@ /// /// Used for crolling up and down the log messages /// - private int scroll = 0; + private int scroll; public LogWindow() : base(Gtk.WindowType.Toplevel) { diff --git a/Mundus/Views/Windows/MainWindow.cs b/Mundus/Views/Windows/MainWindow.cs index ca3b529..80b8094 100644 --- a/Mundus/Views/Windows/MainWindow.cs +++ b/Mundus/Views/Windows/MainWindow.cs @@ -9,7 +9,7 @@ public MainWindow() : base(Gtk.WindowType.Toplevel) { this.Build(); - this.lblBuild.Text = Mundus.Data.Windows.WI.BuildName; + this.lblBuild.Text = WI.BuildName; } protected void OnBtnTutorialClicked(object sender, EventArgs e) diff --git a/Mundus/Views/Windows/PauseWindow.cs b/Mundus/Views/Windows/PauseWindow.cs index 4dde656..75f4386 100644 --- a/Mundus/Views/Windows/PauseWindow.cs +++ b/Mundus/Views/Windows/PauseWindow.cs @@ -9,7 +9,7 @@ public PauseWindow() : base(Gtk.WindowType.Toplevel) { this.Build(); - this.lblBuild.Text = Mundus.Data.Windows.WI.BuildName; + this.lblBuild.Text = WI.BuildName; } /// diff --git a/Mundus/gtk-gui/Mundus.Views.Windows.MainWindow.cs b/Mundus/gtk-gui/Mundus.Views.Windows.MainWindow.cs index 3f8e3b9..da5314b 100644 --- a/Mundus/gtk-gui/Mundus.Views.Windows.MainWindow.cs +++ b/Mundus/gtk-gui/Mundus.Views.Windows.MainWindow.cs @@ -37,7 +37,7 @@ namespace Mundus.Views.Windows this.lblTitle.WidthRequest = 300; this.lblTitle.HeightRequest = 100; this.lblTitle.Name = "lblTitle"; - this.lblTitle.LabelProp = "Mundus (replace with picture)"; + this.lblTitle.LabelProp = "Mundus"; this.lblTitle.Justify = ((global::Gtk.Justification)(3)); this.vboxUI.Add(this.lblTitle); global::Gtk.Box.BoxChild w1 = ((global::Gtk.Box.BoxChild)(this.vboxUI[this.lblTitle])); diff --git a/Mundus/gtk-gui/Mundus.Views.Windows.MusicWindow.cs b/Mundus/gtk-gui/Mundus.Views.Windows.MusicWindow.cs index 2bbbaba..a689d78 100644 --- a/Mundus/gtk-gui/Mundus.Views.Windows.MusicWindow.cs +++ b/Mundus/gtk-gui/Mundus.Views.Windows.MusicWindow.cs @@ -70,6 +70,7 @@ namespace Mundus.Views.Windows this.btnNext = new global::Gtk.Button(); this.btnNext.WidthRequest = 70; this.btnNext.HeightRequest = 50; + this.btnNext.Sensitive = false; this.btnNext.CanFocus = true; this.btnNext.Name = "btnNext"; this.btnNext.UseUnderline = true; @@ -102,6 +103,7 @@ namespace Mundus.Views.Windows this.btnPrevious = new global::Gtk.Button(); this.btnPrevious.WidthRequest = 70; this.btnPrevious.HeightRequest = 50; + this.btnPrevious.Sensitive = false; this.btnPrevious.CanFocus = true; this.btnPrevious.Name = "btnPrevious"; this.btnPrevious.UseUnderline = true; @@ -118,6 +120,7 @@ namespace Mundus.Views.Windows this.btnRandom = new global::Gtk.Button(); this.btnRandom.WidthRequest = 70; this.btnRandom.HeightRequest = 50; + this.btnRandom.Sensitive = false; this.btnRandom.CanFocus = true; this.btnRandom.Name = "btnRandom"; this.btnRandom.UseUnderline = true; diff --git a/Mundus/gtk-gui/Mundus.Views.Windows.NewGameWindow.cs b/Mundus/gtk-gui/Mundus.Views.Windows.NewGameWindow.cs index 0bbc355..2ea610e 100644 --- a/Mundus/gtk-gui/Mundus.Views.Windows.NewGameWindow.cs +++ b/Mundus/gtk-gui/Mundus.Views.Windows.NewGameWindow.cs @@ -247,6 +247,7 @@ namespace Mundus.Views.Windows this.rbCreative.Sensitive = false; this.rbCreative.CanFocus = true; this.rbCreative.Name = "rbCreative"; + this.rbCreative.Active = true; this.rbCreative.DrawIndicator = true; this.rbCreative.UseUnderline = true; this.rbCreative.Group = new global::GLib.SList(global::System.IntPtr.Zero); @@ -263,6 +264,7 @@ namespace Mundus.Views.Windows this.rbEasy.WidthRequest = 90; this.rbEasy.CanFocus = true; this.rbEasy.Name = "rbEasy"; + this.rbEasy.Active = true; this.rbEasy.DrawIndicator = true; this.rbEasy.UseUnderline = true; this.rbEasy.Group = new global::GLib.SList(global::System.IntPtr.Zero); @@ -311,6 +313,7 @@ namespace Mundus.Views.Windows this.rbLarge.WidthRequest = 90; this.rbLarge.CanFocus = true; this.rbLarge.Name = "rbLarge"; + this.rbLarge.Active = true; this.rbLarge.DrawIndicator = true; this.rbLarge.UseUnderline = true; this.rbLarge.Group = new global::GLib.SList(global::System.IntPtr.Zero); @@ -342,6 +345,7 @@ namespace Mundus.Views.Windows this.rbMLarge = new global::Gtk.RadioButton("Large"); this.rbMLarge.CanFocus = true; this.rbMLarge.Name = "rbMLarge"; + this.rbMLarge.Active = true; this.rbMLarge.DrawIndicator = true; this.rbMLarge.UseUnderline = true; this.rbMLarge.Group = new global::GLib.SList(global::System.IntPtr.Zero); diff --git a/Mundus/gtk-gui/Mundus.Views.Windows.SettingsWindow.cs b/Mundus/gtk-gui/Mundus.Views.Windows.SettingsWindow.cs index 94e0260..0c77586 100644 --- a/Mundus/gtk-gui/Mundus.Views.Windows.SettingsWindow.cs +++ b/Mundus/gtk-gui/Mundus.Views.Windows.SettingsWindow.cs @@ -87,7 +87,7 @@ namespace Mundus.Views.Windows // Container child tbUI.Gtk.Table+TableChild this.lblTitle = new global::Gtk.Label(); this.lblTitle.Name = "lblTitle"; - this.lblTitle.LabelProp = "Settings (replace with picture)"; + this.lblTitle.LabelProp = "Settings"; this.tbUI.Add(this.lblTitle); global::Gtk.Table.TableChild w6 = ((global::Gtk.Table.TableChild)(this.tbUI[this.lblTitle])); w6.LeftAttach = ((uint)(2)); diff --git a/Mundus/gtk-gui/gui.stetic b/Mundus/gtk-gui/gui.stetic index 9232005..3bba2ff 100644 --- a/Mundus/gtk-gui/gui.stetic +++ b/Mundus/gtk-gui/gui.stetic @@ -23895,7 +23895,7 @@ - Settings (replace with picture) + Settings 2 @@ -24872,6 +24872,7 @@ 70 50 + False True TextOnly Next @@ -24926,6 +24927,7 @@ 70 50 + False True TextOnly Prev @@ -24952,6 +24954,7 @@ 70 50 + False True TextOnly Rnd @@ -25143,7 +25146,7 @@ 300 100 - Mundus (replace with picture) + Mundus Fill diff --git a/Mundus/packages.config b/Mundus/packages.config index 871b669..f82577d 100644 --- a/Mundus/packages.config +++ b/Mundus/packages.config @@ -24,6 +24,7 @@ + diff --git a/MundusTests/ApplicationSetup.cs b/MundusTests/ApplicationSetup.cs index bd39d97..429097d 100644 --- a/MundusTests/ApplicationSetup.cs +++ b/MundusTests/ApplicationSetup.cs @@ -1,7 +1,7 @@ -using Mundus.Data; -using Mundus.Data.Windows; +using Gtk; +using Mundus.Data; +using Mundus.Service.Windows; using NUnit.Framework; -using Gtk; [SetUpFixture] public static class ApplicationSetup { diff --git a/MundusTests/DataTests/Mobs/MITests.cs b/MundusTests/DataTests/Mobs/MITests.cs index 85595d7..bf8b12d 100644 --- a/MundusTests/DataTests/Mobs/MITests.cs +++ b/MundusTests/DataTests/Mobs/MITests.cs @@ -1,6 +1,6 @@ namespace MundusTests.DataTests.Mobs { - using Mundus.Data.Tiles.Mobs; + using Mundus.Service.Tiles.Mobs; using NUnit.Framework; [TestFixture] diff --git a/MundusTests/ServiceTests/SuperLayers/ImageControllerTests.cs b/MundusTests/ServiceTests/SuperLayers/ImageControllerTests.cs index 248adbe..9e1e1c6 100644 --- a/MundusTests/ServiceTests/SuperLayers/ImageControllerTests.cs +++ b/MundusTests/ServiceTests/SuperLayers/ImageControllerTests.cs @@ -2,8 +2,8 @@ { using Gtk; using Mundus.Data; - using Mundus.Data.Tiles.Mobs; using Mundus.Service.SuperLayers; + using Mundus.Service.Tiles.Mobs; using NUnit.Framework; using static Mundus.Service.SuperLayers.ImageController; using static Mundus.Service.Tiles.Mobs.Inventory; diff --git a/MundusTests/ServiceTests/Tiles/Crafting/CraftingControllerTests.cs b/MundusTests/ServiceTests/Tiles/Crafting/CraftingControllerTests.cs index 5961c72..a7be0ee 100644 --- a/MundusTests/ServiceTests/Tiles/Crafting/CraftingControllerTests.cs +++ b/MundusTests/ServiceTests/Tiles/Crafting/CraftingControllerTests.cs @@ -2,9 +2,9 @@ { using System.Linq; using Mundus.Data; - using Mundus.Data.Tiles.Mobs; - using Mundus.Data.Tiles.Presets; - using Mundus.Service.Tiles.Crafting; + using Mundus.Service.Tiles; + using Mundus.Service.Tiles.Items.Presets; + using Mundus.Service.Tiles.Mobs; using NUnit.Framework; [TestFixture] @@ -20,7 +20,7 @@ MI.Player.Inventory.AppendToItems(MaterialPresets.GetALandStick()); } - CraftingController.CraftItemPlayer(recipe); + RecipeController.CraftItemPlayer(recipe); Assert.Contains(recipe.ResultItem, MI.Player.Inventory.Items.Where(x => x != null).Select(x => x.stock_id).ToArray(), "Result item isn't added to player's inventory"); Assert.AreEqual(1, MI.Player.Inventory.Items.Where(x => x != null).Count(), "Not all required items are removed from player's inventory"); diff --git a/MundusTests/ServiceTests/Tiles/Mobs/MobTileTests.cs b/MundusTests/ServiceTests/Tiles/Mobs/MobTileTests.cs index a4329dc..d2b7575 100644 --- a/MundusTests/ServiceTests/Tiles/Mobs/MobTileTests.cs +++ b/MundusTests/ServiceTests/Tiles/Mobs/MobTileTests.cs @@ -1,9 +1,9 @@ namespace MundusTests.ServiceTests.Tiles.Mobs { using Mundus.Data; - using Mundus.Data.Windows; using Mundus.Service.Tiles.Items.Types; using Mundus.Service.Tiles.Mobs; + using Mundus.Service.Windows; using NUnit.Framework; [TestFixture] -- cgit v1.2.3