예제 #1
0
  @Override
  public boolean doEquip(Hero hero) {

    if (hero.belongings.ring1 != null && hero.belongings.ring2 != null) {

      GLog.w(Game.getVar(R.string.Ring_Info1));
      return false;

    } else {

      if (hero.belongings.ring1 == null) {
        hero.belongings.ring1 = this;
      } else {
        hero.belongings.ring2 = this;
      }

      detach(hero.belongings.backpack);

      activate(hero);

      cursedKnown = true;
      if (cursed) {
        equipCursed(hero);
        GLog.n(String.format(Game.getVar(R.string.Ring_Info2), this));
      }

      hero.spendAndNext(Artifact.TIME_TO_EQUIP);
      return true;
    }
  }
예제 #2
0
  private static void displayBadge(Badge badge) {

    if (badge == null) {
      return;
    }

    if (global.contains(badge)) {

      if (!badge.meta) {
        GLog.h("Badge endorsed: %s", badge.description);
      }

    } else {

      global.add(badge);
      saveNeeded = true;

      if (badge.meta) {
        GLog.h("New super badge: %s", badge.description);
      } else {
        GLog.h("New badge: %s", badge.description);
      }
      PixelScene.showBadge(badge);
    }
  }
예제 #3
0
  @Override
  protected void doRead() {

    new Flare(5, 32).color(0xFF0000, true).show(curUser.sprite, 2f);
    Sample.INSTANCE.play(Assets.SND_READ);
    Invisibility.dispel();

    int count = 0;
    Mob affected = null;
    for (Mob mob : Dungeon.level.mobs.toArray(new Mob[0])) {
      if (Level.fieldOfView[mob.pos]) {
        Buff.affect(mob, Terror.class, Terror.DURATION).object = curUser.id();

        count++;
        affected = mob;
      }
    }

    switch (count) {
      case 0:
        GLog.i("The scroll emits a brilliant flash of red light");
        break;
      case 1:
        GLog.i(
            "The scroll emits a brilliant flash of red light and the " + affected.name + " flees!");
        break;
      default:
        GLog.i("The scroll emits a brilliant flash of red light and the monsters flee!");
    }
    setKnown();

    readAnimation();
  }
예제 #4
0
  protected void wandEffect(final int cell) {
    setKnown();

    QuickSlot.target(curItem, Actor.findChar(cell));

    if (curCharges > 0) {

      getCurUser().busy();

      fx(
          cell,
          new Callback() {
            @Override
            public void call() {
              onZap(cell);
              wandUsed();
            }
          });

      Invisibility.dispel(getCurUser());
    } else {

      getCurUser().spendAndNext(TIME_TO_ZAP);
      GLog.w(TXT_FIZZLES);
      levelKnown = true;

      if (Random.Int(5) == 0) {
        identify();
      }

      updateQuickslot();
    }
  }
  @Override
  public void selectKind(int kind) {
    this.kind = kind;
    JSONObject json = defMap.get(name);

    try {
      texture(json.getString("texture"));

      int width = json.getInt("width");

      TextureFilm film = new TextureFilm(texture, width, json.getInt("height"));

      bloodColor = json.optInt("bloodColor", 0xFFBB0000);
      levitating = json.optBoolean("levitating", false);
      framesInRow = texture.width / width;

      idle = readAnimation(json, "idle", film);
      run = readAnimation(json, "run", film);
      attack = readAnimation(json, "attack", film);
      die = readAnimation(json, "die", film);
      zap = attack.clone();

    } catch (Exception e) {
      GLog.w("Something bad happens when loading %s", name);
    }

    play(idle);
  }
