@Test public void getItemsInRoom() throws Exception { // setup Room getItemsInRoom = new Room("test"); DirtyDiaper diaperInRoom = new DirtyDiaper("somekid"); DirtyDiaper diaperInRoom2 = new DirtyDiaper("somekid2"); getItemsInRoom.addItem(diaperInRoom); getItemsInRoom.addItem(diaperInRoom2); ArrayList listOfItemsInRoom = getItemsInRoom.getItemsInRoom(); // does the diaper exist in the room? assertTrue(listOfItemsInRoom.contains(diaperInRoom)); assertTrue(listOfItemsInRoom.contains(diaperInRoom2)); }
public void recursiveDropMOB(MOB mob, Room room, Item thisContainer, boolean bodyFlag) { // caller is responsible for recovering any env // stat changes! if (CMLib.flags().isHidden(thisContainer)) thisContainer .baseEnvStats() .setDisposition( thisContainer.baseEnvStats().disposition() & ((int) EnvStats.ALLMASK - EnvStats.IS_HIDDEN)); mob.delInventory(thisContainer); thisContainer.unWear(); if (!bodyFlag) bodyFlag = (thisContainer instanceof DeadBody); if (bodyFlag) { room.addItem(thisContainer); thisContainer.setExpirationDate(0); } else room.addItemRefuse(thisContainer, CMProps.getIntVar(CMProps.SYSTEMI_EXPIRE_PLAYER_DROP)); thisContainer.recoverEnvStats(); boolean nothingDone = true; do { nothingDone = true; for (int i = 0; i < mob.inventorySize(); i++) { Item thisItem = mob.fetchInventory(i); if ((thisItem != null) && (thisItem.container() == thisContainer)) { recursiveDropMOB(mob, room, thisItem, bodyFlag); nothingDone = false; break; } } } while (!nothingDone); }
public void makePuddle(Room R, int oldWeather, int newWeather) { for (int i = 0; i < R.numItems(); i++) { final Item I = R.getItem(i); if ((I instanceof Drink) && (!CMLib.flags().isGettable(I)) && ((I.name().toLowerCase().indexOf("puddle") >= 0) || (I.name().toLowerCase().indexOf("snow") >= 0))) return; } final Item I = CMClass.getItem("GenLiquidResource"); CMLib.flags().setGettable(I, false); ((Drink) I).setLiquidHeld(100); ((Drink) I).setLiquidRemaining(100); ((Drink) I).setLiquidType(RawMaterial.RESOURCE_FRESHWATER); I.setMaterial(RawMaterial.RESOURCE_FRESHWATER); I.basePhyStats().setDisposition(I.basePhyStats().disposition() | PhyStats.IS_UNSAVABLE); CMLib.materials().addEffectsToResource(I); I.recoverPhyStats(); if (coldWetWeather(oldWeather)) { I.setName(L("some snow")); I.setDisplayText(L("some snow rests on the ground here.")); I.setDescription(L("the snow is white and still quite cold!")); } else { I.setName(L("a puddle of water")); I.setDisplayText(L("a puddle of water has formed here.")); I.setDescription(L("It looks drinkable.")); } R.addItem(I, ItemPossessor.Expire.Monster_EQ); R.recoverRoomStats(); }
@Override protected Item buildMyPlant(MOB mob, Room room) { final int code = material & RawMaterial.RESOURCE_MASK; final Item newItem = CMClass.getBasicItem("GenItem"); final String name = CMLib.english().startWithAorAn(RawMaterial.CODES.NAME(code).toLowerCase() + " tree"); newItem.setName(name); newItem.setDisplayText(L("@x1 grows here.", newItem.name())); newItem.setDescription(""); newItem.basePhyStats().setWeight(10000); CMLib.flags().setGettable(newItem, false); newItem.setMaterial(material); newItem.setSecretIdentity(mob.Name()); newItem.setMiscText(newItem.text()); room.addItem(newItem); final Chant_SummonTree newChant = new Chant_SummonTree(); newItem.basePhyStats().setLevel(10 + newChant.getX1Level(mob)); newItem.setExpirationDate(0); room.showHappens( CMMsg.MSG_OK_ACTION, L("a tall, healthy @x1 tree sprouts up.", RawMaterial.CODES.NAME(code).toLowerCase())); room.recoverPhyStats(); newChant.plantsLocationR = room; newChant.littlePlantsI = newItem; if (CMLib.law().doesOwnThisLand(mob, room)) { newChant.setInvoker(mob); newChant.setMiscText(mob.Name()); newItem.addNonUninvokableEffect(newChant); } else newChant.beneficialAffect(mob, newItem, 0, (newChant.adjustedLevel(mob, 0) * 240) + 450); room.recoverPhyStats(); return newItem; }
@Test public void testClearItems() { // setup Room testRemoveItem = new Room("test"); DirtyDiaper diaperInRoom = new DirtyDiaper("somekid"); DirtyDiaper diaperInRoom2 = new DirtyDiaper("somekid2"); testRemoveItem.addItem(diaperInRoom); testRemoveItem.addItem(diaperInRoom2); ArrayList listOfItemsInRoom = testRemoveItem.getItemsInRoom(); // does the diaper exist in the room right now? assertTrue(listOfItemsInRoom.contains(diaperInRoom)); assertTrue(listOfItemsInRoom.contains(diaperInRoom2)); testRemoveItem.clearItems(listOfItemsInRoom); // is the list empty? assertTrue(listOfItemsInRoom.isEmpty()); }
// Changed to work with an arraylist public void drop(int itemNum) { if (itemNum > 0 & itemNum <= itemCount) { switch (itemNum) { case 1: { myLoc.addItem(myItems.get(0)); myItems.remove(0); itemCount--; break; } case 2: { myLoc.addItem(myItems.get(1)); myItems.remove(1); itemCount--; break; } } } }
@Test public void testRemoveItem() throws Exception { // setup Room testRemoveItem = new Room("test"); DirtyDiaper diaperInRoom = new DirtyDiaper("somekid"); DirtyDiaper diaperInRoom2 = new DirtyDiaper("somekid2"); testRemoveItem.addItem(diaperInRoom); testRemoveItem.addItem(diaperInRoom2); ArrayList listOfItemsInRoom = testRemoveItem.getItemsInRoom(); // does the diaper exist in the room right now? assertTrue(listOfItemsInRoom.contains(diaperInRoom)); assertTrue(listOfItemsInRoom.contains(diaperInRoom2)); // remove items from the room testRemoveItem.removeItem(diaperInRoom2); // does diaperInRoom2 exist in the room now? assertFalse(listOfItemsInRoom.contains(diaperInRoom2)); }
public static Item buildPlant(MOB mob, Room room) { Item newItem = CMClass.getItem("GenItem"); newItem.setMaterial(RawMaterial.RESOURCE_GREENS); switch (CMLib.dice().roll(1, 5, 0)) { case 1: newItem.setName("some happy flowers"); newItem.setDisplayText("some happy flowers are growing here."); newItem.setDescription("Happy flowers with little red and yellow blooms."); break; case 2: newItem.setName("some happy weeds"); newItem.setDisplayText("some happy weeds are growing here."); newItem.setDescription("Long stalked little plants with tiny bulbs on top."); break; case 3: newItem.setName("a pretty fern"); newItem.setDisplayText("a pretty fern is growing here."); newItem.setDescription("Like a tiny bush, this dark green plant is lovely."); break; case 4: newItem.setName("a patch of sunflowers"); newItem.setDisplayText("a patch of sunflowers is growing here."); newItem.setDescription("Happy flowers with little yellow blooms."); break; case 5: newItem.setName("a patch of bluebonnets"); newItem.setDisplayText("a patch of bluebonnets is growing here."); newItem.setDescription("Happy flowers with little blue and purple blooms."); break; } Chant_SummonPlants newChant = new Chant_SummonPlants(); newItem.basePhyStats().setLevel(10 + (10 * newChant.getX1Level(mob))); newItem.basePhyStats().setWeight(1); newItem.setSecretIdentity(mob.Name()); newItem.setMiscText(newItem.text()); room.addItem(newItem); newItem.setExpirationDate(0); room.showHappens(CMMsg.MSG_OK_ACTION, "Suddenly, " + newItem.name() + " sprout(s) up here."); newChant.PlantsLocation = room; newChant.littlePlants = newItem; if (CMLib.law().doesOwnThisProperty(mob, room)) { newChant.setInvoker(mob); newChant.setMiscText(mob.Name()); newItem.addNonUninvokableEffect(newChant); } else newChant.beneficialAffect(mob, newItem, 0, (newChant.adjustedLevel(mob, 0) * 240) + 450); room.recoverPhyStats(); return newItem; }
public static void colorForSale(Room R, boolean rental, boolean reset) { synchronized (("SYNC" + R.roomID()).intern()) { R = CMLib.map().getRoom(R); final String theStr = rental ? RENTSTR : SALESTR; final String otherStr = rental ? SALESTR : RENTSTR; int x = R.description().indexOf(otherStr); while (x >= 0) { R.setDescription(R.description().substring(0, x)); CMLib.database().DBUpdateRoom(R); x = R.description().indexOf(otherStr); } final String oldDescription = R.description(); x = R.description().indexOf(theStr.trim()); if ((x < 0) || (reset && (!R.displayText() .equals(CMath.bset(R.domainType(), Room.INDOORS) ? INDOORSTR : OUTDOORSTR)))) { if (reset) { R.setDescription(""); R.setDisplayText(CMath.bset(R.domainType(), Room.INDOORS) ? INDOORSTR : OUTDOORSTR); x = -1; } if (x < 0) R.setDescription(R.description() + theStr); else if (!reset) R.setDescription(R.description().substring(0, x + theStr.trim().length())); if (!R.description().equals(oldDescription)) CMLib.database().DBUpdateRoom(R); } else { R.setDescription(R.description().substring(0, x + theStr.trim().length())); if (!R.description().equals(oldDescription)) CMLib.database().DBUpdateRoom(R); } Item I = R.findItem(null, "$id$"); if ((I == null) || (!I.ID().equals("GenWallpaper"))) { I = CMClass.getItem("GenWallpaper"); CMLib.flags().setReadable(I, true); I.setName(("id")); I.setReadableText(CMLib.lang().L("This room is " + CMLib.map().getExtendedRoomID(R))); I.setDescription(CMLib.lang().L("This room is @x1", CMLib.map().getExtendedRoomID(R))); R.addItem(I); CMLib.database().DBUpdateItems(R); } } }
/** This method drops all of the items that the monster is carrying into the room it is in. */ public void dropItems() { ArrayList<Item> inventory = getInventory(); for (Item i : inventory) currentRoom.addItem(i); }
public boolean doArchonDBCompare(MOB mob, String scope, String firstWord, Vector commands) throws java.io.IOException { CMClass.CMObjectType doType = OBJECT_TYPES.get(firstWord.toUpperCase()); if (doType == null) doType = OBJECT_TYPES.get(firstWord.toUpperCase() + "S"); if (doType != null) commands.remove(0); else doType = CMClass.CMObjectType.LOCALE; final String theRest = CMParms.combineQuoted(commands, 0); DBConnector dbConnector = null; final String dbClass = CMParms.getParmStr(theRest, "DBCLASS", ""); final String dbService = CMParms.getParmStr(theRest, "DBSERVICE", ""); final String dbUser = CMParms.getParmStr(theRest, "DBUSER", ""); final String dbPass = CMParms.getParmStr(theRest, "DBPASS", ""); final int dbConns = CMParms.getParmInt(theRest, "DBCONNECTIONS", 3); final int dbPingIntMins = CMParms.getParmInt(theRest, "DBPINGINTERVALMINS", 30); final boolean dbReuse = CMParms.getParmBool(theRest, "DBREUSE", true); final String ignore = CMParms.getParmStr(theRest, "IGNORE", ""); final String maskStr = CMParms.getParmStr(theRest, "MASK", ""); final Set<String> ignores = new SHashSet(CMParms.parseCommas(ignore.toUpperCase(), true)); final MaskingLibrary.CompiledZapperMask mask = CMLib.masking().maskCompile(maskStr); if (dbClass.length() == 0) { mob.tell(L("This command requires DBCLASS= to be set.")); return false; } if (dbService.length() == 0) { mob.tell(L("This command requires DBSERVICE= to be set.")); return false; } if (dbUser.length() == 0) { mob.tell(L("This command requires DBUSER= to be set.")); return false; } if (dbPass.length() == 0) { mob.tell(L("This command requires DBPASS= to be set.")); return false; } dbConnector = new DBConnector( dbClass, dbService, dbUser, dbPass, dbConns, dbPingIntMins, dbReuse, false, false); dbConnector.reconnect(); final DBInterface dbInterface = new DBInterface(dbConnector, null); final DBConnection DBTEST = dbConnector.DBFetch(); if (DBTEST != null) dbConnector.DBDone(DBTEST); mob.tell(L("Loading database rooms...")); final List<Room> rooms = new LinkedList<Room>(); if ((!dbConnector.amIOk()) || (!dbInterface.isConnected())) { mob.tell(L("Failed to connect to database.")); return false; } if (scope.equalsIgnoreCase("AREA")) rooms.addAll( Arrays.asList(dbInterface.DBReadRoomObjects(mob.location().getArea().Name(), false))); else if (scope.equalsIgnoreCase("ROOM")) { final Room R = dbInterface.DBReadRoomObject(mob.location().roomID(), false); if (R != null) rooms.add(R); } else for (final Enumeration<Area> e = CMLib.map().areas(); e.hasMoreElements(); ) rooms.addAll(Arrays.asList(dbInterface.DBReadRoomObjects(e.nextElement().Name(), false))); if (rooms.size() == 0) { mob.tell(L("No rooms found.")); return false; } for (final Room R : rooms) dbInterface.DBReadContent(R.roomID(), R, false); mob.tell(L("Data loaded, starting scan.")); final Comparator<MOB> convM = new Comparator<MOB>() { @Override public int compare(MOB arg0, MOB arg1) { final int x = arg0.ID().compareTo(arg1.ID()); return (x != 0) ? x : arg0.Name().compareTo(arg1.Name()); } }; final Comparator<Item> convI = new Comparator<Item>() { @Override public int compare(Item arg0, Item arg1) { final int x = arg0.ID().compareTo(arg1.ID()); return (x != 0) ? x : arg0.Name().compareTo(arg1.Name()); } }; try { for (final Room dbR : rooms) { Room R = CMLib.map().getRoom(dbR.roomID()); if (R == null) { if (doType == CMClass.CMObjectType.LOCALE) Log.sysOut("Merge", dbR.roomID() + " not in database"); // import, including exits! continue; } synchronized (("SYNC" + dbR.roomID()).intern()) { final Area.State oldFlags = R.getArea().getAreaState(); R.getArea().setAreaState(Area.State.FROZEN); boolean updateMobs = false; boolean updateItems = false; final boolean updateRoom = false; R = CMLib.map().getRoom(R); CMLib.map().resetRoom(R); final List<MOB> mobSetL = new Vector<MOB>(); for (final Enumeration<MOB> e = dbR.inhabitants(); e.hasMoreElements(); ) mobSetL.add(e.nextElement()); final MOB[] mobSet = mobSetL.toArray(new MOB[0]); Arrays.sort(mobSet, convM); String lastName = ""; int ct = 1; final HashSet<MOB> doneM = new HashSet<MOB>(); for (final MOB dbM : mobSet) { if (!lastName.equals(dbM.Name())) ct = 1; else ct++; final String rName = dbM.Name() + "." + ct; MOB M = null; int ctr = ct; for (final Enumeration<MOB> m = R.inhabitants(); m.hasMoreElements(); ) { final MOB M1 = m.nextElement(); if (M1.Name().equalsIgnoreCase(dbM.Name()) && ((--ctr) <= 0)) { M = M1; break; } } if (M == null) { if (amMerging(doType, mask, dbM) && (!ignore.contains("MISSING"))) { if (mob.session() .confirm( L( "MOB: @x1.@x2 not in local room.\n\rWould you like to add it (y/N)?", dbR.roomID(), rName), L("N"))) { M = (MOB) dbM.copyOf(); M.bringToLife(R, true); doneM.add(M); updateMobs = true; Log.sysOut("Merge", mob.Name() + " added mob " + dbR.roomID() + "." + rName); } } } else { doneM.add(M); if (amMerging(doType, mask, dbM)) { if (!dbM.sameAs(M)) { final MOB oldM = (MOB) M.copyOf(); if ((dbMerge(mob, "^MMOB " + dbR.roomID() + "." + rName + "^N", dbM, M, ignores)) && (!oldM.sameAs(M))) { Log.sysOut("Merge", mob.Name() + " modified mob " + dbR.roomID() + "." + rName); updateMobs = true; } } } final STreeSet<Item> itemSetL = new STreeSet<Item>(convI); for (final Enumeration<Item> e = dbM.items(); e.hasMoreElements(); ) itemSetL.add(e.nextElement()); final Item[] itemSet = itemSetL.toArray(new Item[0]); Arrays.sort(itemSet, convI); String lastIName = ""; int ict = 1; final HashSet<Item> doneI = new HashSet<Item>(); for (final Item dbI : itemSet) { if (!lastIName.equals(dbI.Name())) ict = 1; else ict++; final String rIName = dbI.Name() + "." + ict; Item I = null; ctr = ict; for (final Enumeration<Item> i = M.items(); i.hasMoreElements(); ) { final Item I1 = i.nextElement(); if (I1.Name().equalsIgnoreCase(dbI.Name()) && ((--ctr) <= 0)) { I = I1; break; } } if (I == null) { if (amMerging(doType, mask, dbI) && (!ignore.contains("MISSING"))) { if (mob.session() .confirm( L( "Item: @x1.@x2.@x3 not in local room.\n\rWould you like to add it (y/N)?", dbR.roomID(), dbM.Name(), rIName), L("N"))) { I = (Item) dbI.copyOf(); M.addItem(I); doneI.add(I); final Item cI = (dbI.container() == null) ? null : M.findItem(dbI.container().Name()); if (cI instanceof Container) I.setContainer((Container) cI); updateMobs = true; Log.sysOut( "Merge", mob.Name() + " added item " + dbR.roomID() + "." + dbM.Name() + "." + rIName); } } } else if (amMerging(doType, mask, dbI)) { doneI.add(I); if (!dbI.sameAs(I)) { final Item oldI = (Item) I.copyOf(); if ((dbMerge( mob, "^IITEM ^M" + dbR.roomID() + "." + dbM.Name() + "." + rIName + "^N", dbI, I, ignores)) && (!oldI.sameAs(I))) { Log.sysOut( "Merge", mob.Name() + " modified item " + dbR.roomID() + "." + dbM.Name() + "." + rIName); updateMobs = true; } } } lastIName = dbI.Name(); } for (final Enumeration<Item> i = M.items(); i.hasMoreElements(); ) { final Item I = i.nextElement(); if (amMerging(doType, mask, I) && (!doneI.contains(I)) && (!ignore.contains("EXTRA"))) { if (mob.session() .confirm( L( "Item: @x1.@x2.@x3 not in database.\n\rWould you like to delete it (y/N)?", R.roomID(), M.Name(), I.Name()), L("N"))) { M.delItem(I); updateMobs = true; Log.sysOut( "Merge", mob.Name() + " deleted item " + R.roomID() + "." + M.Name() + "." + I.Name()); } } } } lastName = dbM.Name(); } for (final Enumeration<MOB> r = R.inhabitants(); r.hasMoreElements(); ) { final MOB M = r.nextElement(); if (amMerging(doType, mask, M) && (!doneM.contains(M)) && (M.isMonster()) && (!ignore.contains("EXTRA"))) { if (mob.session() .confirm( L( "MOB: @x1.@x2 not in database.\n\rWould you like to delete it (y/N)?", R.roomID(), M.Name()), L("N"))) { R.delInhabitant(M); updateMobs = true; Log.sysOut("Merge", mob.Name() + " deleted mob " + R.roomID() + "." + M.Name()); } } } final STreeSet<Item> itemSetL = new STreeSet<Item>(convI); for (final Enumeration<Item> e = dbR.items(); e.hasMoreElements(); ) itemSetL.add(e.nextElement()); final Item[] itemSet = itemSetL.toArray(new Item[0]); Arrays.sort(itemSet, convI); lastName = ""; ct = 1; final HashSet<Item> doneI = new HashSet<Item>(); for (final Item dbI : itemSet) { if (!lastName.equals(dbI.Name())) ct = 1; else ct++; final String rName = dbI.Name() + "." + ct; Item I = null; int ctr = ct; for (final Enumeration<Item> i = R.items(); i.hasMoreElements(); ) { final Item I1 = i.nextElement(); if (I1.Name().equalsIgnoreCase(dbI.Name()) && ((--ctr) <= 0)) { I = I1; break; } } if (I == null) { if (amMerging(doType, mask, dbI) && (!ignore.contains("MISSING"))) { if (mob.session() .confirm( L( "Item: @x1.@x2 not in local room.\n\rWould you like to add it (y/N)?", dbR.roomID(), rName), L("N"))) { I = (Item) dbI.copyOf(); R.addItem(I); doneI.add(I); final Item cI = (dbI.container() == null) ? null : R.findItem(dbI.container().Name()); if (cI instanceof Container) I.setContainer((Container) cI); updateItems = true; Log.sysOut("Merge", mob.Name() + " added item " + dbR.roomID() + "." + rName); } } } else if (amMerging(doType, mask, dbI)) { doneI.add(I); if (!dbI.sameAs(I)) { final Item oldI = (Item) I.copyOf(); if ((dbMerge(mob, "^IITEM " + dbR.roomID() + "." + rName + "^N", dbI, I, ignores)) && (!oldI.sameAs(I))) { Log.sysOut("Merge", mob.Name() + " modified item " + dbR.roomID() + "." + rName); updateItems = true; } } } lastName = dbI.Name(); } for (final Enumeration<Item> i = R.items(); i.hasMoreElements(); ) { final Item I = i.nextElement(); if (amMerging(doType, mask, I) && (!doneI.contains(I)) && (!ignore.contains("EXTRA"))) { if (mob.session() .confirm( L( "Item: @x1.@x2 not in database.\n\rWould you like to delete it (y/N)?", R.roomID(), I.Name()), L("N"))) { R.delItem(I); updateItems = true; Log.sysOut("Merge", mob.Name() + " deleted item " + R.roomID() + "." + I.Name()); } } } if (updateRoom) CMLib.database().DBUpdateRoom(R); if (updateItems) CMLib.database().DBUpdateItems(R); if (updateMobs) CMLib.database().DBUpdateMOBs(R); CMLib.map().resetRoom(R); R.getArea().setAreaState(oldFlags); } dbR.destroy(); } mob.tell(L("Done")); } catch (final CMException cme) { mob.tell(L("Cancelled.")); } dbInterface.shutdown(); return true; }
private void setItems(int start, int end, Room room) { for (int i = start; i <= end; i++) room.addItem(weapons[i]); }
public Room createAdventure() { // The outside: Room outside = new Room(); outside.setDesc( "You are standing outside Hogwarts School of Witchcraft and\n" + "Wizardry, near the Whomping Willow. You are searching\n" + "for the hidden Galleons that may perhaps be in the cave that\n" + "opens straight below you (outside)."); // Room 1: Room r1 = new Room(); r1.setDesc( "Too bad this cave is not on the Marauder's Map. You shout\n" + "'Lumos' to ignite your wand, and you see there is a narrow,\n" + " dark passage to the east (r1)."); // Connect the outside to Room 1: outside.setSide(5, r1); r1.setSide(4, outside); entrance = outside; // Room 2: Room r2 = new Room(); r2.setDesc( "You are in a gloomy oval shaped room with grey walls.\n" + " \"Enemies of the heir, beware\" is written on the wall.\n" + "There is a dim light to the west, and a narrow\n" + "dark hole to the east only about 18 inches high (r2)."); // Room 3: Room r3 = new Room(); r3.setDesc( "You really need your wand here. \n" + "There is a wide passage that quickly narrows\n" + "to the west, a bright opening to the east,\n" + "and a deep hole that appears to have no bottom\n" + "in the middle of the room (r3)."); // Connect Rooms 1, 2, & 3: r1.setSide(2, r2); r2.setSide(3, r1); r2.setSide(2, r3); r3.setSide(3, r2); // Room 4: Room r4 = new Room(); r4.setDesc( "There is what looks like a giant snake skin\n" + "in the corner. Perhaps from the Basilisk? A passage leads to\n" + " the west, another one to the north, and a slippery route\n" + "goes down steeply. You can hear the shrieks of mandrakes (r4)."); // Room 5: Room r5 = new Room(); r5.setDesc( "There is a dim light from above and the shrieks\n" + "are clearly coming from a passageway to the east (r5)."); // Room 6: Room r6 = new Room(); r6.setDesc("The ceiling is full of pixies.\n" + "Make sure to cover your head (r6)!"); // Room 7: Room r7 = new Room(); r7.setDesc( "This room is very damp. There are puddles on the floor\n" + "and a steady dripping from above. Let's hope Moaning\n" + "Myrtle didn't flood the girls' lavatory(r7)."); // Connect rooms 3, 4, 5, 6, & 7. r3.setSide(2, r4); r3.setSide(5, r5); r4.setSide(3, r3); r4.setSide(5, r7); r5.setSide(4, r3); r5.setSide(2, r6); r6.setSide(3, r5); r7.setSide(4, r4); // Room 8: Room r8 = new Room(); r8.setDesc( "Ron's rat, Scabbers runs across your foot, and woah! Here " + "comes Crookshanks chasing behind. A narrow passage runs\n" + "to the east and an even narrower one runs to the west (r8)."); // Room 9: Room r9 = new Room(); r9.setDesc( "Water drips from the ceiling as you cover your head.\n " + "There is no exit from this room with only the option to turn back east.\n" + "Will you decide to enter the chamber again? (r9)"); // Room 10: Room r10 = new Room(); r10.setDesc( "It appears that someone has been here. The harp is\n" + "playing to put Fluffy, the three-headed dog asleep.\n" + "Oh wait! It looks like Fluffy is gaurding something.\n" + "There's a trap door on the floor, but it is locked.\n" + "'Alohomora' won't help you here, you need a key (r10)."); // Room 11: Room r11 = new Room(); r11.setDesc("This room is very dark. You can just barely see (r11)."); Treasure theTreasure = new Treasure(); theTreasure.setDesc("A bag filled with shiny gold Galleons."); r11.addItem(theTreasure); // Lets connect them: r4.setSide(0, r8); r8.setSide(1, r4); r8.setSide(3, r9); r8.setSide(2, r10); r9.setSide(2, r8); r10.setSide(3, r8); // Create a key and put it in r6: Key theKey = new Key(); theKey.setDesc("A shiny gold key."); r6.addItem(theKey); // We add a door between r10 and r11: Door theDoor = new Door(r10, r11, theKey); r10.setSide(5, theDoor); r11.setSide(4, theDoor); // Now return the entrance: entrance = outside; return entrance; }