public void TestIndexUsesAnExistingBoard() { var board = new Board(); var controller = new HomeController(); var controllerContext = new ControllerContextMock(controller); controllerContext.Session.SetupGet(s => s["Board"]).Returns(board); var result = controller.Index() as ViewResult; Assert.IsNotNull(result.ViewData["Board"]); Assert.AreEqual(board, result.ViewData["Board"]); }
/// <summary> /// Constructs a board object from an existing board object, copying its size and content. /// </summary> /// <param name="fromBoard">The source board object.</param> public Board(Board fromBoard) { SizeX = fromBoard.SizeX; SizeY = fromBoard.SizeY; content = new Content[SizeX, SizeY]; for (int i = 0; i < SizeX; i++) { for (int j = 0; j < SizeY; j++) { content[i, j] = fromBoard.content[i, j]; } } }
private void InitializeFromGameInfo() { Board = new Board(GameInfo.BoardSizeX, GameInfo.BoardSizeY); if (GameInfo.Handicap > 0 && !GameInfo.FreePlacedHandicap) SetHandicap(GameInfo.Handicap); Turn = GameInfo.StartingPlayer; Root = this; }
/// <summary> /// Constructs a Game object from a Board object and a turn to play. /// </summary> /// <param name="bs">The source Board.</param> /// <param name="turn">The color of the player whose turn it is to play.</param> protected Game(Board bs, Content turn) { Board = new Board(bs); Turn = turn; }
/// <summary> /// Constructs a Game object from an existing Game object. This constructor is used when making /// game moves. /// </summary> /// <param name="fromGame">The Game object before the move.</param> protected Game(Game fromGame) { Board = new Board(fromGame.Board); Turn = fromGame.Turn.Opposite(); captures[Content.White] = fromGame.captures[Content.White]; captures[Content.Black] = fromGame.captures[Content.Black]; foreach (var p in fromGame.superKoSet) superKoSet.Add(p); Root = fromGame.Root; }
public void Start(PlayerRepresentation whitePlayer, PlayerRepresentation blackPlayer, PictureBox gameBoard, MenuItem startMenuItem, MenuItem stopMenuItem, Board.BoardSize boardSize) { this.startMenuItem = startMenuItem; this.stopMenuItem = stopMenuItem; startMenuItem.Enabled = false; stopMenuItem.Enabled = true; mouseMoveEvent = new MouseEventHandler(GameBoard_MouseMove); paintEvent = new PaintEventHandler(GameBoard_Paint); mouseLeaveEvent = new EventHandler(GameBoard_MouseLeave); clickEvent = new EventHandler(GameBoard_Click); this.whitePlayer = whitePlayer; this.blackPlayer = blackPlayer; whitePlayer.Start(false); blackPlayer.Start(true); this.gameBoard = gameBoard; Game.Instance.Start(whitePlayer.PlayerName, blackPlayer.PlayerName, boardSize); this.boardSize = (Int32) boardSize; gameBoard.Width = blockSize * ((Int32) boardSize) + (2 * 5); gameBoard.Height = blockSize * ((Int32) boardSize) + (2 * 5); gameBoard.MouseMove += mouseMoveEvent; gameBoard.Paint += paintEvent; gameBoard.MouseLeave += mouseLeaveEvent; gameBoard.Click += clickEvent; gameBoard.Refresh(); }
// Methods public void Start(String whiteName, String blackName, Board.BoardSize boardSize) { if(started) { Stop(); } white = new Player(whiteName); black = new Player(blackName); active = black; Board.Instance.Start(boardSize); started = true; }