示例#1
0
        /// <summary>
        ///  Domain Service create
        ///       CalculateStats( Match)
        ///
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task EndMatch(EndMatch input)
        {
            var match = await _matchRepository.GetAsync(input.MatchId);

            match.End();
            GameKeeper.CalculateTicTacToeStats(match);

            //if (input.WinningPlayerId == match.FirstPlayerId)
            //{
            //    match.FirstPlayer.Win = Convert.ToInt32(match.FirstPlayer.Win) + 1;
            //    match.FirstPlayer.Score = Convert.ToInt32(match.FirstPlayer.Score) + 1;
            //    match.SecondPlayer.Loss = Convert.ToInt32(match.SecondPlayer.Loss) + 1;

            //if (input.WinningPlayerId == match.SecondPlayerId)
            //{
            //    match.SecondPlayer.Win = Convert.ToInt32(match.SecondPlayer.Win) + 1;
            //    match.SecondPlayer.Score = Convert.ToInt32(match.SecondPlayer.Score)+ 1;
            //    match.FirstPlayer.Loss = Convert.ToInt32(match.FirstPlayer.Loss) + 1;
            //    match.WinningPlayerId = match.SecondPlayerId;
            //}
            //if (input.WinningPlayerId == 0)
            //{
            //    match.FirstPlayer.Ties = match.FirstPlayer.Ties.Value + 1;
            //    match.FirstPlayer.Score = Convert.ToInt32(match.FirstPlayer.Score) + 0.5;
            //    match.SecondPlayer.Ties = Convert.ToInt32(match.SecondPlayer.Ties) + 1;
            //    match.SecondPlayer.Score = Convert.ToInt32(match.SecondPlayer.Score) + 0.5;
            //}
        }