Search in sources :

Example 1 with Gold

use of com.watabou.pixeldungeon.items.Gold in project pixel-dungeon by watabou.

the class Level method drop.

public Heap drop(Item item, int cell) {
    if (Dungeon.isChallenged(Challenges.NO_FOOD) && item instanceof Food) {
        item = new Gold(item.price());
    } else if (Dungeon.isChallenged(Challenges.NO_ARMOR) && item instanceof Armor) {
        item = new Gold(item.price());
    } else if (Dungeon.isChallenged(Challenges.NO_HEALING) && item instanceof PotionOfHealing) {
        item = new Gold(item.price());
    } else if (Dungeon.isChallenged(Challenges.NO_HERBALISM) && item instanceof SeedPouch) {
        item = new Gold(item.price());
    } else if (Dungeon.isChallenged(Challenges.NO_SCROLLS) && (item instanceof Scroll || item instanceof ScrollHolder)) {
        if (item instanceof ScrollOfUpgrade) {
        // These scrolls still can be found
        } else {
            item = new Gold(item.price());
        }
    }
    if ((map[cell] == Terrain.ALCHEMY) && !(item instanceof Plant.Seed)) {
        int n;
        do {
            n = cell + NEIGHBOURS8[Random.Int(8)];
        } while (map[n] != Terrain.EMPTY_SP);
        cell = n;
    }
    Heap heap = heaps.get(cell);
    if (heap == null) {
        heap = new Heap();
        heap.pos = cell;
        if (map[cell] == Terrain.CHASM || (Dungeon.level != null && pit[cell])) {
            Dungeon.dropToChasm(item);
            GameScene.discard(heap);
        } else {
            heaps.put(cell, heap);
            GameScene.add(heap);
        }
    } else if (heap.type == Heap.Type.LOCKED_CHEST || heap.type == Heap.Type.CRYSTAL_CHEST) {
        int n;
        do {
            n = cell + Level.NEIGHBOURS8[Random.Int(8)];
        } while (!Level.passable[n] && !Level.avoid[n]);
        return drop(item, n);
    }
    heap.drop(item);
    if (Dungeon.level != null) {
        press(cell, null);
    }
    return heap;
}
Also used : Gold(com.watabou.pixeldungeon.items.Gold) Plant(com.watabou.pixeldungeon.plants.Plant) Armor(com.watabou.pixeldungeon.items.armor.Armor) SeedPouch(com.watabou.pixeldungeon.items.bags.SeedPouch) Scroll(com.watabou.pixeldungeon.items.scrolls.Scroll) PotionOfHealing(com.watabou.pixeldungeon.items.potions.PotionOfHealing) ScrollHolder(com.watabou.pixeldungeon.items.bags.ScrollHolder) ScrollOfUpgrade(com.watabou.pixeldungeon.items.scrolls.ScrollOfUpgrade) Heap(com.watabou.pixeldungeon.items.Heap) Food(com.watabou.pixeldungeon.items.food.Food)

Example 2 with Gold

use of com.watabou.pixeldungeon.items.Gold in project pixel-dungeon by watabou.

the class RatKingPainter 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;
    switch(Random.Int(10)) {
        case 0:
            prize = Generator.random(Generator.Category.WEAPON);
            if (prize instanceof MissileWeapon) {
                prize.quantity(1);
            } else {
                prize.degrade(Random.Int(3));
            }
            break;
        case 1:
            prize = Generator.random(Generator.Category.ARMOR).degrade(Random.Int(3));
            break;
        default:
            prize = new Gold(Random.IntRange(1, 5));
            break;
    }
    level.drop(prize, pos).type = Heap.Type.CHEST;
}
Also used : Item(com.watabou.pixeldungeon.items.Item) Gold(com.watabou.pixeldungeon.items.Gold) MissileWeapon(com.watabou.pixeldungeon.items.weapon.missiles.MissileWeapon)

