Esempio n. 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;
            //}
        }
Esempio n. 2
0
        public async Task EndMatch(EndMatch input)
        {
            var match = await _matchRepository.GetAsync(input.Id);

            if (input.WinningPlayerId == match.FirstPlayerId)
            {
                match.FirstPlayer.Win   = match.FirstPlayer.Win + 1;
                match.FirstPlayer.Score = match.FirstPlayer.Score + 1;
                match.SecondPlayer.Loss = match.SecondPlayer.Loss + 1;
                match.WinningPlayerId   = match.FirstPlayerId;
            }
            if (input.WinningPlayerId == match.SecondPlayerId)
            {
                match.SecondPlayer.Win   = match.SecondPlayer.Win + 1;
                match.SecondPlayer.Score = match.SecondPlayer.Score + 1;
                match.FirstPlayer.Loss   = match.FirstPlayer.Loss + 1;
                match.WinningPlayerId    = match.SecondPlayerId;
            }
            if (input.WinningPlayerId == 0)
            {
                match.FirstPlayer.Ties   = match.FirstPlayer.Ties + 1;
                match.FirstPlayer.Score  = match.FirstPlayer.Score + 0.5;
                match.SecondPlayer.Ties  = match.SecondPlayer.Ties + 1;
                match.SecondPlayer.Score = match.SecondPlayer.Score + 0.5;
            }
        }
Esempio n. 3
0
    protected virtual void End()
    {
        EndMatch endMatch = GetComponent <EndMatch> ();

        endMatch.SetWinner(GetWinner());
        endMatch.enabled = true;
        Destroy(this);
    }
Esempio n. 4
0
        public static string ToggleTag(string str, string startTag, string Endtag)
        {
            bool HaveSameStartTag = false, HaveSamaeEndTag = false;
            var  StartMatch_ = Regex.Matches(str.Trim(), startTag);
            var  EndMatch_   = Regex.Matches(str.Trim(), Endtag);

            HaveSameStartTag = StartMatch_.Count > 0 ? StartMatch_[0].Index < 2 ? true : false : false;
            HaveSamaeEndTag  = EndMatch_.Count > 0 ? EndMatch_[0].EndIndex() + 1 >= str.Length ? true : false:false;

            Match StartMatch, EndMatch;

            if (HaveSamaeEndTag && HaveSameStartTag)
            {
                StartMatch = StartMatch_[0]; EndMatch = EndMatch_.Last();
                return(str.ReplaceRangeWithChar('\uFFFF', StartMatch.Index, StartMatch.EndIndex())
                       .ReplaceRangeWithChar('\uFFFF', EndMatch.Index, EndMatch.EndIndex()).Replace("\uFFFF", ""));
            }
            else
            {
                return(!HaveSamaeEndTag && HaveSameStartTag ?
                       str + Endtag : HaveSamaeEndTag && !HaveSameStartTag ? startTag + str
                : !HaveSamaeEndTag && !HaveSameStartTag ? startTag + str + Endtag:str);
            }
        }
 // Use this for initialization
 void Start()
 {
     playerID = 1;
     currentPlayerText = currentPlayerText.GetComponent<Text>();
     buttonsDatabase = buttonsDatabase.GetComponent<ButtonsDatabase>();
     scoreScript = scoreScript.GetComponent<ScoreScript>();
     endMatch = GetComponent<EndMatch>();
 }
Esempio n. 6
0
 // Start is called before the first frame update
 void Start()
 {
     instance = this;
 }