V0.1.1: Ankh/dew vial changes
This commit is contained in:
@@ -19,6 +19,9 @@ package com.shatteredpixel.shatteredpixeldungeon.items;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.QuickSlot;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
@@ -34,44 +37,44 @@ import com.watabou.utils.Bundle;
|
||||
public class DewVial extends Item {
|
||||
|
||||
private static final int MAX_VOLUME = 10;
|
||||
|
||||
|
||||
private static final String AC_DRINK = "DRINK";
|
||||
|
||||
|
||||
private static final float TIME_TO_DRINK = 1f;
|
||||
|
||||
|
||||
private static final String TXT_VALUE = "%+dHP";
|
||||
private static final String TXT_STATUS = "%d/%d";
|
||||
|
||||
|
||||
private static final String TXT_AUTO_DRINK = "The dew vial was emptied to heal your wounds.";
|
||||
private static final String TXT_COLLECTED = "You collected a dewdrop into your dew vial.";
|
||||
private static final String TXT_FULL = "Your dew vial is full!";
|
||||
private static final String TXT_EMPTY = "Your dew vial is empty!";
|
||||
|
||||
|
||||
{
|
||||
name = "dew vial";
|
||||
image = ItemSpriteSheet.VIAL;
|
||||
|
||||
|
||||
defaultAction = AC_DRINK;
|
||||
|
||||
|
||||
unique = true;
|
||||
}
|
||||
|
||||
|
||||
private int volume = 0;
|
||||
|
||||
|
||||
private static final String VOLUME = "volume";
|
||||
|
||||
|
||||
@Override
|
||||
public void storeInBundle( Bundle bundle ) {
|
||||
super.storeInBundle( bundle );
|
||||
bundle.put( VOLUME, volume );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void restoreFromBundle( Bundle bundle ) {
|
||||
super.restoreFromBundle( bundle );
|
||||
volume = bundle.getInt( VOLUME );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ArrayList<String> actions( Hero hero ) {
|
||||
ArrayList<String> actions = super.actions( hero );
|
||||
@@ -80,104 +83,99 @@ public class DewVial extends Item {
|
||||
}
|
||||
return actions;
|
||||
}
|
||||
|
||||
private static final double NUM = 20;
|
||||
private static final double POW = Math.log10( NUM );
|
||||
|
||||
|
||||
@Override
|
||||
public void execute( final Hero hero, String action ) {
|
||||
if (action.equals( AC_DRINK )) {
|
||||
|
||||
|
||||
if (volume > 0) {
|
||||
|
||||
int value = (int)Math.ceil( Math.pow( volume, POW ) / NUM * hero.HT );
|
||||
int value = 1 + (Dungeon.depth - 1) / 5;
|
||||
if (hero.heroClass == HeroClass.HUNTRESS) {
|
||||
value++;
|
||||
}
|
||||
value *= volume;
|
||||
value = (int)Math.max(volume*volume*.01*hero.HT, value);
|
||||
int effect = Math.min( hero.HT - hero.HP, value );
|
||||
if (effect > 0) {
|
||||
hero.HP += effect;
|
||||
hero.sprite.emitter().burst( Speck.factory( Speck.HEALING ), volume > 5 ? 2 : 1 );
|
||||
hero.sprite.showStatus( CharSprite.POSITIVE, TXT_VALUE, effect );
|
||||
}
|
||||
|
||||
volume = 0;
|
||||
|
||||
|
||||
volume = 0;
|
||||
|
||||
hero.spend( TIME_TO_DRINK );
|
||||
hero.busy();
|
||||
|
||||
|
||||
Sample.INSTANCE.play( Assets.SND_DRINK );
|
||||
hero.sprite.operate( hero.pos );
|
||||
|
||||
updateQuickslot();
|
||||
|
||||
|
||||
QuickSlot.refresh();
|
||||
|
||||
|
||||
} else {
|
||||
GLog.w( TXT_EMPTY );
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
super.execute( hero, action );
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void empty() {volume = 0; QuickSlot.refresh();}
|
||||
|
||||
@Override
|
||||
public boolean isUpgradable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isIdentified() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public boolean isFull() {
|
||||
return volume >= MAX_VOLUME;
|
||||
}
|
||||
|
||||
|
||||
public void collectDew( Dewdrop dew ) {
|
||||
|
||||
|
||||
GLog.i( TXT_COLLECTED );
|
||||
volume += dew.quantity;
|
||||
if (volume >= MAX_VOLUME) {
|
||||
volume = MAX_VOLUME;
|
||||
GLog.p( TXT_FULL );
|
||||
}
|
||||
|
||||
updateQuickslot();
|
||||
|
||||
QuickSlot.refresh();
|
||||
}
|
||||
|
||||
|
||||
public void fill() {
|
||||
volume = MAX_VOLUME;
|
||||
updateQuickslot();
|
||||
QuickSlot.refresh();
|
||||
}
|
||||
|
||||
public static void autoDrink( Hero hero ) {
|
||||
DewVial vial = hero.belongings.getItem( DewVial.class );
|
||||
if (vial != null && vial.isFull()) {
|
||||
vial.execute( hero );
|
||||
hero.sprite.emitter().start( ShaftParticle.FACTORY, 0.2f, 3 );
|
||||
|
||||
GLog.w( TXT_AUTO_DRINK );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static final Glowing WHITE = new Glowing( 0xFFFFCC );
|
||||
|
||||
|
||||
@Override
|
||||
public Glowing glowing() {
|
||||
return isFull() ? WHITE : null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String status() {
|
||||
return Utils.format( TXT_STATUS, volume, MAX_VOLUME );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String info() {
|
||||
return
|
||||
return
|
||||
"You can store excess dew in this tiny vessel for drinking it later. " +
|
||||
"If the vial is full, in a moment of deadly peril the dew will be " +
|
||||
"consumed automatically.";
|
||||
"The more full the vial is, the more each dew drop will heal you. " +
|
||||
"A full vial is as strong as a potion of healing.";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user