v0.7.1: improved how trans/recycle handle exotics, stones, elixirs/brews

This commit is contained in:
Evan Debenham 2018-11-17 15:27:39 -05:00
parent 63a5f57b01
commit 24e311dc58
2 changed files with 47 additions and 5 deletions

View File

@ -29,9 +29,12 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.Artifact; import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.Artifact;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion; import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.brews.Brew;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.elixirs.Elixir;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.exotic.ExoticPotion; import com.shatteredpixel.shatteredpixeldungeon.items.potions.exotic.ExoticPotion;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.Ring; import com.shatteredpixel.shatteredpixeldungeon.items.rings.Ring;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.exotic.ExoticScroll; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.exotic.ExoticScroll;
import com.shatteredpixel.shatteredpixeldungeon.items.stones.Runestone;
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;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MagesStaff; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MagesStaff;
@ -53,9 +56,14 @@ public class ScrollOfTransmutation extends InventoryScroll {
} }
public static boolean canTransmute(Item item){ public static boolean canTransmute(Item item){
return item instanceof MagesStaff || item instanceof MeleeWeapon || item instanceof Potion return item instanceof MeleeWeapon ||
|| item instanceof Scroll || item instanceof Ring || item instanceof Wand (item instanceof Potion && !(item instanceof Elixir || item instanceof Brew)) ||
|| item instanceof Plant.Seed || item instanceof Artifact; item instanceof Scroll ||
item instanceof Ring ||
item instanceof Wand ||
item instanceof Plant.Seed ||
item instanceof Runestone ||
item instanceof Artifact;
} }
@Override @Override
@ -76,7 +84,9 @@ public class ScrollOfTransmutation extends InventoryScroll {
} else if (item instanceof Wand) { } else if (item instanceof Wand) {
result = changeWand( (Wand)item ); result = changeWand( (Wand)item );
} else if (item instanceof Plant.Seed) { } else if (item instanceof Plant.Seed) {
result = changeSeed( (Plant.Seed)item ); result = changeSeed((Plant.Seed) item);
} else if (item instanceof Runestone) {
result = changeStone((Runestone) item);
} else if (item instanceof Artifact) { } else if (item instanceof Artifact) {
result = changeArtifact( (Artifact)item ); result = changeArtifact( (Artifact)item );
} else { } else {
@ -219,6 +229,17 @@ public class ScrollOfTransmutation extends InventoryScroll {
return n; return n;
} }
private Runestone changeStone( Runestone r ) {
Runestone n;
do {
n = (Runestone) Generator.random( Generator.Category.STONE );
} while (n.getClass() == r.getClass());
return n;
}
private Scroll changeScroll( Scroll s ) { private Scroll changeScroll( Scroll s ) {
try { try {
if (s instanceof ExoticScroll) { if (s instanceof ExoticScroll) {

View File

@ -21,11 +21,16 @@
package com.shatteredpixel.shatteredpixeldungeon.items.spells; package com.shatteredpixel.shatteredpixeldungeon.items.spells;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.shatteredpixel.shatteredpixeldungeon.items.Generator; import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion; import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.brews.Brew;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.elixirs.Elixir;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.exotic.ExoticPotion;
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.ScrollOfTransmutation;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.exotic.ExoticScroll;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.exotic.ScrollOfDivination; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.exotic.ScrollOfDivination;
import com.shatteredpixel.shatteredpixeldungeon.items.stones.Runestone; import com.shatteredpixel.shatteredpixeldungeon.items.stones.Runestone;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
@ -47,8 +52,24 @@ public class Recycle extends InventorySpell {
do { do {
if (item instanceof Potion) { if (item instanceof Potion) {
result = Generator.random(Generator.Category.POTION); result = Generator.random(Generator.Category.POTION);
if (item instanceof ExoticPotion){
try {
result = ExoticPotion.regToExo.get(result.getClass()).newInstance();
} catch ( Exception e ){
ShatteredPixelDungeon.reportException(e);
result = item;
}
}
} else if (item instanceof Scroll) { } else if (item instanceof Scroll) {
result = Generator.random(Generator.Category.SCROLL); result = Generator.random(Generator.Category.SCROLL);
if (item instanceof ExoticScroll){
try {
result = ExoticScroll.regToExo.get(result.getClass()).newInstance();
} catch ( Exception e ){
ShatteredPixelDungeon.reportException(e);
result = item;
}
}
} else if (item instanceof Plant.Seed) { } else if (item instanceof Plant.Seed) {
result = Generator.random(Generator.Category.SEED); result = Generator.random(Generator.Category.SEED);
} else { } else {
@ -63,7 +84,7 @@ public class Recycle extends InventorySpell {
} }
public static boolean isRecyclable(Item item){ public static boolean isRecyclable(Item item){
return item instanceof Potion || return (item instanceof Potion && !(item instanceof Elixir || item instanceof Brew)) ||
item instanceof Scroll || item instanceof Scroll ||
item instanceof Plant.Seed || item instanceof Plant.Seed ||
item instanceof Runestone; item instanceof Runestone;