public void submit(boolean win) { load(); Record rec = new Record(); rec.info = Dungeon.resultDescription; rec.win = win; rec.heroClass = Dungeon.hero.heroClass; rec.armorTier = Dungeon.hero.tier(); rec.herolevel = Dungeon.hero.lvl; rec.depth = Dungeon.depth; rec.score = score(win); String gameFile = Utils.format(DETAILS_FILE, SystemTime.now); try { Dungeon.saveGame(gameFile); rec.gameFile = gameFile; } catch (IOException e) { rec.gameFile = ""; } records.add(rec); Collections.sort(records, scoreComparator); lastRecord = records.indexOf(rec); int size = records.size(); while (size > TABLE_SIZE) { Record removedGame; if (lastRecord == size - 1) { removedGame = records.remove(size - 2); lastRecord--; } else { removedGame = records.remove(size - 1); } if (removedGame.gameFile.length() > 0) { Game.instance.deleteFile(removedGame.gameFile); } size = records.size(); } totalNumber++; if (win) { wonNumber++; } Badges.validateGamesPlayed(); save(); }
public boolean checkOwner(Char owner) { if (!owner.isAlive() && owner instanceof Hero) { Dungeon.fail(Utils.format(ResultDescriptions.GLYPH, name())); GLog.n("%s killed you...", name()); Badges.validateDeathFromGlyph(); return true; } else { return false; } }
public StatsTab() { super(); if (Dungeon.challenges > 0) GAP--; String heroClass = Dungeon.hero.className(); IconTitle title = new IconTitle(); title.icon(HeroSprite.avatar(Dungeon.hero.heroClass, Dungeon.hero.tier())); title.label(Utils.format(TXT_TITLE, Dungeon.hero.lvl, heroClass).toUpperCase(Locale.ENGLISH)); title.color(Window.SHPX_COLOR); title.setRect(0, 0, WIDTH, 0); add(title); float pos = title.bottom(); if (Dungeon.challenges > 0) { RedButton btnCatalogus = new RedButton(TXT_CHALLENGES) { @Override protected void onClick() { Game.scene().add(new WndChallenges(Dungeon.challenges, false)); } }; btnCatalogus.setRect(0, pos, btnCatalogus.reqWidth() + 2, btnCatalogus.reqHeight() + 2); add(btnCatalogus); pos = btnCatalogus.bottom(); } pos += GAP + GAP; pos = statSlot(this, TXT_STR, Integer.toString(Dungeon.hero.STR), pos); pos = statSlot(this, TXT_HEALTH, Integer.toString(Dungeon.hero.HT), pos); pos += GAP; pos = statSlot(this, TXT_DURATION, Integer.toString((int) Statistics.duration), pos); pos += GAP; pos = statSlot(this, TXT_DEPTH, Integer.toString(Statistics.deepestFloor), pos); pos = statSlot(this, TXT_ENEMIES, Integer.toString(Statistics.enemiesSlain), pos); pos = statSlot(this, TXT_GOLD, Integer.toString(Statistics.goldCollected), pos); pos += GAP; pos = statSlot(this, TXT_FOOD, Integer.toString(Statistics.foodEaten), pos); pos = statSlot(this, TXT_ALCHEMY, Integer.toString(Statistics.potionsCooked), pos); pos = statSlot(this, TXT_ANKHS, Integer.toString(Statistics.ankhsUsed), pos); }
@Override protected void layout() { bg.x = x; bg.y = y; slot.setRect(x, y, HEIGHT, HEIGHT); name.x = slot.right() + 2; name.y = y + (height - name.baseLine()) / 2; String str = Utils.capitalize(item.name()); name.text(str); name.measure(); if (name.width() > width - name.x) { do { str = str.substring(0, str.length() - 1); name.text(str + "..."); name.measure(); } while (name.width() > width - name.x); } super.layout(); }
@Override public String toString() { return levelKnown ? Utils.format(TXT_TO_STRING, super.toString(), STR) : super.toString(); }
@Override public String toString() { return Utils.format(TXT_FROM_DEPTH, depth); }