Search in sources :

Example 6 with Gold

use of com.shatteredpixel.shatteredpixeldungeon.items.Gold in project shattered-pixel-dungeon-gdx by 00-Evan.

the class CryptRoom method prize.

private static Item prize(Level level) {
    // 1 floor set higher than normal
    Armor prize = Generator.randomArmor((Dungeon.depth / 5) + 1);
    if (Challenges.isItemBlocked(prize)) {
        return new Gold().random();
    }
    // if it isn't already cursed, give it a free upgrade
    if (!prize.cursed) {
        prize.upgrade();
        // curse the armor, unless it has a glyph
        if (!prize.hasGoodGlyph()) {
            prize.cursed = prize.cursedKnown = true;
            prize.inscribe(Armor.Glyph.randomCurse());
        }
    }
    return prize;
}
Also used : Gold(com.shatteredpixel.shatteredpixeldungeon.items.Gold) Armor(com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor)

Example 7 with Gold

use of com.shatteredpixel.shatteredpixeldungeon.items.Gold in project shattered-pixel-dungeon-gdx by 00-Evan.

the class WndTradeItem method sell.

private void sell(Item item) {
    Hero hero = Dungeon.hero;
    if (item.isEquipped(hero) && !((EquipableItem) item).doUnequip(hero, false)) {
        return;
    }
    item.detachAll(hero.belongings.backpack);
    new Gold(item.price()).doPickUp(hero);
    // selling items in the sell interface doesn't spend time
    hero.spend(-hero.cooldown());
}
Also used : Gold(com.shatteredpixel.shatteredpixeldungeon.items.Gold) Hero(com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero) EquipableItem(com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem)

Example 8 with Gold

use of com.shatteredpixel.shatteredpixeldungeon.items.Gold in project shattered-pixel-dungeon-gdx by 00-Evan.

the class Bones method pickItem.

private static Item pickItem(Hero hero) {
    Item item = null;
    if (Random.Int(3) != 0) {
        switch(Random.Int(6)) {
            case 0:
                item = hero.belongings.weapon;
                break;
            case 1:
                item = hero.belongings.armor;
                break;
            case 2:
                item = hero.belongings.misc1;
                break;
            case 3:
                item = hero.belongings.misc2;
                break;
            case 4:
            case 5:
                item = Dungeon.quickslot.randomNonePlaceholder();
                break;
        }
        if (item == null || !item.bones) {
            return pickItem(hero);
        }
    } else {
        Iterator<Item> iterator = hero.belongings.backpack.iterator();
        Item curItem;
        ArrayList<Item> items = new ArrayList<Item>();
        while (iterator.hasNext()) {
            curItem = iterator.next();
            if (curItem.bones)
                items.add(curItem);
        }
        if (Random.Int(3) < items.size()) {
            item = Random.element(items);
            if (item.stackable) {
                item.quantity(Random.NormalIntRange(1, (item.quantity() + 1) / 2));
            }
        } else {
            if (Dungeon.gold > 100) {
                item = new Gold(Random.NormalIntRange(50, Dungeon.gold / 2));
            } else {
                item = new Gold(50);
            }
        }
    }
    return item;
}
Also used : Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Gold(com.shatteredpixel.shatteredpixeldungeon.items.Gold) ArrayList(java.util.ArrayList)

Example 9 with Gold

use of com.shatteredpixel.shatteredpixeldungeon.items.Gold in project shattered-pixel-dungeon-gdx by 00-Evan.

the class Mimic method spawnAt.

public static Mimic spawnAt(int pos, List<Item> items) {
    if (Dungeon.level.pit[pos])
        return null;
    Char ch = Actor.findChar(pos);
    if (ch != null) {
        ArrayList<Integer> candidates = new ArrayList<>();
        for (int n : PathFinder.NEIGHBOURS8) {
            int cell = pos + n;
            if ((Dungeon.level.passable[cell] || Dungeon.level.avoid[cell]) && Actor.findChar(cell) == null) {
                candidates.add(cell);
            }
        }
        if (candidates.size() > 0) {
            int newPos = Random.element(candidates);
            Actor.addDelayed(new Pushing(ch, ch.pos, newPos), -1);
            ch.pos = newPos;
            Dungeon.level.press(newPos, ch);
        } else {
            return null;
        }
    }
    Mimic m = new Mimic();
    m.items = new ArrayList<>(items);
    m.adjustStats(Dungeon.depth);
    m.pos = pos;
    m.state = m.HUNTING;
    GameScene.add(m, 1);
    m.sprite.turnTo(pos, Dungeon.hero.pos);
    if (Dungeon.level.heroFOV[m.pos]) {
        CellEmitter.get(pos).burst(Speck.factory(Speck.STAR), 10);
        Sample.INSTANCE.play(Assets.SND_MIMIC);
    }
    // generate an extra reward for killing the mimic
    Item reward = null;
    do {
        switch(Random.Int(5)) {
            case 0:
                reward = new Gold().random();
                break;
            case 1:
                reward = Generator.randomMissile();
                break;
            case 2:
                reward = Generator.randomArmor();
                break;
            case 3:
                reward = Generator.randomWeapon();
                break;
            case 4:
                reward = Generator.random(Generator.Category.RING);
                break;
        }
    } while (reward == null || Challenges.isItemBlocked(reward));
    m.items.add(reward);
    return m;
}
Also used : Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Gold(com.shatteredpixel.shatteredpixeldungeon.items.Gold) Char(com.shatteredpixel.shatteredpixeldungeon.actors.Char) Pushing(com.shatteredpixel.shatteredpixeldungeon.effects.Pushing) ArrayList(java.util.ArrayList)

