Ejemplo n.º 1
0
 private void EndOfMatch(ChessCom.MatchEvent result)
 {
     _timer?.Stop();
     if (result == ChessCom.MatchEvent.Draw)
     {
     }
     else if ((result == ChessCom.MatchEvent.WhiteWin && _clientIsPlayer == ClientIsPlayer.White) || (result == ChessCom.MatchEvent.BlackWin && _clientIsPlayer == ClientIsPlayer.Black))
     {
         WriteTextNonInvoke("Congratulations you won!!" + "\n");
     }
     else
     {
         WriteTextNonInvoke("You lost, stupid idiot." + "\n");
     }
     _clientIsPlayer = ClientIsPlayer.Both;
     _globalState.VisionRules.Enabled = false;
     _globalState.CalculateVision();
     ClearBoard();
     UpdateBoardFromGlobalState();
     lookForMatchButton.IsEnabled = true;
 }
Ejemplo n.º 2
0
        public void StartMatch(bool isWhitePlayer, string matchToken, ChessCom.VisionRules rules, ChessCom.TimeRules timeRules)
        {
            WriteTextNonInvoke("Starting match: " + matchToken + ", you are " + (isWhitePlayer?"white":"black"));
            WriteTextNonInvoke("Opponent username: "******"", To = ""
            };
            _lastMoveFrom = null;
            _lastMoveTo   = null;
            _killedPices.Clear();
            ClearBoard();
            var vr = new VisionRules
            {
                Enabled          = rules.Enabled,
                ViewMoveFields   = rules.ViewMoveFields,
                ViewRange        = rules.ViewRange,
                ViewCaptureField = rules.ViewCaptureField,
                PiceOverwrite    = new Dictionary <Pices, VisionRules>()
            };

            foreach (var keyValOR in rules.PiceOverwriter)
            {
                vr.PiceOverwrite.Add((Pices)keyValOR.Key, new VisionRules {
                    Enabled = keyValOR.Value.Enabled, ViewMoveFields = keyValOR.Value.ViewMoveFields, ViewRange = keyValOR.Value.ViewRange
                });
            }
            _whiteStaticTimeLeft       = new TimeSpan(0, timeRules.PlayerTime.Minutes, timeRules.PlayerTime.Seconds);
            _whiteTimeSpan             = _whiteStaticTimeLeft;
            lbWhiteTimeLeft.Content    = _whiteTimeSpan.ToString(@"mm\:ss");
            lbWhiteTimePerMove.Content = $"+{timeRules.SecondsPerMove}s";
            _blackStaticTimeLeft       = new TimeSpan(0, timeRules.PlayerTime.Minutes, timeRules.PlayerTime.Seconds);
            _blackTimeSpan             = _whiteStaticTimeLeft;
            lbBlackTimeLeft.Content    = _whiteTimeSpan.ToString(@"mm\:ss");
            lbBlackTimePerMove.Content = $"+{timeRules.SecondsPerMove}s";
            _timeRules = timeRules;

            _globalState = GlobalState.CreateStartState(vr);
            UpdateBoardFromGlobalState();
        }