Пример #1
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();
        }
Пример #2
0
        public MainWindow()
        {
            InitializeComponent();
            DataContext = new MyLittleFuckingDataContext();
            var ver = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);

            Title = $"Slug Chess v{ver.FileMajorPart}.{ver.FileMinorPart}.{ver.FileBuildPart}";
#if DEBUG
            Title += $" Debug";
#endif
            //Uri pageUri = new Uri("pack://*****:*****@spaceslug.no. Continue to singleplayer?";
                MessageBoxButton button      = MessageBoxButton.YesNo;
                MessageBoxImage  icon        = MessageBoxImage.Error;
                var result = MessageBox.Show(textBoxText, popupText, button, icon);
                if (result == MessageBoxResult.No)
                {
                    Application.Current.Shutdown();
                }
            }
        }