public override bool Validate(IMovementContext context) { var tower = new RookPiece(); var bishop = new BishopPiece(); return(tower.Validate(context) && bishop.Validate(context)); }
public void TestBishopMoveFromInsideTheBoard() { var pos = new Position(2, 5); var bishop = new BishopPiece(1, pos); var moves = new HashSet <Position>(bishop.ValidMovesFor(pos)); Assert.IsNotNull(moves); Assert.AreEqual(9, moves.Count); var possibles = new[] { new Position(1, 4), new Position(3, 6), new Position(4, 7), new Position(5, 8), new Position(1, 6), new Position(3, 4), new Position(4, 3), new Position(5, 2), new Position(6, 1) }; foreach (var possible in possibles) { Assert.IsTrue(moves.Contains(possible)); } }
public void TestBishopPieceMoveFails() { //Arange var piece = new ChessPiece(); piece.type = ChessPieceType.Bishop; piece.from = "g1"; piece.to = "f5"; var logic = new BishopPiece(_logger); //Act var response = logic.move(piece); //Assert Assert.False(response); }
public void TestBishopMoveFromCorner() { var pos = new Position(1, 1); var bishop = new BishopPiece(1, pos); var moves = new HashSet <Position>(bishop.ValidMovesFor(pos)); Assert.IsNotNull(moves); Assert.AreEqual(7, moves.Count); var possibles = new[] { new Position(2, 2), new Position(3, 3), new Position(4, 4), new Position(5, 5), new Position(6, 6), new Position(7, 7), new Position(8, 8) }; foreach (var possible in possibles) { Assert.IsTrue(moves.Contains(possible)); } }
// Use this for initialization void Start() { firstClickX = -1; firstClickZ = -1; playerTurn = true; //TODO for other person place switch; //TODO: also switch spaces of queens for other person gameSpaces = new GameObject[][] { new GameObject[GAMESIZE], new GameObject[GAMESIZE], new GameObject[GAMESIZE], new GameObject[GAMESIZE], new GameObject[GAMESIZE], new GameObject[GAMESIZE], new GameObject[GAMESIZE], new GameObject[GAMESIZE] }; gamePieces = new Piece[][] { new Piece[GAMESIZE], new Piece[GAMESIZE], new Piece[GAMESIZE], new Piece[GAMESIZE], new Piece[GAMESIZE], new Piece[GAMESIZE], new Piece[GAMESIZE], new Piece[GAMESIZE] }; bool odd = true; for (int z = 0; z < GAMESIZE; z++) { for (int x = 0; x < GAMESIZE; x++) { if (z < 2) { //TODO: Change color depending on team. GameObject tempObject; string tempString = "Piece" + x + "," + z; Piece tempPiece; if (z == 1) { tempObject = Instantiate(pawn, new Vector3(x, 0, z), Quaternion.identity) as GameObject; tempPiece = new PawnPiece(tempString, tempObject, true); } else if (x == 0 || x == GAMESIZE - 1) { tempObject = Instantiate(rook, new Vector3(x, 0, z), Quaternion.identity) as GameObject; tempPiece = new RookPiece(tempString, tempObject, true); } else if (x == 1 || x == GAMESIZE - 2) { tempObject = Instantiate(knight, new Vector3(x, 0, z), Quaternion.identity) as GameObject; tempPiece = new KnightPiece(tempString, tempObject, true); } else if (x == 2 || x == GAMESIZE - 3) { tempObject = Instantiate(bishop, new Vector3(x, 0, z), Quaternion.identity) as GameObject; tempPiece = new BishopPiece(tempString, tempObject, true); } else if (x == 3) { tempObject = Instantiate(queen, new Vector3(x, 0, z), Quaternion.identity) as GameObject; tempPiece = new QueenPiece(tempString, tempObject, true); } else if (x == 4) { tempObject = Instantiate(king, new Vector3(x, 0, z), Quaternion.identity) as GameObject; tempPiece = new KingPiece(tempString, tempObject, true); } else { tempObject = Instantiate(pawn, new Vector3(x, 0, z), Quaternion.identity) as GameObject; tempPiece = new PawnPiece(tempString, tempObject, true); } Renderer rend = tempPiece.getGameObject().GetComponent <Renderer>(); rend.material.color = teamColor; gamePieces[x][z] = tempPiece; } else if (z >= GAMESIZE - 2) { GameObject tempObject; string tempString = "Piece" + x + "," + z; Piece tempPiece; if (z == GAMESIZE - 2) { tempObject = Instantiate(pawn, new Vector3(x, 0, z), Quaternion.identity) as GameObject; tempPiece = new PawnPiece(tempString, tempObject, false); } else if (x == 0 || x == GAMESIZE - 1) { tempObject = Instantiate(rook, new Vector3(x, 0, z), Quaternion.identity) as GameObject; tempPiece = new RookPiece(tempString, tempObject, false); } else if (x == 1 || x == GAMESIZE - 2) { tempObject = Instantiate(knight, new Vector3(x, 0, z), Quaternion.identity) as GameObject; tempPiece = new KnightPiece(tempString, tempObject, false); } else if (x == 2 || x == GAMESIZE - 3) { tempObject = Instantiate(bishop, new Vector3(x, 0, z), Quaternion.identity) as GameObject; tempPiece = new BishopPiece(tempString, tempObject, false); } else if (x == 3) { tempObject = Instantiate(queen, new Vector3(x, 0, z), Quaternion.identity) as GameObject; tempPiece = new QueenPiece(tempString, tempObject, false); } else if (x == 4) { tempObject = Instantiate(king, new Vector3(x, 0, z), Quaternion.identity) as GameObject; tempPiece = new KingPiece(tempString, tempObject, false); } else { tempObject = Instantiate(pawn, new Vector3(x, 0, z), Quaternion.identity) as GameObject; tempPiece = new PawnPiece(tempString, tempObject, false); } gamePieces[x][z] = tempPiece; } if (odd) { gameSpaces[x][z] = Instantiate(spaces, new Vector3(x, 0, z), Quaternion.identity) as GameObject; gameSpaces[x][z].GetComponent <Renderer>().material.color = teamColor; } else { gameSpaces[x][z] = Instantiate(spaces, new Vector3(x, 0, z), Quaternion.identity) as GameObject; gameSpaces[x][z].GetComponent <Renderer>().material.color = Color.white; } gameSpaces[x][z].transform.name = "Space" + x + "," + z; odd = !odd; } odd = !odd; } updateFogOfWarBoard(); }