simple commit
continuous-integration/drone/push Build is failing Details

pull/106/head
Ismail TAHA JANAN 3 years ago
parent 1149c916c4
commit 3a263b4dca

@ -9,14 +9,14 @@ namespace Model.Dice
{ {
public IEnumerable<AbstractDieFace<T>> ListFaces => listFaces; public IEnumerable<AbstractDieFace<T>> ListFaces => listFaces;
private readonly List<T> listFaces = new(); private readonly List<AbstractDieFace<T>> listFaces = new();
protected AbstractDie(params T[] faces) protected AbstractDie(params AbstractDieFace<T>[] faces)
{ {
listFaces.AddRange(faces); listFaces.AddRange(faces);
} }
public T GetRandomFace() public AbstractDieFace<T> GetRandomFace()
{ {
int faceIndex = rnd.Next(0, ListFaces.Count()); int faceIndex = rnd.Next(0, ListFaces.Count());
return ListFaces.ElementAt(faceIndex); return ListFaces.ElementAt(faceIndex);

@ -10,7 +10,7 @@ using System.Threading.Tasks;
namespace Model.Dice namespace Model.Dice
{ {
public class ColorDie : AbstractDie<ColorDieFace,Color> public class ColorDie : AbstractDie<Color>
{ {
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>,object>>>> public class DieManager : IManager<KeyValuePair<string, IEnumerable<AbstractDie<AbstractDieFace<object>>>>>
{ {
private readonly Dictionary<string, IEnumerable<AbstractDie<AbstractDieFace<object>,object>>> diceGroups = new(); private readonly Dictionary<string, IEnumerable<AbstractDie<AbstractDieFace<object>>>> diceGroups = new();
public KeyValuePair<string, IEnumerable<AbstractDie<AbstractDieFace<object>,object>>> Add(KeyValuePair<string, IEnumerable<AbstractDie<AbstractDieFace<object>,object>>> toAdd) public KeyValuePair<string, IEnumerable<AbstractDie<AbstractDieFace<object>>>> Add(KeyValuePair<string, IEnumerable<AbstractDie<AbstractDieFace<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>,object>>>> GetAll() public IEnumerable<KeyValuePair<string, IEnumerable<AbstractDie<AbstractDieFace<object>>>>> GetAll()
{ {
return diceGroups.AsEnumerable(); return diceGroups.AsEnumerable();
} }
public KeyValuePair<string, IEnumerable<AbstractDie<AbstractDieFace<object>,object>>> GetOneByName(string name) public KeyValuePair<string, IEnumerable<AbstractDie<AbstractDieFace<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>,object>>>(name, diceGroups[name]); return new KeyValuePair<string, IEnumerable<AbstractDie<AbstractDieFace<object>>>>(name, diceGroups[name]);
} }
public void Remove(KeyValuePair<string, IEnumerable<AbstractDie<AbstractDieFace<object>,object>>> toRemove) public void Remove(KeyValuePair<string, IEnumerable<AbstractDie<AbstractDieFace<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>,object>>> Update(KeyValuePair<string, IEnumerable<AbstractDie<AbstractDieFace<object>,object>>> before, KeyValuePair<string, IEnumerable<AbstractDie<AbstractDieFace<object>,object>>> after) public KeyValuePair<string, IEnumerable<AbstractDie<AbstractDieFace<object>>>> Update(KeyValuePair<string, IEnumerable<AbstractDie<AbstractDieFace<object>>>> before, KeyValuePair<string, IEnumerable<AbstractDie<AbstractDieFace<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))
@ -60,17 +60,17 @@ namespace Model.Dice
return before; return before;
} }
/*
IEnumerable<KeyValuePair<string, IEnumerable<AbstractDie<Faces.AbstractDieFace<object>, object>>>> IManager<KeyValuePair<string, IEnumerable<AbstractDie<Faces.AbstractDieFace<object>, object>>>>.GetAll() IEnumerable<KeyValuePair<string, IEnumerable<AbstractDie<Faces.AbstractDieFace<object>>>> IManager<KeyValuePair<string, IEnumerable<AbstractDie<Faces.AbstractDieFace<object>>>>>.GetAll()
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
KeyValuePair<string, IEnumerable<AbstractDie<Faces.AbstractDieFace<object>, object>>> IManager<KeyValuePair<string, IEnumerable<AbstractDie<Faces.AbstractDieFace<object>, object>>>>.GetOneByName(string name) KeyValuePair<string, IEnumerable<AbstractDie<Faces.AbstractDieFace<object>>>> IManager<KeyValuePair<string, IEnumerable<AbstractDie<Faces.AbstractDieFace<object>>>>>.GetOneByName(string name)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
*/
} }
} }

@ -7,9 +7,9 @@ using Model.Dice.Faces;
namespace Model.Dice namespace Model.Dice
{ {
public class HomogeneousDice: AbstractDie<AbstractDieFace<object>,object> public class HomogeneousDice<T>: AbstractDie<T>
{ {
public HomogeneousDice(params AbstractDieFace<object>[] faces) : base(faces) public HomogeneousDice(params AbstractDieFace<T>[] faces) : base(faces)
{ {
} }

@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace Model.Dice namespace Model.Dice
{ {
public class ImageDie : HomogeneousDice public class ImageDie : HomogeneousDice<Uri>
{ {
public ImageDie(params ImageDieFace[] faces) : base(faces) public ImageDie(params ImageDieFace[] faces) : base(faces)
{ {

@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace Model.Dice namespace Model.Dice
{ {
public class NumberDie : HomogeneousDice public class NumberDie : HomogeneousDice<int>
{ {
public NumberDie(params NumberDieFace[] faces) : base(faces) public NumberDie(params NumberDieFace[] faces) : base(faces)
{ {

@ -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>,object>> Dice => dice; public IEnumerable<AbstractDie<AbstractDieFace<object>>> Dice => dice;
private readonly IEnumerable<AbstractDie<AbstractDieFace<object>, object>> dice; private readonly IEnumerable<AbstractDie<AbstractDieFace<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>, object>> dice, IEnumerable<Turn> turns) public Game(string name, IManager<Player> playerManager, IEnumerable<AbstractDie<AbstractDieFace<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>, object>> dice) public Game(string name, IManager<Player> playerManager, IEnumerable<AbstractDie<AbstractDieFace<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>, AbstractDieFace> ThrowAll() private Dictionary<AbstractDie<AbstractDieFace<object>>, AbstractDieFace<object>> ThrowAll()
{ {
Dictionary<AbstractDie<AbstractDieFace>, AbstractDieFace> faces = new(); Dictionary<AbstractDie<AbstractDieFace<object>>, AbstractDieFace<object>> faces = new();
foreach (AbstractDie<AbstractDieFace> die in dice) foreach (AbstractDie<AbstractDieFace<object>> die in dice)
{ {
faces.Add(die, die.GetRandomFace()); faces.Add(die, die.GetRandomFace());
} }

Loading…
Cancel
Save