示例#1
0
        private void OnNewBoardStateAvailable(BoardState boardState)
        {
            ((Command)Capitulate).RaiseCanExecuteChanged();

            if (boardState == null)
            {
                GameStatus = GameStatus.Unloaded;

                TopPlayerName             = "- - - - -";
                TopPlayerWallCountLeft    = 10;
                BottomPlayerWallCountLeft = 10;
                MovesLeft         = "--";
                TopPlayerRestTime = "--";

                GameProgress.Clear();
            }
            else
            {
                GameStatus = GameStatus.Active;

                TopPlayerName = boardState.TopPlayer.Player.Name;

                TopPlayerWallCountLeft    = boardState.TopPlayer.WallsToPlace;
                BottomPlayerWallCountLeft = boardState.BottomPlayer.WallsToPlace;

                if (boardState.CurrentMover.PlayerType == PlayerType.BottomPlayer)
                {
                    if (GameProgress.Count > 0)
                    {
                        GameProgress[GameProgress.Count - 1] = GameProgress[GameProgress.Count - 1] + $" {boardState.LastMove}";
                    }

                    var currentMovesLeft = int.Parse(MovesLeft);
                    MovesLeft = (currentMovesLeft - 1).ToString();

                    StopTimer();
                }
                else
                {
                    GameProgress.Add($"{GameProgress.Count + 1}: " + $"{boardState.LastMove}");
                    StartTimer();
                }
            }
        }