Exemple #1
0
 public Piece(piecesTypes name,Player pl)
 {
     _name = name;
     _player = pl;
     switch(name)
     {
         case piecesTypes.Marshal:
         case piecesTypes.General:
         case piecesTypes.Colonel:
         case piecesTypes.Major:
         case piecesTypes.Captain:
         case piecesTypes.Lieutenant:
         case piecesTypes.Sergeant:
         case piecesTypes.Miner:
         case piecesTypes.Spy:
             _canRun = false;
             _canMove = true;
             break;
         case piecesTypes.Scout:
             _canMove = true;
             _canRun = true;
             break;
         case piecesTypes.Bomb:
         case piecesTypes.Flag:
             _canMove = false;
             _canRun = false;
             break;
         default: break;
     }
 }
Exemple #2
0
        static void Main(string[] args)
        {
            Player p1 = new Player("David", SpaceType.Player1, PlayerColor.Red);
            Player p2 = new Player("Paul", SpaceType.Player2, PlayerColor.Blue);
            Game plop = new Game(p1,p2);

            Position pos1 = new Position();
            pos1.row = 3;
            pos1.col = 4;

            Position pos2 = new Position();
            pos2.row = 6;
            pos2.col = 4;

            plop.setPieceOnGrid(plop.player2Pieces[2], pos1);
            plop.setPieceOnGrid(plop.player1Pieces[0], pos2);

            plop.start();

            plop.initialGrid.displayGrid();

            for (int i = 1; i <8;i++ )
            {
                Position nextPos = new Position();
                nextPos.row = pos1.row+1;
                nextPos.col = pos1.col;
                switch (plop.movePiece(pos1, nextPos))
                {
                    case 1: Console.WriteLine("Piece MOVED !");
                        break;
                    case 10: Console.WriteLine("WIN !!!");
                        break;
                    case 20: Console.WriteLine("TIE !");
                        break;
                    case 30: Console.WriteLine("LOST !!!");
                        break;
                    case 50: Console.WriteLine("You found the flag !");
                        break;
                    default: Console.WriteLine("Move not allowed !");
                        break;
                }
                pos1.row++;
                plop.initialGrid.displayGrid();
            }
            Console.ReadLine();
        }
Exemple #3
0
 public void GetPlayerName()
 {
     string name = "TestName";
     var player = new Player(name);
     Assert.AreEqual(player.Name, name);
 }
Exemple #4
0
 public void GetDefaultPlayerName()
 {
     Player player = new Player();
     Assert.AreEqual(player.Name, "Name");
 }
Exemple #5
0
        private void initPlayerPieces(Player p1, Player p2)
        {
            player1Pieces = new List<Piece>();
            player2Pieces = new List<Piece>();

            player1Pieces.Add(new Piece(piecesTypes.Marshal,p1));
            player1Pieces.Add(new Piece(piecesTypes.General, p1));
            player1Pieces.Add(new Piece(piecesTypes.Spy, p1));
            player1Pieces.Add(new Piece(piecesTypes.Flag, p1));
            for (int i = 0; i < 2; i++) player1Pieces.Add(new Piece(piecesTypes.Colonel, p1));
            for (int i = 0; i < 3; i++) player1Pieces.Add(new Piece(piecesTypes.Major, p1));
            for (int i = 0; i < 4; i++) player1Pieces.Add(new Piece(piecesTypes.Captain, p1));
            for (int i = 0; i < 4; i++) player1Pieces.Add(new Piece(piecesTypes.Lieutenant, p1));
            for (int i = 0; i < 4; i++) player1Pieces.Add(new Piece(piecesTypes.Sergeant, p1));
            for (int i = 0; i < 5; i++) player1Pieces.Add(new Piece(piecesTypes.Miner, p1));
            for (int i = 0; i < 8; i++) player1Pieces.Add(new Piece(piecesTypes.Scout, p1));
            for (int i = 0; i < 6; i++) player1Pieces.Add(new Piece(piecesTypes.Bomb, p1));

            player2Pieces.Add(new Piece(piecesTypes.Marshal, p2));
            player2Pieces.Add(new Piece(piecesTypes.General, p2));
            player2Pieces.Add(new Piece(piecesTypes.Spy, p2));
            player2Pieces.Add(new Piece(piecesTypes.Flag, p2));
            for (int i = 0; i < 2; i++) player2Pieces.Add(new Piece(piecesTypes.Colonel, p2));
            for (int i = 0; i < 3; i++) player2Pieces.Add(new Piece(piecesTypes.Major, p2));
            for (int i = 0; i < 4; i++) player2Pieces.Add(new Piece(piecesTypes.Captain, p2));
            for (int i = 0; i < 4; i++) player2Pieces.Add(new Piece(piecesTypes.Lieutenant, p2));
            for (int i = 0; i < 4; i++) player2Pieces.Add(new Piece(piecesTypes.Sergeant, p2));
            for (int i = 0; i < 5; i++) player2Pieces.Add(new Piece(piecesTypes.Miner, p2));
            for (int i = 0; i < 8; i++) player2Pieces.Add(new Piece(piecesTypes.Scout, p2));
            for (int i = 0; i < 6; i++) player2Pieces.Add(new Piece(piecesTypes.Bomb, p2));
        }
Exemple #6
0
 public Game(Player p1, Player p2)
 {
     initPlayerPieces(p1,p2);
     initGrid();
 }