public static void validateItemLevelAquired(Item item) { // This method should be called: // 1) When an item gets obtained (Item.collect) // 2) When an item gets upgraded (ScrollOfUpgrade, ScrollOfWeaponUpgrade, ShortSword, // WandOfMagicMissile) // 3) When an item gets identified if (!item.levelKnown) { return; } Badge badge = null; if (!local.contains(Badge.ITEM_LEVEL_1) && item.level() >= 3) { badge = Badge.ITEM_LEVEL_1; local.add(badge); } if (!local.contains(Badge.ITEM_LEVEL_2) && item.level() >= 6) { badge = Badge.ITEM_LEVEL_2; local.add(badge); } if (!local.contains(Badge.ITEM_LEVEL_3) && item.level() >= 9) { badge = Badge.ITEM_LEVEL_3; local.add(badge); } if (!local.contains(Badge.ITEM_LEVEL_4) && item.level() >= 12) { badge = Badge.ITEM_LEVEL_4; local.add(badge); } displayBadge(badge); }
@Override public void onOperateComplete() { if (curAction instanceof HeroAction.Unlock) { if (theKey != null) { theKey.detach(belongings.backpack); theKey = null; } int doorCell = ((HeroAction.Unlock) curAction).dst; int door = Dungeon.level.map[doorCell]; Level.set(doorCell, door == Terrain.LOCKED_DOOR ? Terrain.DOOR : Terrain.UNLOCKED_EXIT); GameScene.updateMap(doorCell); } else if (curAction instanceof HeroAction.OpenChest) { if (theKey != null) { theKey.detach(belongings.backpack); theKey = null; } Heap heap = Dungeon.level.heaps.get(((HeroAction.OpenChest) curAction).dst); if (heap.type == Type.SKELETON) { Sample.INSTANCE.play(Assets.SND_BONES); } heap.open(this); } curAction = null; super.onOperateComplete(); }
@Override protected void onThrow(int cell) { if (Dungeon.level.map[cell] == Terrain.ALCHEMY || Dungeon.level.pit[cell]) { super.onThrow(cell); } else { Dungeon.level.plant(this, cell); } }
private boolean actPickUp(HeroAction.PickUp action) { int dst = action.dst; if (pos == dst) { Heap heap = Dungeon.level.heaps.get(pos); if (heap != null) { Item item = heap.pickUp(); if (item.doPickUp(this)) { if (item instanceof Dewdrop) { } else { if ((item instanceof ScrollOfUpgrade && ((ScrollOfUpgrade) item).isKnown()) || (item instanceof PotionOfStrength && ((PotionOfStrength) item).isKnown())) { GLog.p(TXT_YOU_NOW_HAVE, item.name()); } else { GLog.i(TXT_YOU_NOW_HAVE, item.name()); } } if (!heap.isEmpty()) { GLog.i(TXT_SOMETHING_ELSE); } curAction = null; } else { Dungeon.level.drop(item, pos).sprite.drop(); ready(); } } else { ready(); } return false; } else if (getCloser(dst)) { return true; } else { ready(); return false; } }
@Override protected void onItemSelected(Item item) { ScrollOfRemoveCurse.uncurse(Dungeon.hero, item); if (item instanceof Weapon) { ((Weapon) item).enchant(); } else { ((Armor) item).inscribe(); } item.fix(); curUser.sprite.emitter().start(Speck.factory(Speck.LIGHT), 0.1f, 5); Enchanting.show(curUser, item); GLog.w(TXT_GLOWS, item.name()); }
@Override public void execute(Hero hero, String action) { if (action.equals(AC_READ)) { if (hero.buff(Blindness.class) != null) { GLog.w(TXT_BLINDED); } else { curUser = hero; curItem = detach(hero.belongings.backpack); doRead(); } } else { super.execute(hero, action); } }
@Override public void execute(Hero hero, String action) { if (action.equals(AC_PLANT)) { hero.spend(TIME_TO_PLANT); hero.busy(); ((Seed) detach(hero.belongings.backpack)).onThrow(hero.pos); hero.getSprite().operate(hero.pos); } else if (action.equals(Food.AC_EAT)) { detach(hero.belongings.backpack); hero.getSprite().operate(hero.pos); hero.busy(); SpellSprite.show(hero, SpellSprite.FOOD); Sample.INSTANCE.play(Assets.SND_EAT); hero.spend(Food.TIME_TO_EAT); } super.execute(hero, action); }