diff --git a/Sources/Model/Games/GameRunner.cs b/Sources/Model/Games/GameRunner.cs
index 1e80c4d..a477c74 100644
--- a/Sources/Model/Games/GameRunner.cs
+++ b/Sources/Model/Games/GameRunner.cs
@@ -42,19 +42,19 @@ namespace Model.Games
}
///
- /// saves a given game
+ /// saves a given game -- does not allow copies yet: if a game with the same name exists, it is overwritten
///
/// a game to save
///
public void SaveGame(Game game)
{
- if(game != null)
+ if (game != null)
{
games.Remove(games.FirstOrDefault(g => g.Name == game.Name));
// will often be an update: if game with that name exists, it is removed, else, nothing happens above
games.Add(game);
}
-
+
}
///
@@ -66,18 +66,16 @@ namespace Model.Games
public void LoadGame(string name)
{
Game game = GetOneGameByName(name);
- PlayGame(game);
}
///
- /// creates a new game -- copies are OK
+ /// creates a new game
///
///
public void StartNewGame(string name, PlayerManager playerManager, IEnumerable> dice)
{
Game game = new(name, playerManager, dice);
SaveGame(game);
- PlayGame(game);
}
public void DeleteGame(Game game)
@@ -85,16 +83,76 @@ namespace Model.Games
games.Remove(game);
}
- private void PlayGame(Game game)
+ ///
+ /// plays one turn of the game
+ ///
+ /// the game from which a turn will be played
+ public void PlayGame(Game game)
{
- while(true)
- {
- Player current = game.GetWhoPlaysNow();
- game.PerformTurn(current);
- game.PrepareNextPlayer(current);
- // TODO
- break;
- }
+ Player current = game.GetWhoPlaysNow();
+ game.PerformTurn(current);
+ game.PrepareNextPlayer(current);
+ }
+
+ public void AddGlobalPlayer(Player player)
+ {
+ globalPlayerManager.Add(player);
+ }
+
+ public IEnumerable GetGlobalPlayers()
+ {
+ return globalPlayerManager.GetAll();
+ }
+
+ public Player GetOneGlobalPlayerByName(string name)
+ {
+ return globalPlayerManager.GetOneByName(name);
+ }
+
+ public void UpdateGlobalPlayer(Player oldPlayer, Player newPlayer)
+ {
+ globalPlayerManager.Update(oldPlayer, newPlayer);
+ }
+
+ public void DeleteGlobalPlayer(Player oldPlayer)
+ {
+ globalPlayerManager.Remove(oldPlayer);
+ }
+
+ public void AddGlobalDiceGroup(string name, IEnumerable> dice)
+ {
+ globalDieManager.Add(new KeyValuePair>>(name, dice));
+ }
+
+ public IEnumerable>>> GetGlobalDiceGroups()
+ {
+ return globalDieManager.GetAll();
+ }
+
+ public KeyValuePair>> GetOneGlobalDiceGroupByName(string name)
+ {
+ return globalDieManager.GetOneByName(name);
+ }
+
+ ///
+ /// only updates names
+ ///
+ /// old name
+ /// new name
+ public void UpdateGlobalDiceGroup(string oldName, string newName)
+ {
+ KeyValuePair>> oldDiceGroup = GetOneGlobalDiceGroupByName(oldName);
+ KeyValuePair>> newDiceGroup = new(newName, oldDiceGroup.Value);
+ globalDieManager.Update(oldDiceGroup, newDiceGroup);
+ }
+
+ ///
+ /// will remove those dice groups from other games, potentially breaking them
+ ///
+ ///
+ public void DeleteGlobalDiceGroup(string oldName)
+ {
+ globalDieManager.Remove(GetOneGlobalDiceGroupByName(oldName));
}
}
}