Ejemplo n.º 1
0
        public BoardSquareViewModel(Cell <ReversiGame> reversiGameCell, int indexVertical, int indexHorizontal)
        {
            this.gameCell = reversiGameCell;
            this.position = new Vector2D(indexHorizontal, indexVertical);

            this.Player      = gameCell.Derive(p => p.Board[position]);
            this.isValidMove = gameCell.Derive(p => p.IsValidMove(position));

            this.SelectSquare = new SelectSquareCommand(this, isValidMove);
        }
Ejemplo n.º 2
0
 public PlayerViewModel(BoardViewModel parent, Player player, int dimension)
 {
     this.parent = parent;
     this.player = player;
     Score       = Cell.Derive(this.parent.ReversiGame, g => g.Board.CountStones(player));
     ScoreBar    = Cell.Derive(Score, s => ScoreBarSize(s, dimension));
 }
Ejemplo n.º 3
0
 public BoardSquareViewModel(Cell <ReversiGame> game, int rowNumber, int columnNumber)
 {
     position        = new Vector2D(rowNumber, columnNumber);
     Owner           = Cell.Derive(game, g => SetOwnerOrCandidate(g));
     Type            = Cell.Derive(game, g => SetType(g));
     PutStoneCommand = new PutStoneCommand(game, position);
 }
Ejemplo n.º 4
0
 public StartViewModel()
 {
     Player1         = new PlayerInfoViewModel("Player 1", "Black");
     Player2         = new PlayerInfoViewModel("Player 2", "White");
     Dimension       = Cell.Create(8);
     DimensionString = Cell.Derive(Dimension, dim => dim.ToString() + " x " + dim.ToString());
 }
Ejemplo n.º 5
0
        public ColorPickerViewModel(Cell <GameInformation> info, int index, int pI, MenuViewModel parent)
        {
            this.colorIndex  = index;
            this.info        = info;
            this.playerIndex = pI;
            this.Color       = info.Derive(c => c.GetColor(colorIndex));

            this.parent    = parent;
            this.PickColor = new ColorButton(this);
        }
Ejemplo n.º 6
0
        public BoardViewModel(int dimension, PlayerInfoViewModel player1, PlayerInfoViewModel player2)
        {
            ReversiGame = Cell.Create(new ReversiGame(dimension, dimension));
            InitializePlayers(dimension, player1, player2);

            IsGameOver      = Cell.Derive(ReversiGame, g => g.IsGameOver);
            Winner          = Cell.Derive(ReversiGame, g => GetWinner(g));
            GameOverMessage = Cell.Derive(ReversiGame, g => CreateGameOverMessage(g));

            Rows = Enumerable.Range(0, ReversiGame.Value.Board.Height).Select(i => new BoardRowViewModel(ReversiGame, i)).ToList().AsReadOnly();
        }