Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package edu.pcc.cis.zuul;
- import java.util.ArrayList;
- import java.util.Random;
- /**
- * Represents a game scenario including connected rooms and items
- *
- * @author Tony Pham
- * @version 2018.02.26
- */
- public class Scenario
- {
- private ArrayList<Room> rooms;
- private Room startRoom;
- private Room currentRoom;
- private Room transporterRoom;
- private Random random;
- /**
- * Constructor for objects of class Scenario
- */
- public Scenario()
- {
- random = new Random();
- startRoom = new Room("");
- currentRoom = new Room("");
- transporterRoom = new Room("");
- // Set up your rooms, exits, and items
- // Move code from Game.createRooms here
- Room tardis, entrance, policestation, club, lab, cityhall, hospital, center, cellar, watchtower;
- // create the rooms
- tardis = new TransporterRoom("outside the main entrance of town, you stumble upon a strange blue phone booth"); //problem
- entrance = new Room("at the main entrance of town, a thick blanket fog covers the entirety of town,");
- entrance.addItem("and found a dirty Journal", 5);
- cellar = new Room("down into the cellar the smell of decomposing matter is strong,");
- cellar.addItem("and found a folder", 2);
- watchtower = new Room("up in the watchtower, it is cold and you can't see anything thanks to the fog,");
- watchtower.addItem("and found a pair of binoculars", 4);
- policestation = new Room("in the police station, you find find evidence of a gunfight that left bullet holes scattered throughout the place,");
- policestation.addItem("and found a gun", 6);
- club = new Room("in the local club, where you find broken bottles scattered around the premises covered in strange black goo,");
- club.addItem("and found a water flask", 3);
- lab = new Room("in the science lab, you find broken glass and the signs of an explosion,");
- lab.addItem("and found a vial of strange liquid", 1);
- cityhall = new Room("in the mayor's office, you find papers strewn all over the place,");
- cityhall.addItem("and found a notebook full of notes", 2);
- hospital = new Room("in the hospital, you find signs of a struggle along with black goo splattered all over the place along with the sound of something scratching against one of the doors,");
- hospital.addItem("and found a small first-aid kit along with a stash of granola bars", 7);
- center = new Room("in the center of town, you find signs of a huge accident along with cars that are either burnt out are have been broken into. You find black goo on some of the broken windows.");
- center.addItem("and found a flashlight", 2);
- // initialise room exits
- tardis.setExit("south", entrance );
- entrance.setExit("east", policestation);
- entrance.setExit("south", center);
- entrance.setExit("north", tardis );
- policestation.setExit("up", watchtower);
- policestation.setExit("west", entrance);
- club.setExit("north", center);
- lab.setExit("north", hospital);
- lab.setExit("down", cellar);
- cityhall.setExit("east", center);
- hospital.setExit("west", center);
- hospital.setExit("south", lab);
- center.setExit("north", entrance);
- center.setExit("east", hospital);
- center.setExit("south", club);
- center.setExit("west", cityhall);
- cellar.setExit("up", lab);
- watchtower.setExit("down", policestation);
- // Set the start room
- startRoom = entrance; // start game outside
- // Create the rooms ArrayList and add all your rooms to it
- rooms = new ArrayList<Room>();
- rooms.add(entrance);
- rooms.add(policestation);
- rooms.add(club);
- rooms.add(lab);
- rooms.add(cityhall);
- rooms.add(hospital);
- rooms.add(center);
- rooms.add(cellar);
- rooms.add(watchtower);
- rooms.add(tardis);
- }
- /**
- * @return the start room for this scenario
- */
- public Room getStartRoom()
- {
- return this.startRoom;
- }
- /**
- * @return a random room from this scenario
- */
- public Room getRandomRoom()
- {
- return rooms.get(random.nextInt(rooms.size()));
- }
- }
- ///////////////////////////////////////////////////////////////////////////////////////////////////////
- package edu.pcc.cis.zuul;
- public class TransporterRoom extends Room{
- private Scenario scenario;
- private String description;
- /**
- * initialize TransporterRoom
- * @param description
- * @param scenario
- */
- public TransporterRoom(String description, Scenario scenario) {
- //this.description = description;
- //scenario = new Scenario();
- super(description);
- this.scenario = scenario;
- }
- /**
- *
- * @return A random room using the Scenario given in this class's constructor.
- */
- private Room findRandomRoom()
- {
- return scenario.getRandomRoom();
- }
- /**
- * @return similar string as Room class, but with an extra message
- */
- @Override
- public String getExitString() {
- return super.getExitString() + "\nAlso, the doorknob seems to be glowing...";
- }
- }
Add Comment
Please, Sign In to add comment