public void Move(Cell source, Cell destination) { if (!source.IsOccupied() || !_gameMover.GetValidMoves(source).Contains(destination)) return; if (destination.GetState() == Cell.State.Empty) destination.SetPiece(source.GetPiece()); else { int winner = Attack((int) source.GetPieceRank(), (int) destination.GetPieceRank()); if (winner == 1) destination.SetPiece(source.GetPiece()); if (winner == 0) destination.RemovePiece(); } source.RemovePiece(); }
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()); }
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()); }
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); }
public void CellCanGetPieceColor() { var cell = new Cell("Test"); var piece = new Piece("Blue", Army.Rank.Bomb); cell.SetPiece(piece); Assert.AreEqual("Blue", cell.GetPieceColor()); }