Exemplo n.º 1
1
  public static void addDebugModifications(Thing h) {
    h.set("IsImmortal", 1);
    h.set("IsDebugMode", 1);

    if ("QuickTester".equals(h.getString("HeroName"))) {
      h.addThing(Spell.create("Annihilation"));
      h.addThing(Spell.create("Blaze"));
      h.addThing(Spell.create("Ultimate Destruction"));
      Wish.makeWish("skills", 100);
    }
  }
Exemplo n.º 2
0
  /**
   * Posts an university wish to the server.
   *
   * @param universityName - university name
   * @param name - name
   * @param email - email address
   * @param message - message
   */
  public void postWish(String universityName, String name, String email, String message) {
    // No Connection -> event no Connection, abort
    if (!isOnline()) {
      postErrorEvent(ErrorEvent.ErrorType.NO_NETWORK, "No Internet Connection!");
      return;
    }

    try {
      // create wish
      Wish wish = new Wish();
      wish.setUniversityName(universityName);
      wish.setName(name);
      wish.setEmail(email);
      wish.setMessage(message);
      wish.setAppVersion(BuildConfig.VERSION_NAME);

      // post to server
      restClient.getRestApi().postWish(wish);

      // post event
      EventBus.getDefault().post(new PostWishDoneEvent());
    } catch (RetrofitError e) {
      postRetrofitError(TAG, e);
    }
  }
Exemplo n.º 3
0
  public static Thing createHero(String name, String race, String profession) {

    Thing h = createBaseHero(race);
    Game.instance().initialize(h);

    if ((name == null) || (name.equals(""))) name = "Tester";
    setHeroName(h, name);

    // Debug mode modifications
    if (Game.isDebug()) {
      addDebugModifications(h);
    }

    // Race Modifications
    applyRace(h, race);

    // Professions
    applyProfession(h, profession);

    // Bonus items based on skills
    applyBonusItems(h);

    // set up HPS and MPS
    h.set(RPG.ST_HPSMAX, h.getBaseStat(RPG.ST_TG) + RPG.d(6));
    h.set(RPG.ST_MPSMAX, h.getBaseStat(RPG.ST_WP) + RPG.d(6));

    h.set(RPG.ST_HPS, h.getStat(RPG.ST_HPSMAX));
    h.set(RPG.ST_MPS, h.getStat(RPG.ST_MPSMAX));

    Being.utiliseItems(h);

    Wish.makeWish("id", 100);

    // score starts at zero
    h.set("Score", 0);

    // religion
    ArrayList gods = Gods.getPossibleGods(h);
    int gl = gods.size();
    if (gl > 0) {
      h.set("Religion", gods.get(RPG.r(gl)));
    } else {
      Game.warn("No religion available for " + race + " " + profession);
    }

    createHeroHistory(h);

    // performance improvement with flattened properties
    h.flattenProperties();

    return h;
  }
Exemplo n.º 4
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();
  }