v0.9.4: refactored transmuting a bit, fixed transmuted wand errors
This commit is contained in:
parent
b08f3479c1
commit
8d0630a607
|
@ -33,6 +33,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfStrength;
|
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfStrength;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.rings.Ring;
|
import com.shatteredpixel.shatteredpixeldungeon.items.rings.Ring;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll;
|
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.scrolls.ScrollOfUpgrade;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand;
|
import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
|
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
|
||||||
|
@ -50,25 +51,7 @@ public class WaterOfTransmutation extends WellWater {
|
||||||
@Override
|
@Override
|
||||||
protected Item affectItem( Item item, int pos ) {
|
protected Item affectItem( Item item, int pos ) {
|
||||||
|
|
||||||
if (item instanceof MagesStaff) {
|
item = ScrollOfTransmutation.changeItem(item);
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
//incase a never-seen item pops out
|
//incase a never-seen item pops out
|
||||||
if (item != null&& item.isIdentified()){
|
if (item != null&& item.isIdentified()){
|
||||||
|
@ -95,153 +78,6 @@ public class WaterOfTransmutation extends WellWater {
|
||||||
return Landmark.WELL_OF_TRANSMUTATION;
|
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
|
@Override
|
||||||
public String tileDesc() {
|
public String tileDesc() {
|
||||||
return Messages.get(this, "desc");
|
return Messages.get(this, "desc");
|
||||||
|
|
|
@ -75,29 +75,7 @@ public class ScrollOfTransmutation extends InventoryScroll {
|
||||||
@Override
|
@Override
|
||||||
protected void onItemSelected(Item item) {
|
protected void onItemSelected(Item item) {
|
||||||
|
|
||||||
Item result;
|
Item result = changeItem(item);
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result == null){
|
if (result == null){
|
||||||
//This shouldn't ever trigger
|
//This shouldn't ever trigger
|
||||||
|
@ -124,7 +102,31 @@ public class ScrollOfTransmutation extends InventoryScroll {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private MagesStaff changeStaff( MagesStaff staff ){
|
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 static MagesStaff changeStaff( MagesStaff staff ){
|
||||||
Class<?extends Wand> wandClass = staff.wandClass();
|
Class<?extends Wand> wandClass = staff.wandClass();
|
||||||
|
|
||||||
if (wandClass == null){
|
if (wandClass == null){
|
||||||
|
@ -142,7 +144,7 @@ public class ScrollOfTransmutation extends InventoryScroll {
|
||||||
return staff;
|
return staff;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Weapon changeWeapon( Weapon w ) {
|
private static Weapon changeWeapon( Weapon w ) {
|
||||||
|
|
||||||
Weapon n;
|
Weapon n;
|
||||||
Generator.Category c;
|
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;
|
Ring n;
|
||||||
do {
|
do {
|
||||||
n = (Ring)Generator.random( Generator.Category.RING );
|
n = (Ring)Generator.random( Generator.Category.RING );
|
||||||
|
@ -197,7 +199,7 @@ public class ScrollOfTransmutation extends InventoryScroll {
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Artifact changeArtifact( Artifact a ) {
|
private static Artifact changeArtifact( Artifact a ) {
|
||||||
Artifact n = Generator.randomArtifact();
|
Artifact n = Generator.randomArtifact();
|
||||||
|
|
||||||
if (n != null && !Challenges.isItemBlocked(n)){
|
if (n != null && !Challenges.isItemBlocked(n)){
|
||||||
|
@ -211,7 +213,7 @@ public class ScrollOfTransmutation extends InventoryScroll {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Wand changeWand( Wand w ) {
|
private static Wand changeWand( Wand w ) {
|
||||||
|
|
||||||
Wand n;
|
Wand n;
|
||||||
do {
|
do {
|
||||||
|
@ -225,17 +227,19 @@ public class ScrollOfTransmutation extends InventoryScroll {
|
||||||
n.upgrade( level );
|
n.upgrade( level );
|
||||||
|
|
||||||
n.levelKnown = w.levelKnown;
|
n.levelKnown = w.levelKnown;
|
||||||
|
n.curChargeKnown = w.curChargeKnown;
|
||||||
n.cursedKnown = w.cursedKnown;
|
n.cursedKnown = w.cursedKnown;
|
||||||
n.cursed = w.cursed;
|
n.cursed = w.cursed;
|
||||||
n.curseInfusionBonus = w.curseInfusionBonus;
|
n.curseInfusionBonus = w.curseInfusionBonus;
|
||||||
n.resinBonus = w.resinBonus;
|
n.resinBonus = w.resinBonus;
|
||||||
|
|
||||||
|
n.curCharges = w.curCharges;
|
||||||
n.updateLevel();
|
n.updateLevel();
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Plant.Seed changeSeed( Plant.Seed s ) {
|
private static Plant.Seed changeSeed( Plant.Seed s ) {
|
||||||
|
|
||||||
Plant.Seed n;
|
Plant.Seed n;
|
||||||
|
|
||||||
|
@ -246,7 +250,7 @@ public class ScrollOfTransmutation extends InventoryScroll {
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Runestone changeStone( Runestone r ) {
|
private static Runestone changeStone( Runestone r ) {
|
||||||
|
|
||||||
Runestone n;
|
Runestone n;
|
||||||
|
|
||||||
|
@ -257,7 +261,7 @@ public class ScrollOfTransmutation extends InventoryScroll {
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Scroll changeScroll( Scroll s ) {
|
private static Scroll changeScroll( Scroll s ) {
|
||||||
if (s instanceof ExoticScroll) {
|
if (s instanceof ExoticScroll) {
|
||||||
return Reflection.newInstance(ExoticScroll.exoToReg.get(s.getClass()));
|
return Reflection.newInstance(ExoticScroll.exoToReg.get(s.getClass()));
|
||||||
} else {
|
} 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) {
|
if (p instanceof ExoticPotion) {
|
||||||
return Reflection.newInstance(ExoticPotion.exoToReg.get(p.getClass()));
|
return Reflection.newInstance(ExoticPotion.exoToReg.get(p.getClass()));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -74,7 +74,7 @@ public abstract class Wand extends Item {
|
||||||
|
|
||||||
protected Charger charger;
|
protected Charger charger;
|
||||||
|
|
||||||
private boolean curChargeKnown = false;
|
public boolean curChargeKnown = false;
|
||||||
|
|
||||||
public boolean curseInfusionBonus = false;
|
public boolean curseInfusionBonus = false;
|
||||||
public int resinBonus = 0;
|
public int resinBonus = 0;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user