Add comments, break keyboard..?
continuous-integration/drone/push Build is passing Details

pull/90/head
Alexis Drai 3 years ago
parent cccd21ca12
commit 8f42e7577e

@ -1,64 +1,83 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Model.Dice; using Model.Dice;
using Model.Dice.Faces; using Model.Dice.Faces;
using Model.Players; using Model.Players;
namespace Model.Games namespace Model.Games
{ {
public class GameRunner public class GameRunner
{ {
private readonly IManager<Player> globalPlayerManager; private readonly IManager<Player> globalPlayerManager;
private readonly IManager<KeyValuePair<string, IEnumerable<AbstractDie<AbstractDieFace>>>> globalDieManager; private readonly IManager<KeyValuePair<string, IEnumerable<AbstractDie<AbstractDieFace>>>> globalDieManager;
private readonly List<Game> games; private readonly List<Game> games;
public GameRunner(IManager<Player> globalPlayerManager, IManager<KeyValuePair<string, IEnumerable<AbstractDie<AbstractDieFace>>>> globalDieManager, List<Game> games) public GameRunner(IManager<Player> globalPlayerManager, IManager<KeyValuePair<string, IEnumerable<AbstractDie<AbstractDieFace>>>> globalDieManager, List<Game> games)
{ {
this.globalPlayerManager = globalPlayerManager; this.globalPlayerManager = globalPlayerManager;
this.globalDieManager = globalDieManager; this.globalDieManager = globalDieManager;
this.games = games ?? new(); this.games = games ?? new();
} }
public IEnumerable<Game> GetAllGames() => games.AsEnumerable(); public IEnumerable<Game> GetAllGames() => games.AsEnumerable();
/// <summary> /// <summary>
/// finds the game with that name and returns it /// finds the game with that name and returns it
/// <br/> /// <br/>
/// that copy does not belong to this gamerunner's games, so it should not be modified /// that copy does not belong to this gamerunner's games, so it should not be modified
/// </summary> /// </summary>
/// <param name="name">a games's name</param> /// <param name="name">a games's name</param>
/// <returns>game with said name, <em>or null</em> if no such game was found</returns> /// <returns>game with said name, <em>or null</em> if no such game was found</returns>
public Game GetOneGameByName(string name) public Game GetOneGameByName(string name)
{ {
if (!string.IsNullOrWhiteSpace(name)) if (!string.IsNullOrWhiteSpace(name))
{ {
Game result = games.FirstOrDefault(g => g.Name == name); Game result = games.FirstOrDefault(g => g.Name == name);
return result; // may return null return result; // may return null
} }
throw new ArgumentException("param should not be null or blank", nameof(name)); throw new ArgumentException("param should not be null or blank", nameof(name));
} }
public void SaveGame(Game game) /// <summary>
{ /// saves a given game
throw new NotSupportedException(); /// </summary>
} /// <param name="game">a game to save</param>
/// <exception cref="NotSupportedException"></exception>
public Game LoadGame(string name) public void SaveGame(Game game)
{ {
throw new NotSupportedException(); throw new NotSupportedException();
} }
public void StartNewGame() /// <summary>
{ /// loads a game by name
throw new NotSupportedException(); /// </summary>
} /// <param name="name">name of game to be loaded</param>
/// <returns>loaded game</returns>
public void DeleteGame(Game game) /// <exception cref="NotSupportedException"></exception>
{ public Game LoadGame(string name)
throw new NotSupportedException(); {
} throw new NotSupportedException();
} }
}
/// <summary>
/// creates a new game
/// </summary>
/// <exception cref="NotSupportedException"></exception>
public void StartNewGame()
{
throw new NotSupportedException();
}
public void DeleteGame(Game game)
{
throw new NotSupportedException();
}
private void PlayGame(Game game)
{
throw new NotSupportedException();
}
}
}

Loading…
Cancel
Save