Example #1
0
 public void BoardCanSetCellPiece()
 {
     var piece = new Piece("Blue", Army.Rank.General);
     Cell cellI9 = board.GetCell("I9");
     board.SetCellPiece("I9", piece);
     Assert.AreEqual(piece, board.GetCellPiece("I9"));
 }
Example #2
0
 public int GetPieceMoveRule(Piece piece)
 {
     if (_gametypeName == "Classic")
         return GetClassicPieceMoveRule(piece);
     else
         return 0;
 }
Example #3
0
 public void SetPiece(Piece piece)
 {
     if (_currentState == State.Invalid)
         throw new CannotSetOrRemovePieceToInvalidCellException();
     this._currentState = State.Occupied;
     this._piece = piece;
 }
Example #4
0
 public void Initialize()
 {
     redPiece = new Piece("Red");
     bluePiece = new Piece("Blue");
     redArmy = new Army("Red");
     blueArmy = new Army("Blue");
 }
Example #5
0
 private int GetClassicPieceMoveRule(Piece piece)
 {
     if (piece.GetRank() == Army.Rank.Scout)
         return -1;
     if (piece.GetRank() == Army.Rank.Bomb || piece.GetRank() == Army.Rank.Flag)
         return 0;
     return 1;
 }
Example #6
0
 public void CanRemoveCellPiece()
 {
     var cell = new Cell();
     var piece = new Piece("Orange", Army.Rank.Scout);
     Assert.AreEqual(Cell.State.Empty, cell.GetState());
     cell.SetPiece(piece);
     Assert.AreEqual(Cell.State.Occupied, cell.GetState());
     cell.RemovePiece();
     Assert.AreEqual(Cell.State.Empty, cell.GetState());
 }
Example #7
0
 public void CanSetCellPiece()
 {
     var cell = new Cell("Test");
     var piece = new Piece("Green", Army.Rank.Major);
     Assert.AreEqual(Cell.State.Empty, cell.GetState());
     cell.SetPiece(piece);
     Assert.AreEqual(Cell.State.Occupied, cell.GetState());
     Assert.AreEqual(piece, cell.GetPiece());
     Assert.AreEqual("Green", cell.GetPiece().GetColor());
 }
Example #8
0
 public void BoardCanGetCellPieceRank()
 {
     var i1Cell = board.GetCell("I1");
     var piece = new Piece("Silver", Army.Rank.Spy);
     i1Cell.SetPiece(piece);
     Assert.AreEqual(Army.Rank.Spy, board.GetCellPieceRank("I1"));
 }
Example #9
0
 public void BoardCanGetCellPieceColor()
 {
     var d5Cell = board.GetCell("D8");
     var piece = new Piece("Magenta", Army.Rank.Flag);
     d5Cell.SetPiece(piece);
     Assert.AreEqual("Magenta", board.GetCellPieceColor("D8"));
 }
Example #10
0
 public void BoardCanGetCellPiece()
 {
     var e9Cell = board.GetCell("E9");
     var piece = new Piece("Purple", Army.Rank.Flag);
     e9Cell.SetPiece(piece);
     Assert.AreEqual(piece, board.GetCellPiece("E9"));
 }
Example #11
0
 public void CellCanGetPieceRank()
 {
     var cell = new Cell("Test");
     var piece = new Piece("Blue", Army.Rank.Bomb);
     cell.SetPiece(piece);
     Army.Rank? cellPieceRank = cell.GetPieceRank();
     Assert.AreEqual(Army.Rank.Bomb, cellPieceRank);
 }
Example #12
0
 public void CellCanGetPieceColor()
 {
     var cell = new Cell("Test");
     var piece = new Piece("Blue", Army.Rank.Bomb);
     cell.SetPiece(piece);
     Assert.AreEqual("Blue", cell.GetPieceColor());
 }
Example #13
0
 public void GetAdjacentCellCurrentPieceOrNameForC9()
 {
     var d9Piece = new Piece("Purple", Army.Rank.Colonel);
     board.GetCell("D9").SetPiece(d9Piece);
     Assert.AreEqual(d9Piece, board.GetCell("C9").GetAdjacent(Cell.Touching.Right).GetPiece());
     Assert.AreEqual("B9", board.GetCell("C9").GetAdjacent(Cell.Touching.Left).Name);
 }
Example #14
0
 public void SetCellPiece(string c, Piece piece)
 {
     _cells[c].SetPiece(piece);
 }
Example #15
0
 public void GetPieceRank()
 {
     var scoutPiece = new Piece("Red", Army.Rank.Scout);
     Assert.AreEqual(Army.Rank.Scout, scoutPiece.GetRank());
 }
Example #16
0
 //method used by players to set up the game
 //they can only set up their pieces in spaces defined in initGrid().
 public bool setPieceOnGrid(Piece p,Position pos)
 {
     if (p.piecePlayer.playerType != initialGrid.mainGrid[pos.row,pos.col]._type) return false;
     initialGrid.mainGrid[pos.row, pos.col]._piece = p;
     return true;
 }