예제 #1
0
        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";
        }
예제 #2
0
        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";
        }
예제 #3
0
        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();
        }
예제 #4
0
 public TokenValidator(Token playerToken)
 {
     _playerToken = playerToken;
 }
예제 #5
0
        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);
        }