Example 10 with Gold

use of com.shatteredpixel.shatteredpixeldungeon.items.Gold in project shattered-pixel-dungeon-gdx by 00-Evan.

the class SecretHoardRoom method paint.

@Override
public void paint(Level level) {
    super.paint(level);
    Painter.fill(level, this, Terrain.WALL);
    Painter.fill(level, this, 1, Terrain.EMPTY);
    Class<? extends Trap> trapClass;
    if (Random.Int(2) == 0) {
        trapClass = RockfallTrap.class;
    } else if (Dungeon.depth >= 10) {
        trapClass = DisintegrationTrap.class;
    } else {
        trapClass = PoisonDartTrap.class;
    }
    int goldPos;
    // half of the internal space of the room
    int totalGold = ((width() - 2) * (height() - 2)) / 2;
    // no matter how much gold it drops, roughly equals 8 gold stacks.
    float goldRatio = 8 / (float) totalGold;
    for (int i = 0; i < totalGold; i++) {
        do {
            goldPos = level.pointToCell(random());
        } while (level.heaps.get(goldPos) != null);
        Item gold = new Gold().random();
        gold.quantity(Math.round(gold.quantity() * goldRatio));
        level.drop(gold, goldPos);
    }
    for (Point p : getPoints()) {
        if (Random.Int(2) == 0 && level.map[level.pointToCell(p)] == Terrain.EMPTY) {
            try {
                level.setTrap(trapClass.newInstance().reveal(), level.pointToCell(p));
                Painter.set(level, p, Terrain.TRAP);
            } catch (Exception e) {
                ShatteredPixelDungeon.reportException(e);
            }
        }
    }
    entrance().set(Door.Type.HIDDEN);
}
Also used : Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Gold(com.shatteredpixel.shatteredpixeldungeon.items.Gold) DisintegrationTrap(com.shatteredpixel.shatteredpixeldungeon.levels.traps.DisintegrationTrap) PoisonDartTrap(com.shatteredpixel.shatteredpixeldungeon.levels.traps.PoisonDartTrap) Point(com.watabou.utils.Point) Point(com.watabou.utils.Point)

Aggregations

Gold (com.shatteredpixel.shatteredpixeldungeon.items.Gold)13 Item (com.shatteredpixel.shatteredpixeldungeon.items.Item)7 ArrayList (java.util.ArrayList)4 Hero (com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero)2 Heap (com.shatteredpixel.shatteredpixeldungeon.items.Heap)2 Char (com.shatteredpixel.shatteredpixeldungeon.actors.Char)1 Skeleton (com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Skeleton)1 Pushing (com.shatteredpixel.shatteredpixeldungeon.effects.Pushing)1 Bomb (com.shatteredpixel.shatteredpixeldungeon.items.Bomb)1 EquipableItem (com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem)1 Honeypot (com.shatteredpixel.shatteredpixeldungeon.items.Honeypot)1 Armor (com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor)1 Artifact (com.shatteredpixel.shatteredpixeldungeon.items.artifacts.Artifact)1 IronKey (com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey)1 PotionOfLiquidFlame (com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfLiquidFlame)1 CorpseDust (com.shatteredpixel.shatteredpixeldungeon.items.quest.CorpseDust)1 DisintegrationTrap (com.shatteredpixel.shatteredpixeldungeon.levels.traps.DisintegrationTrap)1 PoisonDartTrap (com.shatteredpixel.shatteredpixeldungeon.levels.traps.PoisonDartTrap)1 Bundle (com.watabou.utils.Bundle)1 Point (com.watabou.utils.Point)1