예제 #6
0
  @Override
  public boolean doEquip(Hero hero) {

    detachAll(hero.belongings.backpack);

    if (hero.belongings.weapon == null || hero.belongings.weapon.doUnequip(hero, true)) {

      hero.belongings.weapon = this;
      activate(hero);

      QuickSlot.refresh();

      cursedKnown = true;
      if (cursed) {
        equipCursed(hero);
        GLog.n(TXT_EQUIP_CURSED, name());
      }

      hero.spendAndNext(TIME_TO_EQUIP);
      return true;

    } else {

      collect(hero.belongings.backpack);
      return false;
    }
  }
예제 #7
0
  @Override
  public boolean attack(Char enemy) {

    for (int i = 1; i < Ballistica.distance; i++) {

      int pos = Ballistica.trace[i];

      Char ch = Actor.findChar(pos);
      if (ch == null) {
        continue;
      }

      if (hit(this, ch, true)) {
        ch.damage(Random.NormalIntRange(14, 20), this);

        if (Dungeon.visible[pos]) {
          ch.getSprite().flash();
          CellEmitter.center(pos).burst(PurpleParticle.BURST, Random.IntRange(1, 2));
        }

        if (!ch.isAlive() && ch == Dungeon.hero) {
          Dungeon.fail(
              Utils.format(ResultDescriptions.MOB, Utils.indefinite(getName()), Dungeon.depth));
          GLog.n(TXT_DEATHGAZE_KILLED, getName());
        }
      } else {
        ch.getSprite().showStatus(CharSprite.NEUTRAL, ch.defenseVerb());
      }
    }

    return true;
  }
예제 #8
0
 @Override
 protected void onZap(int cell) {
   Char ch = Actor.findChar(cell);
   if (ch != null) {
     Buff.affect(ch, Poison.class).set(Poison.durationFactor(ch) * (5 + level()));
   } else {
     GLog.i(Game.getVar(R.string.WandOfPoison_Info1));
   }
 }
예제 #9
0
  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;
    }
  }
예제 #10
0
  private boolean actOpenChest(HeroAction.OpenChest action) {
    int dst = action.dst;
    if (Level.adjacent(pos, dst) || pos == dst) {

      Heap heap = Dungeon.level.heaps.get(dst);
      if (heap != null
          && (heap.type == Type.CHEST
              || heap.type == Type.TOMB
              || heap.type == Type.SKELETON
              || heap.type == Type.LOCKED_CHEST
              || heap.type == Type.CRYSTAL_CHEST)) {

        theKey = null;

        if (heap.type == Type.LOCKED_CHEST || heap.type == Type.CRYSTAL_CHEST) {

          theKey = belongings.getKey(GoldenKey.class, Dungeon.depth);

          if (theKey == null) {
            GLog.w(TXT_LOCKED_CHEST);
            ready();
            return false;
          }
        }

        switch (heap.type) {
          case TOMB:
            Sample.INSTANCE.play(Assets.SND_TOMB);
            Camera.main.shake(1, 0.5f);
            break;
          case SKELETON:
            break;
          default:
            Sample.INSTANCE.play(Assets.SND_UNLOCK);
        }

        spend(Key.TIME_TO_UNLOCK);
        sprite.operate(dst);

      } else {
        ready();
      }

      return false;

    } else if (getCloser(dst)) {

      return true;

    } else {
      ready();
      return false;
    }
  }
  @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);
  }
예제 #12
0
  public Item upgrade(boolean enchant) {
    if (enchantment != null) {
      if (!enchant && Random.Int(level) > 0) {
        GLog.w(TXT_INCOMPATIBLE);
        enchant(null);
      }
    } else {
      if (enchant) {
        enchant(Enchantment.random());
      }
    }

    return super.upgrade();
  }
예제 #13
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);
      }
    }
  }
예제 #14
0
  private void inscribeArmor(Armor armor) {

    detach(getCurUser().belongings.backpack);

    Class<? extends Armor.Glyph> oldGlyphClass =
        armor.glyph != null ? armor.glyph.getClass() : null;
    Armor.Glyph glyph = Armor.Glyph.random();
    while (glyph.getClass() == oldGlyphClass) {
      glyph = Armor.Glyph.random();
    }

    GLog.w(TXT_INSCRIBED, glyph.name(), armor.name());

    armor.inscribe(glyph);

    inscribeEffect();
  }
