v0.9.4: refactored transmuting a bit, fixed transmuted wand errors

This commit is contained in:
Evan Debenham 2021-08-14 17:21:07 -04:00
parent b08f3479c1
commit 8d0630a607
3 changed files with 40 additions and 200 deletions

View File

@ -33,6 +33,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfStrength;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.Ring;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTransmutation;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfUpgrade;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
@ -50,25 +51,7 @@ public class WaterOfTransmutation extends WellWater {
@Override
protected Item affectItem( Item item, int pos ) {
if (item instanceof MagesStaff) {
item = changeStaff( (MagesStaff)item );
} else if (item instanceof MeleeWeapon) {
item = changeWeapon( (MeleeWeapon)item );
} else if (item instanceof Scroll) {
item = changeScroll( (Scroll)item );
} else if (item instanceof Potion) {
item = changePotion( (Potion)item );
} else if (item instanceof Ring) {
item = changeRing( (Ring)item );
} else if (item instanceof Wand) {
item = changeWand( (Wand)item );
} else if (item instanceof Plant.Seed) {
item = changeSeed( (Plant.Seed)item );
} else if (item instanceof Artifact) {
item = changeArtifact( (Artifact)item );
} else {
item = null;
}
item = ScrollOfTransmutation.changeItem(item);
//incase a never-seen item pops out
if (item != null&& item.isIdentified()){
@ -94,153 +77,6 @@ public class WaterOfTransmutation extends WellWater {
protected Landmark record() {
return Landmark.WELL_OF_TRANSMUTATION;
}
private MagesStaff changeStaff( MagesStaff staff ){
Class<?extends Wand> wandClass = staff.wandClass();
if (wandClass == null){
return null;
} else {
Wand n;
do {
n = (Wand)Generator.random(Category.WAND);
} while (Challenges.isItemBlocked(n) || n.getClass() == wandClass);
n.level(0);
n.identify();
staff.imbueWand(n, null);
}
return staff;
}
private Weapon changeWeapon( MeleeWeapon w ) {
Weapon n;
Category c = Generator.wepTiers[w.tier-1];
do {
n = (MeleeWeapon)Reflection.newInstance(c.classes[Random.chances(c.probs)]);
} while (Challenges.isItemBlocked(n) || n.getClass() == w.getClass());
int level = w.level();
if (w.curseInfusionBonus) level--;
if (level > 0) {
n.upgrade( level );
} else if (level < 0) {
n.degrade( -level );
}
n.enchantment = w.enchantment;
n.curseInfusionBonus = w.curseInfusionBonus;
n.levelKnown = w.levelKnown;
n.cursedKnown = w.cursedKnown;
n.cursed = w.cursed;
n.augment = w.augment;
return n;
}
private Ring changeRing( Ring r ) {
Ring n;
do {
n = (Ring)Generator.random( Category.RING );
} while (Challenges.isItemBlocked(n) || n.getClass() == r.getClass());
n.level(0);
int level = r.level();
if (level > 0) {
n.upgrade( level );
} else if (level < 0) {
n.degrade( -level );
}
n.levelKnown = r.levelKnown;
n.cursedKnown = r.cursedKnown;
n.cursed = r.cursed;
return n;
}
private Artifact changeArtifact( Artifact a ) {
Artifact n = Generator.randomArtifact();
if (n != null && !Challenges.isItemBlocked(n)){
n.cursedKnown = a.cursedKnown;
n.cursed = a.cursed;
n.levelKnown = a.levelKnown;
n.transferUpgrade(a.visiblyUpgraded());
return n;
}
return null;
}
private Wand changeWand( Wand w ) {
Wand n;
do {
n = (Wand)Generator.random( Category.WAND );
} while ( Challenges.isItemBlocked(n) || n.getClass() == w.getClass());
n.level( 0 );
int level = w.level();
if (w.curseInfusionBonus) level--;
level -= w.resinBonus;
n.upgrade( level );
n.levelKnown = w.levelKnown;
n.cursedKnown = w.cursedKnown;
n.cursed = w.cursed;
n.curseInfusionBonus = w.curseInfusionBonus;
n.resinBonus = w.resinBonus;
n.updateLevel();
return n;
}
private Plant.Seed changeSeed( Plant.Seed s ) {
Plant.Seed n;
do {
n = (Plant.Seed)Generator.random( Category.SEED );
} while (n.getClass() == s.getClass());
return n;
}
private Scroll changeScroll( Scroll s ) {
if (s instanceof ScrollOfUpgrade) {
return null;
} else {
Scroll n;
do {
n = (Scroll)Generator.random( Category.SCROLL );
} while (n.getClass() == s.getClass());
return n;
}
}
private Potion changePotion( Potion p ) {
if (p instanceof PotionOfStrength) {
return null;
} else {
Potion n;
do {
n = (Potion)Generator.random( Category.POTION );
} while (n.getClass() == p.getClass());
return n;
}
}
@Override
public String tileDesc() {

View File

@ -75,29 +75,7 @@ public class ScrollOfTransmutation extends InventoryScroll {
@Override
protected void onItemSelected(Item item) {
Item result;
if (item instanceof MagesStaff) {
result = changeStaff( (MagesStaff)item );
} else if (item instanceof MeleeWeapon || item instanceof MissileWeapon) {
result = changeWeapon( (Weapon)item );
} else if (item instanceof Scroll) {
result = changeScroll( (Scroll)item );
} else if (item instanceof Potion) {
result = changePotion( (Potion)item );
} else if (item instanceof Ring) {
result = changeRing( (Ring)item );
} else if (item instanceof Wand) {
result = changeWand( (Wand)item );
} else if (item instanceof Plant.Seed) {
result = changeSeed((Plant.Seed) item);
} else if (item instanceof Runestone) {
result = changeStone((Runestone) item);
} else if (item instanceof Artifact) {
result = changeArtifact( (Artifact)item );
} else {
result = null;
}
Item result = changeItem(item);
if (result == null){
//This shouldn't ever trigger
@ -123,8 +101,32 @@ public class ScrollOfTransmutation extends InventoryScroll {
}
}
public static Item changeItem( Item item ){
if (item instanceof MagesStaff) {
return changeStaff( (MagesStaff)item );
} else if (item instanceof MeleeWeapon || item instanceof MissileWeapon) {
return changeWeapon( (Weapon)item );
} else if (item instanceof Scroll) {
return changeScroll( (Scroll)item );
} else if (item instanceof Potion) {
return changePotion( (Potion)item );
} else if (item instanceof Ring) {
return changeRing( (Ring)item );
} else if (item instanceof Wand) {
return changeWand( (Wand)item );
} else if (item instanceof Plant.Seed) {
return changeSeed((Plant.Seed) item);
} else if (item instanceof Runestone) {
return changeStone((Runestone) item);
} else if (item instanceof Artifact) {
return changeArtifact( (Artifact)item );
} else {
return null;
}
}
private MagesStaff changeStaff( MagesStaff staff ){
private static MagesStaff changeStaff( MagesStaff staff ){
Class<?extends Wand> wandClass = staff.wandClass();
if (wandClass == null){
@ -142,7 +144,7 @@ public class ScrollOfTransmutation extends InventoryScroll {
return staff;
}
private Weapon changeWeapon( Weapon w ) {
private static Weapon changeWeapon( Weapon w ) {
Weapon n;
Generator.Category c;
@ -175,7 +177,7 @@ public class ScrollOfTransmutation extends InventoryScroll {
}
private Ring changeRing( Ring r ) {
private static Ring changeRing( Ring r ) {
Ring n;
do {
n = (Ring)Generator.random( Generator.Category.RING );
@ -197,7 +199,7 @@ public class ScrollOfTransmutation extends InventoryScroll {
return n;
}
private Artifact changeArtifact( Artifact a ) {
private static Artifact changeArtifact( Artifact a ) {
Artifact n = Generator.randomArtifact();
if (n != null && !Challenges.isItemBlocked(n)){
@ -211,7 +213,7 @@ public class ScrollOfTransmutation extends InventoryScroll {
return null;
}
private Wand changeWand( Wand w ) {
private static Wand changeWand( Wand w ) {
Wand n;
do {
@ -223,19 +225,21 @@ public class ScrollOfTransmutation extends InventoryScroll {
if (w.curseInfusionBonus) level--;
level -= w.resinBonus;
n.upgrade( level );
n.levelKnown = w.levelKnown;
n.curChargeKnown = w.curChargeKnown;
n.cursedKnown = w.cursedKnown;
n.cursed = w.cursed;
n.curseInfusionBonus = w.curseInfusionBonus;
n.resinBonus = w.resinBonus;
n.curCharges = w.curCharges;
n.updateLevel();
return n;
}
private Plant.Seed changeSeed( Plant.Seed s ) {
private static Plant.Seed changeSeed( Plant.Seed s ) {
Plant.Seed n;
@ -246,7 +250,7 @@ public class ScrollOfTransmutation extends InventoryScroll {
return n;
}
private Runestone changeStone( Runestone r ) {
private static Runestone changeStone( Runestone r ) {
Runestone n;
@ -257,7 +261,7 @@ public class ScrollOfTransmutation extends InventoryScroll {
return n;
}
private Scroll changeScroll( Scroll s ) {
private static Scroll changeScroll( Scroll s ) {
if (s instanceof ExoticScroll) {
return Reflection.newInstance(ExoticScroll.exoToReg.get(s.getClass()));
} else {
@ -265,7 +269,7 @@ public class ScrollOfTransmutation extends InventoryScroll {
}
}
private Potion changePotion( Potion p ) {
private static Potion changePotion( Potion p ) {
if (p instanceof ExoticPotion) {
return Reflection.newInstance(ExoticPotion.exoToReg.get(p.getClass()));
} else {

View File

@ -74,7 +74,7 @@ public abstract class Wand extends Item {
protected Charger charger;
private boolean curChargeKnown = false;
public boolean curChargeKnown = false;
public boolean curseInfusionBonus = false;
public int resinBonus = 0;