Esempio n. 1
0
 public void move() {
   currRm.updateMap();
   print("Instructions:");
   print("u/U -        Up");
   print("d/D -        Down");
   print("l/L -        Left");
   print("r/R -        Right");
   print("s/save -     Save your current info");
   print("Stat -       Displays your stats");
   print("quit -       Quits the game without saving");
   System.out.println("Stage:       " + getStage() + "/200");
   boolean chosen;
   chosen = false;
   while (!chosen) {
     System.out.print(player.name() + "@stuyablo $ ");
     Scanner sc = new Scanner(System.in);
     String response = sc.next();
     if (response.toUpperCase().equals("U")) {
       chosen = true;
       action("UP");
     } else if (response.toUpperCase().equals("D")) {
       chosen = true;
       action("DOWN");
     } else if (response.toUpperCase().equals("L")) {
       chosen = true;
       action("LEFT");
     } else if (response.toUpperCase().equals("R")) {
       chosen = true;
       action("RIGHT");
     } else if (response.toUpperCase().equals("S") || response.toUpperCase().equals("SAVE")) {
       try {
         FileOutputStream saveFile = new FileOutputStream("stuyablosave.txt");
         ObjectOutputStream save = new ObjectOutputStream(saveFile);
         save.writeObject(player.name());
         save.writeObject(player.level());
         save.writeObject(player.experience());
         save.writeObject(player.maxHealth());
         save.writeObject(player.health());
         save.writeObject(player.strength());
         save.writeObject(player.speed());
         save.writeObject(player.dexterity());
         save.writeObject(super.stage);
         save.writeObject(player.type());
         save.writeObject(currRm.room);
         save.writeObject(player.xcor());
         save.writeObject(player.ycor());
         save.close();
       } catch (Exception e) {
         e.printStackTrace();
       }
     } else if (response.toUpperCase().equals("STAT")) {
       System.out.println("Level:         " + player.level);
       System.out.println("Experience:    " + player.experience);
       player.displayStats();
     } else if (response.toUpperCase().equals("QUIT")) {
       System.out.println("Exiting... ");
       System.exit(0);
     } else if (response.toUpperCase().equals("CLEAR")) {
       System.out.print("\033\143");
       currRm.updateMap();
     } else if (response.toUpperCase().equals("DEVMODE")) {
       if (devmd) {
         devmd = false;
         System.out.println("Devmode off");
       } else {
         devmd = true;
         System.out.println("Devmode on");
       }
     } else if (response.toUpperCase().equals("SETHEALTH") && devmd) {
       Scanner devconsole = new Scanner(System.in);
       System.out.print(" $ Value: ");
       try {
         player.setMaxHealth((int) (devconsole.nextInt()));
         player.setHealth(player.maxHealth());
       } catch (Exception e) {
         System.out.println("Invalid value. Please use an int");
       }
     } else if (response.toUpperCase().equals("SETSTRENGTH") && devmd) {
       Scanner devconsole = new Scanner(System.in);
       System.out.print(" $ Value: ");
       try {
         player.setStrength((int) (devconsole.nextInt()));
       } catch (Exception e) {
         System.out.println("Invalid value. Please use an int");
       }
     } else if (response.toUpperCase().equals("SETSTAGE") && devmd) {
       Scanner devconsole = new Scanner(System.in);
       System.out.print(" $ Value: ");
       try {
         setStage((int) (devconsole.nextInt()));
         chosen = true;
       } catch (Exception e) {
         System.out.println("Invalid value. Please use an int");
       }
     } else if (response.toUpperCase().equals("SETDEXTERITY") && devmd) {
       Scanner devconsole = new Scanner(System.in);
       System.out.print(" $ Value: ");
       try {
         player.setDexterity((int) (devconsole.nextInt()));
       } catch (Exception e) {
         System.out.println("Invalid value. Please use an int");
       }
     } else if (response.toUpperCase().equals("SETSPEED") && devmd) {
       Scanner devconsole = new Scanner(System.in);
       System.out.print(" $ Value: ");
       try {
         player.setSpeed((int) (devconsole.nextInt()));
       } catch (Exception e) {
         System.out.println("Invalid value. Please use an int");
       }
     } else if (response.toUpperCase().equals("SETLEVEL") && devmd) {
       Scanner devconsole = new Scanner(System.in);
       System.out.print(" $ Value: ");
       try {
         player.setLevel((int) (devconsole.nextInt()));
       } catch (Exception e) {
         System.out.println("Invalid value. Please use an int");
       }
     } else if (response.toUpperCase().equals("SETNAME") && devmd) {
       Scanner devconsole = new Scanner(System.in);
       System.out.print(" $ Value: ");
       try {
         player.setName(devconsole.next());
       } catch (Exception e) {
         System.out.println("Invalid value.");
       }
     } else {
       System.out.println("Invalid Command");
     }
   }
   //		setStage(getStage() + 1);
   if (player.experience() >= player.level * 100) {
     player.setLevel(player.level + 1);
     if (player.level() == 3) {
       System.out.println("You have unlocked your class special move!");
     }
     player.setExperience(0);
     System.out.println("You have levelled up!");
     player.setStrength(player.strength() + 2);
     player.setSpeed(player.speed() + 1);
     player.setDexterity(player.dexterity() + 2);
     player.setMaxHealth(player.maxHealth() + 15);
   }
   player.setHealth(player.maxHealth());
 }
Esempio n. 2
0
 // Constructor
 public Labyrinth(BaseChar bc) {
   player = bc;
   devmd = false;
   currRm = new RoomGen(player, this);
   currRm.MapGen(player.xcor(), player.ycor());
 }