Skip to content

Commit

Permalink
WellOfTransmutation will change spell in SpellBook to random, cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhael-Danilov committed Jan 23, 2025
1 parent 92330eb commit 7f86d62
Show file tree
Hide file tree
Showing 6 changed files with 251 additions and 262 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,5 @@ public static Item random(Item item) {
}
return item;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

public class SpellBook extends Artifact {

@Packable()
@Packable
private String spell;

public SpellBook() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public WndFortuneTeller(FortuneTellerNPC fortuneTellerNPC, final Char hero) {

int finalUnknownItemsCount = unknownItemsCount;

RedButton btnYes = new RedButton( StringsManager.getVar(R.string.Wnd_Button_Yes) + " ( " + goldCost + " )" ) {
RedButton btnYes = new RedButton( StringsManager.getVar(R.string.Wnd_Button_Yes) + " (" + goldCost + ")" ) {
@Override
protected void onClick() {
if (finalUnknownItemsCount > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,28 @@
package com.watabou.pixeldungeon.actors.blobs;

import com.nyrds.LuaInterface;
import com.nyrds.pixeldungeon.items.Treasury;
import com.nyrds.pixeldungeon.utils.ItemsList;
import com.nyrds.platform.audio.Sample;
import com.watabou.pixeldungeon.Assets;
import com.watabou.pixeldungeon.Badges;
import com.watabou.pixeldungeon.Dungeon;
import com.watabou.pixeldungeon.Journal;
import com.watabou.pixeldungeon.Statistics;
import com.watabou.pixeldungeon.effects.BlobEmitter;
import com.watabou.pixeldungeon.effects.CellEmitter;
import com.watabou.pixeldungeon.effects.Speck;
import com.watabou.pixeldungeon.effects.Splash;
import com.watabou.pixeldungeon.items.Heap;
import com.watabou.pixeldungeon.items.Item;
import com.watabou.pixeldungeon.levels.Level;
import com.watabou.pixeldungeon.plants.Seed;
import com.watabou.utils.Random;

public class Alchemy extends Blob {

private static final int SEEDS_TO_POTION = 3;

@Override
protected void evolve() {
for (int i = 0;i<getLength();i++) {
Expand All @@ -31,9 +43,65 @@ public static void transmute( int cell ) {

Heap heap = level.getHeap( cell );
if (heap != null) {

Item result = heap.transmute();
if (result != null) {

Item result = ItemsList.DUMMY;

CellEmitter.get(heap.pos).burst(Speck.factory(Speck.BUBBLE), 3);
Splash.at(heap.pos, 0xFFFFFF, 3);

float[] chances = new float[heap.items.size()];
int count = 0;

int index = 0;
for (Item item : heap.items) {
if (item instanceof Seed) {
count += item.quantity();
chances[index++] = item.quantity();
} else {
count = 0;
break;
}
}

if (count >= SEEDS_TO_POTION) {

CellEmitter.get(heap.pos).burst(Speck.factory(Speck.WOOL), 6);
Sample.INSTANCE.play(Assets.SND_PUFF);

if (Random.Int(count) == 0) {

CellEmitter.center(heap.pos).burst(Speck.factory(Speck.EVOKE), 3);

heap.destroy();

Statistics.potionsCooked++;
Badges.validatePotionsCooked();

result = Treasury.getLevelTreasury().random(Treasury.Category.POTION);

} else {

Seed proto = (Seed) heap.items.get(Random.chances(chances));
Class<? extends Item> itemClass = proto.alchemyClass;

heap.destroy();

Statistics.potionsCooked++;
Badges.validatePotionsCooked();

if (itemClass == null) {
result = Treasury.getLevelTreasury().random(Treasury.Category.POTION);
} else {
try {
result = itemClass.newInstance();
} catch (Exception e) {

}
}
}
}

if (result.valid()) {
level.animatedDrop( result, cell );
}
}
Expand Down
Loading

0 comments on commit 7f86d62

Please sign in to comment.