예제 #1
0
 public Arrow(Room room)
 {
     role = "Arrow";
     this.room = room;
 }
예제 #2
0
 public void setRoom(Room room)
 {
     this.room = room;
 }
예제 #3
0
 public void roomReset(Room back)
 {
     Room temp = this.back;
     this.back = back;
     left = temp;
 }
예제 #4
0
 public void setBack(Room back)
 {
     this.back = back;
 }
예제 #5
0
 public void setRight(Room right)
 {
     this.right = right;
 }
예제 #6
0
 public void setLeft(Room left)
 {
     this.left = left;
 }
예제 #7
0
 public Agent(Room room)
 {
     role = "";
     this.room = room;
 }
예제 #8
0
 private Room getNextRoom(int roomNum, Room currRoom)
 {
     // Check if the next room is to the left or to the right
     if (currRoom.getLeft().getRoomNum() == roomNum)
     {
         return currRoom.getLeft();
     }
     else if (currRoom.getRight().getRoomNum() == roomNum)
     {
         return currRoom.getRight();
     }
     else
     {
         return null;
     }
 }
예제 #9
0
        public String shoot(int roomNum)
        {
            Random random = new Random();
            int nextRoomNum = 0;
            Room[] rooms = new Room[5];
            Room nextRoom = getNextRoom(roomNum, JamesBond.getRoom());

            if (nextRoom == null)
            {
                return "Cannot Shoot";
            }
            maxArrows--;
            rooms[0] = nextRoom;

            int i = 1;
            while (i < maxRoomsToShoot)
            {
                nextRoomNum = random.Next(1, 2);
                if (nextRoomNum == 1)
                {
                    nextRoomNum = nextRoom.getLeft().getRoomNum();
                }
                else
                {
                    nextRoomNum = nextRoom.getRight().getRoomNum();
                }
                nextRoom = getNextRoom(nextRoomNum, rooms[i-1]);
                rooms[i] = nextRoom;
                i++;
            }

            for (int j = 0; j < rooms.Length; j++)
            {
                Creature creature = rooms[j].getCreature();

                if (creature != null)
                {
                    String role = creature.getRole();
                    if (role.Equals("Wumpus"))
                    {
                        return "win";
                    }
                }
            }
            if (maxArrows == 0)
            {
                return "lose";
            }
            return "Nothing happened";
        }