public void TestQueenSetupMethod() { Position pos = new Position(1, 1); var queen = new QueenPiece(3, pos); queen.Setup(); Assert.AreEqual(queen.StartPosition, pos); }
public void TestQueenPlayMethod() { Position pos = new Position(1, 1); Dictionary <string, Position> posDict = new Dictionary <string, Position>(); var queen = new QueenPiece(3, pos); var currPos = queen.Play(posDict); Assert.AreEqual(queen.StartPosition, pos); Assert.AreNotEqual(queen.StartPosition, currPos); }
public void replacePawnForQueen(Piece tempPiece, int xPos, int zPos) { GameObject tempGO = tempPiece.getGameObject(); GameObject tempObject = Instantiate(queen, new Vector3(xPos, 0, zPos), Quaternion.identity) as GameObject; Piece tempQueen = new QueenPiece(tempPiece.name, tempObject, true); string queenReplaceString = tempPiece.name.Replace("Piece", ""); string[] queenTempString = queenReplaceString.Split(','); int queenX = System.Convert.ToInt32(queenTempString [0]); int queenZ = System.Convert.ToInt32(queenTempString [1]); Renderer rend = tempQueen.getGameObject().GetComponent <Renderer>(); rend.material.color = teamColor; gamePieces[queenX][queenZ] = tempQueen; tempGO.transform.Translate(new Vector3(-GAMESIZE, 0, -GAMESIZE)); tempGO.SetActive(false); }
public void TestQueenpMoveFromInsideTheBoard() { var pos = new Position(2, 3); var queen = new QueenPiece(1, pos); var moves = new HashSet <Position>(queen.ValidMovesFor(pos)); Assert.IsNotNull(moves); Assert.AreEqual(23, moves.Count); var possibles = new[] { new Position(7, 3), new Position(6, 3), new Position(5, 3), new Position(4, 3), new Position(3, 3), new Position(8, 3), new Position(1, 3), new Position(2, 7), new Position(2, 6), new Position(2, 5), new Position(2, 4), new Position(2, 8), new Position(2, 2), new Position(2, 1), new Position(1, 2), new Position(1, 4), new Position(3, 4), new Position(4, 5), new Position(5, 6), new Position(6, 7), new Position(7, 8), new Position(3, 2), new Position(4, 1) }; foreach (var possible in possibles) { Assert.IsTrue(moves.Contains(possible)); } }
public void TestQueenpMoveFromCorner() { var pos = new Position(8, 8); var queen = new QueenPiece(1, pos); var moves = new HashSet <Position>(queen.ValidMovesFor(pos)); Assert.IsNotNull(moves); Assert.AreEqual(21, moves.Count); var possibles = new[] { new Position(7, 8), new Position(6, 8), new Position(5, 8), new Position(4, 8), new Position(3, 8), new Position(2, 8), new Position(1, 8), new Position(8, 7), new Position(8, 6), new Position(8, 5), new Position(8, 4), new Position(8, 3), new Position(8, 2), new Position(8, 1), new Position(7, 7), new Position(6, 6), new Position(5, 5), new Position(4, 4), new Position(3, 3), new Position(2, 2), new Position(1, 1) }; 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(); }