Implémentation de toutes les méthodes dans les StubData
continuous-integration/drone/push Build is failing Details

EF
Théo DUPIN 2 years ago
parent 915942b9b2
commit d4662f43ac

@ -12,9 +12,11 @@ namespace Model
public int Id { get; set; } public int Id { get; set; }
public TimeSpan Duration { get; set; } public TimeSpan Duration { get; set; }
public DateOnly Date { get; set; } public DateOnly Date { get; set; }
//public ReadOnlyCollection<Player> Players { get; private set; }
//private List<Player> players = new(); public ReadOnlyCollection<Player> Players { get; private set; }
private List<Player> players = new();
public ReadOnlyCollection<Turn> Turns { get; private set; } public ReadOnlyCollection<Turn> Turns { get; private set; }
private List<Turn> turns = new(); private List<Turn> turns = new();
@ -27,8 +29,6 @@ namespace Model
public GameMode GameMode { get; set; } public GameMode GameMode { get; set; }
public Player Player { get; set; }
//public Game(TimeSpan duration, DateOnly date, Dictionary<Player,Grille> grilles, Dictionary<Player, int> scores, List<Turn> turns, GameMode gameMode,int id=0) //public Game(TimeSpan duration, DateOnly date, Dictionary<Player,Grille> grilles, Dictionary<Player, int> scores, List<Turn> turns, GameMode gameMode,int id=0)
//{ //{
@ -45,6 +45,7 @@ namespace Model
public Game(DateOnly date, Player owner, GameMode gameMode, int id = 0) public Game(DateOnly date, Player owner, GameMode gameMode, int id = 0)
{ {
Date = date; Date = date;
Players = new ReadOnlyCollection<Player>(players);
Grilles = new ReadOnlyDictionary<Player, Grille>(grilles); Grilles = new ReadOnlyDictionary<Player, Grille>(grilles);
Scores = new ReadOnlyDictionary<Player, int>(scores); Scores = new ReadOnlyDictionary<Player, int>(scores);
Turns = new ReadOnlyCollection<Turn>(turns); Turns = new ReadOnlyCollection<Turn>(turns);
@ -52,7 +53,6 @@ namespace Model
scores.Add(owner, 0); scores.Add(owner, 0);
GameMode = gameMode; GameMode = gameMode;
Id = id; Id = id;
Player = owner;
} }
public bool AddPlayerToGame(Player player) public bool AddPlayerToGame(Player player)
@ -76,7 +76,7 @@ namespace Model
return false; return false;
} }
public bool AddCaseValue(Player player, int value, int index) public bool AddCaseValueToPlayer(Player player, int value, int index)
{ {
if (grilles.ContainsKey(player) == true && scores.ContainsKey(player) == true) if (grilles.ContainsKey(player) == true && scores.ContainsKey(player) == true)
{ {

@ -24,17 +24,15 @@ namespace Model
Task<int> GetNbItemsByPseudo(string charPseudo); Task<int> GetNbItemsByPseudo(string charPseudo);
//byId ? //byId ?
} }
public interface IGamesManager : IGenericDataManager<Game?> public interface IGamesManager : IGenericDataManager<Game?>
{ {
Task<bool> AddPlayer(Player player); Task<bool> AddPlayer(Player player);
Task<bool> AddScoreToPlayer(int id, int score); Task<bool> AddScoreToPlayer(int idGame, int idPlayer, int score);
Task<bool> AddCaseValueToPlayer(int id, int value, int index); Task<bool> AddCaseValueToPlayer(int idGame, int idPlayer, int value, int index);
Task<bool> AddTurn(Turn turn); Task<bool> AddTurn(Turn turn);
Task<bool> AddTime(TimeSpan time); Task<bool> AddTime(TimeSpan time);
} }
public interface IGamesModeManager : IGenericDataManager<GameMode?> public interface IGamesModeManager : IGenericDataManager<GameMode?>

@ -34,7 +34,7 @@ namespace Stub
{ {
if (item == null || collection.Contains(item)) if (item == null || collection.Contains(item))
{ {
return Task.FromResult<T?>(default(T)); return Task.FromResult(default(T));
} }
collection.Add(item); collection.Add(item);
return Task.FromResult<T?>(item); return Task.FromResult<T?>(item);

@ -27,29 +27,22 @@ namespace Stub
=> this.parent = parent; => this.parent = parent;
public Task<Case?> AddItem(Case? item) public Task<Case?> AddItem(Case? item)
{ => parent.Cases.AddItem(item);
throw new NotImplementedException();
}
public Task<bool> DeleteItem(Case? item) public Task<bool> DeleteItem(Case? item)
{ => parent.Cases.DeleteItem(item);
throw new NotImplementedException();
}
public Task<IEnumerable<Case?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false) public Task<IEnumerable<Case?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false)
{ => parent.Cases.GetItemsWithFilterAndOrdering(
throw new NotImplementedException(); c => true,
} index, count,
orderingPropertyName, descending);
public Task<int> GetNbItems() public Task<int> GetNbItems()
{ => Task.FromResult(parent.Cases.Count());
throw new NotImplementedException();
}
public Task<Case?> UpdateItem(Case? oldItem, Case? newItem) public Task<Case?> UpdateItem(Case? oldItem, Case? newItem)
{ => parent.Cases.UpdateItem(oldItem, newItem);
throw new NotImplementedException();
}
} }
} }
} }

