コード例 #1
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());
 }
コード例 #2
0
ファイル: Game.cs プロジェクト: AHaleIII/stratego
        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();
        }