예제 #15
0
  @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);
    }
  }
예제 #16
0
        @Override
        public void onSelect(Integer target) {

          if (target != null) {

            if (target == getCurUser().getPos()) {
              GLog.i(TXT_SELF_TARGET);
              return;
            }

            final Wand curWand = (Wand) Wand.curItem;

            final int cell = Ballistica.cast(getCurUser().getPos(), target, true, curWand.hitChars);
            getCurUser().getSprite().zap(cell);

            curWand.wandEffect(cell);
          }
        }
  @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());
  }
예제 #18
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);
    }
  }
예제 #19
0
  private boolean actUnlock(HeroAction.Unlock action) {
    int doorCell = action.dst;
    if (Level.adjacent(pos, doorCell)) {

      theKey = null;
      int door = Dungeon.level.map[doorCell];

      if (door == Terrain.LOCKED_DOOR) {

        theKey = belongings.getKey(IronKey.class, Dungeon.depth);

      } else if (door == Terrain.LOCKED_EXIT) {

        theKey = belongings.getKey(SkeletonKey.class, Dungeon.depth);
      }

      if (theKey != null) {

        spend(Key.TIME_TO_UNLOCK);
        sprite.operate(doorCell);

        Sample.INSTANCE.play(Assets.SND_UNLOCK);

      } else {
        GLog.w(TXT_LOCKED_DOOR);
        ready();
      }

      return false;

    } else if (getCloser(doorCell)) {

      return true;

    } else {
      ready();
      return false;
    }
  }
예제 #20
0
 @Override
 protected void apply(Hero hero) {
   GLog.w(TXT_NO_SMELL);
   Buff.prolong(hero, GasesImmunity.class, GasesImmunity.DURATION);
   setKnown();
 }
예제 #21
0
 public static String uiLanguage() {
   String deviceLocale = Locale.getDefault().getLanguage();
   GLog.i("Device locale: %s", deviceLocale);
   return Preferences.INSTANCE.getString(Preferences.KEY_LOCALE, deviceLocale);
 }
예제 #22
0
 @Override
 protected void apply(Hero hero) {
   setKnown();
   heal(Dungeon.hero);
   GLog.p("Your wounds heal completely.");
 }
예제 #23
0
  @Override
  public void add(Buff buff) {
    super.add(buff);

    if (sprite != null) {
      if (buff instanceof Burning) {
        GLog.w("You catch fire!");
        interrupt();
      } else if (buff instanceof Paralysis) {
        GLog.w("You are paralysed!");
        interrupt();
      } else if (buff instanceof Poison) {
        GLog.w("You are poisoned!");
        interrupt();
      } else if (buff instanceof Ooze) {
        GLog.w("Caustic ooze eats your flesh. Wash away it!");
      } else if (buff instanceof Roots) {
        GLog.w("You can't move!");
      } else if (buff instanceof Weakness) {
        GLog.w("You feel weakened!");
      } else if (buff instanceof Blindness) {
        GLog.w("You are blinded!");
      } else if (buff instanceof Fury) {
        GLog.w("You become furious!");
        sprite.showStatus(CharSprite.POSITIVE, "furious");
      } else if (buff instanceof Charm) {
        GLog.w("You are charmed!");
      } else if (buff instanceof Cripple) {
        GLog.w("You are crippled!");
      } else if (buff instanceof Bleeding) {
        GLog.w("You are bleeding!");
      } else if (buff instanceof Vertigo) {
        GLog.w("Everything is spinning around you!");
        interrupt();
      } else if (buff instanceof Light) {
        sprite.add(CharSprite.State.ILLUMINATED);
      }
    }

    BuffIndicator.refreshHero();
  }