Example 3 with Gold

use of com.watabou.pixeldungeon.items.Gold in project pixel-dungeon by watabou.

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);
    int price = item.price();
    new Gold(price).doPickUp(hero);
    GLog.i(TXT_SOLD, item.name(), price);
}
Also used : Gold(com.watabou.pixeldungeon.items.Gold) Hero(com.watabou.pixeldungeon.actors.hero.Hero) EquipableItem(com.watabou.pixeldungeon.items.EquipableItem)

Example 4 with Gold

use of com.watabou.pixeldungeon.items.Gold in project pixel-dungeon by watabou.

the class Mimic method attackProc.

@Override
public int attackProc(Char enemy, int damage) {
    if (enemy == Dungeon.hero && Random.Int(3) == 0) {
        Gold gold = new Gold(Random.Int(Dungeon.gold / 10, Dungeon.gold / 2));
        if (gold.quantity() > 0) {
            Dungeon.gold -= gold.quantity();
            Dungeon.level.drop(gold, Dungeon.hero.pos).sprite.drop();
        }
    }
    return super.attackProc(enemy, damage);
}
Also used : Gold(com.watabou.pixeldungeon.items.Gold)

Example 5 with Gold

use of com.watabou.pixeldungeon.items.Gold in project pixel-dungeon by watabou.

the class Bones method leave.

public static void leave() {
    item = null;
    switch(Random.Int(4)) {
        case 0:
            item = Dungeon.hero.belongings.weapon;
            break;
        case 1:
            item = Dungeon.hero.belongings.armor;
            break;
        case 2:
            item = Dungeon.hero.belongings.ring1;
            break;
        case 3:
            item = Dungeon.hero.belongings.ring2;
            break;
    }
    if (item == null) {
        if (Dungeon.gold > 0) {
            item = new Gold(Random.IntRange(1, Dungeon.gold));
        } else {
            item = new Gold(1);
        }
    }
    depth = Dungeon.depth;
    Bundle bundle = new Bundle();
    bundle.put(LEVEL, depth);
    bundle.put(ITEM, item);
    try {
        OutputStream output = Game.instance.openFileOutput(BONES_FILE, Game.MODE_PRIVATE);
        Bundle.write(bundle, output);
        output.close();
    } catch (IOException e) {
    }
}
Also used : Gold(com.watabou.pixeldungeon.items.Gold) Bundle(com.watabou.utils.Bundle) OutputStream(java.io.OutputStream) IOException(java.io.IOException)

Aggregations

Gold (com.watabou.pixeldungeon.items.Gold)9 Hero (com.watabou.pixeldungeon.actors.hero.Hero)2 Heap (com.watabou.pixeldungeon.items.Heap)2 Item (com.watabou.pixeldungeon.items.Item)2 Belongings (com.watabou.pixeldungeon.actors.hero.Belongings)1 EquipableItem (com.watabou.pixeldungeon.items.EquipableItem)1 Armor (com.watabou.pixeldungeon.items.armor.Armor)1 ScrollHolder (com.watabou.pixeldungeon.items.bags.ScrollHolder)1 SeedPouch (com.watabou.pixeldungeon.items.bags.SeedPouch)1 Food (com.watabou.pixeldungeon.items.food.Food)1 IronKey (com.watabou.pixeldungeon.items.keys.IronKey)1 PotionOfHealing (com.watabou.pixeldungeon.items.potions.PotionOfHealing)1 Scroll (com.watabou.pixeldungeon.items.scrolls.Scroll)1 ScrollOfUpgrade (com.watabou.pixeldungeon.items.scrolls.ScrollOfUpgrade)1 MissileWeapon (com.watabou.pixeldungeon.items.weapon.missiles.MissileWeapon)1 Plant (com.watabou.pixeldungeon.plants.Plant)1 Bundle (com.watabou.utils.Bundle)1 Point (com.watabou.utils.Point)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1