@ -23,55 +23,88 @@ namespace Stub
public GamesManager(StubData parent) public GamesManager(StubData parent)
=> this.parent = parent; => this.parent = parent;
Task<bool> IGamesManager.AddCaseValueToPlayer(int id, int value, int index) Task<bool> IGamesManager.AddCaseValueToPlayer(int idGame, int idPlayer, int value, int index)
{ {
throw new NotImplementedException(); var game = parent.games.FirstOrDefault(g => g.Id == idGame);
if(game == null)
{
return Task.FromResult(false);
} }
var player = game.Players.FirstOrDefault(p => p.Id == idPlayer);
Task<Game?> IGenericDataManager<Game?>.AddItem(Game? item) if(player == null)
{ {
throw new NotImplementedException(); return Task.FromResult(false);
}
game.AddCaseValueToPlayer(player, value, index);
return Task.FromResult(true);
} }
Task<bool> IGamesManager.AddPlayer(Player player) Task<bool> IGamesManager.AddPlayer(Player player)
{ {
throw new NotImplementedException(); var game = parent.games.FirstOrDefault();
if(game == null)
{
return Task.FromResult(false) ;
}
game.Players.AddItem(player);
return Task.FromResult(true);
} }
Task<bool> IGamesManager.AddScoreToPlayer(int id, int score) Task<bool> IGamesManager.AddScoreToPlayer(int idGame, int idPlayer, int score)
{ {
throw new NotImplementedException(); var game = parent.games.FirstOrDefault(g => g.Id == idGame);
if( game == null)
{
return Task.FromResult(false);
}
var player = game.Players.FirstOrDefault(p => p.Id == idPlayer);
if(player == null)
{
return Task.FromResult(false);
}
game.AddScoreToPlayer(player, score);
return Task.FromResult(true);
} }
Task<bool> IGamesManager.AddTime(TimeSpan time) Task<bool> IGamesManager.AddTime(TimeSpan time)
{ {
throw new NotImplementedException(); var game = parent.games.FirstOrDefault();
if (game == null)
{
return Task.FromResult(false);
}
game.AddTime(time);
return Task.FromResult(true);
} }
Task<bool> IGamesManager.AddTurn(Turn turn) Task<bool> IGamesManager.AddTurn(Turn turn)
{ {
throw new NotImplementedException(); var game = parent.games.FirstOrDefault();
if( game == null)
{
return Task.FromResult(false);
}
game.AddTurn(turn);
return Task.FromResult(true);
} }
Task<Game?> IGenericDataManager<Game?>.AddItem(Game? item)
=> parent.games.AddItem(item);
Task<bool> IGenericDataManager<Game?>.DeleteItem(Game? item) Task<bool> IGenericDataManager<Game?>.DeleteItem(Game? item)
{ => parent.games.DeleteItem(item);
throw new NotImplementedException();
}
Task<IEnumerable<Game?>> IGenericDataManager<Game?>.GetItems(int index, int count, string? orderingPropertyName, bool descending) Task<IEnumerable<Game?>> IGenericDataManager<Game?>.GetItems(int index, int count, string? orderingPropertyName, bool descending)
{ => parent.games.GetItemsWithFilterAndOrdering(
throw new NotImplementedException(); g => true,
} index, count,
orderingPropertyName, descending);
Task<int> IGenericDataManager<Game?>.GetNbItems() Task<int> IGenericDataManager<Game?>.GetNbItems()
{ => Task.FromResult(parent.games.Count());
throw new NotImplementedException();
}
Task<Game?> IGenericDataManager<Game?>.UpdateItem(Game? oldItem, Game? newItem) Task<Game?> IGenericDataManager<Game?>.UpdateItem(Game? oldItem, Game? newItem)
{ => parent.games.UpdateItem(oldItem, newItem);
throw new NotImplementedException();
}
} }
} }
} }

