v0.7.0: adjusted base identification mechanics for exotics

This commit is contained in:
Evan Debenham 2018-07-13 18:31:08 -04:00
parent 7e30247c09
commit e3ec860e18
4 changed files with 67 additions and 15 deletions

View File

@ -182,6 +182,10 @@ public class ItemStatusHandler<T extends Item> {
known.add( (Class<? extends T>)item.getClass() ); known.add( (Class<? extends T>)item.getClass() );
} }
public void know( Class<?extends T> itemCls ){
known.add( itemCls );
}
public HashSet<Class<? extends T>> known() { public HashSet<Class<? extends T>> known() {
return known; return known;
} }

View File

@ -39,6 +39,8 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.ItemStatusHandler; import com.shatteredpixel.shatteredpixeldungeon.items.ItemStatusHandler;
import com.shatteredpixel.shatteredpixeldungeon.items.Recipe; import com.shatteredpixel.shatteredpixeldungeon.items.Recipe;
import com.shatteredpixel.shatteredpixeldungeon.items.bags.Bag;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.exotic.ExoticPotion;
import com.shatteredpixel.shatteredpixeldungeon.journal.Catalog; import com.shatteredpixel.shatteredpixeldungeon.journal.Catalog;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
@ -168,12 +170,26 @@ public class Potion extends Item {
image = handler.image(this); image = handler.image(this);
color = handler.label(this); color = handler.label(this);
} }
if (isKnown()){ setAction();
if (mustThrowPots.contains(this.getClass())) { }
defaultAction = AC_THROW;
} else if (canThrowPots.contains(this.getClass())){ @Override
defaultAction = AC_CHOOSE; public boolean collect( Bag container ) {
} if (super.collect( container )){
setAction();
return true;
} else {
return false;
}
}
public void setAction(){
if (isKnown() && mustThrowPots.contains(this.getClass())) {
defaultAction = AC_THROW;
} else if (isKnown() &&canThrowPots.contains(this.getClass())){
defaultAction = AC_CHOOSE;
} else {
defaultAction = AC_DRINK;
} }
} }
@ -295,11 +311,10 @@ public class Potion extends Item {
if (!isKnown()) { if (!isKnown()) {
handler.know(this); handler.know(this);
updateQuickslot(); updateQuickslot();
if (mustThrowPots.contains(this.getClass())){ Potion p = Dungeon.hero.belongings.getItem(getClass());
defaultAction = AC_THROW; if (p != null) p.setAction();
} else if (canThrowPots.contains(this.getClass())){ p = Dungeon.hero.belongings.getItem(ExoticPotion.regToExo.get(getClass()));
defaultAction = AC_CHOOSE; if (p != null) p.setAction();
}
} }
if (Dungeon.hero.isAlive()) { if (Dungeon.hero.isAlive()) {

View File

@ -21,6 +21,7 @@
package com.shatteredpixel.shatteredpixeldungeon.items.potions.exotic; package com.shatteredpixel.shatteredpixeldungeon.items.potions.exotic;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.Recipe; import com.shatteredpixel.shatteredpixeldungeon.items.Recipe;
@ -46,17 +47,35 @@ public class ExoticPotion extends Potion {
@Override @Override
public boolean isKnown() { public boolean isKnown() {
//assume it is IDed as ided potions are needed for alchemy return handler != null && handler.isKnown( exoToReg.get(this.getClass()) );
return true; }
@Override
public void setKnown() {
if (!isKnown()) {
handler.know(exoToReg.get(this.getClass()));
updateQuickslot();
Potion p = Dungeon.hero.belongings.getItem(getClass());
if (p != null) p.setAction();
p = Dungeon.hero.belongings.getItem(exoToReg.get(this.getClass()));
if (p != null) p.setAction();
}
} }
@Override @Override
public void reset() { public void reset() {
super.reset();
if (handler != null && handler.contains(exoToReg.get(this.getClass()))) { if (handler != null && handler.contains(exoToReg.get(this.getClass()))) {
image = handler.image(exoToReg.get(this.getClass())) + 16; image = handler.image(exoToReg.get(this.getClass())) + 16;
} }
} }
//TODO
@Override
public int price() {
return super.price();
}
public static class PotionToExotic extends Recipe{ public static class PotionToExotic extends Recipe{
@Override @Override

View File

@ -43,12 +43,20 @@ public abstract class ExoticScroll extends Scroll {
@Override @Override
public boolean isKnown() { public boolean isKnown() {
//assume it is IDed as ided scrolls are needed for alchemy return handler != null && handler.isKnown( exoToReg.get(this.getClass()) );
return true; }
@Override
public void setKnown() {
if (!isKnown()) {
handler.know(exoToReg.get(this.getClass()));
updateQuickslot();
}
} }
@Override @Override
public void reset() { public void reset() {
super.reset();
if (handler != null && handler.contains(exoToReg.get(this.getClass()))) { if (handler != null && handler.contains(exoToReg.get(this.getClass()))) {
image = handler.image(exoToReg.get(this.getClass())) + 16; image = handler.image(exoToReg.get(this.getClass())) + 16;
} }
@ -59,6 +67,12 @@ public abstract class ExoticScroll extends Scroll {
} }
//TODO
@Override
public int price() {
return super.price();
}
public static class ScrollToExotic extends Recipe { public static class ScrollToExotic extends Recipe {
@Override @Override