예제 #1
0
 @Override
 public boolean doPickUp(Hero hero) {
   identify();
   Badges.validateRingOfHaggler();
   Badges.validateItemLevelAquired(this);
   return super.doPickUp(hero);
 }
예제 #2
0
  @Override
  public void die(Object cause) {

    Badges.Badge badgeToCheck = null;
    switch (Dungeon.hero.heroClass) {
      case WARRIOR:
        badgeToCheck = Badge.MASTERY_WARRIOR;
        break;
      case MAGE:
        badgeToCheck = Badge.MASTERY_MAGE;
        break;
      case ROGUE:
        badgeToCheck = Badge.MASTERY_ROGUE;
        break;
      case HUNTRESS:
        badgeToCheck = Badge.MASTERY_HUNTRESS;
        break;
    }
    if (!Badges.isUnlocked(badgeToCheck) || Dungeon.hero.subClass != HeroSubClass.NONE) {
      Dungeon.level.drop(new TomeOfMastery(), pos).sprite.drop();
    }

    GameScene.bossSlain();
    Dungeon.level.drop(new SkeletonKey(), pos).sprite.drop();
    super.die(cause);

    Badges.validateBossSlain();

    yell(Game.getVar(R.string.Tengu_Info1));
  }
예제 #3
0
  public void setKnown() {
    if (!isKnown()) {
      handler.know(this);
    }

    Badges.validateAllWandsIdentified();
  }
예제 #4
0
  public static void win(String desc) {

    if (challenges != 0) {
      Badges.validateChampion();
    }

    resultDescription = desc;
    Rankings.INSTANCE.submit(true);
  }
예제 #5
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);
    }
  }
예제 #6
0
  public void setDonationLevel(int level) {
    if (level < donated()) {
      return;
    }

    if (donated() == 0 && level != 0) {
      Sample.INSTANCE.play(Assets.SND_GOLD);
      Badges.validateSupporter();
    }
    donated(level);
  }
  @Override
  protected void onItemSelected(Item item) {

    Weapon weapon = (Weapon) item;

    ScrollOfRemoveCurse.uncurse(Dungeon.hero, weapon);
    weapon.upgrade(true);

    GLog.p(TXT_LOOKS_BETTER, weapon.name());

    Badges.validateItemLevelAquired(weapon);

    curUser.sprite.emitter().start(Speck.factory(Speck.UP), 0.2f, 3);
  }
예제 #8
0
  @Override
  public boolean doPickUp(Hero hero) {

    Dungeon.gold += quantity;
    Statistics.goldCollected += quantity;
    Badges.validateGoldCollected();

    GameScene.pickUp(this);
    hero.sprite.showStatus(CharSprite.NEUTRAL, TXT_VALUE, quantity);
    hero.spendAndNext(TIME_TO_PICK_UP);

    Sample.INSTANCE.play(Assets.SND_GOLD, 1, 1, Random.Float(0.9f, 1.1f));

    return true;
  }
예제 #9
0
  @Override
  public void proc(Char attacker, Char defender, int damage) {

    if (enchantment != null) {
      enchantment.proc(this, attacker, defender, damage);
    }

    if (!levelKnown) {
      if (--hitsToKnow <= 0) {
        levelKnown = true;
        GLog.i(TXT_IDENTIFY, name(), toString());
        Badges.validateItemLevelAquired(this);
      }
    }
  }
예제 #10
0
  @Override
  public boolean doPickUp(Hero hero) {
    if (super.doPickUp(hero)) {

      if (!Statistics.amuletObtained) {
        Statistics.amuletObtained = true;
        Badges.validateVictory();

        showAmuletScene(true);
      }

      return true;
    } else {
      return false;
    }
  }
예제 #11
0
  public void earnExp(int exp) {

    this.exp += exp;

    boolean levelUp = false;
    while (this.exp >= maxExp()) {
      this.exp -= maxExp();
      lvl++;

      HT += 5;
      HP += 5;
      attackSkill++;
      defenseSkill++;

      if (lvl < 10) {
        updateAwareness();
      }

      levelUp = true;
    }

    if (levelUp) {

      GLog.p(TXT_NEW_LEVEL, lvl);
      sprite.showStatus(CharSprite.POSITIVE, TXT_LEVEL_UP);
      Sample.INSTANCE.play(Assets.SND_LEVELUP);

      Badges.validateLevelReached();
    }

    if (subClass == HeroSubClass.WARLOCK) {

      int value = Math.min(HT - HP, 1 + (Dungeon.depth - 1) / 5);
      if (value > 0) {
        HP += value;
        sprite.emitter().burst(Speck.factory(Speck.HEALING), 1);
      }

      ((Hunger) buff(Hunger.class)).satisfy(10);
    }
  }
예제 #12
0
  public static void init() {

    challenges = PixelDungeon.challenges();

    Actor.clear();

    PathFinder.setMapSize(Level.WIDTH, Level.HEIGHT);

    Scroll.initLabels();
    Potion.initColors();
    Wand.initWoods();
    Ring.initGems();

    Statistics.reset();
    Journal.reset();

    depth = 0;
    gold = 0;

    potionOfStrength = 0;
    scrollsOfUpgrade = 0;
    arcaneStyli = 0;
    dewVial = true;
    transmutation = Random.IntRange(6, 14);

    chapters = new HashSet<Integer>();

    Ghost.Quest.reset();
    WandMaker.Quest.reset();
    Blacksmith.Quest.reset();
    Imp.Quest.reset();

    Room.shuffleTypes();

    hero = new Hero();
    hero.live();

    Badges.reset();

    StartScene.curClass.initHero(hero);
  }
예제 #13
0
  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);
  }