@ -23,29 +23,22 @@ namespace Stub
=> this.parent = parent; => this.parent = parent;
public Task<GameMode?> AddItem(GameMode? item) public Task<GameMode?> AddItem(GameMode? item)
{ => parent.GamesMode.AddItem(item);
throw new NotImplementedException();
}
public Task<bool> DeleteItem(GameMode? item) public Task<bool> DeleteItem(GameMode? item)
{ => parent.GamesMode.DeleteItem(item);
throw new NotImplementedException();
}
public Task<IEnumerable<GameMode?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false) public Task<IEnumerable<GameMode?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false)
{ => parent.GamesMode.GetItemsWithFilterAndOrdering(
throw new NotImplementedException(); g => true,
} index, count,
orderingPropertyName, descending);
public Task<int> GetNbItems() public Task<int> GetNbItems()
{ => Task.FromResult(parent.GamesMode.Count());
throw new NotImplementedException();
}
public Task<GameMode?> UpdateItem(GameMode? oldItem, GameMode? newItem) public Task<GameMode?> UpdateItem(GameMode? oldItem, GameMode? newItem)
{ => parent.GamesMode.UpdateItem(oldItem, newItem);
throw new NotImplementedException();
}
} }
} }
} }

@ -23,14 +23,10 @@ namespace Stub
=> this.parent = parent; => this.parent = parent;
public Task<Stats?> AddItem(Stats? item) public Task<Stats?> AddItem(Stats? item)
{ => parent.stats.AddItem(item);
throw new NotImplementedException();
}
public Task<bool> DeleteItem(Stats? item) public Task<bool> DeleteItem(Stats? item)
{ => parent.stats.DeleteItem(item);
throw new NotImplementedException();
}
public Task<IEnumerable<Stats?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false) public Task<IEnumerable<Stats?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false)
=> parent.stats.GetItemsWithFilterAndOrdering( => parent.stats.GetItemsWithFilterAndOrdering(
@ -39,14 +35,10 @@ namespace Stub
orderingPropertyName, descending); orderingPropertyName, descending);
public Task<int> GetNbItems() public Task<int> GetNbItems()
{ => Task.FromResult(parent.stats.Count());
throw new NotImplementedException();
}
public Task<Stats?> UpdateItem(Stats? oldItem, Stats? newItem) public Task<Stats?> UpdateItem(Stats? oldItem, Stats? newItem)
{ => parent.stats.UpdateItem(oldItem, newItem);
throw new NotImplementedException();
}
} }
} }
} }

@ -23,29 +23,22 @@ namespace Stub
=> this.parent = parent; => this.parent = parent;
public Task<Turn?> AddItem(Turn? item) public Task<Turn?> AddItem(Turn? item)
{ => parent.Turns.AddItem(item);
throw new NotImplementedException();
}
public Task<bool> DeleteItem(Turn? item) public Task<bool> DeleteItem(Turn? item)
{ => parent.Turns.DeleteItem(item);
throw new NotImplementedException();
}
public Task<IEnumerable<Turn?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false) public Task<IEnumerable<Turn?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false)
{ => parent.Turns.GetItemsWithFilterAndOrdering(
throw new NotImplementedException(); t => true,
} index, count,
orderingPropertyName, descending);
public Task<int> GetNbItems() public Task<int> GetNbItems()
{ => Task.FromResult(parent.Turns.Count());
throw new NotImplementedException();
}
public Task<Turn?> UpdateItem(Turn? oldItem, Turn? newItem) public Task<Turn?> UpdateItem(Turn? oldItem, Turn? newItem)
{ => parent.Turns.UpdateItem(oldItem, newItem);
throw new NotImplementedException();
}
} }
} }
} }

Loading…
Cancel
Save