private MoveResult CreateSwapResult(SwapData swapData) { var movesData = new MoveElementData[] { new MoveElementData(swapData.First, swapData.Second), new MoveElementData(swapData.Second, swapData.First), }; return(new MoveResult(movesData)); }
public void BoardApplyGravityCorrectlyAfterRemovingBlocksVertically() { // given: const int minimalMatchCount = 3; var types = new List <int[]> { new int[] { 2, 2, }, new int[] { 3, 1, }, new int[] { 1, 2, }, new int[] { 1, 0, }, new int[] { 1, 2, }, new int[] { 4, 2, }, }; var expectedMove1 = new MoveElementData(new Coordinate(4, 0), new Coordinate(1, 0)); var expectedMove2 = new MoveElementData(new Coordinate(5, 0), new Coordinate(2, 0)); var sut = CreateBoardWithElements(types); var matches = sut.GetMatches(minimalMatchCount); // when: var movedElements = sut.RemoveBlocks(matches); // then: // -1 2 // -1 1 // -1 2 // 2 0 // 3 2 // 4 2 Assert.AreEqual(4, sut[0, 0].Type); Assert.AreEqual(3, sut[1, 0].Type); Assert.AreEqual(2, sut[2, 0].Type); Assert.AreEqual(BlockData.invalidColorId, sut[3, 0].Type); Assert.AreEqual(BlockData.invalidColorId, sut[4, 0].Type); Assert.AreEqual(BlockData.invalidColorId, sut[5, 0].Type); Assert.AreEqual(2, sut[0, 1].Type); Assert.AreEqual(2, sut[1, 1].Type); Assert.AreEqual(0, sut[2, 1].Type); Assert.AreEqual(2, sut[3, 1].Type); Assert.AreEqual(1, sut[4, 1].Type); Assert.AreEqual(2, sut[5, 1].Type); Assert.AreEqual(2, movedElements.Length); Assert.AreEqual(movedElements[0], expectedMove1); Assert.AreEqual(movedElements[1], expectedMove2); }
public void BoardApplyGravityCorrectlyAfterRemovingBlocksHorizontally() { // given: const int rowsCount = 3; const int columnsCount = 2; const int matchCount = 2; // 0 2 // 2 0 // 1 1 var sut = new Board(rowsCount, columnsCount); sut[0, 0] = new BlockData(1); sut[0, 1] = new BlockData(1); sut[1, 0] = new BlockData(2); sut[1, 1] = new BlockData(0); sut[2, 0] = new BlockData(0); sut[2, 1] = new BlockData(2); var expectedMove1 = new MoveElementData(new Coordinate(1, 0), new Coordinate(0, 0)); var expectedMove2 = new MoveElementData(new Coordinate(1, 1), new Coordinate(0, 1)); var expectedMove3 = new MoveElementData(new Coordinate(2, 0), new Coordinate(1, 0)); var expectedMove4 = new MoveElementData(new Coordinate(2, 1), new Coordinate(1, 1)); var matches = sut.GetMatches(matchCount); // when: var movedElements = sut.RemoveBlocks(matches); // then: // -1 -1 // 0 2 // 2 0 Assert.AreEqual(2, sut[0, 0].Type); Assert.AreEqual(0, sut[0, 1].Type); Assert.AreEqual(0, sut[1, 0].Type); Assert.AreEqual(2, sut[1, 1].Type); Assert.AreEqual(BlockData.invalidColorId, sut[2, 0].Type); Assert.AreEqual(BlockData.invalidColorId, sut[2, 1].Type); Assert.AreEqual(4, movedElements.Length); Assert.AreEqual(movedElements[0], expectedMove1); Assert.AreEqual(movedElements[1], expectedMove2); Assert.AreEqual(movedElements[2], expectedMove3); Assert.AreEqual(movedElements[3], expectedMove4); }
public void AddCastleElementList(int villageID, byte[,] elementList, long[] troopsToDelete, MoveElementData[] troopsToMove) { this.AddCastleElement(villageID, 0, 0, 0, -1L, false, false, elementList, troopsToDelete, troopsToMove); }
public void AddCastleElement(int villageID, int elementType, int x, int y, long clientElementNumber, bool reinforcement, bool vassalReinforcement, byte[,] elementList, long[] troopsToDelete, MoveElementData[] troopsToMove) { if (this.AddCastleElement_Callback == null) { this.AddCastleElement_Callback = new AsyncCallback(this.OurRemoteAsyncCallBack_AddCastleElement); } RemoteAsyncDelegate_AddCastleElement element = new RemoteAsyncDelegate_AddCastleElement(this.service.AddCastleElement); this.registerRPCcall(element.BeginInvoke(this.UserID, this.SessionID, villageID, elementType, x, y, clientElementNumber, -1, -1, reinforcement, vassalReinforcement, elementList, troopsToDelete, troopsToMove, this.AddCastleElement_Callback, null), typeof(AddCastleElement_ReturnType)); }