Search in sources :

Example 1 with Gold

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

the class Bones method get.

public static Item get() {
    if (depth == -1) {
        try {
            Bundle bundle = FileUtils.bundleFromFile(BONES_FILE);
            depth = bundle.getInt(LEVEL);
            item = (Item) bundle.get(ITEM);
            return get();
        } catch (IOException e) {
            return null;
        }
    } else {
        // heroes who are challenged cannot find bones
        if (depth == Dungeon.depth && Dungeon.challenges == 0) {
            FileUtils.deleteFile(BONES_FILE);
            depth = 0;
            // Enforces artifact uniqueness
            if (item instanceof Artifact) {
                if (Generator.removeArtifact(((Artifact) item).getClass())) {
                    try {
                        // generates a new artifact of the same type, always +0
                        Artifact artifact = (Artifact) item.getClass().newInstance();
                        artifact.cursed = true;
                        artifact.cursedKnown = true;
                        return artifact;
                    } catch (Exception e) {
                        ShatteredPixelDungeon.reportException(e);
                        return new Gold(item.price());
                    }
                } else {
                    return new Gold(item.price());
                }
            }
            if (item.isUpgradable()) {
                item.cursed = true;
                item.cursedKnown = true;
                if (item.isUpgradable()) {
                    // caps at +3
                    if (item.level() > 3) {
                        item.degrade(item.level() - 3);
                    }
                    item.levelKnown = false;
                }
            }
            item.reset();
            return item;
        } else {
            return null;
        }
    }
}
Also used : Gold(com.shatteredpixel.shatteredpixeldungeon.items.Gold) Bundle(com.watabou.utils.Bundle) IOException(java.io.IOException) Artifact(com.shatteredpixel.shatteredpixeldungeon.items.artifacts.Artifact) IOException(java.io.IOException)

Example 2 with Gold

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

the class RingOfWealth method generateRareDrop.

// TODO this is a start, but i'm sure this could be made more interesting...
private static ArrayList<Item> generateRareDrop() {
    float roll = Random.Float();
    ArrayList<Item> items = new ArrayList<>();
    if (roll < 0.6f) {
        switch(Random.Int(3)) {
            case 0:
                items.add(new Gold().random());
                break;
            case 1:
                items.add(Generator.random(Generator.Category.POTION));
                break;
            case 2:
                items.add(Generator.random(Generator.Category.SCROLL));
                break;
        }
    } else if (roll < 0.9f) {
        switch(Random.Int(3)) {
            case 0:
                items.add(Generator.random(Generator.Category.SEED));
                items.add(Generator.random(Generator.Category.SEED));
                items.add(Generator.random(Generator.Category.SEED));
                items.add(Generator.random(Generator.Category.SEED));
                items.add(Generator.random(Generator.Category.SEED));
                break;
            case 1:
                items.add(Generator.random(Random.Int(2) == 0 ? Generator.Category.POTION : Generator.Category.SCROLL));
                items.add(Generator.random(Random.Int(2) == 0 ? Generator.Category.POTION : Generator.Category.SCROLL));
                items.add(Generator.random(Random.Int(2) == 0 ? Generator.Category.POTION : Generator.Category.SCROLL));
                break;
            case 2:
                items.add(new Bomb().random());
                items.add(new Honeypot());
                break;
        }
    } else {
        Gold g = new Gold();
        g.random();
        g.quantity(g.quantity() * 5);
        items.add(g);
    }
    return items;
}
Also used : Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Gold(com.shatteredpixel.shatteredpixeldungeon.items.Gold) ArrayList(java.util.ArrayList) Bomb(com.shatteredpixel.shatteredpixeldungeon.items.Bomb) Honeypot(com.shatteredpixel.shatteredpixeldungeon.items.Honeypot)

Example 3 with Gold

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

the class GrassyGraveRoom method paint.

@Override
public void paint(Level level) {
    Painter.fill(level, this, Terrain.WALL);
    for (Door door : connected.values()) {
        door.set(Door.Type.REGULAR);
    }
    Painter.fill(level, this, 1, Terrain.GRASS);
    int w = width() - 2;
    int h = height() - 2;
    int nGraves = Math.max(w, h) / 2;
    int index = Random.Int(nGraves);
    int shift = Random.Int(2);
    for (int i = 0; i < nGraves; i++) {
        int pos = w > h ? left + 1 + shift + i * 2 + (top + 2 + Random.Int(h - 2)) * level.width() : (left + 2 + Random.Int(w - 2)) + (top + 1 + shift + i * 2) * level.width();
        level.drop(i == index ? Generator.random() : new Gold().random(), pos).type = Heap.Type.TOMB;
    }
}
Also used : Gold(com.shatteredpixel.shatteredpixeldungeon.items.Gold)

Example 4 with Gold

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

the class MassGraveRoom method paint.

public void paint(Level level) {
    Door entrance = entrance();
    entrance.set(Door.Type.BARRICADE);
    level.addItemToSpawn(new PotionOfLiquidFlame());
    Painter.fill(level, this, Terrain.WALL);
    Painter.fill(level, this, 1, Terrain.EMPTY_SP);
    Bones b = new Bones();
    b.setRect(left + 1, top, width() - 2, height() - 1);
    level.customTiles.add(b);
    // 50% 1 skeleton, 50% 2 skeletons
    for (int i = 0; i <= Random.Int(2); i++) {
        Skeleton skele = new Skeleton();
        int pos;
        do {
            pos = level.pointToCell(random());
        } while (level.map[pos] != Terrain.EMPTY_SP || level.findMob(pos) != null);
        skele.pos = pos;
        level.mobs.add(skele);
    }
    ArrayList<Item> items = new ArrayList<>();
    // 100% corpse dust, 2x100% 1 coin, 2x30% coins, 1x60% random item, 1x30% armor
    items.add(new CorpseDust());
    items.add(new Gold(1));
    items.add(new Gold(1));
    if (Random.Float() <= 0.3f)
        items.add(new Gold());
    if (Random.Float() <= 0.3f)
        items.add(new Gold());
    if (Random.Float() <= 0.6f)
        items.add(Generator.random());
    if (Random.Float() <= 0.3f)
        items.add(Generator.randomArmor());
    for (Item item : items) {
        int pos;
        do {
            pos = level.pointToCell(random());
        } while (level.map[pos] != Terrain.EMPTY_SP || level.heaps.get(pos) != null);
        Heap h = level.drop(item, pos);
        h.type = Heap.Type.SKELETON;
    }
}
Also used : Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Gold(com.shatteredpixel.shatteredpixeldungeon.items.Gold) PotionOfLiquidFlame(com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfLiquidFlame) ArrayList(java.util.ArrayList) Skeleton(com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Skeleton) Heap(com.shatteredpixel.shatteredpixeldungeon.items.Heap) CorpseDust(com.shatteredpixel.shatteredpixeldungeon.items.quest.CorpseDust)

Example 5 with Gold

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

the class RatKingRoom method addChest.

private static void addChest(Level level, int pos, int door) {
    if (pos == door - 1 || pos == door + 1 || pos == door - level.width() || pos == door + level.width()) {
        return;
    }
    Item prize = new Gold(Random.IntRange(10, 25));
    level.drop(prize, pos).type = Heap.Type.CHEST;
}
Also used : Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Gold(com.shatteredpixel.shatteredpixeldungeon.items.Gold)

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