コード例 #1
0
ファイル: GameController.cs プロジェクト: Saura81/Drones
        public List <string> EditRound(int roundId, string move)
        {
            var roundInProgress = updateRoundPlayerData(move);

            List <string> callback = new List <string>();

            if (string.IsNullOrEmpty(roundInProgress.Winner))
            {
                callback.Add(_gameDao.saveRound(roundInProgress).ToString());

                if (string.IsNullOrEmpty(roundInProgress.FirstPlayerMove))
                {
                    callback.Add(roundInProgress.FirstPlayerName);
                }
                else
                {
                    callback.Add(roundInProgress.SecondPlayerName);
                }
            }
            else
            {
                _gameDao.saveRound(roundInProgress);

                var winner = _gameDao.HaveWinner(roundInProgress);

                if (!string.IsNullOrEmpty(winner))
                {
                    callback.Add(winner);
                    return(callback);
                }
                else
                {
                    var newRound = _gameDao.StartNewRound(new TblRounds
                    {
                        FirstPlayerName  = roundInProgress.FirstPlayerName,
                        SecondPlayerName = roundInProgress.SecondPlayerName
                    });
                    callback.Add(newRound.ToString());
                    callback.Add(roundInProgress.FirstPlayerName);
                }
            }

            return(callback);
        }