Beispiel #1
0
 private void talk(int p, final Thing t) {
   int subtype = getStat("SubType");
   Thing h = Game.hero();
   try {
     switch (p) {
       case CHATTER:
         t.incStat("ChatCount", 1);
         handleChatter(subtype, t.getStat("ChatCount"), t);
         return;
       case TEACHER:
         if (h.getStat(RPG.ST_SKILLPOINTS) > 0) {
           Game.message("\"I see you have potential\"");
           Game.message("\"I can teach you for a small fee...\"");
         } else {
           Game.message("\"There is nothing more I can teach you now.\"");
         }
         return;
         // added by ppirrip
       case BLACKSMITH:
         Game.message("\"I can repair your gear for a small fee...\"");
         return;
       default:
         Game.message("You get no response.");
     }
   } catch (Exception e) {
     e.printStackTrace();
     Game.message("\"Mumble mumble mumble\"");
   }
 }
Beispiel #2
0
  private String getDeathString(Thing h) {
    if (h.getStat("HPS") <= 0) {
      Thing t = h.getThing("Killer");
      if (t == null) {
        return "Killed by divine power";
      }
      t.remove();

      String killer = t.getAName();
      if (t.getFlag("IsEffect")) killer = t.name();

      if (killer.equals("you")) killer = "stupidity";
      return "Killed by " + killer;
    }

    return "Defeated The Tyrant";
  }
Beispiel #3
0
  public void gameOver() {
    Wish.makeWish("identification", 100);
    Game.message("");

    Thing h = Game.hero();

    String outcome = getDeathString(h);

    String story = null;

    getScreen().getMappanel().repaint();

    String hresult = "No high score available in debug mode";

    int sc = h.getStat("Score");
    String score = Integer.toString(sc);
    String level = Integer.toString(h.getLevel());
    String seed = Integer.toString(h.getStat("Seed"));
    String name = h.getString("HeroName");
    String profession = h.getString("Profession");
    String race = h.getString("Race");

    try {
      String urldeath = URLEncoder.encode(outcome, fileEncoding);
      String urlname = URLEncoder.encode(name, fileEncoding);

      String check =
          Integer.toString((sc + name.length() * profession.length() * race.length()) ^ 12345678);
      String st =
          "&name="
              + urlname
              + "&race="
              + race
              + "&profession="
              + profession
              + "&level="
              + level
              + "&score="
              + score
              + "&check="
              + check
              + "&version="
              + Game.VERSION
              + "&seed="
              + seed
              + "&death="
              + urldeath;

      String url = "http://tyrant.sourceforge.net/logscore.php?client=tyrant" + st;

      Game.warn((Game.isDebug() ? "NOT " : "") + "Sending data:");
      Game.warn(st);

      if (!Game.isDebug()) {
        URL u = new URL(url);
        InputStream s = u.openStream();

        String returnstring = "";
        int b = s.read();
        while (b >= 0) {
          returnstring = returnstring + (char) b;
          b = s.read();
        }

        int ok = returnstring.indexOf("OK:");
        if (ok >= 0) {
          hresult = "High score logged.\n";
          hresult += "You are in position " + returnstring.substring(ok + 3).trim();
        } else {
          hresult = "Failed to log high score";
          Game.warn(returnstring);
        }
      }
    } catch (Exception e) {
      Game.warn(e.getMessage());
      hresult = "High score feature not available";
    }

    if ((!h.isDead())) {
      story =
          "You have defeated The Tyrant!\n"
              + "\n"
              + "Having saved the world from such malevolent evil, you are crowned as the new Emperor of Daedor, greatly beloved by all the people of the Earth.\n"
              + "\n"
              + "You rule an Empire of peace and prosperity, and enjoy a long and happy life.\n"
              + "\n"
              + "Hurrah for Emperor "
              + h.getString("HeroName")
              + "!!\n";

      if (Game.isDebug()) {
        story =
            "You have defeated The Tyrant in Debug Mode.\n"
                + "\n"
                + "Now go and do it the hard way....\n";
      }

    } else {
      story =
          "\n"
              + "It's all over...... "
              + outcome
              + "\n"
              + "\n"
              + "You have failed in your adventures and died a hideous death.\n"
              + "\n"
              + "You reached level "
              + level
              + "\n"
              + "Your score is "
              + score
              + "\n"
              + "\n"
              + hresult
              + "\n";
    }

    Game.message("GAME OVER - " + outcome);

    Game.message("Would you like to see your final posessions? (y/n)");

    char c = Game.getOption("yn");

    if (c == 'y') {
      Game.selectItem("Your final posessions:", h);
    }

    // display the final story
    Game.scrollTextScreen(story);

    // display the final story
    String killData = Hero.reportKillData();
    Game.scrollTextScreen(killData);

    Game.over = true;

    Lib.clear();

    // recreate lib in background
    Game.asynchronousCreateLib();
  }