public string Start(string token) { var playerToken = new Token(token); new TokenValidator(playerToken) .GameExists() .PlayerExists() .NotStarted() .IsHost(); var game = Games[playerToken.GameId]; game.Start(); return "Success"; }
public string InvitePlayer(string token, string email) { var playerToken = new Token(token); new TokenValidator(playerToken) .GameExists() .PlayerExists() .NotStarted() .IsHost(); var game = Games[playerToken.GameId]; game.AddPlayer(email); return "Success"; }
public List<GameInfoForPlayer> Info(string token, string state) { var playerToken = new Token(token); new TokenValidator(playerToken) .GameExists() .PlayerExists(); var game = Games[playerToken.GameId]; if (string.IsNullOrEmpty(state)) { return game.Infos[playerToken.PlayerId]; } var latestStateId = Parse(state); return game.Infos[playerToken.PlayerId].Where(x => x.GameStateId > latestStateId).ToList(); }
public TokenValidator(Token playerToken) { _playerToken = playerToken; }
public void SetPrice(string token, int price) { var playerToken = new Token(token); new TokenValidator(playerToken) .GameExists() .Started() .PlayerExists(); var game = Games[playerToken.GameId]; game.SetPrice(playerToken.PlayerId, price); }