Beispiel #1
0
 public bool hasStink()
 {
     for (int iPassage = 0; iPassage <= this.getNumPassages(); iPassage++)
     {
         Room room = null;
         if (iPassage == 0)
         {
             if (!this.hasDoor() || !this.isDoorOpen())
             {
                 continue;
             }
             room = this.fDoor;
         }
         else
         {
             room = this.getPassage(iPassage);
         }
         Utility.Assert(room != null, "Room.hasStink - room != null (2)");
         if (room.hasMuck())
         {
             //				str += "It stinks of serpent-muck.\n";
             return(true);
         }
     }
     return(false);
 }
Beispiel #2
0
        public void process()
        {
            Utility.Trace("Maze.process");
            for (int iRoom = 1; iRoom <= fNumRooms; iRoom++)
            {
                Room room = this.getRoom(iRoom);
                room.process();
            }

            // Wizard
            //
            Room aRoom = fWizard;

            while (aRoom == fWizard && fWizard != null)
            {
                int no = GameEngine.rand.range(1, this.getNumRooms());
                aRoom = this.getRoom(no);
                if (aRoom.hasMuck())
                {
                    Utility.Trace("The wizard disposed of muck in cavern " + aRoom.getRoomNumber());
                    aRoom.removeMuck();
                }
                break;
            }
            fWizard = aRoom;

            Utility.Trace("Maze.process - janitor");
            // Janitor
            //
            if (fJanitor != null)
            {
                Utility.Trace("Janitor path: " + this.getJanitorPath());
                if (fJanitor.fWeb)
                {
                    Utility.Trace("The janitor is removing a web in cavern " + fJanitor.getRoomNumber());
                    if (GameEngine.rand.range(1, 2) == 1)
                    {
                        Utility.Trace("The janitor removed a web in cavern " + fJanitor.getRoomNumber());
                        fJanitor.fWeb = false;
                    }
                }
                else if (fJanitor.fPit)
                {
                    Utility.Trace("The janitor is filling in pit in cavern " + fJanitor.getRoomNumber());
                    if (GameEngine.rand.range(1, 2) == 1)
                    {
                        Utility.Trace("The janitor filled in pit in cavern " + fJanitor.getRoomNumber());
                        fJanitor.fPit = false;
                    }
                }
                else if (fJanitor.hasMuck())
                {
                    Utility.Trace("The janitor is cleaning up muck in cavern " + fJanitor.getRoomNumber());
                    if (GameEngine.rand.range(1, 3) == 1)
                    {
                        Utility.Trace("The janitor cleaned up muck in cavern " + fJanitor.getRoomNumber());
                        fJanitor.removeMuck();
                    }
                }
                else
                {
                    if (fJanitor.getRoomNumber() == fJanitorTarget.getRoomNumber())
                    {
                        while (fJanitor.getRoomNumber() == fJanitorTarget.getRoomNumber())
                        {
                            int no = GameEngine.rand.range(1, this.getNumRooms());
                            if (!this.getRoom(no).isLair())
                            {
                                no = GameEngine.rand.range(1, this.getNumRooms());
                            }
                            fJanitorTarget = this.getRoom(no);
                        }

                        // Set new target! Help adventurer if any.
                        Room target = null;
                        int  thirst = GameEngine.rand.range(0, 20);
                        for (int iPlayer = 1; iPlayer <= GameEngine.instance.fNumPlayers; iPlayer++)
                        {
                            Player player = GameEngine.instance.getPlayer(iPlayer);
                            if (player.isAlive() && !player.hasEscaped() && player.fWater <= thirst)
                            {
                                target = player.fRoom;
                                thirst = player.fWater;
                                Utility.Trace("The janitor detects a thirsty player in cavern " + player.fRoom.getRoomNumber());
                            }
                        }

                        if (target != null && target != fJanitor)
                        {
                            fJanitorTarget = target;
                            Utility.Trace("The janitor is rescuing a thirsty player in cavern " + target.getRoomNumber());
                        }
                    }

                    // take one step towards the target
                    Room[] path = GameEngine.instance.fMaze.findRoute(fJanitor, fJanitorTarget, null, Maze.USE_EVERYTHING);
                    Utility.Assert(path.Length > 0, "Maze.process - path.length > 0");
                    Utility.Trace("The janitor is moving towards " + fJanitorTarget.getRoomNumber() + " via " + path[0].getRoomNumber());
                    aRoom = path[0];

                    int num = fJanitor.getNumPassages();
                    if (fJanitor.hasDoor() && !fJanitor.isExitDoor() /* && !fJanitor.isDoorLocked() */)
                    {
                        num++;
                    }
                    Room tmp = aRoom;
                    for (int i = 0; i < num; i++)
                    {
                        if (tmp.hasMuck())
                        {
                            aRoom = tmp;
                            Utility.Trace("The janitor smells muck in cavern " + aRoom.getRoomNumber());
                            break;
                        }
                        if (tmp.fPit)
                        {
                            aRoom = tmp;
                            Utility.Trace("The janitor feels a draft from cavern " + aRoom.getRoomNumber());
                            break;
                        }
                        if (tmp.fWeb)
                        {
                            aRoom = tmp;
                            Utility.Trace("The janitor sees a web in cavern " + aRoom.getRoomNumber());
                            break;
                        }
                        if (fJanitor.isBlockedByPortcullis(tmp))
                        {
                            Utility.Trace("The janitor raises the portcullis between cavern " + fJanitor.getRoomNumber() + " and " + tmp.getRoomNumber());
                            fJanitor.openPortcullis(tmp);
                            tmp.openPortcullis(fJanitor);
                        }
                        int no = GameEngine.rand.range(1, num);
                        if (no > fJanitor.getNumPassages())
                        {
                            tmp = fJanitor.fDoor;
                        }
                        else
                        {
                            tmp = fJanitor.getPassage(no);
                        }
                    }

                    if (fJanitorUnlockedDoor != null)
                    {
                        if (!fJanitorUnlockedDoor.isDoorJammed())
                        {
                            if (fJanitorUnlockedDoor.isDoorOpen())
                            {
                                Utility.Trace("The janitor closes the door between cavern " + fJanitor.getRoomNumber() + " and " + fJanitorUnlockedDoor.getRoomNumber());
                                fJanitorUnlockedDoor.closeDoor();
                                fJanitor.closeDoor();
                            }
                            if (!fJanitorUnlockedDoor.isDoorLocked())
                            {
                                Utility.Trace("The janitor locks the door between cavern " + fJanitor.getRoomNumber() + " and " + fJanitorUnlockedDoor.getRoomNumber());
                                fJanitorUnlockedDoor.lockDoor();
                                fJanitor.lockDoor();
                            }
                        }
                        fJanitorUnlockedDoor = null;
                    }
//				if (fJanitorRaisedPortcullis != null)
//				{
//					Utility.Trace("The janitor lowers the portcullis between cavern " + fJanitor.getRoomNumber() + " and " + fJanitorRaisedPortcullis.getRoomNumber());
//					fJanitor.closePortcullis();
//					fJanitorRaisedPortcullis.closePortcullis();
//				}
                    if (fJanitor.hasDoor() && fJanitor.fDoor == aRoom)
                    {
                        if (fJanitor.isDoorLocked())
                        {
                            Utility.Trace("The janitor unlocks the door between cavern " + fJanitor.getRoomNumber() + " and " + aRoom.getRoomNumber());
                            fJanitor.unlockDoor();
                            aRoom.unlockDoor();
                            fJanitorUnlockedDoor = fJanitor;
                        }
                        if (!fJanitor.isDoorOpen())
                        {
                            Utility.Trace("The janitor opens the door between cavern " + fJanitor.getRoomNumber() + " and " + aRoom.getRoomNumber());
                            fJanitor.openDoor();
                            aRoom.openDoor();
                        }
                    }
                    if (fJanitor.isBlockedByPortcullis(aRoom))
                    {
                        Utility.Trace("The janitor raises the portcullis between cavern " + fJanitor.getRoomNumber() + " and " + aRoom.getRoomNumber());
                        fJanitor.openPortcullis(aRoom);
                        aRoom.openPortcullis(fJanitor);
                    }
                    Utility.Trace("The janitor moves to cavern " + aRoom.getRoomNumber());
                    fJanitor = aRoom;
                }
            }
            fPlayerInWeb = false;
            Utility.Trace("Maze.process - done");
        }
