code with error
continuous-integration/drone/push Build is failing Details

pull/106/head
Ismail TAHA JANAN 2 years ago
parent 3a263b4dca
commit 3886fc7934

@ -20,16 +20,16 @@ namespace Data
gr.GlobalPlayerManager.Add(player3); gr.GlobalPlayerManager.Add(player3);
List<HomogeneousDice> monopolyDice = new(); List<HomogeneousDice<int>> monopolyDice = new();
List<HomogeneousDice> dndDice = new(); List<NumberDie> dndDice = new();
string monopolyName = "Monopoly", dndName = "DnD"; string monopolyName = "Monopoly", dndName = "DnD";
NumberDieFace[] d6Faces = new NumberDieFace[] { new(1), new(2), new(3), new(4), new(5), new(6) }; 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 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[] { NumberDieFace[] d20Faces = new NumberDieFace[] {
new(1), new(2), new(3), new(4), new(5), new(1), new(2), new(3), new(4), new(5),
@ -40,8 +40,8 @@ namespace Data
dndDice.Add(new NumberDie(d20Faces)); dndDice.Add(new NumberDie(d20Faces));
gr.GlobalDieManager.Add(new KeyValuePair<string, IEnumerable<AbstractDie<AbstractDieFace>>>(dndName, dndDice.AsEnumerable())); gr.GlobalDieManager.Add(new KeyValuePair<string, IEnumerable<AbstractDie<AbstractDieFace<object>>>>(dndName, dndDice.AsEnumerable()));
gr.GlobalDieManager.Add(new KeyValuePair<string, IEnumerable<AbstractDie<AbstractDieFace>>>(monopolyName, monopolyDice.AsEnumerable())); gr.GlobalDieManager.Add(new KeyValuePair<string, IEnumerable<AbstractDie<AbstractDieFace<object>>>>(monopolyName, monopolyDice.AsEnumerable()));
string game1 = "Forgotten Realms", game2 = "4e", game3 = "The Coopers"; string game1 = "Forgotten Realms", game2 = "4e", game3 = "The Coopers";

@ -14,6 +14,7 @@ namespace Model.Dice
{ {
public ColorDie(params ColorDieFace[] faces) : base(faces) public ColorDie(params ColorDieFace[] faces) : base(faces)
{ {
} }
} }
} }

