diff --git a/Sources/Data/Stub.cs b/Sources/Data/Stub.cs index 38b7923..b39f763 100644 --- a/Sources/Data/Stub.cs +++ b/Sources/Data/Stub.cs @@ -20,16 +20,16 @@ namespace Data gr.GlobalPlayerManager.Add(player3); - List monopolyDice = new(); - List dndDice = new(); + List> monopolyDice = new(); + List dndDice = new(); string monopolyName = "Monopoly", dndName = "DnD"; NumberDieFace[] d6Faces = new NumberDieFace[] { new(1), new(2), new(3), new(4), new(5), new(6) }; + monopolyDice.Add(new NumberDie(new NumberDieFace(1), new NumberDieFace(1), new NumberDieFace(1), new NumberDieFace(1))); monopolyDice.Add(new NumberDie(d6Faces)); - monopolyDice.Add(new NumberDie(d6Faces)); - monopolyDice.Add(new ColorDie(new("#ff0000"), new("#00ff00"), new("#0000ff"), new("#ffff00"), new("#000000"), new("#ffffff"))); + //monopolyDice.Add(new ColorDie(new("#ff0000"), new("#00ff00"), new("#0000ff"), new("#ffff00"), new("#000000"), new("#ffffff"))); NumberDieFace[] d20Faces = new NumberDieFace[] { new(1), new(2), new(3), new(4), new(5), @@ -40,8 +40,8 @@ namespace Data dndDice.Add(new NumberDie(d20Faces)); - gr.GlobalDieManager.Add(new KeyValuePair>>(dndName, dndDice.AsEnumerable())); - gr.GlobalDieManager.Add(new KeyValuePair>>(monopolyName, monopolyDice.AsEnumerable())); + gr.GlobalDieManager.Add(new KeyValuePair>>>(dndName, dndDice.AsEnumerable())); + gr.GlobalDieManager.Add(new KeyValuePair>>>(monopolyName, monopolyDice.AsEnumerable())); string game1 = "Forgotten Realms", game2 = "4e", game3 = "The Coopers"; diff --git a/Sources/Model/Dice/ColorDie.cs b/Sources/Model/Dice/ColorDie.cs index d136db8..49d71de 100644 --- a/Sources/Model/Dice/ColorDie.cs +++ b/Sources/Model/Dice/ColorDie.cs @@ -14,6 +14,7 @@ namespace Model.Dice { public ColorDie(params ColorDieFace[] faces) : base(faces) { + } } } diff --git a/Sources/Model/Dice/DieManager.cs b/Sources/Model/Dice/DieManager.cs index 704f200..6b6c85a 100644 --- a/Sources/Model/Dice/DieManager.cs +++ b/Sources/Model/Dice/DieManager.cs @@ -5,30 +5,30 @@ using System.Linq; namespace Model.Dice { - public class DieManager : IManager>>>> + public class DieManager : IManager>>> { - private readonly Dictionary>>> diceGroups = new(); + private readonly Dictionary>> diceGroups = new(); - public KeyValuePair>>> Add(KeyValuePair>>> toAdd) + public KeyValuePair>> Add(KeyValuePair>> toAdd) { // on trim la clé d'abord diceGroups.Add(toAdd.Key.Trim(), toAdd.Value); return toAdd; } - public IEnumerable>>>> GetAll() + public IEnumerable>>> GetAll() { return diceGroups.AsEnumerable(); } - public KeyValuePair>>> GetOneByName(string name) + public KeyValuePair>> GetOneByName(string name) { // les groupes de dés nommés : // ils sont case-sensistive, mais "mon jeu" == "mon jeu " == " mon jeu" - return new KeyValuePair>>>(name, diceGroups[name]); + return new KeyValuePair>>(name, diceGroups[name]); } - public void Remove(KeyValuePair>>> toRemove) + public void Remove(KeyValuePair>> toRemove) { diceGroups.Remove(toRemove.Key); } @@ -43,7 +43,7 @@ namespace Model.Dice throw new NotImplementedException(); }*/ - public KeyValuePair>>> Update(KeyValuePair>>> before, KeyValuePair>>> after) + public KeyValuePair>> Update(KeyValuePair>> before, KeyValuePair>> after) { // pas autorisé de changer les dés, juste le nom if (!before.Value.Equals(after.Value)) diff --git a/Sources/Model/Games/Game.cs b/Sources/Model/Games/Game.cs index 6b9a85b..37b2722 100644 --- a/Sources/Model/Games/Game.cs +++ b/Sources/Model/Games/Game.cs @@ -57,8 +57,8 @@ namespace Model.Games /// /// the group of dice used for this game /// - public IEnumerable>> Dice => dice; - private readonly IEnumerable>> dice; + public IEnumerable> Dice => dice; + private readonly IEnumerable> dice; /// /// constructs a Game with its own history of Turns. @@ -68,7 +68,7 @@ namespace Model.Games /// the turns that have been done so far /// the game's player manager, doing CRUD on players and switching whose turn it is /// the group of dice used for this game - public Game(string name, IManager playerManager, IEnumerable>> dice, IEnumerable turns) + public Game(string name, IManager playerManager, IEnumerable> dice, IEnumerable turns) { Name = name; PlayerManager = playerManager; @@ -83,7 +83,7 @@ namespace Model.Games /// the name of the game 😎 /// the game's player manager, doing CRUD on players and switching whose turn it is /// the group of dice used for this game - public Game(string name, IManager playerManager, IEnumerable>> dice) + public Game(string name, IManager playerManager, IEnumerable> dice) : this(name, playerManager, dice, null) { } @@ -161,10 +161,10 @@ namespace Model.Games /// throws all the Dice in FavGroup and returns a list of their Faces /// /// list of AbstractDieFaces after a throw - private Dictionary>, AbstractDieFace> ThrowAll() + private Dictionary, AbstractDieFace> ThrowAll() { - Dictionary>, AbstractDieFace> faces = new(); - foreach (AbstractDie> die in dice) + Dictionary, AbstractDieFace> faces = new(); + foreach (AbstractDie die in dice) { faces.Add(die, die.GetRandomFace()); } diff --git a/Sources/Model/Games/GameRunner.cs b/Sources/Model/Games/GameRunner.cs index 4498d7f..6fc9d38 100644 --- a/Sources/Model/Games/GameRunner.cs +++ b/Sources/Model/Games/GameRunner.cs @@ -12,17 +12,17 @@ namespace Model.Games public class GameRunner : IManager { public IManager GlobalPlayerManager { get; private set; } - public IManager,object>>>> GlobalDieManager { get; private set; } + public IManager>>> GlobalDieManager { get; private set; } private readonly List games; - public GameRunner(IManager globalPlayerManager, IManager,object>>>> globalDieManager, List games) + public GameRunner(IManager globalPlayerManager, IManager>>> globalDieManager, List games) { GlobalPlayerManager = globalPlayerManager; GlobalDieManager = globalDieManager; this.games = games ?? new(); } - public GameRunner(IManager globalPlayerManager, IManager,object>>>> globalDieManager) + public GameRunner(IManager globalPlayerManager, IManager>>> globalDieManager) : this(globalPlayerManager, globalDieManager, null){ } @@ -65,7 +65,7 @@ namespace Model.Games /// /// creates a new game /// - public Game StartNewGame(string name, IManager playerManager, IEnumerable,object>> dice) + public Game StartNewGame(string name, IManager playerManager, IEnumerable> dice) { Game game = new(name, playerManager, dice); return Add(game); diff --git a/Sources/Model/Games/Turn.cs b/Sources/Model/Games/Turn.cs index ea202d4..7c7f33e 100644 --- a/Sources/Model/Games/Turn.cs +++ b/Sources/Model/Games/Turn.cs @@ -33,8 +33,8 @@ namespace Model.Games /// /// the collection of Face that were rolled /// - public IEnumerable, AbstractDieFace>> DiceNFaces => diceNFaces.AsEnumerable(); - private readonly Dictionary, AbstractDieFace> diceNFaces; + public IEnumerable, AbstractDieFace>> DiceNFaces => diceNFaces.AsEnumerable(); + private readonly Dictionary, AbstractDieFace> diceNFaces; /// /// this private constructor is to be used only by factories @@ -42,7 +42,7 @@ namespace Model.Games /// date and time of the turn /// player who played the turn /// faces that were rolled - private Turn(DateTime when, Player player, Dictionary, AbstractDieFace> diceNFaces) + private Turn(DateTime when, Player player, Dictionary, AbstractDieFace> diceNFaces) { When = when; Player = player; @@ -59,7 +59,7 @@ namespace Model.Games /// player who played the turn /// faces that were rolled /// a new Turn object - public static Turn CreateWithSpecifiedTime(DateTime when, Player player, Dictionary, AbstractDieFace> diceNFaces) + public static Turn CreateWithSpecifiedTime(DateTime when, Player player, Dictionary, AbstractDieFace> diceNFaces) { if (player is null) { @@ -87,7 +87,7 @@ namespace Model.Games /// player who played the turn /// faces that were rolled /// a new Turn object - public static Turn CreateWithDefaultTime(Player player, Dictionary, AbstractDieFace> diceNFaces) + public static Turn CreateWithDefaultTime(Player player, Dictionary, AbstractDieFace> diceNFaces) { return CreateWithSpecifiedTime(DateTime.UtcNow, player, diceNFaces); } @@ -108,7 +108,7 @@ namespace Model.Games date, time, Player.ToString()); - foreach (AbstractDieFace face in this.diceNFaces.Values) + foreach (AbstractDieFace face in this.diceNFaces.Values) { sb.Append(" " + face.ToString()); }