Esempio n. 1
0
        public void UpdateMatch(UpdateSettings command)
        {
            var host     = _match.GetHost();
            var opponent = _match.GetOpponent();

            if (_match.IsTurn(MatchRole.Host))
            {
                host.SetGoFlagUpdatePassLock(false, false, true);
                opponent.SetGoFlagUpdatePassLock(true, true, false);
            }
            else
            {
                host.SetGoFlagUpdatePassLock(true, true, false);
                opponent.SetGoFlagUpdatePassLock(false, false, true);
            }

            var user = _match.GetUser(command.UserId);

            _match.Videos.Add(new Video
            {
                VideoIndex = _match.Videos.Count,
                UserIndex  = user.Index,
                UserId     = user.UserId,
                VideoPath  = CdnUrlHelper.CreateVideoUrl(_routing.Cdn, _match.Id.ToString(), command.Video),
                ThumbPath  = CdnUrlHelper.CreateThumbUrl(_routing.Cdn, _match.Id.ToString(), command.Thumb)
            });

            _match.Chain     += $" {command.Move.Trim()} ->";
            _match.Turn       = _match.GetTurnName();
            _match.LastUpdate = DateTime.Now;
            _match.Round++;
        }
Esempio n. 2
0
        public void UpdateMatch(UpdateSettings command)
        {
            var user = _match.GetUser(command.UserId);

            _match.Videos.Add(new Video
            {
                VideoIndex = _match.Videos.Count,
                UserIndex  = user.Index,
                UserId     = user.UserId,
                VideoPath  = CdnUrlHelper.CreateVideoUrl(_routing.Cdn, _match.Id.ToString(), command.Video),
                ThumbPath  = CdnUrlHelper.CreateThumbUrl(_routing.Cdn, _match.Id.ToString(), command.Thumb)
            });

            var host     = _match.GetHost();
            var opponent = _match.GetOpponent();

            if (_match.TurnType == TurnType.Blitz && _match.Videos.Count(x => x.UserId == user.UserId) == 3)
            {
                user.SetGoFlagUpdatePassLock(false, false, true, lockIn: true);
            }
            else if (_match.TurnType == TurnType.Classic)
            {
                if (_match.IsTurn(MatchRole.Host))
                {
                    host.SetGoFlagUpdatePassLock(false, false, true);
                    opponent.SetGoFlagUpdatePassLock(true, true, false);
                }
                else if (_match.IsTurn(MatchRole.Opponent))
                {
                    host.SetGoFlagUpdatePassLock(true, true, false);
                    opponent.SetGoFlagUpdatePassLock(false, false, true);
                    _match.Round++;
                }

                _match.Turn = _match.GetTurnName();
            }
            else if (_match.TurnType == TurnType.Alternating)
            {
                if (_match.IsTurn(MatchRole.Host))
                {
                    if (_match.Round == 2)
                    {
                        host.SetGoFlagUpdatePassLock(true, false, true);
                        opponent.SetGoFlagUpdatePassLock(false, true, false);
                        _match.Round++;
                    }
                    else
                    {
                        host.SetGoFlagUpdatePassLock(false, false, true);
                        opponent.SetGoFlagUpdatePassLock(true, true, false);
                    }
                }
                else if (_match.IsTurn(MatchRole.Opponent))
                {
                    if (_match.Round % 2 == 0)
                    {
                        host.SetGoFlagUpdatePassLock(true, true, false);
                        opponent.SetGoFlagUpdatePassLock(false, false, true);
                    }
                    else
                    {
                        host.SetGoFlagUpdatePassLock(false, true, false);
                        opponent.SetGoFlagUpdatePassLock(true, false, true);
                        _match.Round++;
                    }
                }

                _match.Turn = _match.GetTurnName();
            }

            if (_match.Round > 3)
            {
                host.SetLockUser();
                opponent.SetLockUser();
            }

            _match.LastUpdate = DateTime.Now;
        }
Esempio n. 3
0
        public void UpdateMatch(UpdateSettings command)
        {
            var user = _match.GetUser(command.UserId);

            _match.Videos.Add(new Video
            {
                VideoIndex = _match.Videos.Count,
                UserIndex  = user.Index,
                UserId     = user.UserId,
                VideoPath  = CdnUrlHelper.CreateVideoUrl(_routing.Cdn, _match.Id.ToString(), command.Video),
                ThumbPath  = CdnUrlHelper.CreateThumbUrl(_routing.Cdn, _match.Id.ToString(), command.Thumb)
            });

            var tempRound = _match.Round;

            var host     = _match.GetHost();
            var opponent = _match.GetOpponent();

            if (_match.Round % 2 == 1)
            {
                if (_match.IsTurn(MatchRole.Host))
                {
                    host.Points++;
                    host.SetGoFlagUpdatePassLock(false, false, true);
                    opponent.SetGoFlagUpdatePassLock(true, true, false, pass: true);
                }
                else
                {
                    opponent.Points++;
                    host.SetGoFlagUpdatePassLock(false, true, false);
                    opponent.SetGoFlagUpdatePassLock(true, false, true);
                    _match.Round++;
                }
            }
            else if (_match.IsTurn(MatchRole.Host))
            {
                host.Points++;
                host.SetGoFlagUpdatePassLock(true, false, true);
                opponent.SetGoFlagUpdatePassLock(false, true, false);
                _match.Round++;
            }
            else
            {
                host.SetGoFlagUpdatePassLock(true, true, false, pass: true);
                opponent.SetGoFlagUpdatePassLock(false, false, true);
                opponent.Points++;
            }

            if (tempRound == _match.Round)
            {
                if (IsNullOrEmpty(_match.Chain))
                {
                    _match.Chain = command.Move.Trim();
                }
                else
                {
                    _match.Chain += $"|{command.Move.Trim()}";
                }
            }

            CopyCatHelper.CompleteCopyCat(_match);

            _match.Turn       = _match.GetTurnName();
            _match.LastUpdate = DateTime.Now;
        }