v0.6.3: improved alchemy interface and added a new recipe
This commit is contained in:
parent
8a632f0d02
commit
bf4a891b9a
core/src/main
java/com/shatteredpixel/shatteredpixeldungeon
items
windows
resources/com/shatteredpixel/shatteredpixeldungeon/messages
|
@ -24,6 +24,7 @@ package com.shatteredpixel.shatteredpixeldungeon.items;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.food.Blandfruit;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.TippedDart;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
@ -31,9 +32,10 @@ public abstract class Recipe {
|
|||
|
||||
public abstract boolean testIngredients(ArrayList<Item> ingredients);
|
||||
|
||||
//not currently used
|
||||
public abstract int cost(ArrayList<Item> ingredients);
|
||||
|
||||
public abstract Item cook(ArrayList<Item> ingredients);
|
||||
public abstract Item brew(ArrayList<Item> ingredients);
|
||||
|
||||
public abstract Item sampleOutput(ArrayList<Item> ingredients);
|
||||
|
||||
|
@ -74,7 +76,7 @@ public abstract class Recipe {
|
|||
}
|
||||
|
||||
@Override
|
||||
public final Item cook(ArrayList<Item> ingredients) {
|
||||
public final Item brew(ArrayList<Item> ingredients) {
|
||||
if (!testIngredients(ingredients)) return null;
|
||||
|
||||
for(int i = 0; i < inputs.length; i++){
|
||||
|
@ -113,11 +115,12 @@ public abstract class Recipe {
|
|||
};
|
||||
|
||||
private static Recipe[] twoIngredientRecipes = new Recipe[]{
|
||||
new Blandfruit.cookFruit()
|
||||
new Blandfruit.CookFruit(),
|
||||
new TippedDart.TipDart()
|
||||
};
|
||||
|
||||
private static Recipe[] threeIngredientRecipes = new Recipe[]{
|
||||
new Potion.randomPotion()
|
||||
new Potion.RandomPotion()
|
||||
};
|
||||
|
||||
public static Recipe findRecipe(ArrayList<Item> ingredients){
|
||||
|
|
|
@ -231,7 +231,7 @@ public class Blandfruit extends Food {
|
|||
return potionGlow;
|
||||
}
|
||||
|
||||
public static class cookFruit extends Recipe {
|
||||
public static class CookFruit extends Recipe {
|
||||
|
||||
@Override
|
||||
//also sorts ingredients if it can
|
||||
|
@ -271,7 +271,7 @@ public class Blandfruit extends Food {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Item cook(ArrayList<Item> ingredients) {
|
||||
public Item brew(ArrayList<Item> ingredients) {
|
||||
if (!testIngredients(ingredients)) return null;
|
||||
|
||||
ingredients.get(0).quantity(ingredients.get(0).quantity() - 1);
|
||||
|
|
|
@ -337,7 +337,7 @@ public class Potion extends Item {
|
|||
}
|
||||
|
||||
|
||||
public static class randomPotion extends Recipe{
|
||||
public static class RandomPotion extends Recipe {
|
||||
|
||||
@Override
|
||||
public boolean testIngredients(ArrayList<Item> ingredients) {
|
||||
|
@ -359,7 +359,7 @@ public class Potion extends Item {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Item cook(ArrayList<Item> ingredients) {
|
||||
public Item brew(ArrayList<Item> ingredients) {
|
||||
if (!testIngredients(ingredients)) return null;
|
||||
|
||||
for (Item ingredient : ingredients){
|
||||
|
@ -401,7 +401,16 @@ public class Potion extends Item {
|
|||
|
||||
@Override
|
||||
public Item sampleOutput(ArrayList<Item> ingredients) {
|
||||
return new WndBag.Placeholder(ItemSpriteSheet.POTION_HOLDER);
|
||||
return new WndBag.Placeholder(ItemSpriteSheet.POTION_HOLDER){
|
||||
{
|
||||
name = Messages.get(RandomPotion.class, "name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String info() {
|
||||
return "";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,13 @@ import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.PinCushion;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Recipe;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.plants.Earthroot;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.plants.Firebloom;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.plants.Plant;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public abstract class TippedDart extends Dart {
|
||||
|
||||
|
@ -49,4 +56,70 @@ public abstract class TippedDart extends Dart {
|
|||
public int price() {
|
||||
return 12 * quantity;
|
||||
}
|
||||
|
||||
|
||||
public static class TipDart extends Recipe{
|
||||
|
||||
@Override
|
||||
//also sorts ingredients if it can
|
||||
public boolean testIngredients(ArrayList<Item> ingredients) {
|
||||
if (ingredients.size() != 2) return false;
|
||||
|
||||
if (ingredients.get(0).getClass() == Dart.class){
|
||||
if (!(ingredients.get(1) instanceof Plant.Seed)){
|
||||
return false;
|
||||
}
|
||||
} else if (ingredients.get(0) instanceof Plant.Seed){
|
||||
if (ingredients.get(1).getClass() == Dart.class){
|
||||
Item temp = ingredients.get(0);
|
||||
ingredients.set(0, ingredients.get(1));
|
||||
ingredients.set(1, temp);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
Plant.Seed seed = (Plant.Seed) ingredients.get(1);
|
||||
|
||||
if (ingredients.get(0).quantity() >= 2
|
||||
&& seed.quantity() >= 1
|
||||
&& (seed instanceof Firebloom.Seed || seed instanceof Earthroot.Seed)){
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cost(ArrayList<Item> ingredients) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item brew(ArrayList<Item> ingredients) {
|
||||
if (!testIngredients(ingredients)) return null;
|
||||
|
||||
ingredients.get(0).quantity(ingredients.get(0).quantity() - 2);
|
||||
ingredients.get(1).quantity(ingredients.get(1).quantity() - 1);
|
||||
|
||||
if (ingredients.get(1) instanceof Firebloom.Seed){
|
||||
return new IncendiaryDart().quantity(2);
|
||||
} else {
|
||||
return new CurareDart().quantity(2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item sampleOutput(ArrayList<Item> ingredients) {
|
||||
if (!testIngredients(ingredients)) return null;
|
||||
|
||||
if (ingredients.get(1) instanceof Firebloom.Seed){
|
||||
return new IncendiaryDart().quantity(2);
|
||||
} else {
|
||||
return new CurareDart().quantity(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,11 +22,12 @@
|
|||
package com.shatteredpixel.shatteredpixeldungeon.windows;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Badges;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Recipe;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.Dart;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||
|
@ -42,7 +43,6 @@ import com.watabou.noosa.ColorBlock;
|
|||
import com.watabou.noosa.Image;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
import com.watabou.noosa.particles.Emitter;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
@ -98,17 +98,53 @@ public class WndAlchemy extends Window {
|
|||
GameScene.selectItem( itemSelector, WndBag.Mode.ALCHEMY, Messages.get(WndAlchemy.class, "select") );
|
||||
}
|
||||
};
|
||||
inputs[i].setRect(15, h, BTN_SIZE, BTN_SIZE);
|
||||
inputs[i].setRect(10, h, BTN_SIZE, BTN_SIZE);
|
||||
add(inputs[i]);
|
||||
h += BTN_SIZE + 2;
|
||||
}
|
||||
|
||||
Image arrow = Icons.get(Icons.RESUME);
|
||||
arrow.hardlight(0, 0, 0);
|
||||
arrow.x = (w - arrow.width)/2f;
|
||||
arrow.y = inputs[1].top() + (inputs[1].height() - arrow.height)/2f;
|
||||
PixelScene.align(arrow);
|
||||
add(arrow);
|
||||
btnCombine = new RedButton(""){
|
||||
Image arrow;
|
||||
|
||||
@Override
|
||||
protected void createChildren() {
|
||||
super.createChildren();
|
||||
|
||||
arrow = Icons.get(Icons.RESUME);
|
||||
add(arrow);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void layout() {
|
||||
super.layout();
|
||||
arrow.x = x + (width - arrow.width)/2f;
|
||||
arrow.y = y + (height - arrow.height)/2f;
|
||||
PixelScene.align(arrow);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable(boolean value) {
|
||||
super.enable(value);
|
||||
if (value){
|
||||
arrow.tint(1, 1, 0, 1);
|
||||
arrow.alpha(1f);
|
||||
bg.alpha(1f);
|
||||
} else {
|
||||
arrow.color(0, 0, 0);
|
||||
arrow.alpha(0.6f);
|
||||
bg.alpha(0.6f);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onClick() {
|
||||
super.onClick();
|
||||
combine();
|
||||
}
|
||||
};
|
||||
btnCombine.enable(false);
|
||||
btnCombine.setRect((w-30)/2f, inputs[1].top()+5, 30, inputs[1].height()-10);
|
||||
add(btnCombine);
|
||||
|
||||
output = new ItemSlot(){
|
||||
@Override
|
||||
|
@ -119,7 +155,7 @@ public class WndAlchemy extends Window {
|
|||
}
|
||||
}
|
||||
};
|
||||
output.setRect(w - BTN_SIZE - 15, inputs[1].top(), BTN_SIZE, BTN_SIZE);
|
||||
output.setRect(w - BTN_SIZE - 10, inputs[1].top(), BTN_SIZE, BTN_SIZE);
|
||||
|
||||
ColorBlock outputBG = new ColorBlock(output.width(), output.height(), 0x9991938C);
|
||||
outputBG.x = output.left();
|
||||
|
@ -142,30 +178,29 @@ public class WndAlchemy extends Window {
|
|||
|
||||
float btnWidth = (w-14)/2f;
|
||||
|
||||
btnCombine = new RedButton(Messages.get(this, "combine")){
|
||||
RedButton btnRecipes = new RedButton(Messages.get(this, "recipes_title")){
|
||||
@Override
|
||||
protected void onClick() {
|
||||
super.onClick();
|
||||
combine();
|
||||
ShatteredPixelDungeon.scene().addToFront(new WndMessage(Messages.get(WndAlchemy.class, "recipes_text")));
|
||||
}
|
||||
};
|
||||
btnCombine.setRect(5, h, btnWidth, 18);
|
||||
PixelScene.align(btnCombine);
|
||||
btnCombine.enable(false);
|
||||
add(btnCombine);
|
||||
btnRecipes.setRect(5, h, btnWidth, 18);
|
||||
PixelScene.align(btnRecipes);
|
||||
add(btnRecipes);
|
||||
|
||||
RedButton btnCancel = new RedButton(Messages.get(this, "cancel")){
|
||||
RedButton btnClose = new RedButton(Messages.get(this, "close")){
|
||||
@Override
|
||||
protected void onClick() {
|
||||
super.onClick();
|
||||
onBackPressed();
|
||||
}
|
||||
};
|
||||
btnCancel.setRect(w - 5 - btnWidth, h, btnWidth, 18);
|
||||
PixelScene.align(btnCancel);
|
||||
add(btnCancel);
|
||||
btnClose.setRect(w - 5 - btnWidth, h, btnWidth, 18);
|
||||
PixelScene.align(btnClose);
|
||||
add(btnClose);
|
||||
|
||||
h += btnCancel.height();
|
||||
h += btnClose.height();
|
||||
|
||||
resize(w, h);
|
||||
}
|
||||
|
@ -176,7 +211,11 @@ public class WndAlchemy extends Window {
|
|||
if (item != null) {
|
||||
for (int i = 0; i < inputs.length; i++) {
|
||||
if (inputs[i].item == null){
|
||||
inputs[i].item(item.detach(Dungeon.hero.belongings.backpack));
|
||||
if (item instanceof Dart){
|
||||
inputs[i].item(item.detachAll(Dungeon.hero.belongings.backpack));
|
||||
} else {
|
||||
inputs[i].item(item.detach(Dungeon.hero.belongings.backpack));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -221,7 +260,7 @@ public class WndAlchemy extends Window {
|
|||
Item result = null;
|
||||
|
||||
if (recipe != null){
|
||||
result = recipe.cook(ingredients);
|
||||
result = recipe.brew(ingredients);
|
||||
}
|
||||
|
||||
if (result != null){
|
||||
|
@ -235,9 +274,13 @@ public class WndAlchemy extends Window {
|
|||
}
|
||||
|
||||
for (int i = 0; i < inputs.length; i++){
|
||||
if (inputs[i].item != null && inputs[i].item.quantity() <= 0) {
|
||||
inputs[i].slot.item(new WndBag.Placeholder(ItemSpriteSheet.SOMETHING));
|
||||
inputs[i].item = null;
|
||||
if (inputs[i].item != null) {
|
||||
if (inputs[i].item.quantity() <= 0) {
|
||||
inputs[i].slot.item(new WndBag.Placeholder(ItemSpriteSheet.SOMETHING));
|
||||
inputs[i].item = null;
|
||||
} else {
|
||||
inputs[i].slot.item(inputs[i].item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MeleeWeapon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.Boomerang;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.Dart;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.plants.BlandfruitBush;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.plants.Plant.Seed;
|
||||
|
@ -405,7 +406,7 @@ public class WndBag extends WndTabbed {
|
|||
mode == Mode.SCROLL && (item instanceof Scroll) ||
|
||||
mode == Mode.UNIDED_POTION_OR_SCROLL && (!item.isIdentified() && (item instanceof Scroll || item instanceof Potion)) ||
|
||||
mode == Mode.EQUIPMENT && (item instanceof EquipableItem) ||
|
||||
mode == Mode.ALCHEMY && ((item instanceof Seed && !(item instanceof BlandfruitBush.Seed)) || (item instanceof Blandfruit && ((Blandfruit) item).potionAttrib == null)) ||
|
||||
mode == Mode.ALCHEMY && ((item instanceof Seed && !(item instanceof BlandfruitBush.Seed)) || (item instanceof Blandfruit && ((Blandfruit) item).potionAttrib == null) || (item.getClass() == Dart.class)) ||
|
||||
mode == Mode.ALL
|
||||
);
|
||||
//extra logic for cursed weapons or armor
|
||||
|
|
|
@ -436,6 +436,7 @@ items.potions.potion.no=No, I changed my mind
|
|||
items.potions.potion.sure_drink=Are you sure you want to drink it? In most cases you should throw such potions at your enemies.
|
||||
items.potions.potion.sure_throw=Are you sure you want to throw it? In most cases it makes sense to drink it.
|
||||
items.potions.potion.shatter=The flask shatters and the liquid splashes harmlessly.
|
||||
items.potions.potion$randompotion.name=Random Potion
|
||||
|
||||
items.potions.potionofexperience.name=potion of experience
|
||||
items.potions.potionofexperience.desc=The storied experiences of multitudes of battles reduced to liquid form, this draught will instantly raise your experience level.
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
windows.wndalchemy.title=Alchemy
|
||||
windows.wndalchemy.text=Combine three seeds to create a potion!
|
||||
windows.wndalchemy.text=Combine ingredients to create something new!
|
||||
windows.wndalchemy.combine=Combine
|
||||
windows.wndalchemy.cancel=Cancel
|
||||
windows.wndalchemy.close=Close
|
||||
windows.wndalchemy.select=Select an item
|
||||
windows.wndalchemy.recipes_title=Recipes
|
||||
windows.wndalchemy.recipes_text=_Random Potion:_\nMix three seeds of any type to create a random potion. The potion is more likely to relate to one of the seeds used.\n\n_Cooked Blandfruit:_\nMix a blandfruit with one seed to imbue the blandfruit with that seed's properties.\n\n_Tipped Darts:_\nMix two regular darts with a seed of either firebloom or earthroot to create two tipped darts!
|
||||
|
||||
windows.wndblacksmith.prompt=Ok, a deal is a deal, here's what I can do for you: I can reforge 2 items and turn them into one of a better quality.
|
||||
windows.wndblacksmith.select=Reforge an item
|
||||
|
|
Loading…
Reference in New Issue
Block a user