@Override public void onSelect(Item item) { if (item != null && item instanceof Scroll && item.isIdentified()) { String scroll = convertName(item.getClass().getSimpleName()); Hero hero = Dungeon.hero; for (int i = 0; (i <= 1 && i < scrolls.size()); i++) { if (scrolls.get(i).equals(scroll)) { hero.sprite.operate(hero.pos); hero.busy(); hero.spend(2f); Sample.INSTANCE.play(Assets.SND_BURNING); hero.sprite.emitter().burst(ElmoParticle.FACTORY, 12); scrolls.remove(i); item.detach(hero.belongings.backpack); upgrade(); GLog.i("You infuse the scroll's energy into the book."); return; } } if (item != null) GLog.w("You are unable to add this scroll to the book."); } else if (item instanceof Scroll && !item.isIdentified()) GLog.w("You're not sure what type of scroll this is yet."); }
@Override public void execute(Hero hero, String action) { if (action.equals(AC_READ)) { if (hero.buff(Blindness.class) != null) GLog.w("You cannot read from the book while blinded."); else if (!isEquipped(hero)) GLog.i("You need to equip your spellbook to do that."); else if (charge == 0) GLog.i("Your spellbook is out of energy for now."); else if (cursed) GLog.i("Your cannot read from a cursed spellbook."); else { charge--; Scroll scroll; do { scroll = (Scroll) Generator.random(Generator.Category.SCROLL); } while (scroll == null || // gotta reduce the rate on these scrolls or that'll be all the item does. ((scroll instanceof ScrollOfIdentify || scroll instanceof ScrollOfRemoveCurse || scroll instanceof ScrollOfMagicMapping) && Random.Int(2) == 0)); scroll.ownedByBook = true; scroll.execute(hero, AC_READ); } } else if (action.equals(AC_ADD)) { GameScene.selectItem(itemSelector, mode, inventoryTitle); } else super.execute(hero, action); }
@Override public boolean doEquip(Hero hero) { detach(hero.belongings.backpack); if (hero.belongings.armor == null || hero.belongings.armor.doUnequip(hero, true, false)) { hero.belongings.armor = this; cursedKnown = true; if (cursed) { equipCursed(hero); GLog.n(TXT_EQUIP_CURSED, toString()); } ((HeroSprite) hero.sprite).updateArmor(); hero.spendAndNext(2 * time2equip(hero)); return true; } else { collect(hero.belongings.backpack); return false; } }
@Override public void execute(final Hero hero, String action) { if (action.equals(AC_BLESS)) { DewVial vial = hero.belongings.getItem(DewVial.class); if (vial != null) { blessed = true; vial.empty(); GLog.p(TXT_BLESS); hero.spend(1f); hero.busy(); Sample.INSTANCE.play(Assets.SND_DRINK); CellEmitter.get(hero.pos).start(Speck.factory(Speck.LIGHT), 0.2f, 3); hero.sprite.operate(hero.pos); } } else { super.execute(hero, action); } }
@Override public void apply(Hero hero) { setKnown(); hero.earnExp(hero.maxExp()); }
@Override protected float time2equip(Hero hero) { return hero.speed(); }