예제 #1
0
        override public void displayRoom(Room room)
        {
            fShotsFired = 0;

            Player player = fEngine.getCurrentPlayer();

            String str = fEngine.getAdjacentMonsterDescription(room);

            str += room.getAdjacentMonsterDescription();
            str += room.getAdjacentPlayerDescription();
            str  = str + room.getDescription();
            str += "The room contains:\n";
            String content = room.getContentDescription();

            content += fEngine.getMonsterContentDescription(room);
            if (content.Length == 0)
            {
                content = "Nothing";
            }
            str += content;

            //		str = str + "\n" + "You are in cavern " + room.getRoomNumber();
            System.Console.WriteLine(str);
            System.Console.WriteLine("What do you wish to do?");
            if (player.canMove())
            {
                System.Console.WriteLine("1   Move");
            }
            if (fEngine.hasAdjacentMonster(room) && player.canShoot())
            {
                System.Console.WriteLine("2   Shoot");
            }
            if (room.hasTakeableContent() && player.needsContent(room))
            {
                System.Console.WriteLine("3   Take");
            }
            if (room.hasDoor())
            {
                if (!room.isDoorLocked())
                {
                    System.Console.WriteLine("4   Open/close door");
                }
                else if (player.hasKey())
                {
                    System.Console.WriteLine("4   Unlock/lock door");
                }
            }
            System.Console.WriteLine("5   Inventory");
            if (fEngine.hasAdjacentMonster(room) && player.hasChargedStaff())
            {
                System.Console.WriteLine("6   Cast Bolt");
            }
            if (fEngine.hasMonster(room) && player.canAttack())
            {
                System.Console.WriteLine("7   Fight");
            }
            if (fEngine.hasMonster(room) && player.hasChargedStaff())
            {
                System.Console.WriteLine("8   Cast Fireball");
            }
            System.Console.WriteLine("9   Wait");
            System.Console.WriteLine("10   Map");

            while (true)
            {
                for (int i = Player.kNumCommands - 1; i > 0; --i)
                {
                    player.fCommands[i] = player.fCommands[i - 1];
                }
                player.fCommands[0] = "";

                int no = this.readNumber();
                if (no == 1)
                {
                    player.fCommands[0] = "Move";
                    fEngine.doCommandMove();
                    break;
                }
                if (no == 2)
                {
                    fEngine.doCommandShootArrow();
                    break;
                }
                if (no == 3)
                {
                    fEngine.doCommandTake();
                    break;
                }
                if (no == 4)
                {
                    fEngine.doCommandDoor(true);
                    break;
                }
                if (no == 5)
                {
                    this.displayInventory();
                    break;
                }
                if (no == 6)
                {
                    fEngine.doCommandCastLightningBolt();
                    break;
                }
                if (no == 7)
                {
                    fEngine.doCommandFight();
                    break;
                }
                if (no == 8)
                {
                    fEngine.doCommandCastFireball();
                    break;
                }
                if (no == 9)
                {
                    fEngine.processNextPlayer();
                    break;
                }
                if (no == 10)
                {
                    this.displayMap();
                    break;
                }
            }
        }