Exemplo n.º 1
0
        private void LoadProblem(TsumegoProblem problem)
        {
            Rectangle rect = problem.GetBoundingBoard();

            BoardViewModel.BoardControlState.OriginX     = rect.X;
            BoardViewModel.BoardControlState.OriginY     = rect.Y;
            BoardViewModel.BoardControlState.BoardWidth  = rect.Width;
            BoardViewModel.BoardControlState.BoardHeight = rect.Height;
            _currentProblem            = problem;
            _currentProblemTree        = _currentProblem.SpawnThisProblem();
            CurrentProblemName         = _currentProblem.Name;
            CurrentProblemInstructions = _currentProblemTree.Comment;
            CurrentNode   = _currentProblemTree;
            _playerToMove = _currentProblem.ColorToPlay;
            _humansColor  = _playerToMove;
            if (_humansColor == StoneColor.Black)
            {
                CurrentNodeStatus = Localizer.Tsumego_BlackToPlay;
            }
            else
            {
                CurrentNodeStatus = Localizer.Tsumego_WhiteToPlay;
            }
            WrongVisible   = false;
            CorrectVisible = false;
            GoToPreviousProblemCommand.RaiseCanExecuteChanged();
            GoToNextProblemCommand.RaiseCanExecuteChanged();
            UndoOneMoveCommand.RaiseCanExecuteChanged();
            RaisePropertyChanged(nameof(CurrentProblemPermanentlySolved));
        }
Exemplo n.º 2
0
        private static void ProcessTsumegoFile(FileInfo fileInfo, string relativePath)
        {
            string content    = File.ReadAllText(fileInfo.FullName);
            var    problem    = TsumegoProblem.CreateFromSgfText(content);
            var    plainBoard = new StoneColor[problem.InitialBoard.Size.Width, problem.InitialBoard.Size.Height];

            for (int x = 0; x < problem.InitialBoard.Size.Width; x++)
            {
                for (int y = 0; y < problem.InitialBoard.Size.Height; y++)
                {
                    plainBoard[x, y] = problem.InitialBoard[x, y];
                }
            }
            TsumegoProblemDefinition definition = new TsumegoProblemDefinition(problem.Name, problem.InitialBoard.Size.Width, problem.InitialBoard.Size.Height,
                                                                               plainBoard, Path.Combine(relativePath, fileInfo.Name));

            Definitions.Add(definition);
        }