public void AvaliableMove_Rock() { // setup environment for test GameController.StartGame (); List<Piece> PL1 = GameController.Players [0].PieceList; List<Piece> PL2 = GameController.Players [1].PieceList; for (int i = 0; i < PL1.Count; i++) { PL1 [i].isDead = true; PL1 [i].X = -1; PL1 [i].Y = -1; PL2 [i].isDead = true; PL2 [i].X = -1; PL2 [i].Y = -1; } UtilityFunctions.CheckAvaiMoveOfAllPieces (); //test piece Piece testRock = new Rock (2, 2, true); testRock.AvailableMoves (); Assert.IsTrue (hasContain (testRock.AvaliableMove_X, testRock.AvaliableMove_Y, 0, 2)); Assert.IsTrue (hasContain (testRock.AvaliableMove_X, testRock.AvaliableMove_Y, 1, 2)); Assert.IsTrue (hasContain (testRock.AvaliableMove_X, testRock.AvaliableMove_Y, 3, 2)); Assert.IsTrue (hasContain (testRock.AvaliableMove_X, testRock.AvaliableMove_Y, 4, 2)); Assert.IsTrue (hasContain (testRock.AvaliableMove_X, testRock.AvaliableMove_Y, 2, 0)); Assert.IsTrue (hasContain (testRock.AvaliableMove_X, testRock.AvaliableMove_Y, 2, 1)); Assert.IsTrue (hasContain (testRock.AvaliableMove_X, testRock.AvaliableMove_Y, 2, 3)); Assert.IsTrue (hasContain (testRock.AvaliableMove_X, testRock.AvaliableMove_Y, 2, 4)); Piece testRock2 = new Rock (0, 7, false); testRock2.AvailableMoves (); Assert.IsTrue (hasContain (testRock2.AvaliableMove_X, testRock2.AvaliableMove_Y, 0, 0)); Assert.IsTrue (hasContain (testRock2.AvaliableMove_X, testRock2.AvaliableMove_Y, 0, 1)); Assert.IsTrue (hasContain (testRock2.AvaliableMove_X, testRock2.AvaliableMove_Y, 0, 2)); Assert.IsTrue (hasContain (testRock2.AvaliableMove_X, testRock2.AvaliableMove_Y, 0, 3)); Assert.IsTrue (hasContain (testRock2.AvaliableMove_X, testRock2.AvaliableMove_Y, 0, 4)); Assert.IsTrue (hasContain (testRock2.AvaliableMove_X, testRock2.AvaliableMove_Y, 0, 5)); Assert.IsTrue (hasContain (testRock2.AvaliableMove_X, testRock2.AvaliableMove_Y, 0, 6)); Assert.IsTrue (hasContain (testRock2.AvaliableMove_X, testRock2.AvaliableMove_Y, 1, 7)); Assert.IsTrue (hasContain (testRock2.AvaliableMove_X, testRock2.AvaliableMove_Y, 2, 7)); Assert.IsTrue (hasContain (testRock2.AvaliableMove_X, testRock2.AvaliableMove_Y, 3, 7)); Assert.IsTrue (hasContain (testRock2.AvaliableMove_X, testRock2.AvaliableMove_Y, 4, 7)); Assert.IsTrue (hasContain (testRock2.AvaliableMove_X, testRock2.AvaliableMove_Y, 5, 7)); Assert.IsTrue (hasContain (testRock2.AvaliableMove_X, testRock2.AvaliableMove_Y, 6, 7)); Assert.IsTrue (hasContain (testRock2.AvaliableMove_X, testRock2.AvaliableMove_Y, 7, 7)); }
public void Attack_Rock() { // setup environment for test GameController.StartGame (); List<Piece> PL1 = GameController.Players [0].PieceList; List<Piece> PL2 = GameController.Players [1].PieceList; for (int i = 0; i < PL1.Count; i++) { PL1 [i].isDead = true; PL1 [i].X = -1; PL1 [i].Y = -1; PL2 [i].isDead = true; PL2 [i].X = -1; PL2 [i].Y = -1; } UtilityFunctions.CheckAvaiMoveOfAllPieces (); //test piece Piece testRock = new Rock (2, 2, true); Piece testPawn = null; Piece testPawn2 = null; //get a pwan from write player for test attack foreach (Piece p in PL1) { if (p.type == PieceType.Pawn) { testPawn = p; break; } } testPawn.isDead = false; testPawn.X = 2; testPawn.Y = 4; testRock.AvailableMoves (); testRock.Move (2, 4); Assert.AreEqual (true, testPawn.isDead); //get a pwan from black player for test attack foreach (Piece p in PL2) { if (p.type == PieceType.Pawn) { testPawn2 = p; break; } } testPawn2.isDead = false; testPawn2.X = 1; testPawn2.Y = 4; testRock.AvailableMoves (); testRock.Move (1, 4); Assert.AreEqual (false, testPawn2.isDead); }