Beispiel #3
0
        public String getAdjacentMonsterDescription()
        {
            String str = "";

            for (int iPassage = 0; iPassage <= this.getNumPassages(); iPassage++)
            {
                Room room = null;
                if (iPassage == 0)
                {
                    if (!this.hasDoor() || !this.isDoorOpen())
                    {
                        continue;
                    }
                    room = this.fDoor;
                }
                else
                {
                    room = this.getPassage(iPassage);
                }
                Utility.Assert(room != null, "Room.getAdjacentDescription - room != null");
                if (room.fPit)
                {
                    str += "You can feel a draft.\n";
                }
            }
            for (int iPassage = 0; iPassage <= this.getNumPassages(); iPassage++)
            {
                Room room = null;
                if (iPassage == 0)
                {
                    if (!this.hasDoor() || !this.isDoorOpen())
                    {
                        continue;
                    }
                    room = this.fDoor;
                }
                else
                {
                    room = this.getPassage(iPassage);
                }
                Utility.Assert(room != null, "Room.getAdjacentDescription - room != null (2)");
                if (room.hasMuck())
                {
//				str += "It stinks of serpent-muck.\n";
                    str += "It stinks in here.\n";
                }
            }
            for (int iPassage = 0; iPassage <= this.getNumPassages(); iPassage++)
            {
                Room room = null;
                if (iPassage == 0)
                {
                    if (!this.hasDoor() || !this.isDoorOpen())
                    {
                        continue;
                    }
                    room = this.fDoor;
                }
                else
                {
                    room = this.getPassage(iPassage);
                }
                Utility.Assert(room != null, "Room.getAdjacentDescription - room != null (5)");
                if (GameEngine.instance.fMaze.isJanitor(room) && (room.hasMuck() || room.fPit))
                {
                    //				str += "Someone is cleaning in cavern " + room.getRoomNumber() + ".\n";
                    str += "Someone is cleaning nearby.\n";
                }
            }
            for (int iPassage = 0; iPassage <= this.getNumPassages(); iPassage++)
            {
                Room room = null;
                if (iPassage == 0)
                {
                    if (!this.hasDoor() || !this.isDoorOpen())
                    {
                        continue;
                    }
                    room = this.fDoor;
                }
                else
                {
                    room = this.getPassage(iPassage);
                }
                Utility.Assert(room != null, "Room.getAdjacentDescription - room != null (3)");
                if (room.fDragonSwords > 0 || room.fSerpentShields > 0 || room.fSandals > 0 || room.hasStaffs() || room.fRing != 0)
                {
                    if (Player.fKnowsItems || Player.hasExplored(room))
                    {
                        // Check if the player really wants the item
                        //
                        bool   wants  = false;
                        Player player = GameEngine.instance.getCurrentPlayer();
                        if (room.fDragonSwords > 0 && player.fDragonSwords < player.getMaxNumDragonSwords())
                        {
                            wants = true;
                        }
                        else if (room.fSerpentShields > 0 && player.fSerpentShields < player.getMaxNumSerpentShields())
                        {
                            wants = true;
                        }
                        else if (room.fSandals > 0 && (player.fSandals == 0))
                        {
                            wants = true;
                        }
                        if ((room.fRing | player.fRing) != player.fRing)
                        {
                            wants = true;
                        }
                        else if (room.hasStaffs() && player.getMaxNumStaffs() > 0)
                        {
                            Staff best = room.fStaffs.getBestStaff();
                            if (player.wantsStaff(best))
                            {
                                wants = true;
                            }
                        }

                        if (wants)
                        {
                            str += "You feel a potent power from cavern " + room.getRoomNumber() + ".\n";
                        }
                    }
                    else
                    {
                        str += "You feel a potent power.\n";
                    }
                }
            }
            for (int iPassage = 0; iPassage <= this.getNumPassages(); iPassage++)
            {
                Room room = null;
                if (iPassage == 0)
                {
                    if (!this.hasDoor() || !this.isDoorOpen())
                    {
                        continue;
                    }
                    room = this.fDoor;
                }
                else
                {
                    room = this.getPassage(iPassage);
                }
                Utility.Assert(room != null, "Room.getAdjacentDescription - room != null (4)");
            }
            return(str);
        }