public static void preview(GamesInProgress.Info info, Bundle bundle) { info.depth = bundle.getInt(DEPTH); if (info.depth == -1) { info.depth = bundle.getInt("maxDepth"); // FIXME } Hero.preview(info, bundle.getBundle(HERO)); }
@Override public void restoreFromBundle(Bundle bundle) { info = bundle.getString(REASON); win = bundle.getBoolean(WIN); score = bundle.getInt(SCORE); heroClass = HeroClass.restoreInBundle(bundle); armorTier = bundle.getInt(TIER); gameFile = bundle.getString(GAME); // Here lies a collection of messy logic, some to account for transferring pre-0.2.3 rankings // to the new // system, some to account for errors in that process which were patched. // commented here is info about what was added when, and why, eventually after almost everyone // has // dropped 0.2.2 this can be phased out. // 0.2.3, adds depth and parses info, works almost perfectly, except for the edge case in the // next comment. if (!bundle.contains(DEPTH)) { try { depth = Integer.parseInt(info.replaceAll("[\\D]", "")); } catch (Exception e) { depth = 0; } info = info.split("on level")[0].trim(); } else depth = bundle.getInt(DEPTH); // 0.2.3d, fixes a case where a player who died to dm-300 would have a recorded depth of // 30015. if (depth == 30015) depth = 15; // basically every patch until 0.2.3d, extracts the hero's level from the bundle structure. // the second condition in the if is important, helps account for bugged rankings from pre // 0.2.3d if (!bundle.contains(LEVEL) || bundle.getInt(LEVEL) == 0 && ShatteredPixelDungeon.version() < 30) { try { InputStream input = Game.instance.openFileInput(gameFile); Bundle gameBundle = Bundle.read(input); input.close(); herolevel = gameBundle.getBundle("hero").getInt("lvl"); } catch (Exception e) { herolevel = 0; } } else herolevel = bundle.getInt(LEVEL); }
@Override public void restoreFromBundle(Bundle bundle) { super.restoreFromBundle(bundle); maxCharges = bundle.getInt(MAX_CHARGES); curCharges = bundle.getInt(CUR_CHARGES); curChargeKnown = bundle.getBoolean(CUR_CHARGE_KNOWN); }
@Override public void restoreFromBundle(Bundle bundle) { super.restoreFromBundle(bundle); stairs = bundle.getInt(STAIRS); enteredArena = bundle.getBoolean(ENTERED); keyDropped = bundle.getBoolean(DROPPED); }
@Override public void restoreFromBundle(Bundle bundle) { super.restoreFromBundle(bundle); if ((hitsToKnow = bundle.getInt(UNFAMILIRIARITY)) == 0) { hitsToKnow = HITS_TO_KNOW; } inscribe((Glyph) bundle.get(GLYPH)); }
@Override public void restoreFromBundle( Bundle bundle ) { super.restoreFromBundle(bundle); if ((hitsToKnow = bundle.getInt( UNFAMILIRIARITY )) == 0) { hitsToKnow = HITS_TO_KNOW; } enchantment = (Enchantment)bundle.get( ENCHANTMENT ); imbue = bundle.getEnum( IMBUE, Imbue.class ); }
@Override public void restoreFromBundle(Bundle bundle) { super.restoreFromBundle(bundle); heroClass = HeroClass.restoreInBundle(bundle); subClass = HeroSubClass.restoreInBundle(bundle); attackSkill = bundle.getInt(ATTACK); defenseSkill = bundle.getInt(DEFENSE); STR = bundle.getInt(STRENGTH); updateAwareness(); lvl = bundle.getInt(LEVEL); exp = bundle.getInt(EXPERIENCE); belongings.restoreFromBundle(bundle); }
public static void restoreFromBundle(Bundle bundle) { goldCollected = bundle.getInt(GOLD); deepestFloor = bundle.getInt(DEEPEST); enemiesSlain = bundle.getInt(SLAIN); foodEaten = bundle.getInt(FOOD); potionsCooked = bundle.getInt(ALCHEMY); piranhasKilled = bundle.getInt(PIRANHAS); nightHunt = bundle.getInt(NIGHT); ankhsUsed = bundle.getInt(ANKHS); duration = bundle.getFloat(DURATION); amuletObtained = bundle.getBoolean(AMULET); }
public void load() { if (records != null) { return; } records = new ArrayList<Rankings.Record>(); try { InputStream input = Game.instance.openFileInput(RANKINGS_FILE); Bundle bundle = Bundle.read(input); input.close(); for (Bundlable record : bundle.getCollection(RECORDS)) { records.add((Record) record); } lastRecord = bundle.getInt(LATEST); totalNumber = bundle.getInt(TOTAL); if (totalNumber == 0) { totalNumber = records.size(); } wonNumber = bundle.getInt(WON); if (wonNumber == 0) { for (Record rec : records) { if (rec.win) { wonNumber++; } } } } catch (IOException e) { } }
private void restore(Bundle bundle, String[] allLabels, Integer[] allImages) { ArrayList<String> labelsLeft = new ArrayList<String>(Arrays.asList(allLabels)); ArrayList<Integer> imagesLeft = new ArrayList<Integer>(Arrays.asList(allImages)); for (int i = 0; i < items.length; i++) { Class<? extends T> item = (Class<? extends T>) (items[i]); String itemName = item.toString(); if (bundle.contains(itemName + PFX_LABEL)) { String label = bundle.getString(itemName + PFX_LABEL); labels.put(item, label); labelsLeft.remove(label); Integer image = bundle.getInt(itemName + PFX_IMAGE); images.put(item, image); imagesLeft.remove(image); if (bundle.getBoolean(itemName + PFX_KNOWN)) { known.add(item); } } else { int index = Random.Int(labelsLeft.size()); labels.put(item, labelsLeft.get(index)); labelsLeft.remove(index); images.put(item, imagesLeft.get(index)); imagesLeft.remove(index); } } }
@Override public void restoreFromBundle(Bundle bundle) { super.restoreFromBundle(bundle); damage = bundle.getInt(DAMAGE); }
@Override public void restoreFromBundle(Bundle bundle) { super.restoreFromBundle(bundle); spawn(bundle.getInt(LEVEL)); }
@Override public void restoreFromBundle(Bundle bundle) { pos = bundle.getInt(POS); }
@Override public void restoreFromBundle(Bundle bundle) { super.restoreFromBundle(bundle); demonGooGeneration = bundle.getInt(DEMONGOOGENERATION); }
public static void loadGame(String fileName, boolean fullLoad) throws IOException { Bundle bundle = gameBundle(fileName); Dungeon.challenges = bundle.getInt(CHALLENGES); Dungeon.level = null; Dungeon.depth = -1; if (fullLoad) { PathFinder.setMapSize(Level.WIDTH, Level.HEIGHT); } Scroll.restore(bundle); Potion.restore(bundle); Wand.restore(bundle); Ring.restore(bundle); potionOfStrength = bundle.getInt(POS); scrollsOfUpgrade = bundle.getInt(SOU); arcaneStyli = bundle.getInt(AS); dewVial = bundle.getBoolean(DV); transmutation = bundle.getInt(WT); if (fullLoad) { chapters = new HashSet<Integer>(); int ids[] = bundle.getIntArray(CHAPTERS); if (ids != null) { for (int id : ids) { chapters.add(id); } } Bundle quests = bundle.getBundle(QUESTS); if (!quests.isNull()) { Ghost.Quest.restoreFromBundle(quests); WandMaker.Quest.restoreFromBundle(quests); Blacksmith.Quest.restoreFromBundle(quests); Imp.Quest.restoreFromBundle(quests); } else { Ghost.Quest.reset(); WandMaker.Quest.reset(); Blacksmith.Quest.reset(); Imp.Quest.reset(); } Room.restoreRoomsFromBundle(bundle); } Bundle badges = bundle.getBundle(BADGES); if (!badges.isNull()) { Badges.loadLocal(badges); } else { Badges.reset(); } String qsClass = bundle.getString(QUICKSLOT); if (qsClass != null) { try { quickslot = Class.forName(qsClass); } catch (ClassNotFoundException e) { } } else { quickslot = null; } @SuppressWarnings("unused") String version = bundle.getString(VERSION); hero = null; hero = (Hero) bundle.get(HERO); gold = bundle.getInt(GOLD); depth = bundle.getInt(DEPTH); Statistics.restoreFromBundle(bundle); Journal.restoreFromBundle(bundle); }
@Override public void restoreFromBundle(Bundle bundle) { super.restoreFromBundle(bundle); level = bundle.getInt(LEVEL); }
@Override public void restoreFromBundle(Bundle bundle) { time = bundle.getFloat(TIME); id = bundle.getInt(ID); }
public static void restoreNextID(Bundle bundle) { nextID = bundle.getInt(NEXTID); }
@Override public void restoreFromBundle(Bundle bundle) { feature = Feature.valueOf(bundle.getString(FEATURE)); depth = bundle.getInt(DEPTH); }
public static void preview(GamesInProgress.Info info, Bundle bundle) { // Refactoring needed! Armor armor = (Armor) bundle.get("armor"); info.armor = armor == null ? 0 : armor.tier; info.level = bundle.getInt(LEVEL); }
public static void preview(GamesInProgress.Info info, Bundle bundle) { info.level = bundle.getInt(LEVEL); }
@Override public void restoreFromBundle(Bundle bundle) { super.restoreFromBundle(bundle); quantity = bundle.getInt(VALUE); }
@Override public void restoreFromBundle(Bundle bundle) { super.restoreFromBundle(bundle); hitsToDisarm = bundle.getInt(DISARMHITS); }