public void TestGetDistance() { var board = new BlockBoardStorage(1, 2, null); var items = new BoardStorageItem[3, 3]; var bonusItems = new BoardStorageItem[3, 3]; var pass1 = new Pass(null, null, new IntVector2(1, 2), new IntVector2(1, 1), new IntVector2(2, 2)); var pass2 = new Pass(null, null, new IntVector2(1, 1), new IntVector2(2, 2), new IntVector2(1, 1)); bonusItems[1, 1] = pass1; board.FillBlockForTesting(new IntVector2(1, 1), items, bonusItems); bonusItems[1, 1] = null; bonusItems[2, 2] = pass2; board.FillBlockForTesting(new IntVector2(1, 2), items, bonusItems); var graph = new Graph(board); var cell0 = board.GetBlock(new IntVector2(1, 1)).GetCellByPosition(new IntVector2(1, 2)); var cell1 = board.GetBlock(new IntVector2(1, 1)).GetCellByPosition(new IntVector2(1, 1)); var cell2 = board.GetBlock(new IntVector2(1, 2)).GetCellByPosition(new IntVector2(2, 2)); Assert.True(graph.GetDistance(cell0, cell2) == 1); Assert.True(graph.GetDistance(cell0, cell1) == 1); }
public void TestBoardWithTwoBlocksGetUserArmies() { var board = new BlockBoardStorage(1, 2, null); var items = new BoardStorageItem[3, 3]; var bonusItems = new BoardStorageItem[3, 3]; var playerType = PlayerType.FIRST; var item1 = new ArmyStorageItem(new UserArmy(playerType, null), null); var item2 = new ArmyStorageItem(new UserArmy(playerType, null), null); var item3 = new ArmyStorageItem(new UserArmy(playerType, null), null); var item4 = new ArmyStorageItem(new UserArmy(playerType, null), null); items[1, 1] = item1; items[2, 2] = item2; board.FillBlockForTesting(new IntVector2(1, 1), items, bonusItems); items[1, 1] = item3; items[2, 2] = item4; board.FillBlockForTesting(new IntVector2(1, 2), items, bonusItems); var armies = board.FindPlayerArmies(playerType); Assert.True(armies.Count == 4); }
public void TestBoardWithTwoBlocksGetPasses() { var board = new BlockBoardStorage(1, 2, null); var items = new BoardStorageItem[3, 3]; var bonusItems = new BoardStorageItem[3, 3]; var pass1 = new Pass(null, null, new IntVector2(1, 2), new IntVector2(1, 1), new IntVector2(2, 2)); var pass2 = new Pass(null, null, new IntVector2(1, 2), new IntVector2(2, 2), new IntVector2(1, 1)); var pass3 = new Pass(null, null, new IntVector2(1, 1), new IntVector2(1, 1), new IntVector2(2, 2)); var pass4 = new Pass(null, null, new IntVector2(1, 1), new IntVector2(2, 2), new IntVector2(1, 1)); bonusItems[1, 1] = pass1; bonusItems[2, 2] = pass2; board.FillBlockForTesting(new IntVector2(1, 1), items, bonusItems); bonusItems[1, 1] = pass3; bonusItems[2, 2] = pass4; board.FillBlockForTesting(new IntVector2(1, 2), items, bonusItems); var passes = board.GetPassesAsFromToCells(); Assert.True(passes.Count() == 4); }
public void TestGetOpponentPlayerType() { var first = PlayerType.FIRST; var second = PlayerType.SECOND; Assert.True(BlockBoardStorage.GetOpponentPlayerType(first) == second); Assert.True(BlockBoardStorage.GetOpponentPlayerType(second) == first); }
public AIPlayer(UserController controller, PlayerType playerType, BlockBoardStorage boardStorage, BoardManager boardManager, InputListener inputListener) { this.playerType = playerType; this.controller = controller; this.boardManager = boardManager; this.inputListener = inputListener; this.boardStorage = boardStorage; }
public void TestGetDistanceInNotConnectedGraph() { var board = new BlockBoardStorage(1, 2, null); var items = new BoardStorageItem[3, 3]; var bonusItems = new BoardStorageItem[3, 3]; board.FillBlockForTesting(new IntVector2(1, 1), items, bonusItems); board.FillBlockForTesting(new IntVector2(1, 2), items, bonusItems); var graph = new Graph(board); var cell0 = board.GetBlock(new IntVector2(1, 1)).GetCellByPosition(new IntVector2(1, 2)); var cell1 = board.GetBlock(new IntVector2(1, 1)).GetCellByPosition(new IntVector2(1, 1)); var cell2 = board.GetBlock(new IntVector2(1, 2)).GetCellByPosition(new IntVector2(2, 2)); Assert.True(graph.GetDistance(cell0, cell2) > 2); Assert.True(graph.GetDistance(cell0, cell1) == 1); }
public void TestGetUserArmiesWithoutArmies() { var board = new BlockBoardStorage(1, 1, null); var items = new BoardStorageItem[3, 3]; var bonusItems = new BoardStorageItem[3, 3]; var item1 = new ArmyStorageItem(new UserArmy(PlayerType.FIRST, null), null); var item2 = new ArmyStorageItem(new UserArmy(PlayerType.FIRST, null), null); items[1, 1] = item1; items[2, 2] = item2; board.FillBlockForTesting(new IntVector2(1, 1), items, bonusItems); var foundItems = board.FindPlayerArmies(PlayerType.SECOND); Assert.True(foundItems.Count == 0); }
public BoardManager(BlockBoardStorage boardStorage, IntVector2 firstStartBlock, IntVector2 secondStartBlock) { this.boardStorage = boardStorage; firstPlayerBlockPosition = firstStartBlock; secondPlayerBlockPosition = secondStartBlock; }