Ejemplo n.º 1
0
  public static void saveGame(String fileName) throws IOException {
    try {
      Bundle bundle = new Bundle();

      bundle.put(VERSION, Game.version);
      bundle.put(CHALLENGES, challenges);
      bundle.put(HERO, hero);
      bundle.put(GOLD, gold);
      bundle.put(DEPTH, depth);

      bundle.put(POS, potionOfStrength);
      bundle.put(SOU, scrollsOfUpgrade);
      bundle.put(AS, arcaneStyli);
      bundle.put(DV, dewVial);
      bundle.put(WT, transmutation);

      int count = 0;
      int ids[] = new int[chapters.size()];
      for (Integer id : chapters) {
        ids[count++] = id;
      }
      bundle.put(CHAPTERS, ids);

      Bundle quests = new Bundle();
      Ghost.Quest.storeInBundle(quests);
      WandMaker.Quest.storeInBundle(quests);
      Blacksmith.Quest.storeInBundle(quests);
      Imp.Quest.storeInBundle(quests);
      bundle.put(QUESTS, quests);

      Room.storeRoomsInBundle(bundle);

      Statistics.storeInBundle(bundle);
      Journal.storeInBundle(bundle);

      if (quickslot instanceof Class) {
        bundle.put(QUICKSLOT, ((Class<?>) quickslot).getName());
      }

      Scroll.save(bundle);
      Potion.save(bundle);
      Wand.save(bundle);
      Ring.save(bundle);

      Bundle badges = new Bundle();
      Badges.saveLocal(badges);
      bundle.put(BADGES, badges);

      OutputStream output = Game.instance.openFileOutput(fileName, Game.MODE_PRIVATE);
      Bundle.write(bundle, output);
      output.close();

    } catch (Exception e) {

      GamesInProgress.setUnknown(hero.heroClass);
    }
  }
Ejemplo n.º 2
0
  public static void saveLevel() throws IOException {
    Bundle bundle = new Bundle();
    bundle.put(LEVEL, level);

    OutputStream output =
        Game.instance.openFileOutput(
            Utils.format(depthFile(hero.heroClass), depth), Game.MODE_PRIVATE);
    Bundle.write(bundle, output);
    output.close();
  }
  public void save() {
    Bundle bundle = new Bundle();
    bundle.put(RECORDS, records);
    bundle.put(LATEST, lastRecord);
    bundle.put(TOTAL, totalNumber);
    bundle.put(WON, wonNumber);

    try {
      OutputStream output = Game.instance.openFileOutput(RANKINGS_FILE, Game.MODE_PRIVATE);
      Bundle.write(bundle, output);
      output.close();
    } catch (IOException e) {
    }
  }
Ejemplo n.º 4
0
  public static void saveGlobal() {

    Bundle bundle = null;

    if (saveNeeded) {

      bundle = new Bundle();
      store(bundle, global);

      try {
        OutputStream output = Game.instance.openFileOutput(BADGES_FILE, Game.MODE_PRIVATE);
        Bundle.write(bundle, output);
        output.close();
        saveNeeded = false;
      } catch (IOException e) {

      }
    }
  }