Esempio n. 1
0
        public String getDungeonName()
        {
            int            lairs = 0;
            MonsterCounter mc    = new MonsterCounter();

            for (int i = 1; i <= this.getNumRooms(); ++i)
            {
                Room room = this.getRoom(i);
                if (room.isLair())
                {
                    lairs++;
                    Monster lair = room.createMonster();
                    mc.countMonster(lair);
                }
            }
            return(mc.toString());
//		return lairs + " lairs";
        }
Esempio n. 2
0
        public Room getLair(int lair_no)
        {
            int no = lair_no;

            for (int i = 1; i <= this.getNumRooms(); i++)
            {
                Room room = this.getRoom(i);
                if (room.isLair())
                {
                    no--;
                    if (no == 0)
                    {
                        return(room);
                    }
                }
            }
            Utility.Trace("Maze.getLair called with invalid lair # (" + lair_no + ")");
            return(null);
        }
Esempio n. 3
0
//	public Room getLair()
//	{
//		return fLair;
//	}
        public Room getRandomLair(bool force_create)
        {
            // Find room without door and only one entrance
            int  passages   = 1;
            bool allow_door = false;

            while (true)
            {
                Sequence seq = new Sequence(2, this.getNumRooms());
                //seq.remove(fHermit.getRoomNumber());
                seq.remove(this.getRoom(1).getPassage(1).getRoomNumber());
                seq.remove(this.getRoom(1).getPassage(2).getRoomNumber());
                while (seq.count() > 0)
                {
                    int  no   = seq.remove();
                    Room room = this.getRoom(no);
                    if (room.isLair())
                    {
                        continue;
                    }
                    if ((allow_door || !room.hasDoor()) && room.getNumPassages() <= passages)
                    {
                        while (room.getNumPassages() > 1)
                        {
                            Room other = room.getRandomPassage();
                            if (other != null && other.getRoomNumber() != 1)
                            {
                                room.removePassage(other);
                                other.removePassage(room);
                                Room[] path = this.findRoute(room, other, null, USE_LOCKED_DOORS);
                                if (path.Length == 0)
                                {
                                    room.addPassage(other);
                                    other.addPassage(room);
                                    // try another room
                                    break;
                                }
                            }
                        }
                        if (room.getNumPassages() <= 1)
                        {
                            return(room);
                        }
                    }
                }
                if (allow_door)
                {
                    if (force_create)
                    {
                        passages++;
                        if (passages > 3)
                        {
                            return(null);
                        }
                        allow_door = false;
                    }
                    else
                    {
                        break;
                    }
                }
                else
                {
                    allow_door = true;
                }
            }
            return(null);    // uncomment
//		return this.getRoom(1);
        }