Magic_Ling_Pixel_Dungeon/src/com/shatteredpixel/shatteredpixeldungeon/items/Ankh.java

141 lines
4.3 KiB
Java
Raw Normal View History

2014-07-27 13:39:07 +00:00
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items;
2014-07-27 13:39:07 +00:00
2014-08-13 04:24:18 +00:00
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
2014-08-13 04:24:18 +00:00
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite.Glowing;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.watabou.noosa.audio.Sample;
import com.watabou.utils.Bundle;
2014-08-13 04:24:18 +00:00
import java.util.ArrayList;
2014-07-27 13:39:07 +00:00
public class Ankh extends Item {
2014-08-13 04:24:18 +00:00
public static final String AC_BLESS = "BLESS";
public static final String TXT_DESC_NOBLESS = "Upon resurrection all non-equipped items are lost. " +
"Using a full dew vial, the ankh can be blessed with extra strength.";
public static final String TXT_DESC_BLESSED = "The ankh has been blessed and is now much stronger. " +
"The Ankh will sacrifice itself to save you in a moment of deadly peril.";
public static final String TXT_BLESS = "You bless the ankh with clean water.";
public static final String TXT_REVIVE = "The ankh explodes with life-giving energy!";
{
2014-07-27 13:39:07 +00:00
name = "Ankh";
image = ItemSpriteSheet.ANKH;
}
2014-08-13 04:24:18 +00:00
private Boolean blessed = false;
2014-07-27 13:39:07 +00:00
@Override
public boolean isUpgradable() {
return false;
}
@Override
public boolean isIdentified() {
return true;
}
2014-08-13 04:24:18 +00:00
@Override
public ArrayList<String> actions( Hero hero ) {
ArrayList<String> actions = super.actions(hero);
DewVial vial = hero.belongings.getItem(DewVial.class);
if (vial != null && vial.isFull())
actions.add( AC_BLESS );
return actions;
}
@Override
public void execute( final Hero hero, String action ) {
if (action.equals( AC_BLESS )) {
DewVial vial = hero.belongings.getItem(DewVial.class);
if (vial != null){
blessed = true;
vial.empty();
GLog.p( TXT_BLESS );
hero.spend( 1f );
hero.busy();
2014-08-13 04:24:18 +00:00
Sample.INSTANCE.play( Assets.SND_DRINK );
CellEmitter.get(hero.pos).start(Speck.factory(Speck.LIGHT), 0.2f, 3);
2014-08-13 04:24:18 +00:00
hero.sprite.operate( hero.pos );
}
} else {
super.execute( hero, action );
}
}
2014-07-27 13:39:07 +00:00
@Override
public String info() {
2014-08-13 04:24:18 +00:00
if (blessed)
return
"This ancient symbol of immortality grants the ability to return to life after death. " +
TXT_DESC_BLESSED;
else
return
"This ancient symbol of immortality grants the ability to return to life after death. " +
TXT_DESC_NOBLESS;
2014-07-27 13:39:07 +00:00
}
2014-08-13 04:24:18 +00:00
public Boolean isBlessed(){
return blessed;
}
private static final Glowing WHITE = new Glowing( 0xFFFFCC );
@Override
public Glowing glowing() {
return isBlessed() ? WHITE : null;
}
private static final String BLESSED = "blessed";
@Override
public void storeInBundle( Bundle bundle ) {
super.storeInBundle( bundle );
bundle.put( BLESSED, blessed );
}
@Override
public void restoreFromBundle( Bundle bundle ) {
super.restoreFromBundle( bundle );
//TODO: remove when saves from 0.1.1 are invalidated
if (bundle.contains( BLESSED ))
blessed = bundle.getBoolean( BLESSED );
}
2014-07-27 13:39:07 +00:00
@Override
public int price() {
return 50 * quantity;
}
}