예제 #24
0
  public boolean search(boolean intentional) {

    boolean smthFound = false;

    int positive = 0;
    int negative = 0;
    for (Buff buff : buffs(RingOfDetection.Detection.class)) {
      int bonus = ((RingOfDetection.Detection) buff).level;
      if (bonus > positive) {
        positive = bonus;
      } else if (bonus < 0) {
        negative += bonus;
      }
    }
    int distance = 1 + positive + negative;

    float level = intentional ? (2 * awareness - awareness * awareness) : awareness;
    if (distance <= 0) {
      level /= 2 - distance;
      distance = 1;
    }

    int cx = pos % Level.WIDTH;
    int cy = pos / Level.WIDTH;
    int ax = cx - distance;
    if (ax < 0) {
      ax = 0;
    }
    int bx = cx + distance;
    if (bx >= Level.WIDTH) {
      bx = Level.WIDTH - 1;
    }
    int ay = cy - distance;
    if (ay < 0) {
      ay = 0;
    }
    int by = cy + distance;
    if (by >= Level.HEIGHT) {
      by = Level.HEIGHT - 1;
    }

    for (int y = ay; y <= by; y++) {
      for (int x = ax, p = ax + y * Level.WIDTH; x <= bx; x++, p++) {

        if (Dungeon.visible[p]) {

          if (intentional) {
            sprite.parent.addToBack(new CheckedCell(p));
          }

          if (Level.secret[p] && (intentional || Random.Float() < level)) {

            int oldValue = Dungeon.level.map[p];

            GameScene.discoverTile(p, oldValue);

            Level.set(p, Terrain.discover(oldValue));

            GameScene.updateMap(p);

            ScrollOfMagicMapping.discover(p);

            smthFound = true;
          }
        }
      }
    }

    if (intentional) {
      sprite.showStatus(CharSprite.DEFAULT, TXT_SEARCH);
      sprite.operate(pos);
      if (smthFound) {
        spendAndNext(Random.Float() < level ? TIME_TO_SEARCH : TIME_TO_SEARCH * 2);
      } else {
        spendAndNext(TIME_TO_SEARCH);
      }
    }

    if (smthFound) {
      GLog.w(TXT_NOTICED_SMTH);
      Sample.INSTANCE.play(Assets.SND_SECRET);
      interrupt();
    }

    return smthFound;
  }
예제 #25
0
  @Override
  public void shatter(int cell) {

    PathFinder.buildDistanceMap(cell, BArray.not(Level.losBlocking, null), DISTANCE);

    boolean procd = false;

    Blob[] blobs = {
      Dungeon.level.blobs.get(ToxicGas.class), Dungeon.level.blobs.get(ParalyticGas.class)
    };

    for (int j = 0; j < blobs.length; j++) {

      Blob blob = blobs[j];
      if (blob == null) {
        continue;
      }

      for (int i = 0; i < Level.LENGTH; i++) {
        if (PathFinder.distance[i] < Integer.MAX_VALUE) {

          int value = blob.cur[i];
          if (value > 0) {

            blob.cur[i] = 0;
            blob.volume -= value;
            procd = true;

            if (Dungeon.visible[i]) {
              CellEmitter.get(i).burst(Speck.factory(Speck.DISCOVER), 1);
            }
          }
        }
      }
    }

    boolean heroAffected = PathFinder.distance[Dungeon.hero.pos] < Integer.MAX_VALUE;

    if (procd) {

      if (Dungeon.visible[cell]) {
        splash(cell);
        Sample.INSTANCE.play(Assets.SND_SHATTER);
      }

      setKnown();

      if (heroAffected) {
        GLog.p(TXT_FRESHNESS);
      }

    } else {

      super.shatter(cell);

      if (heroAffected) {
        GLog.i(TXT_FRESHNESS);
        setKnown();
      }
    }
  }