v1.1.0: reworked alchemize spell, shops now sell it and not beacons
This commit is contained in:
parent
accc0bebac
commit
e52fa36cb4
|
@ -1026,8 +1026,14 @@ items.scrolls.exotic.scrollofpsionicblast.desc=This scroll contains incredible d
|
|||
|
||||
###spells
|
||||
items.spells.alchemize.name=alchemize
|
||||
items.spells.alchemize.enemy_near=You cannot do that with enemies nearby.
|
||||
items.spells.alchemize.desc=This spell channels alchemical energy, allowing you to perform alchemy as if you were at a pot with no energy for a short time.
|
||||
items.spells.alchemize.prompt=Alchemize an Item
|
||||
items.spells.alchemize.desc=This spell contains transmutative powers similar to those found in an alchemy pot. Each cast allows the user to turn an item (or stack of items) into gold or alchemical energy.
|
||||
items.spells.alchemize$wndalchemizeitem.sell=Turn into %dg
|
||||
items.spells.alchemize$wndalchemizeitem.sell_1=Turn 1 into %dg
|
||||
items.spells.alchemize$wndalchemizeitem.sell_all=Turn all into %dg
|
||||
items.spells.alchemize$wndalchemizeitem.energize=Turn into %d energy
|
||||
items.spells.alchemize$wndalchemizeitem.energize_1=Turn 1 into %d energy
|
||||
items.spells.alchemize$wndalchemizeitem.energize_all=Turn all into %d energy
|
||||
|
||||
items.spells.aquablast.name=aqua blast
|
||||
items.spells.aquablast.desc=This spell will create a burst of water at the target location. It isn't forceful enough to do damage (even to fiery enemies), but it will spread water to nearby terrain and very briefly stun anything caught in the center of the burst.
|
||||
|
|
|
@ -107,6 +107,14 @@ public class Shopkeeper extends NPC {
|
|||
return GameScene.selectItem( itemSelector );
|
||||
}
|
||||
|
||||
public static boolean canSell(Item item){
|
||||
if (item.value() <= 0) return false;
|
||||
if (item.unique && !item.stackable) return false;
|
||||
if (item instanceof Armor && ((Armor) item).checkSeal() != null) return false;
|
||||
if (item.isEquipped(Dungeon.hero) && item.cursed) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private static WndBag.ItemSelector itemSelector = new WndBag.ItemSelector() {
|
||||
@Override
|
||||
public String textPrompt() {
|
||||
|
@ -115,11 +123,7 @@ public class Shopkeeper extends NPC {
|
|||
|
||||
@Override
|
||||
public boolean itemSelectable(Item item) {
|
||||
if (item.value() <= 0) return false;
|
||||
if (item.unique && !item.stackable) return false;
|
||||
if (item instanceof Armor && ((Armor) item).checkSeal() != null) return false;
|
||||
if (item.isEquipped(Dungeon.hero) && item.cursed) return false;
|
||||
return true;
|
||||
return Shopkeeper.canSell(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -29,6 +29,7 @@ import com.watabou.noosa.audio.Sample;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
//TODO no longer sold in stores, decide what to do with this
|
||||
public class MerchantsBeacon extends Item {
|
||||
|
||||
private static final String AC_USE = "USE";
|
||||
|
|
|
@ -21,15 +21,27 @@
|
|||
|
||||
package com.shatteredpixel.shatteredpixeldungeon.items.spells;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Shopkeeper;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.AlchemicalCatalyst;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.AlchemyScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndEnergizeItem;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndImp;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndInfoItem;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndTradeItem;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
|
||||
//TODO redesign
|
||||
public class Alchemize extends Spell {
|
||||
|
||||
{
|
||||
|
@ -38,33 +50,186 @@ public class Alchemize extends Spell {
|
|||
|
||||
@Override
|
||||
protected void onCast(Hero hero) {
|
||||
if (hero.visibleEnemies() > hero.mindVisionEnemies.size()) {
|
||||
GLog.i( Messages.get(this, "enemy_near") );
|
||||
return;
|
||||
}
|
||||
detach( curUser.belongings.backpack );
|
||||
updateQuickslot();
|
||||
//AlchemyScene.setProvider(this);
|
||||
ShatteredPixelDungeon.switchScene(AlchemyScene.class);
|
||||
GameScene.selectItem( itemSelector );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int value() {
|
||||
//prices of ingredients, divided by output quantity
|
||||
return Math.round(quantity * ((40 + 40) / 4f));
|
||||
return Math.round(quantity * (40 / 8f));
|
||||
}
|
||||
|
||||
//TODO also allow alchemical catalyst? Or save that for an elixir/brew?
|
||||
public static class Recipe extends com.shatteredpixel.shatteredpixeldungeon.items.Recipe.SimpleRecipe {
|
||||
|
||||
{
|
||||
inputs = new Class[]{ArcaneCatalyst.class, AlchemicalCatalyst.class};
|
||||
inQuantity = new int[]{1, 1};
|
||||
inputs = new Class[]{ArcaneCatalyst.class};
|
||||
inQuantity = new int[]{1};
|
||||
|
||||
cost = 6;
|
||||
cost = 3;
|
||||
|
||||
output = Alchemize.class;
|
||||
outQuantity = 4;
|
||||
outQuantity = 8;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static WndBag.ItemSelector itemSelector = new WndBag.ItemSelector() {
|
||||
@Override
|
||||
public String textPrompt() {
|
||||
return Messages.get(Alchemize.class, "prompt");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean itemSelectable(Item item) {
|
||||
return !(item instanceof Alchemize)
|
||||
&& (Shopkeeper.canSell(item) || item.energyVal() > 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSelect( Item item ) {
|
||||
if (item != null) {
|
||||
WndBag parentWnd = GameScene.selectItem( itemSelector );
|
||||
GameScene.show( new WndAlchemizeItem( item, parentWnd ) );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
public static class WndAlchemizeItem extends WndInfoItem {
|
||||
|
||||
private static final float GAP = 2;
|
||||
private static final int BTN_HEIGHT = 18;
|
||||
|
||||
private WndBag owner;
|
||||
|
||||
public WndAlchemizeItem(Item item, WndBag owner) {
|
||||
super(item);
|
||||
|
||||
this.owner = owner;
|
||||
|
||||
float pos = height;
|
||||
|
||||
if (Shopkeeper.canSell(item)) {
|
||||
if (item.quantity() == 1) {
|
||||
|
||||
RedButton btnSell = new RedButton(Messages.get(this, "sell", item.value())) {
|
||||
@Override
|
||||
protected void onClick() {
|
||||
WndTradeItem.sell(item);
|
||||
consumeAlchemize();
|
||||
hide();
|
||||
}
|
||||
};
|
||||
btnSell.setRect(0, pos + GAP, width, BTN_HEIGHT);
|
||||
btnSell.icon(new ItemSprite(ItemSpriteSheet.GOLD));
|
||||
add(btnSell);
|
||||
|
||||
pos = btnSell.bottom();
|
||||
|
||||
} else {
|
||||
|
||||
int priceAll = item.value();
|
||||
RedButton btnSell1 = new RedButton(Messages.get(this, "sell_1", priceAll / item.quantity())) {
|
||||
@Override
|
||||
protected void onClick() {
|
||||
WndTradeItem.sellOne(item);
|
||||
consumeAlchemize();
|
||||
hide();
|
||||
}
|
||||
};
|
||||
btnSell1.setRect(0, pos + GAP, width, BTN_HEIGHT);
|
||||
btnSell1.icon(new ItemSprite(ItemSpriteSheet.GOLD));
|
||||
add(btnSell1);
|
||||
RedButton btnSellAll = new RedButton(Messages.get(this, "sell_all", priceAll)) {
|
||||
@Override
|
||||
protected void onClick() {
|
||||
WndTradeItem.sell(item);
|
||||
consumeAlchemize();
|
||||
hide();
|
||||
}
|
||||
};
|
||||
btnSellAll.setRect(0, btnSell1.bottom() + 1, width, BTN_HEIGHT);
|
||||
btnSellAll.icon(new ItemSprite(ItemSpriteSheet.GOLD));
|
||||
add(btnSellAll);
|
||||
|
||||
pos = btnSellAll.bottom();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (item.energyVal() > 0) {
|
||||
if (item.quantity() == 1) {
|
||||
|
||||
RedButton btnEnergize = new RedButton(Messages.get(this, "energize", item.energyVal())) {
|
||||
@Override
|
||||
protected void onClick() {
|
||||
WndEnergizeItem.energize(item);
|
||||
consumeAlchemize();
|
||||
hide();
|
||||
}
|
||||
};
|
||||
btnEnergize.setRect(0, pos + GAP, width, BTN_HEIGHT);
|
||||
btnEnergize.icon(new ItemSprite(ItemSpriteSheet.ENERGY));
|
||||
add(btnEnergize);
|
||||
|
||||
pos = btnEnergize.bottom();
|
||||
|
||||
} else {
|
||||
|
||||
int energyAll = item.energyVal();
|
||||
RedButton btnEnergize1 = new RedButton(Messages.get(this, "energize_1", energyAll / item.quantity())) {
|
||||
@Override
|
||||
protected void onClick() {
|
||||
WndEnergizeItem.energizeOne(item);
|
||||
consumeAlchemize();
|
||||
hide();
|
||||
}
|
||||
};
|
||||
btnEnergize1.setRect(0, pos + GAP, width, BTN_HEIGHT);
|
||||
btnEnergize1.icon(new ItemSprite(ItemSpriteSheet.ENERGY));
|
||||
add(btnEnergize1);
|
||||
RedButton btnEnergizeAll = new RedButton(Messages.get(this, "energize_all", energyAll)) {
|
||||
@Override
|
||||
protected void onClick() {
|
||||
WndEnergizeItem.energize(item);
|
||||
consumeAlchemize();
|
||||
hide();
|
||||
}
|
||||
};
|
||||
btnEnergizeAll.setRect(0, btnEnergize1.bottom() + 1, width, BTN_HEIGHT);
|
||||
btnEnergizeAll.icon(new ItemSprite(ItemSpriteSheet.ENERGY));
|
||||
add(btnEnergizeAll);
|
||||
|
||||
pos = btnEnergizeAll.bottom();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
resize( width, (int)pos );
|
||||
|
||||
}
|
||||
|
||||
private void consumeAlchemize(){
|
||||
Sample.INSTANCE.play(Assets.Sounds.TELEPORT);
|
||||
if (curItem.quantity() <= 1){
|
||||
curItem.detachAll(Dungeon.hero.belongings.backpack);
|
||||
owner.hide();
|
||||
owner = null;
|
||||
} else {
|
||||
curItem.detach(Dungeon.hero.belongings.backpack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hide() {
|
||||
|
||||
super.hide();
|
||||
|
||||
if (owner != null) {
|
||||
owner.hide();
|
||||
GameScene.selectItem(itemSelector);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfHealing;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfIdentify;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfMagicMapping;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRemoveCurse;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.spells.Alchemize;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.stones.StoneOfAugmentation;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MeleeWeapon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.darts.TippedDart;
|
||||
|
@ -188,8 +189,7 @@ public class ShopRoom extends SpecialRoom {
|
|||
|
||||
itemsToSpawn.add( TippedDart.randomTipped(2) );
|
||||
|
||||
itemsToSpawn.add( new MerchantsBeacon() );
|
||||
|
||||
itemsToSpawn.add( new Alchemize().quantity(Random.IntRange(3, 4)));
|
||||
|
||||
itemsToSpawn.add(ChooseBag(Dungeon.hero.belongings));
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ public class WndEnergizeItem extends WndInfoItem {
|
|||
}
|
||||
}
|
||||
|
||||
private void energize( Item item ) {
|
||||
public static void energize( Item item ) {
|
||||
|
||||
Hero hero = Dungeon.hero;
|
||||
|
||||
|
@ -111,7 +111,7 @@ public class WndEnergizeItem extends WndInfoItem {
|
|||
}
|
||||
}
|
||||
|
||||
private void energizeOne( Item item ) {
|
||||
public static void energizeOne( Item item ) {
|
||||
|
||||
if (item.quantity() <= 1) {
|
||||
energize( item );
|
||||
|
|
|
@ -170,7 +170,7 @@ public class WndTradeItem extends WndInfoItem {
|
|||
}
|
||||
}
|
||||
|
||||
private void sell( Item item ) {
|
||||
public static void sell( Item item ) {
|
||||
|
||||
Hero hero = Dungeon.hero;
|
||||
|
||||
|
@ -185,7 +185,7 @@ public class WndTradeItem extends WndInfoItem {
|
|||
new Gold( item.value() ).doPickUp( hero );
|
||||
}
|
||||
|
||||
private void sellOne( Item item ) {
|
||||
public static void sellOne( Item item ) {
|
||||
|
||||
if (item.quantity() <= 1) {
|
||||
sell( item );
|
||||
|
|
Loading…
Reference in New Issue
Block a user