From 75c09c837ea6eea6f285de7f4555c451d3e66af4 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Mon, 10 Feb 2025 14:18:03 -0500 Subject: [PATCH] v3.0.0: adjusted wealth drop tracking to not be tied to each ring --- .../items/rings/RingOfWealth.java | 63 +++++++------------ 1 file changed, 22 insertions(+), 41 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfWealth.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfWealth.java index 476a3262f..749599446 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfWealth.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfWealth.java @@ -24,6 +24,7 @@ package com.shatteredpixel.shatteredpixeldungeon.items.rings; import com.shatteredpixel.shatteredpixeldungeon.Challenges; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; +import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.CounterBuff; import com.shatteredpixel.shatteredpixeldungeon.effects.Flare; import com.shatteredpixel.shatteredpixeldungeon.items.Generator; import com.shatteredpixel.shatteredpixeldungeon.items.Gold; @@ -50,7 +51,6 @@ import com.watabou.utils.Random; import com.watabou.utils.Reflection; import java.util.ArrayList; -import java.util.HashSet; public class RingOfWealth extends Ring { @@ -111,31 +111,23 @@ public class RingOfWealth extends Ring { int bonus = getBuffedBonus(target, Wealth.class); if (bonus <= 0) return null; - - HashSet buffs = target.buffs(Wealth.class); - float triesToDrop = Float.MIN_VALUE; - int dropsToEquip = Integer.MIN_VALUE; - - //find the largest count (if they aren't synced yet) - for (Wealth w : buffs){ - if (w.triesToDrop() > triesToDrop){ - triesToDrop = w.triesToDrop(); - dropsToEquip = w.dropsToRare(); - } + + CounterBuff triesToDrop = target.buff(TriesToDropTracker.class); + if (triesToDrop.count() == 0){ + triesToDrop.countUp( Random.NormalIntRange(0, 20) ); } - //reset (if needed), decrement, and store counts - if (triesToDrop == Float.MIN_VALUE) { - triesToDrop = Random.NormalIntRange(0, 20); - dropsToEquip = Random.NormalIntRange(5, 10); + CounterBuff dropsToEquip = target.buff(DropsToEquipTracker.class); + if (dropsToEquip.count() == 0){ + dropsToEquip.countUp( Random.NormalIntRange(5, 10) ); } //now handle reward logic ArrayList drops = new ArrayList<>(); - triesToDrop -= tries; - while ( triesToDrop <= 0 ){ - if (dropsToEquip <= 0){ + triesToDrop.countDown(tries); + while ( triesToDrop.count() <= 0 ){ + if (dropsToEquip.count() <= 0){ int equipBonus = 0; //A second ring of wealth can be at most +1 when calculating wealth bonus for equips @@ -154,22 +146,16 @@ public class RingOfWealth extends Ring { i = genEquipmentDrop(equipBonus - 1); } while (Challenges.isItemBlocked(i)); drops.add(i); - dropsToEquip = Random.NormalIntRange(5, 10); + dropsToEquip.countUp(Random.NormalIntRange(5, 10)); } else { Item i; do { i = genConsumableDrop(bonus - 1); } while (Challenges.isItemBlocked(i)); drops.add(i); - dropsToEquip--; + dropsToEquip.countDown(1); } - triesToDrop += Random.NormalIntRange(0, 20); - } - - //store values back into rings - for (Wealth w : buffs){ - w.triesToDrop(triesToDrop); - w.dropsToRare(dropsToEquip); + triesToDrop.countUp( Random.NormalIntRange(0, 20) ); } return drops; @@ -320,22 +306,17 @@ public class RingOfWealth extends Ring { } public class Wealth extends RingBuff { - - private void triesToDrop( float val ){ - triesToDrop = val; - } - - private float triesToDrop(){ - return triesToDrop; - } + } - private void dropsToRare( int val ) { - dropsToRare = val; + public static class TriesToDropTracker extends CounterBuff { + { + revivePersists = true; } + } - private int dropsToRare(){ - return dropsToRare; + public static class DropsToEquipTracker extends CounterBuff { + { + revivePersists = true; } - } }