diff --git a/source/Trek-12/ConsoleApp/Program.cs b/source/Trek-12/ConsoleApp/Program.cs index 6b85432..a9062a1 100644 --- a/source/Trek-12/ConsoleApp/Program.cs +++ b/source/Trek-12/ConsoleApp/Program.cs @@ -3,6 +3,7 @@ using Models; +using Models.Game; Position pos01 = new Position(0,0); Position pos02 = new Position(1,0); diff --git a/source/Trek-12/Models/De.cs b/source/Trek-12/Models/Game/De.cs similarity index 83% rename from source/Trek-12/Models/De.cs rename to source/Trek-12/Models/Game/De.cs index 0063d0c..3ca9642 100644 --- a/source/Trek-12/Models/De.cs +++ b/source/Trek-12/Models/Game/De.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Models +namespace Models.Game { public class De { @@ -37,5 +37,11 @@ namespace Models { Nb = new Random().Next(NbMin, NbMax + 1); } + + public bool IsLower(De de1) + { + if (de1.Nb > this.Nb) return true; + else return false; + } } } \ No newline at end of file diff --git a/source/Trek-12/Models/Game/Game.cs b/source/Trek-12/Models/Game/Game.cs new file mode 100644 index 0000000..606d263 --- /dev/null +++ b/source/Trek-12/Models/Game/Game.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Models.Game +{ + public class Game + { + public Player CurentPlayer { get; set; } + + public Map NameMap { get; set; } + + public De De1 { get; set; } + public De De2 { get; set; } + + public int Turn { get; set; } + + + public Game(Player player,Map map) + { + NameMap = map; + CurentPlayer = player; + De1 = new De(); + De2 = new De(1); + Turn = 0; + } + + public void ThrowDice() + { + De1.Lancer(); + De2.Lancer(); + } + + public int ChooseOperation(Operation o) + { + switch (o) + { + case Operation.LOWER: + if (De1.IsLower(De2)) + { + return De1.Nb; + } + return De2.Nb; + + case Operation.HIGHER: + if (De1.IsLower(De2)) + { + return De2.Nb; + } + return De1.Nb; + + case Operation.SUBTRACTION: + if (De1.IsLower(De2)) + { + return De2.Nb - De1.Nb; + } + return De1.Nb - De2.Nb; + + case Operation.ADDITION: + return De2.Nb + De1.Nb; + + case Operation.MULTIPLICATION: + return De2.Nb * De1.Nb; + default: + return 0; + } + } + } +} diff --git a/source/Trek-12/Models/Map.cs b/source/Trek-12/Models/Game/Map.cs similarity index 88% rename from source/Trek-12/Models/Map.cs rename to source/Trek-12/Models/Game/Map.cs index 2fa974f..e51349d 100644 --- a/source/Trek-12/Models/Map.cs +++ b/source/Trek-12/Models/Game/Map.cs @@ -1,9 +1,9 @@ -namespace Models; +namespace Models.Game; public class Map { - public List Cells { get; private set; } - + public List Cells { get; private set; } + public string Background { get; private set; } public Map(List cells, string background) diff --git a/source/Trek-12/Models/Player.cs b/source/Trek-12/Models/Game/Player.cs similarity index 75% rename from source/Trek-12/Models/Player.cs rename to source/Trek-12/Models/Game/Player.cs index 1f5dbf6..60d6a08 100644 --- a/source/Trek-12/Models/Player.cs +++ b/source/Trek-12/Models/Game/Player.cs @@ -1,21 +1,28 @@ -namespace Models; +namespace Models.Game; public class Player { - public string Pseudo { get; private set; } - + public string Pseudo { get; private set; } + public string ProfilePicture { get; private set; } public Player() { Pseudo = "Player"; ProfilePicture = "DefaultProfilePicture"; - } - + } + public Player(string pseudo, string profilePicture = "DefaultProfilePicture") { Pseudo = pseudo; ProfilePicture = profilePicture; - } - + } + + + + public Operation ChooseOperation() + { + return Operation.LOWER + } + } \ No newline at end of file diff --git a/source/Trek-12/Models/Rules/Rules.cs b/source/Trek-12/Models/Rules/Rules.cs new file mode 100644 index 0000000..d9ef85a --- /dev/null +++ b/source/Trek-12/Models/Rules/Rules.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Models.Rules +{ + public class Rules + { + public bool NearCell(Cell playerChoice, List cells) + { + foreach (var item in cells) + { + if(playerChoice.X == item.X +1 || playerChoice.X == item.X - 1 + || playerChoice.Y == item.Y +1 || playerChoice.Y == item.Y -1 ) + { + return true; + } + } + return false; + } + } +} diff --git a/source/Trek-12/Tests/OperationGridTest.cs b/source/Trek-12/Tests/OperationGridTest.cs new file mode 100644 index 0000000..80f0692 --- /dev/null +++ b/source/Trek-12/Tests/OperationGridTest.cs @@ -0,0 +1,21 @@ +using Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tests +{ + public class OperationGridTest + { + public string Name = "toto"; + [Theory] + [InlineData("toto")] + [InlineData(" ")] + public void testResultGrid(string name) + { + + } + } +}