@ -5,30 +5,30 @@ using System.Linq;
namespace Model.Dice namespace Model.Dice
{ {
public class DieManager : IManager<KeyValuePair<string, IEnumerable<AbstractDie<AbstractDieFace<object>>>>> public class DieManager : IManager<KeyValuePair<string, IEnumerable<AbstractDie<object>>>>
{ {
private readonly Dictionary<string, IEnumerable<AbstractDie<AbstractDieFace<object>>>> diceGroups = new(); private readonly Dictionary<string, IEnumerable<AbstractDie<object>>> diceGroups = new();
public KeyValuePair<string, IEnumerable<AbstractDie<AbstractDieFace<object>>>> Add(KeyValuePair<string, IEnumerable<AbstractDie<AbstractDieFace<object>>>> toAdd) public KeyValuePair<string, IEnumerable<AbstractDie<object>>> Add(KeyValuePair<string, IEnumerable<AbstractDie<object>>> toAdd)
{ {
// on trim la clé d'abord // on trim la clé d'abord
diceGroups.Add(toAdd.Key.Trim(), toAdd.Value); diceGroups.Add(toAdd.Key.Trim(), toAdd.Value);
return toAdd; return toAdd;
} }
public IEnumerable<KeyValuePair<string, IEnumerable<AbstractDie<AbstractDieFace<object>>>>> GetAll() public IEnumerable<KeyValuePair<string, IEnumerable<AbstractDie<object>>>> GetAll()
{ {
return diceGroups.AsEnumerable(); return diceGroups.AsEnumerable();
} }
public KeyValuePair<string, IEnumerable<AbstractDie<AbstractDieFace<object>>>> GetOneByName(string name) public KeyValuePair<string, IEnumerable<AbstractDie<object>>> GetOneByName(string name)
{ {
// les groupes de dés nommés : // les groupes de dés nommés :
// ils sont case-sensistive, mais "mon jeu" == "mon jeu " == " mon jeu" // ils sont case-sensistive, mais "mon jeu" == "mon jeu " == " mon jeu"
return new KeyValuePair<string, IEnumerable<AbstractDie<AbstractDieFace<object>>>>(name, diceGroups[name]); return new KeyValuePair<string, IEnumerable<AbstractDie<object>>>(name, diceGroups[name]);
} }
public void Remove(KeyValuePair<string, IEnumerable<AbstractDie<AbstractDieFace<object>>>> toRemove) public void Remove(KeyValuePair<string, IEnumerable<AbstractDie<object>>> toRemove)
{ {
diceGroups.Remove(toRemove.Key); diceGroups.Remove(toRemove.Key);
} }
@ -43,7 +43,7 @@ namespace Model.Dice
throw new NotImplementedException(); throw new NotImplementedException();
}*/ }*/
public KeyValuePair<string, IEnumerable<AbstractDie<AbstractDieFace<object>>>> Update(KeyValuePair<string, IEnumerable<AbstractDie<AbstractDieFace<object>>>> before, KeyValuePair<string, IEnumerable<AbstractDie<AbstractDieFace<object>>>> after) public KeyValuePair<string, IEnumerable<AbstractDie<object>>> Update(KeyValuePair<string, IEnumerable<AbstractDie<object>>> before, KeyValuePair<string, IEnumerable<AbstractDie<object>>> after)
{ {
// pas autorisé de changer les dés, juste le nom // pas autorisé de changer les dés, juste le nom
if (!before.Value.Equals(after.Value)) if (!before.Value.Equals(after.Value))

@ -57,8 +57,8 @@ namespace Model.Games
/// <summary> /// <summary>
/// the group of dice used for this game /// the group of dice used for this game
/// </summary> /// </summary>
public IEnumerable<AbstractDie<AbstractDieFace<object>>> Dice => dice; public IEnumerable<AbstractDie<object>> Dice => dice;
private readonly IEnumerable<AbstractDie<AbstractDieFace<object>>> dice; private readonly IEnumerable<AbstractDie<object>> dice;
/// <summary> /// <summary>
/// constructs a Game with its own history of Turns. /// constructs a Game with its own history of Turns.
@ -68,7 +68,7 @@ namespace Model.Games
/// <param name="turns">the turns that have been done so far</param> /// <param name="turns">the turns that have been done so far</param>
/// <param name="playerManager">the game's player manager, doing CRUD on players and switching whose turn it is</param> /// <param name="playerManager">the game's player manager, doing CRUD on players and switching whose turn it is</param>
/// <param name="favGroup">the group of dice used for this game</param> /// <param name="favGroup">the group of dice used for this game</param>
public Game(string name, IManager<Player> playerManager, IEnumerable<AbstractDie<AbstractDieFace<object>>> dice, IEnumerable<Turn> turns) public Game(string name, IManager<Player> playerManager, IEnumerable<AbstractDie<object>> dice, IEnumerable<Turn> turns)
{ {
Name = name; Name = name;
PlayerManager = playerManager; PlayerManager = playerManager;
@ -83,7 +83,7 @@ namespace Model.Games
/// <param name="name">the name of the game 😎</param> /// <param name="name">the name of the game 😎</param>
/// <param name="playerManager">the game's player manager, doing CRUD on players and switching whose turn it is</param> /// <param name="playerManager">the game's player manager, doing CRUD on players and switching whose turn it is</param>
/// <param name="favGroup">the group of dice used for this game</param> /// <param name="favGroup">the group of dice used for this game</param>
public Game(string name, IManager<Player> playerManager, IEnumerable<AbstractDie<AbstractDieFace<object>>> dice) public Game(string name, IManager<Player> playerManager, IEnumerable<AbstractDie<object>> dice)
: this(name, playerManager, dice, null) : 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 /// throws all the Dice in FavGroup and returns a list of their Faces
/// </summary> /// </summary>
/// <returns>list of AbstractDieFaces after a throw</returns> /// <returns>list of AbstractDieFaces after a throw</returns>
private Dictionary<AbstractDie<AbstractDieFace<object>>, AbstractDieFace<object>> ThrowAll() private Dictionary<AbstractDie<object>, AbstractDieFace<object>> ThrowAll()
{ {
Dictionary<AbstractDie<AbstractDieFace<object>>, AbstractDieFace<object>> faces = new(); Dictionary<AbstractDie<object>, AbstractDieFace<object>> faces = new();
foreach (AbstractDie<AbstractDieFace<object>> die in dice) foreach (AbstractDie<object> die in dice)
{ {
faces.Add(die, die.GetRandomFace()); faces.Add(die, die.GetRandomFace());
} }

@ -12,17 +12,17 @@ namespace Model.Games
public class GameRunner : IManager<Game> public class GameRunner : IManager<Game>
{ {
public IManager<Player> GlobalPlayerManager { get; private set; } public IManager<Player> GlobalPlayerManager { get; private set; }
public IManager<KeyValuePair<string, IEnumerable<AbstractDie<AbstractDieFace<object>,object>>>> GlobalDieManager { get; private set; } public IManager<KeyValuePair<string, IEnumerable<AbstractDie<object>>>> GlobalDieManager { get; private set; }
private readonly List<Game> games; private readonly List<Game> games;
public GameRunner(IManager<Player> globalPlayerManager, IManager<KeyValuePair<string, IEnumerable<AbstractDie<AbstractDieFace<object>,object>>>> globalDieManager, List<Game> games) public GameRunner(IManager<Player> globalPlayerManager, IManager<KeyValuePair<string, IEnumerable<AbstractDie<object>>>> globalDieManager, List<Game> games)
{ {
GlobalPlayerManager = globalPlayerManager; GlobalPlayerManager = globalPlayerManager;
GlobalDieManager = globalDieManager; GlobalDieManager = globalDieManager;
this.games = games ?? new(); this.games = games ?? new();
} }
public GameRunner(IManager<Player> globalPlayerManager, IManager<KeyValuePair<string, IEnumerable<AbstractDie<AbstractDieFace<object>,object>>>> globalDieManager) public GameRunner(IManager<Player> globalPlayerManager, IManager<KeyValuePair<string, IEnumerable<AbstractDie<object>>>> globalDieManager)
: this(globalPlayerManager, globalDieManager, null){ } : this(globalPlayerManager, globalDieManager, null){ }
@ -65,7 +65,7 @@ namespace Model.Games
/// <summary> /// <summary>
/// creates a new game /// creates a new game
/// </summary> /// </summary>
public Game StartNewGame(string name, IManager<Player> playerManager, IEnumerable<AbstractDie<AbstractDieFace<object>,object>> dice) public Game StartNewGame(string name, IManager<Player> playerManager, IEnumerable<AbstractDie<object>> dice)
{ {
Game game = new(name, playerManager, dice); Game game = new(name, playerManager, dice);
return Add(game); return Add(game);

@ -33,8 +33,8 @@ namespace Model.Games
/// <summary> /// <summary>
/// the collection of Face that were rolled /// the collection of Face that were rolled
/// </summary> /// </summary>
public IEnumerable<KeyValuePair<AbstractDie<AbstractDieFace>, AbstractDieFace>> DiceNFaces => diceNFaces.AsEnumerable(); public IEnumerable<KeyValuePair<AbstractDie<object>, AbstractDieFace<object>>> DiceNFaces => diceNFaces.AsEnumerable();
private readonly Dictionary<AbstractDie<AbstractDieFace>, AbstractDieFace> diceNFaces; private readonly Dictionary<AbstractDie<object>, AbstractDieFace<object>> diceNFaces;
/// <summary> /// <summary>
/// this private constructor is to be used only by factories /// this private constructor is to be used only by factories
@ -42,7 +42,7 @@ namespace Model.Games
/// <param name="when">date and time of the turn</param> /// <param name="when">date and time of the turn</param>
/// <param name="player">player who played the turn</param> /// <param name="player">player who played the turn</param>
/// <param name="faces">faces that were rolled</param> /// <param name="faces">faces that were rolled</param>
private Turn(DateTime when, Player player, Dictionary<AbstractDie<AbstractDieFace>, AbstractDieFace> diceNFaces) private Turn(DateTime when, Player player, Dictionary<AbstractDie<object>, AbstractDieFace<object>> diceNFaces)
{ {
When = when; When = when;
Player = player; Player = player;
@ -59,7 +59,7 @@ namespace Model.Games
/// <param name="player">player who played the turn</param> /// <param name="player">player who played the turn</param>
/// <param name="faces">faces that were rolled</param> /// <param name="faces">faces that were rolled</param>
/// <returns>a new Turn object</returns> /// <returns>a new Turn object</returns>
public static Turn CreateWithSpecifiedTime(DateTime when, Player player, Dictionary<AbstractDie<AbstractDieFace>, AbstractDieFace> diceNFaces) public static Turn CreateWithSpecifiedTime(DateTime when, Player player, Dictionary<AbstractDie<object>, AbstractDieFace<object>> diceNFaces)
{ {
if (player is null) if (player is null)
{ {
@ -87,7 +87,7 @@ namespace Model.Games
/// <param name="player">player who played the turn</param> /// <param name="player">player who played the turn</param>
/// <param name="faces">faces that were rolled</param> /// <param name="faces">faces that were rolled</param>
/// <returns>a new Turn object</returns> /// <returns>a new Turn object</returns>
public static Turn CreateWithDefaultTime(Player player, Dictionary<AbstractDie<AbstractDieFace>, AbstractDieFace> diceNFaces) public static Turn CreateWithDefaultTime(Player player, Dictionary<AbstractDie<object>, AbstractDieFace<object>> diceNFaces)
{ {
return CreateWithSpecifiedTime(DateTime.UtcNow, player, diceNFaces); return CreateWithSpecifiedTime(DateTime.UtcNow, player, diceNFaces);
} }
@ -108,7 +108,7 @@ namespace Model.Games
date, date,
time, time,
Player.ToString()); Player.ToString());
foreach (AbstractDieFace face in this.diceNFaces.Values) foreach (AbstractDieFace<object> face in this.diceNFaces.Values)
{ {
sb.Append(" " + face.ToString()); sb.Append(" " + face.ToString());
} }

Loading…
Cancel
Save