Example #1
0
  public int encounter(Character other) {
    say("You have encountered " + other);
    delay(2000);
    say("His status is:\n" + other.getStatus2());
    delay(2000);

    while (this.health > 0 && other.health > 0) {
      say("Press 1 if you wish to talk.");
      say("Press 2 if you wish to attempt to flee.");
      say("Press 3 if you wish to attack.");

      Scanner sc = new Scanner(System.in);
      int answer = sc.nextInt();

      if (answer == 1) this.talk(other);
      else if (answer == 2) {
        if (this.flee(other)) return 1;
        else return 3;
      } else if (answer == 3) {
        this.attack(other);
        delay(3000);
        other.attack(this);
        delay(3000);
      }
    }
    return 5;
  }