cleaned up formatting:
- removed trailing whitespace - changed all leading whitespace to tabs - removed IDE created author comments
This commit is contained in:
+195
-198
@@ -17,254 +17,251 @@ import com.watabou.utils.Random;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* Created by debenhame on 24/11/2014.
|
||||
*/
|
||||
public class AlchemistsToolkit extends Artifact {
|
||||
|
||||
{
|
||||
name = "Alchemists Toolkit";
|
||||
image = ItemSpriteSheet.ARTIFACT_TOOLKIT;
|
||||
{
|
||||
name = "Alchemists Toolkit";
|
||||
image = ItemSpriteSheet.ARTIFACT_TOOLKIT;
|
||||
|
||||
level = 0;
|
||||
levelCap = 10;
|
||||
}
|
||||
level = 0;
|
||||
levelCap = 10;
|
||||
}
|
||||
|
||||
public static final String AC_BREW = "BREW";
|
||||
public static final String AC_BREW = "BREW";
|
||||
|
||||
//arrays used in containing potion collections for mix logic.
|
||||
public final ArrayList<String> combination = new ArrayList<String>();
|
||||
public ArrayList<String> curGuess = new ArrayList<String>();
|
||||
public ArrayList<String> bstGuess = new ArrayList<String>();
|
||||
//arrays used in containing potion collections for mix logic.
|
||||
public final ArrayList<String> combination = new ArrayList<String>();
|
||||
public ArrayList<String> curGuess = new ArrayList<String>();
|
||||
public ArrayList<String> bstGuess = new ArrayList<String>();
|
||||
|
||||
public int numWrongPlace = 0;
|
||||
public int numRight = 0;
|
||||
public int numWrongPlace = 0;
|
||||
public int numRight = 0;
|
||||
|
||||
private int seedsToPotion = 0;
|
||||
private int seedsToPotion = 0;
|
||||
|
||||
protected String inventoryTitle = "Select a potion";
|
||||
protected WndBag.Mode mode = WndBag.Mode.POTION;
|
||||
protected String inventoryTitle = "Select a potion";
|
||||
protected WndBag.Mode mode = WndBag.Mode.POTION;
|
||||
|
||||
public AlchemistsToolkit() {
|
||||
super();
|
||||
public AlchemistsToolkit() {
|
||||
super();
|
||||
|
||||
Generator.Category cat = Generator.Category.POTION;
|
||||
for (int i = 1; i <= 3; i++){
|
||||
String potion;
|
||||
do{
|
||||
potion = convertName(cat.classes[Random.chances(cat.probs)].getSimpleName());
|
||||
//forcing the player to use experience potions would be completely unfair.
|
||||
} while (combination.contains(potion) || potion.equals("Experience"));
|
||||
combination.add(potion);
|
||||
}
|
||||
}
|
||||
Generator.Category cat = Generator.Category.POTION;
|
||||
for (int i = 1; i <= 3; i++){
|
||||
String potion;
|
||||
do{
|
||||
potion = convertName(cat.classes[Random.chances(cat.probs)].getSimpleName());
|
||||
//forcing the player to use experience potions would be completely unfair.
|
||||
} while (combination.contains(potion) || potion.equals("Experience"));
|
||||
combination.add(potion);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> actions( Hero hero ) {
|
||||
ArrayList<String> actions = super.actions( hero );
|
||||
if (isEquipped( hero ) && level < levelCap && !cursed)
|
||||
actions.add(AC_BREW);
|
||||
return actions;
|
||||
}
|
||||
@Override
|
||||
public ArrayList<String> actions( Hero hero ) {
|
||||
ArrayList<String> actions = super.actions( hero );
|
||||
if (isEquipped( hero ) && level < levelCap && !cursed)
|
||||
actions.add(AC_BREW);
|
||||
return actions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Hero hero, String action ) {
|
||||
if (action.equals(AC_BREW)){
|
||||
GameScene.selectItem(itemSelector, mode, inventoryTitle);
|
||||
} else {
|
||||
super.execute(hero, action);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void execute(Hero hero, String action ) {
|
||||
if (action.equals(AC_BREW)){
|
||||
GameScene.selectItem(itemSelector, mode, inventoryTitle);
|
||||
} else {
|
||||
super.execute(hero, action);
|
||||
}
|
||||
}
|
||||
|
||||
public void guessBrew() {
|
||||
if (curGuess.size() != 3)
|
||||
return;
|
||||
public void guessBrew() {
|
||||
if (curGuess.size() != 3)
|
||||
return;
|
||||
|
||||
int numWrongPlace = 0;
|
||||
int numRight = 0;
|
||||
int numWrongPlace = 0;
|
||||
int numRight = 0;
|
||||
|
||||
for (String potion : curGuess) {
|
||||
if (combination.contains(potion)) {
|
||||
if (curGuess.indexOf(potion) == combination.indexOf(potion)) {
|
||||
numRight++;
|
||||
} else {
|
||||
numWrongPlace++;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (String potion : curGuess) {
|
||||
if (combination.contains(potion)) {
|
||||
if (curGuess.indexOf(potion) == combination.indexOf(potion)) {
|
||||
numRight++;
|
||||
} else {
|
||||
numWrongPlace++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int score = (numRight *3) + numWrongPlace;
|
||||
int score = (numRight *3) + numWrongPlace;
|
||||
|
||||
if (score == 9)
|
||||
score ++;
|
||||
if (score == 9)
|
||||
score ++;
|
||||
|
||||
if (score == 0){
|
||||
if (score == 0){
|
||||
|
||||
GLog.i("Your mixture is complete, but none of the potions you used seem to react well. " +
|
||||
"The brew is useless, you throw it away.");
|
||||
GLog.i("Your mixture is complete, but none of the potions you used seem to react well. " +
|
||||
"The brew is useless, you throw it away.");
|
||||
|
||||
} else if (score > level) {
|
||||
} else if (score > level) {
|
||||
|
||||
level = score;
|
||||
seedsToPotion = 0;
|
||||
bstGuess = curGuess;
|
||||
this.numRight = numRight;
|
||||
this.numWrongPlace = numWrongPlace;
|
||||
level = score;
|
||||
seedsToPotion = 0;
|
||||
bstGuess = curGuess;
|
||||
this.numRight = numRight;
|
||||
this.numWrongPlace = numWrongPlace;
|
||||
|
||||
if (level == 10){
|
||||
bstGuess = new ArrayList<String>();
|
||||
GLog.p("The mixture you've created seems perfect, you don't think there is any way to improve it!");
|
||||
} else {
|
||||
GLog.w("you finish mixing potions, " + brewDesc(numWrongPlace, numRight) +
|
||||
". This is your best brew yet!");
|
||||
}
|
||||
if (level == 10){
|
||||
bstGuess = new ArrayList<String>();
|
||||
GLog.p("The mixture you've created seems perfect, you don't think there is any way to improve it!");
|
||||
} else {
|
||||
GLog.w("you finish mixing potions, " + brewDesc(numWrongPlace, numRight) +
|
||||
". This is your best brew yet!");
|
||||
}
|
||||
|
||||
} else {
|
||||
} else {
|
||||
|
||||
GLog.w("you finish mixing potions, " + brewDesc(numWrongPlace, numRight) +
|
||||
". This brew isn't as good as the current one, you throw it away.");
|
||||
}
|
||||
curGuess = new ArrayList<String>();
|
||||
GLog.w("you finish mixing potions, " + brewDesc(numWrongPlace, numRight) +
|
||||
". This brew isn't as good as the current one, you throw it away.");
|
||||
}
|
||||
curGuess = new ArrayList<String>();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private String brewDesc(int numWrongPlace, int numRight){
|
||||
String result = "";
|
||||
if (numWrongPlace > 0){
|
||||
result += numWrongPlace + " reacted well, but in the wrong order";
|
||||
if (numRight > 0)
|
||||
result += " and ";
|
||||
}
|
||||
if (numRight > 0){
|
||||
result += numRight + " reacted perfectly";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
private String brewDesc(int numWrongPlace, int numRight){
|
||||
String result = "";
|
||||
if (numWrongPlace > 0){
|
||||
result += numWrongPlace + " reacted well, but in the wrong order";
|
||||
if (numRight > 0)
|
||||
result += " and ";
|
||||
}
|
||||
if (numRight > 0){
|
||||
result += numRight + " reacted perfectly";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ArtifactBuff passiveBuff() {
|
||||
return new alchemy();
|
||||
}
|
||||
@Override
|
||||
protected ArtifactBuff passiveBuff() {
|
||||
return new alchemy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
String result = "This toolkit contains a number of regents and herbs used to improve the process of " +
|
||||
"cooking potions.\n\n";
|
||||
@Override
|
||||
public String desc() {
|
||||
String result = "This toolkit contains a number of regents and herbs used to improve the process of " +
|
||||
"cooking potions.\n\n";
|
||||
|
||||
if (isEquipped(Dungeon.hero))
|
||||
if (cursed)
|
||||
result += "The cursed toolkit has bound itself to your side, and refuses to let you use alchemy.\n\n";
|
||||
else
|
||||
result += "The toolkit rests on your hip, the various tools inside make a light jingling sound as you move.\n\n";
|
||||
if (isEquipped(Dungeon.hero))
|
||||
if (cursed)
|
||||
result += "The cursed toolkit has bound itself to your side, and refuses to let you use alchemy.\n\n";
|
||||
else
|
||||
result += "The toolkit rests on your hip, the various tools inside make a light jingling sound as you move.\n\n";
|
||||
|
||||
if (level == 0){
|
||||
result += "The toolkit seems to be missing a key tool, a catalyst mixture. You'll have to make your own " +
|
||||
"out of three common potions to get the most out of the toolkit.";
|
||||
} else if (level == 10) {
|
||||
result += "The mixture you have created seems perfect, and the toolkit is working at maximum efficiency.";
|
||||
} else if (!bstGuess.isEmpty()) {
|
||||
result += "Your current best mixture is made from: " + bstGuess.get(0) + ", " + bstGuess.get(1) + ", "
|
||||
+ bstGuess.get(2) + ", in that order.\n\n";
|
||||
result += "Of the potions in that mix, " + brewDesc(numWrongPlace, numRight) + ".";
|
||||
if (level == 0){
|
||||
result += "The toolkit seems to be missing a key tool, a catalyst mixture. You'll have to make your own " +
|
||||
"out of three common potions to get the most out of the toolkit.";
|
||||
} else if (level == 10) {
|
||||
result += "The mixture you have created seems perfect, and the toolkit is working at maximum efficiency.";
|
||||
} else if (!bstGuess.isEmpty()) {
|
||||
result += "Your current best mixture is made from: " + bstGuess.get(0) + ", " + bstGuess.get(1) + ", "
|
||||
+ bstGuess.get(2) + ", in that order.\n\n";
|
||||
result += "Of the potions in that mix, " + brewDesc(numWrongPlace, numRight) + ".";
|
||||
|
||||
//would only trigger if an upgraded toolkit was gained through transmutation or bones.
|
||||
} else {
|
||||
result += "The toolkit seems to have a catalyst mixture already in it, but it isn't ideal. Unfortunately " +
|
||||
"you have no idea what's in the mixture.";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
//would only trigger if an upgraded toolkit was gained through transmutation or bones.
|
||||
} else {
|
||||
result += "The toolkit seems to have a catalyst mixture already in it, but it isn't ideal. Unfortunately " +
|
||||
"you have no idea what's in the mixture.";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static final String COMBINATION = "combination";
|
||||
private static final String CURGUESS = "curguess";
|
||||
private static final String BSTGUESS = "bstguess";
|
||||
private static final String COMBINATION = "combination";
|
||||
private static final String CURGUESS = "curguess";
|
||||
private static final String BSTGUESS = "bstguess";
|
||||
|
||||
private static final String NUMWRONGPLACE = "numwrongplace";
|
||||
private static final String NUMRIGHT = "numright";
|
||||
private static final String NUMWRONGPLACE = "numwrongplace";
|
||||
private static final String NUMRIGHT = "numright";
|
||||
|
||||
private static final String SEEDSTOPOTION = "seedstopotion";
|
||||
private static final String SEEDSTOPOTION = "seedstopotion";
|
||||
|
||||
@Override
|
||||
public void storeInBundle(Bundle bundle){
|
||||
super.storeInBundle(bundle);
|
||||
bundle.put(NUMWRONGPLACE, numWrongPlace);
|
||||
bundle.put(NUMRIGHT, numRight);
|
||||
@Override
|
||||
public void storeInBundle(Bundle bundle){
|
||||
super.storeInBundle(bundle);
|
||||
bundle.put(NUMWRONGPLACE, numWrongPlace);
|
||||
bundle.put(NUMRIGHT, numRight);
|
||||
|
||||
bundle.put(SEEDSTOPOTION, seedsToPotion);
|
||||
bundle.put(SEEDSTOPOTION, seedsToPotion);
|
||||
|
||||
bundle.put(COMBINATION, combination.toArray(new String[combination.size()]));
|
||||
bundle.put(CURGUESS, curGuess.toArray(new String[curGuess.size()]));
|
||||
bundle.put(BSTGUESS, bstGuess.toArray(new String[bstGuess.size()]));
|
||||
}
|
||||
bundle.put(COMBINATION, combination.toArray(new String[combination.size()]));
|
||||
bundle.put(CURGUESS, curGuess.toArray(new String[curGuess.size()]));
|
||||
bundle.put(BSTGUESS, bstGuess.toArray(new String[bstGuess.size()]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreFromBundle( Bundle bundle ) {
|
||||
super.restoreFromBundle(bundle);
|
||||
numWrongPlace = bundle.getInt( NUMWRONGPLACE );
|
||||
numRight = bundle.getInt( NUMRIGHT );
|
||||
@Override
|
||||
public void restoreFromBundle( Bundle bundle ) {
|
||||
super.restoreFromBundle(bundle);
|
||||
numWrongPlace = bundle.getInt( NUMWRONGPLACE );
|
||||
numRight = bundle.getInt( NUMRIGHT );
|
||||
|
||||
seedsToPotion = bundle.getInt( SEEDSTOPOTION );
|
||||
seedsToPotion = bundle.getInt( SEEDSTOPOTION );
|
||||
|
||||
combination.clear();
|
||||
Collections.addAll( combination, bundle.getStringArray( COMBINATION ));
|
||||
Collections.addAll( curGuess, bundle.getStringArray( CURGUESS ));
|
||||
Collections.addAll( bstGuess, bundle.getStringArray( BSTGUESS ));
|
||||
}
|
||||
combination.clear();
|
||||
Collections.addAll( combination, bundle.getStringArray( COMBINATION ));
|
||||
Collections.addAll( curGuess, bundle.getStringArray( CURGUESS ));
|
||||
Collections.addAll( bstGuess, bundle.getStringArray( BSTGUESS ));
|
||||
}
|
||||
|
||||
|
||||
public class alchemy extends ArtifactBuff {
|
||||
public class alchemy extends ArtifactBuff {
|
||||
|
||||
public boolean tryCook(int count){
|
||||
public boolean tryCook(int count){
|
||||
|
||||
//this logic is handled inside the class with a variable so that it may be stored.
|
||||
//to prevent manipulation where a player could keep throwing in 1-2 seeds until they get lucky.
|
||||
if (seedsToPotion == 0){
|
||||
if (Random.Int(20) < 10+level){
|
||||
if (Random.Int(20) < level){
|
||||
seedsToPotion = 1;
|
||||
} else
|
||||
seedsToPotion = 2;
|
||||
} else
|
||||
seedsToPotion = 3;
|
||||
}
|
||||
//this logic is handled inside the class with a variable so that it may be stored.
|
||||
//to prevent manipulation where a player could keep throwing in 1-2 seeds until they get lucky.
|
||||
if (seedsToPotion == 0){
|
||||
if (Random.Int(20) < 10+level){
|
||||
if (Random.Int(20) < level){
|
||||
seedsToPotion = 1;
|
||||
} else
|
||||
seedsToPotion = 2;
|
||||
} else
|
||||
seedsToPotion = 3;
|
||||
}
|
||||
|
||||
if (count >= seedsToPotion){
|
||||
seedsToPotion = 0;
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
if (count >= seedsToPotion){
|
||||
seedsToPotion = 0;
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected WndBag.Listener itemSelector = new WndBag.Listener() {
|
||||
@Override
|
||||
public void onSelect(Item item) {
|
||||
if (item != null && item instanceof Potion && item.isIdentified()){
|
||||
if (!curGuess.contains(convertName(item.getClass().getSimpleName()))) {
|
||||
protected WndBag.Listener itemSelector = new WndBag.Listener() {
|
||||
@Override
|
||||
public void onSelect(Item item) {
|
||||
if (item != null && item instanceof Potion && item.isIdentified()){
|
||||
if (!curGuess.contains(convertName(item.getClass().getSimpleName()))) {
|
||||
|
||||
Hero hero = Dungeon.hero;
|
||||
hero.sprite.operate( hero.pos );
|
||||
hero.busy();
|
||||
hero.spend( 2f );
|
||||
Sample.INSTANCE.play(Assets.SND_DRINK);
|
||||
Hero hero = Dungeon.hero;
|
||||
hero.sprite.operate( hero.pos );
|
||||
hero.busy();
|
||||
hero.spend( 2f );
|
||||
Sample.INSTANCE.play(Assets.SND_DRINK);
|
||||
|
||||
item.detach(hero.belongings.backpack);
|
||||
item.detach(hero.belongings.backpack);
|
||||
|
||||
curGuess.add(convertName(item.getClass().getSimpleName()));
|
||||
if (curGuess.size() == 3){
|
||||
guessBrew();
|
||||
} else {
|
||||
GLog.i("You mix the " + item.name() + " into your current brew.");
|
||||
}
|
||||
} else {
|
||||
GLog.w("Your current brew already contains that potion.");
|
||||
}
|
||||
} else if (item != null) {
|
||||
GLog.w("You need to select an identified potion.");
|
||||
}
|
||||
}
|
||||
};
|
||||
curGuess.add(convertName(item.getClass().getSimpleName()));
|
||||
if (curGuess.size() == 3){
|
||||
guessBrew();
|
||||
} else {
|
||||
GLog.i("You mix the " + item.name() + " into your current brew.");
|
||||
}
|
||||
} else {
|
||||
GLog.w("Your current brew already contains that potion.");
|
||||
}
|
||||
} else if (item != null) {
|
||||
GLog.w("You need to select an identified potion.");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -13,270 +13,267 @@ import com.watabou.utils.Random;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by Evan on 24/08/2014.
|
||||
*/
|
||||
public class Artifact extends KindofMisc {
|
||||
|
||||
private static final float TIME_TO_EQUIP = 1f;
|
||||
private static final float TIME_TO_EQUIP = 1f;
|
||||
|
||||
private static final String TXT_TO_STRING = "%s";
|
||||
private static final String TXT_TO_STRING_CHARGE = "%s (%d/%d)";
|
||||
private static final String TXT_TO_STRING_LVL = "%s%+d";
|
||||
private static final String TXT_TO_STRING_LVL_CHARGE = "%s%+d (%d/%d)";
|
||||
private static final String TXT_TO_STRING = "%s";
|
||||
private static final String TXT_TO_STRING_CHARGE = "%s (%d/%d)";
|
||||
private static final String TXT_TO_STRING_LVL = "%s%+d";
|
||||
private static final String TXT_TO_STRING_LVL_CHARGE = "%s%+d (%d/%d)";
|
||||
|
||||
protected Buff passiveBuff;
|
||||
protected Buff activeBuff;
|
||||
protected Buff passiveBuff;
|
||||
protected Buff activeBuff;
|
||||
|
||||
//level is used internally to track upgrades to artifacts, size/logic varies per artifact.
|
||||
//already inherited from item superclass
|
||||
//exp is used to count progress towards levels for some artifacts
|
||||
protected int exp = 0;
|
||||
//levelCap is the artifact's maximum level
|
||||
protected int levelCap = 0;
|
||||
//level is used internally to track upgrades to artifacts, size/logic varies per artifact.
|
||||
//already inherited from item superclass
|
||||
//exp is used to count progress towards levels for some artifacts
|
||||
protected int exp = 0;
|
||||
//levelCap is the artifact's maximum level
|
||||
protected int levelCap = 0;
|
||||
|
||||
//the current artifact charge
|
||||
protected int charge = 0;
|
||||
//the build towards next charge, usually rolls over at 1.
|
||||
//better to keep charge as an int and use a separate float than casting.
|
||||
protected float partialCharge = 0;
|
||||
//the maximum charge, varies per artifact, not all artifacts use this.
|
||||
protected int chargeCap = 0;
|
||||
//the current artifact charge
|
||||
protected int charge = 0;
|
||||
//the build towards next charge, usually rolls over at 1.
|
||||
//better to keep charge as an int and use a separate float than casting.
|
||||
protected float partialCharge = 0;
|
||||
//the maximum charge, varies per artifact, not all artifacts use this.
|
||||
protected int chargeCap = 0;
|
||||
|
||||
//used by some artifacts to keep track of duration of effects or cooldowns to use.
|
||||
protected int cooldown = 0;
|
||||
//used by some artifacts to keep track of duration of effects or cooldowns to use.
|
||||
protected int cooldown = 0;
|
||||
|
||||
|
||||
public Artifact(){
|
||||
super();
|
||||
}
|
||||
public Artifact(){
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> actions( Hero hero ) {
|
||||
ArrayList<String> actions = super.actions( hero );
|
||||
actions.add( isEquipped( hero ) ? AC_UNEQUIP : AC_EQUIP );
|
||||
return actions;
|
||||
}
|
||||
@Override
|
||||
public ArrayList<String> actions( Hero hero ) {
|
||||
ArrayList<String> actions = super.actions( hero );
|
||||
actions.add( isEquipped( hero ) ? AC_UNEQUIP : AC_EQUIP );
|
||||
return actions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doEquip( Hero hero ) {
|
||||
@Override
|
||||
public boolean doEquip( Hero hero ) {
|
||||
|
||||
if (hero.belongings.misc1 != null && hero.belongings.misc2 != null) {
|
||||
if (hero.belongings.misc1 != null && hero.belongings.misc2 != null) {
|
||||
|
||||
GLog.w("you can only wear 2 misc items at a time");
|
||||
return false;
|
||||
GLog.w("you can only wear 2 misc items at a time");
|
||||
return false;
|
||||
|
||||
} else if ((hero.belongings.misc1 != null && hero.belongings.misc1.getClass() == this.getClass())
|
||||
|| (hero.belongings.misc2 != null && hero.belongings.misc2.getClass() == this.getClass())){
|
||||
} else if ((hero.belongings.misc1 != null && hero.belongings.misc1.getClass() == this.getClass())
|
||||
|| (hero.belongings.misc2 != null && hero.belongings.misc2.getClass() == this.getClass())){
|
||||
|
||||
GLog.w("you cannot wear two of the same artifact");
|
||||
return false;
|
||||
GLog.w("you cannot wear two of the same artifact");
|
||||
return false;
|
||||
|
||||
} else {
|
||||
} else {
|
||||
|
||||
if (hero.belongings.misc1 == null) {
|
||||
hero.belongings.misc1 = this;
|
||||
} else {
|
||||
hero.belongings.misc2 = this;
|
||||
}
|
||||
if (hero.belongings.misc1 == null) {
|
||||
hero.belongings.misc1 = this;
|
||||
} else {
|
||||
hero.belongings.misc2 = this;
|
||||
}
|
||||
|
||||
detach( hero.belongings.backpack );
|
||||
detach( hero.belongings.backpack );
|
||||
|
||||
activate( hero );
|
||||
activate( hero );
|
||||
|
||||
cursedKnown = true;
|
||||
identify();
|
||||
if (cursed) {
|
||||
equipCursed( hero );
|
||||
GLog.n( "the " + this.name + " painfully binds itself to you" );
|
||||
}
|
||||
cursedKnown = true;
|
||||
identify();
|
||||
if (cursed) {
|
||||
equipCursed( hero );
|
||||
GLog.n( "the " + this.name + " painfully binds itself to you" );
|
||||
}
|
||||
|
||||
hero.spendAndNext( TIME_TO_EQUIP );
|
||||
return true;
|
||||
hero.spendAndNext( TIME_TO_EQUIP );
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void activate( Char ch ) {
|
||||
passiveBuff = passiveBuff();
|
||||
passiveBuff.attachTo(ch);
|
||||
}
|
||||
public void activate( Char ch ) {
|
||||
passiveBuff = passiveBuff();
|
||||
passiveBuff.attachTo(ch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doUnequip( Hero hero, boolean collect, boolean single ) {
|
||||
if (super.doUnequip( hero, collect, single )) {
|
||||
@Override
|
||||
public boolean doUnequip( Hero hero, boolean collect, boolean single ) {
|
||||
if (super.doUnequip( hero, collect, single )) {
|
||||
|
||||
if (hero.belongings.misc1 == this) {
|
||||
hero.belongings.misc1 = null;
|
||||
} else {
|
||||
hero.belongings.misc2 = null;
|
||||
}
|
||||
if (hero.belongings.misc1 == this) {
|
||||
hero.belongings.misc1 = null;
|
||||
} else {
|
||||
hero.belongings.misc2 = null;
|
||||
}
|
||||
|
||||
passiveBuff.detach();
|
||||
passiveBuff = null;
|
||||
passiveBuff.detach();
|
||||
passiveBuff = null;
|
||||
|
||||
if (activeBuff != null){
|
||||
activeBuff.detach();
|
||||
activeBuff = null;
|
||||
}
|
||||
if (activeBuff != null){
|
||||
activeBuff.detach();
|
||||
activeBuff = null;
|
||||
}
|
||||
|
||||
return true;
|
||||
return true;
|
||||
|
||||
} else {
|
||||
} else {
|
||||
|
||||
return false;
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEquipped( Hero hero ) {
|
||||
return hero.belongings.misc1 == this || hero.belongings.misc2 == this;
|
||||
}
|
||||
@Override
|
||||
public boolean isEquipped( Hero hero ) {
|
||||
return hero.belongings.misc1 == this || hero.belongings.misc2 == this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUpgradable() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean isUpgradable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int visiblyUpgraded() {
|
||||
return ((level*10)/levelCap);
|
||||
}
|
||||
@Override
|
||||
public int visiblyUpgraded() {
|
||||
return ((level*10)/levelCap);
|
||||
}
|
||||
|
||||
//transfers upgrades from another artifact, transfer level will equal the displayed level
|
||||
public void transferUpgrade(int transferLvl) {
|
||||
upgrade(Math.round((float)(transferLvl*levelCap)/10));
|
||||
}
|
||||
//transfers upgrades from another artifact, transfer level will equal the displayed level
|
||||
public void transferUpgrade(int transferLvl) {
|
||||
upgrade(Math.round((float)(transferLvl*levelCap)/10));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String info() {
|
||||
if (cursed && cursedKnown && !isEquipped( Dungeon.hero )) {
|
||||
@Override
|
||||
public String info() {
|
||||
if (cursed && cursedKnown && !isEquipped( Dungeon.hero )) {
|
||||
|
||||
return desc() + "\n\nYou can feel a malevolent magic lurking within the " + name() + ".";
|
||||
return desc() + "\n\nYou can feel a malevolent magic lurking within the " + name() + ".";
|
||||
|
||||
} else {
|
||||
} else {
|
||||
|
||||
return desc();
|
||||
return desc();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
if (levelKnown && level/levelCap != 0) {
|
||||
if (chargeCap > 0) {
|
||||
return Utils.format( TXT_TO_STRING_LVL_CHARGE, name(), visiblyUpgraded(), charge, chargeCap );
|
||||
} else {
|
||||
return Utils.format( TXT_TO_STRING_LVL, name(), visiblyUpgraded() );
|
||||
}
|
||||
} else {
|
||||
if (chargeCap > 0) {
|
||||
return Utils.format( TXT_TO_STRING_CHARGE, name(), charge, chargeCap );
|
||||
} else {
|
||||
return Utils.format( TXT_TO_STRING, name() );
|
||||
}
|
||||
}
|
||||
}
|
||||
if (levelKnown && level/levelCap != 0) {
|
||||
if (chargeCap > 0) {
|
||||
return Utils.format( TXT_TO_STRING_LVL_CHARGE, name(), visiblyUpgraded(), charge, chargeCap );
|
||||
} else {
|
||||
return Utils.format( TXT_TO_STRING_LVL, name(), visiblyUpgraded() );
|
||||
}
|
||||
} else {
|
||||
if (chargeCap > 0) {
|
||||
return Utils.format( TXT_TO_STRING_CHARGE, name(), charge, chargeCap );
|
||||
} else {
|
||||
return Utils.format( TXT_TO_STRING, name() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String status() {
|
||||
@Override
|
||||
public String status() {
|
||||
|
||||
//display the current cooldown
|
||||
if (cooldown != 0)
|
||||
return Utils.format( "%d", cooldown );
|
||||
//display the current cooldown
|
||||
if (cooldown != 0)
|
||||
return Utils.format( "%d", cooldown );
|
||||
|
||||
//display as percent
|
||||
if (chargeCap == 100)
|
||||
return Utils.format( "%d%%", charge );
|
||||
//display as percent
|
||||
if (chargeCap == 100)
|
||||
return Utils.format( "%d%%", charge );
|
||||
|
||||
//display as #/#
|
||||
if (chargeCap > 0)
|
||||
return Utils.format( "%d/%d", charge, chargeCap );
|
||||
//display as #/#
|
||||
if (chargeCap > 0)
|
||||
return Utils.format( "%d/%d", charge, chargeCap );
|
||||
|
||||
//if there's no cap -
|
||||
//- but there is charge anyway, display that charge
|
||||
if (charge != 0)
|
||||
return Utils.format( "%d", charge );
|
||||
//if there's no cap -
|
||||
//- but there is charge anyway, display that charge
|
||||
if (charge != 0)
|
||||
return Utils.format( "%d", charge );
|
||||
|
||||
//otherwise, if there's no charge, return null.
|
||||
return null;
|
||||
}
|
||||
//otherwise, if there's no charge, return null.
|
||||
return null;
|
||||
}
|
||||
|
||||
//converts class names to be more concise and readable.
|
||||
protected String convertName(String className){
|
||||
//removes known redundant parts of names.
|
||||
className = className.replaceFirst("ScrollOf|PotionOf", "");
|
||||
//converts class names to be more concise and readable.
|
||||
protected String convertName(String className){
|
||||
//removes known redundant parts of names.
|
||||
className = className.replaceFirst("ScrollOf|PotionOf", "");
|
||||
|
||||
//inserts a space infront of every uppercase character
|
||||
className = className.replaceAll("(\\p{Ll})(\\p{Lu})", "$1 $2");
|
||||
//inserts a space infront of every uppercase character
|
||||
className = className.replaceAll("(\\p{Ll})(\\p{Lu})", "$1 $2");
|
||||
|
||||
return className;
|
||||
};
|
||||
return className;
|
||||
};
|
||||
|
||||
@Override
|
||||
public Item random() {
|
||||
if (Random.Float() < 0.3f) {
|
||||
cursed = true;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public Item random() {
|
||||
if (Random.Float() < 0.3f) {
|
||||
cursed = true;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int price() {
|
||||
int price = 100;
|
||||
if (level > 0)
|
||||
price += 50*((level*10)/levelCap);
|
||||
if (cursed && cursedKnown) {
|
||||
price /= 2;
|
||||
}
|
||||
if (price < 1) {
|
||||
price = 1;
|
||||
}
|
||||
return price;
|
||||
}
|
||||
@Override
|
||||
public int price() {
|
||||
int price = 100;
|
||||
if (level > 0)
|
||||
price += 50*((level*10)/levelCap);
|
||||
if (cursed && cursedKnown) {
|
||||
price /= 2;
|
||||
}
|
||||
if (price < 1) {
|
||||
price = 1;
|
||||
}
|
||||
return price;
|
||||
}
|
||||
|
||||
|
||||
protected ArtifactBuff passiveBuff() {
|
||||
return null;
|
||||
}
|
||||
protected ArtifactBuff passiveBuff() {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected ArtifactBuff activeBuff() {return null; }
|
||||
protected ArtifactBuff activeBuff() {return null; }
|
||||
|
||||
public class ArtifactBuff extends Buff {
|
||||
public class ArtifactBuff extends Buff {
|
||||
|
||||
public int level() {
|
||||
return level;
|
||||
}
|
||||
public int level() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public boolean isCursed() {
|
||||
return cursed;
|
||||
}
|
||||
public boolean isCursed() {
|
||||
return cursed;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static final String IMAGE = "image";
|
||||
private static final String EXP = "exp";
|
||||
private static final String CHARGE = "charge";
|
||||
private static final String PARTIALCHARGE = "partialcharge";
|
||||
private static final String IMAGE = "image";
|
||||
private static final String EXP = "exp";
|
||||
private static final String CHARGE = "charge";
|
||||
private static final String PARTIALCHARGE = "partialcharge";
|
||||
|
||||
@Override
|
||||
public void storeInBundle( Bundle bundle ) {
|
||||
super.storeInBundle(bundle);
|
||||
bundle.put( IMAGE, image );
|
||||
bundle.put( EXP , exp );
|
||||
bundle.put( CHARGE , charge );
|
||||
bundle.put( PARTIALCHARGE , partialCharge );
|
||||
}
|
||||
@Override
|
||||
public void storeInBundle( Bundle bundle ) {
|
||||
super.storeInBundle(bundle);
|
||||
bundle.put( IMAGE, image );
|
||||
bundle.put( EXP , exp );
|
||||
bundle.put( CHARGE , charge );
|
||||
bundle.put( PARTIALCHARGE , partialCharge );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreFromBundle( Bundle bundle ) {
|
||||
super.restoreFromBundle(bundle);
|
||||
if (bundle.contains( IMAGE )) image = bundle.getInt( IMAGE );
|
||||
exp = bundle.getInt( EXP );
|
||||
charge = bundle.getInt( CHARGE );
|
||||
partialCharge = bundle.getFloat( PARTIALCHARGE );
|
||||
}
|
||||
@Override
|
||||
public void restoreFromBundle( Bundle bundle ) {
|
||||
super.restoreFromBundle(bundle);
|
||||
if (bundle.contains( IMAGE )) image = bundle.getInt( IMAGE );
|
||||
exp = bundle.getInt( EXP );
|
||||
charge = bundle.getInt( CHARGE );
|
||||
partialCharge = bundle.getFloat( PARTIALCHARGE );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,127 +8,124 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
/**
|
||||
* Created by debenhame on 03/09/2014.
|
||||
*/
|
||||
public class CapeOfThorns extends Artifact {
|
||||
|
||||
{
|
||||
name = "Cape of Thorns";
|
||||
image = ItemSpriteSheet.ARTIFACT_CAPE;
|
||||
{
|
||||
name = "Cape of Thorns";
|
||||
image = ItemSpriteSheet.ARTIFACT_CAPE;
|
||||
|
||||
level = 0;
|
||||
levelCap = 10;
|
||||
level = 0;
|
||||
levelCap = 10;
|
||||
|
||||
charge = 0;
|
||||
chargeCap = 100;
|
||||
cooldown = 0;
|
||||
charge = 0;
|
||||
chargeCap = 100;
|
||||
cooldown = 0;
|
||||
|
||||
defaultAction = "NONE";
|
||||
}
|
||||
defaultAction = "NONE";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ArtifactBuff passiveBuff() {
|
||||
return new Thorns();
|
||||
}
|
||||
@Override
|
||||
protected ArtifactBuff passiveBuff() {
|
||||
return new Thorns();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
String desc = "These collapsed sheets of metal from the DM-300 have formed together into a rigid wearable " +
|
||||
"cape. The metal is old and coated in thick flakes of rust. It seems to store a deep energy, " +
|
||||
"perhaps it has some of the DM-300's power?";
|
||||
if (isEquipped( Dungeon.hero )) {
|
||||
desc += "\n\n";
|
||||
if (cooldown == 0)
|
||||
desc += "The cape feels reassuringly heavy on your shoulders. You're not sure if it will directly " +
|
||||
"help you in a fight, but it seems to be gaining energy from the damage you take.";
|
||||
else
|
||||
desc += "The cape seems to be releasing some stored energy, " +
|
||||
"it is radiating a protective power at all angles. ";
|
||||
}
|
||||
@Override
|
||||
public String desc() {
|
||||
String desc = "These collapsed sheets of metal from the DM-300 have formed together into a rigid wearable " +
|
||||
"cape. The metal is old and coated in thick flakes of rust. It seems to store a deep energy, " +
|
||||
"perhaps it has some of the DM-300's power?";
|
||||
if (isEquipped( Dungeon.hero )) {
|
||||
desc += "\n\n";
|
||||
if (cooldown == 0)
|
||||
desc += "The cape feels reassuringly heavy on your shoulders. You're not sure if it will directly " +
|
||||
"help you in a fight, but it seems to be gaining energy from the damage you take.";
|
||||
else
|
||||
desc += "The cape seems to be releasing some stored energy, " +
|
||||
"it is radiating a protective power at all angles. ";
|
||||
}
|
||||
|
||||
return desc;
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
|
||||
public class Thorns extends ArtifactBuff{
|
||||
public class Thorns extends ArtifactBuff{
|
||||
|
||||
@Override
|
||||
public boolean act(){
|
||||
if (cooldown > 0) {
|
||||
cooldown--;
|
||||
if (cooldown == 0) {
|
||||
BuffIndicator.refreshHero();
|
||||
GLog.w("Your Cape becomes inert again.");
|
||||
}
|
||||
updateQuickslot();
|
||||
}
|
||||
spend(TICK);
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean act(){
|
||||
if (cooldown > 0) {
|
||||
cooldown--;
|
||||
if (cooldown == 0) {
|
||||
BuffIndicator.refreshHero();
|
||||
GLog.w("Your Cape becomes inert again.");
|
||||
}
|
||||
updateQuickslot();
|
||||
}
|
||||
spend(TICK);
|
||||
return true;
|
||||
}
|
||||
|
||||
public int proc(int damage, Char attacker, Char defender){
|
||||
if (cooldown == 0){
|
||||
charge += damage*(0.5+level*0.05);
|
||||
if (charge >= chargeCap){
|
||||
charge = 0;
|
||||
cooldown = 10+level;
|
||||
GLog.p("Your Cape begins radiating energy, you feel protected!");
|
||||
BuffIndicator.refreshHero();
|
||||
}
|
||||
}
|
||||
public int proc(int damage, Char attacker, Char defender){
|
||||
if (cooldown == 0){
|
||||
charge += damage*(0.5+level*0.05);
|
||||
if (charge >= chargeCap){
|
||||
charge = 0;
|
||||
cooldown = 10+level;
|
||||
GLog.p("Your Cape begins radiating energy, you feel protected!");
|
||||
BuffIndicator.refreshHero();
|
||||
}
|
||||
}
|
||||
|
||||
if (cooldown != 0){
|
||||
int deflected = Random.NormalIntRange(0, damage);
|
||||
damage -= deflected;
|
||||
if (cooldown != 0){
|
||||
int deflected = Random.NormalIntRange(0, damage);
|
||||
damage -= deflected;
|
||||
|
||||
if (attacker != null && Level.adjacent(attacker.pos, defender.pos)) {
|
||||
attacker.damage(deflected, this);
|
||||
}
|
||||
if (attacker != null && Level.adjacent(attacker.pos, defender.pos)) {
|
||||
attacker.damage(deflected, this);
|
||||
}
|
||||
|
||||
exp+= deflected;
|
||||
exp+= deflected;
|
||||
|
||||
if (exp >= (level+1)*5 && level < levelCap){
|
||||
exp -= (level+1)*5;
|
||||
upgrade();
|
||||
GLog.p("Your Cape grows stronger!");
|
||||
}
|
||||
if (exp >= (level+1)*5 && level < levelCap){
|
||||
exp -= (level+1)*5;
|
||||
upgrade();
|
||||
GLog.p("Your Cape grows stronger!");
|
||||
}
|
||||
|
||||
}
|
||||
updateQuickslot();
|
||||
return damage;
|
||||
}
|
||||
}
|
||||
updateQuickslot();
|
||||
return damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Thorns";
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Thorns";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
return "Your cape is radiating energy, surrounding you in a field of deflective force!\n" +
|
||||
"\n" +
|
||||
"All damage you receive is reduced while the thorns effect is active. Additionally, " +
|
||||
"if the attacker is next to you, the reduced amount is deflected back at the attacker.\n" +
|
||||
"\n" +
|
||||
"Your cape will continue radiating energy for " + dispTurns(cooldown) + ".";
|
||||
}
|
||||
@Override
|
||||
public String desc() {
|
||||
return "Your cape is radiating energy, surrounding you in a field of deflective force!\n" +
|
||||
"\n" +
|
||||
"All damage you receive is reduced while the thorns effect is active. Additionally, " +
|
||||
"if the attacker is next to you, the reduced amount is deflected back at the attacker.\n" +
|
||||
"\n" +
|
||||
"Your cape will continue radiating energy for " + dispTurns(cooldown) + ".";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int icon() {
|
||||
if (cooldown == 0)
|
||||
return BuffIndicator.NONE;
|
||||
else
|
||||
return BuffIndicator.THORNS;
|
||||
}
|
||||
@Override
|
||||
public int icon() {
|
||||
if (cooldown == 0)
|
||||
return BuffIndicator.NONE;
|
||||
else
|
||||
return BuffIndicator.THORNS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detach(){
|
||||
cooldown = 0;
|
||||
charge = 0;
|
||||
super.detach();
|
||||
}
|
||||
@Override
|
||||
public void detach(){
|
||||
cooldown = 0;
|
||||
charge = 0;
|
||||
super.detach();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+119
-122
@@ -17,152 +17,149 @@ import com.watabou.utils.Random;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by debenhame on 27/08/2014.
|
||||
*/
|
||||
public class ChaliceOfBlood extends Artifact {
|
||||
|
||||
private static final String TXT_CHALICE = "Chalice of Blood";
|
||||
private static final String TXT_YES = "Yes, I know what I'm doing";
|
||||
private static final String TXT_NO = "No, I changed my mind";
|
||||
private static final String TXT_PRICK =
|
||||
"Each time you use the chalice it will drain more life energy, "+
|
||||
"if you are not careful this draining effect can easily kill you.\n\n"+
|
||||
"Are you sure you want to offer it more life energy?";
|
||||
private static final String TXT_CHALICE = "Chalice of Blood";
|
||||
private static final String TXT_YES = "Yes, I know what I'm doing";
|
||||
private static final String TXT_NO = "No, I changed my mind";
|
||||
private static final String TXT_PRICK =
|
||||
"Each time you use the chalice it will drain more life energy, "+
|
||||
"if you are not careful this draining effect can easily kill you.\n\n"+
|
||||
"Are you sure you want to offer it more life energy?";
|
||||
|
||||
|
||||
{
|
||||
name = "Chalice of Blood";
|
||||
image = ItemSpriteSheet.ARTIFACT_CHALICE1;
|
||||
{
|
||||
name = "Chalice of Blood";
|
||||
image = ItemSpriteSheet.ARTIFACT_CHALICE1;
|
||||
|
||||
level = 0;
|
||||
levelCap = 10;
|
||||
}
|
||||
level = 0;
|
||||
levelCap = 10;
|
||||
}
|
||||
|
||||
public static final String AC_PRICK = "PRICK";
|
||||
public static final String AC_PRICK = "PRICK";
|
||||
|
||||
@Override
|
||||
public ArrayList<String> actions( Hero hero ) {
|
||||
ArrayList<String> actions = super.actions( hero );
|
||||
if (isEquipped( hero ) && level < levelCap && !cursed)
|
||||
actions.add(AC_PRICK);
|
||||
return actions;
|
||||
}
|
||||
@Override
|
||||
public ArrayList<String> actions( Hero hero ) {
|
||||
ArrayList<String> actions = super.actions( hero );
|
||||
if (isEquipped( hero ) && level < levelCap && !cursed)
|
||||
actions.add(AC_PRICK);
|
||||
return actions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Hero hero, String action ) {
|
||||
super.execute(hero, action);
|
||||
if (action.equals(AC_PRICK)){
|
||||
@Override
|
||||
public void execute(Hero hero, String action ) {
|
||||
super.execute(hero, action);
|
||||
if (action.equals(AC_PRICK)){
|
||||
|
||||
int damage = 3*(level*level);
|
||||
int damage = 3*(level*level);
|
||||
|
||||
if (damage > hero.HP*0.75) {
|
||||
if (damage > hero.HP*0.75) {
|
||||
|
||||
GameScene.show(
|
||||
new WndOptions(TXT_CHALICE, TXT_PRICK, TXT_YES, TXT_NO) {
|
||||
@Override
|
||||
protected void onSelect(int index) {
|
||||
if (index == 0)
|
||||
prick(Dungeon.hero);
|
||||
};
|
||||
}
|
||||
);
|
||||
GameScene.show(
|
||||
new WndOptions(TXT_CHALICE, TXT_PRICK, TXT_YES, TXT_NO) {
|
||||
@Override
|
||||
protected void onSelect(int index) {
|
||||
if (index == 0)
|
||||
prick(Dungeon.hero);
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
} else {
|
||||
prick(hero);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
prick(hero);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void prick(Hero hero){
|
||||
int damage = 3*(level*level);
|
||||
private void prick(Hero hero){
|
||||
int damage = 3*(level*level);
|
||||
|
||||
Earthroot.Armor armor = hero.buff(Earthroot.Armor.class);
|
||||
if (armor != null) {
|
||||
damage = armor.absorb(damage);
|
||||
}
|
||||
Earthroot.Armor armor = hero.buff(Earthroot.Armor.class);
|
||||
if (armor != null) {
|
||||
damage = armor.absorb(damage);
|
||||
}
|
||||
|
||||
damage -= Random.IntRange(0, hero.dr());
|
||||
damage -= Random.IntRange(0, hero.dr());
|
||||
|
||||
hero.sprite.operate( hero.pos );
|
||||
hero.busy();
|
||||
hero.spend(3f);
|
||||
if (damage <= 0){
|
||||
GLog.i("You prick yourself, and your blood drips into the chalice.");
|
||||
} else if (damage < 25){
|
||||
GLog.w("You prick yourself and the chalice feeds on you.");
|
||||
Sample.INSTANCE.play(Assets.SND_CURSED);
|
||||
hero.sprite.emitter().burst( ShadowParticle.CURSE, 6 );
|
||||
} else if (damage < 100){
|
||||
GLog.w("Your life essence drains into the chalice.");
|
||||
Sample.INSTANCE.play(Assets.SND_CURSED);
|
||||
hero.sprite.emitter().burst( ShadowParticle.CURSE, 12 );
|
||||
} else {
|
||||
GLog.w("The chalice devours your life energy.");
|
||||
Sample.INSTANCE.play(Assets.SND_CURSED);
|
||||
hero.sprite.emitter().burst( ShadowParticle.CURSE, 18 );
|
||||
}
|
||||
hero.sprite.operate( hero.pos );
|
||||
hero.busy();
|
||||
hero.spend(3f);
|
||||
if (damage <= 0){
|
||||
GLog.i("You prick yourself, and your blood drips into the chalice.");
|
||||
} else if (damage < 25){
|
||||
GLog.w("You prick yourself and the chalice feeds on you.");
|
||||
Sample.INSTANCE.play(Assets.SND_CURSED);
|
||||
hero.sprite.emitter().burst( ShadowParticle.CURSE, 6 );
|
||||
} else if (damage < 100){
|
||||
GLog.w("Your life essence drains into the chalice.");
|
||||
Sample.INSTANCE.play(Assets.SND_CURSED);
|
||||
hero.sprite.emitter().burst( ShadowParticle.CURSE, 12 );
|
||||
} else {
|
||||
GLog.w("The chalice devours your life energy.");
|
||||
Sample.INSTANCE.play(Assets.SND_CURSED);
|
||||
hero.sprite.emitter().burst( ShadowParticle.CURSE, 18 );
|
||||
}
|
||||
|
||||
if (damage > 0)
|
||||
hero.damage(damage, this);
|
||||
if (damage > 0)
|
||||
hero.damage(damage, this);
|
||||
|
||||
if (!hero.isAlive()) {
|
||||
Dungeon.fail(Utils.format( ResultDescriptions.ITEM, name ));
|
||||
GLog.n("The Chalice sucks your life essence dry...");
|
||||
} else {
|
||||
upgrade();
|
||||
}
|
||||
}
|
||||
if (!hero.isAlive()) {
|
||||
Dungeon.fail(Utils.format( ResultDescriptions.ITEM, name ));
|
||||
GLog.n("The Chalice sucks your life essence dry...");
|
||||
} else {
|
||||
upgrade();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item upgrade() {
|
||||
if (level >= 6)
|
||||
image = ItemSpriteSheet.ARTIFACT_CHALICE3;
|
||||
else if (level >= 2)
|
||||
image = ItemSpriteSheet.ARTIFACT_CHALICE2;
|
||||
return super.upgrade();
|
||||
}
|
||||
@Override
|
||||
public Item upgrade() {
|
||||
if (level >= 6)
|
||||
image = ItemSpriteSheet.ARTIFACT_CHALICE3;
|
||||
else if (level >= 2)
|
||||
image = ItemSpriteSheet.ARTIFACT_CHALICE2;
|
||||
return super.upgrade();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ArtifactBuff passiveBuff() {
|
||||
return new chaliceRegen();
|
||||
}
|
||||
@Override
|
||||
protected ArtifactBuff passiveBuff() {
|
||||
return new chaliceRegen();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
String desc = "This shining silver chalice is oddly adorned with sharp gems at the rim. ";
|
||||
if (level < levelCap)
|
||||
desc += "The chalice is pulling your attention strangely, you feel like it wants something from you.";
|
||||
else
|
||||
desc += "The chalice is full and radiating energy.";
|
||||
@Override
|
||||
public String desc() {
|
||||
String desc = "This shining silver chalice is oddly adorned with sharp gems at the rim. ";
|
||||
if (level < levelCap)
|
||||
desc += "The chalice is pulling your attention strangely, you feel like it wants something from you.";
|
||||
else
|
||||
desc += "The chalice is full and radiating energy.";
|
||||
|
||||
if (isEquipped (Dungeon.hero)){
|
||||
desc += "\n\n";
|
||||
if (cursed)
|
||||
desc += "The cursed chalice has bound itself to your hand, and is slowly tugging at your life energy.";
|
||||
else if (level == 0)
|
||||
desc += "As you hold the chalice, you feel oddly compelled to prick yourself on the sharp gems.";
|
||||
else if (level < 3)
|
||||
desc += "Some of your blood is pooled into the chalice, you can subtly feel the chalice feeding life " +
|
||||
"energy into you. You still want to cut yourself on the chalice, even though you know it will hurt.";
|
||||
else if (level < 7)
|
||||
desc += "The chalice is about half full of your blood and you can feel it feeding life energy " +
|
||||
"into you. you still want to hurt yourself, the chalice needs your energy, it's your friend.";
|
||||
else if (level < levelCap)
|
||||
desc += "The chalice is getting pretty full, and the life force it's feeding you is stronger than " +
|
||||
"ever. You should give it more energy, you need too, your friend needs your energy, it needs " +
|
||||
"your help. Your friend knows you have limits though, it doesn't want you to die, just bleed.";
|
||||
else
|
||||
desc += "The chalice is filled to the brim with your life essence. You can feel the chalice pouring " +
|
||||
"life energy back into you. It's your best friend. It's happy with you. So happy. " +
|
||||
"You've done well. So well. You're being rewarded. You don't need to touch the sharp gems anymore.";
|
||||
}
|
||||
if (isEquipped (Dungeon.hero)){
|
||||
desc += "\n\n";
|
||||
if (cursed)
|
||||
desc += "The cursed chalice has bound itself to your hand, and is slowly tugging at your life energy.";
|
||||
else if (level == 0)
|
||||
desc += "As you hold the chalice, you feel oddly compelled to prick yourself on the sharp gems.";
|
||||
else if (level < 3)
|
||||
desc += "Some of your blood is pooled into the chalice, you can subtly feel the chalice feeding life " +
|
||||
"energy into you. You still want to cut yourself on the chalice, even though you know it will hurt.";
|
||||
else if (level < 7)
|
||||
desc += "The chalice is about half full of your blood and you can feel it feeding life energy " +
|
||||
"into you. you still want to hurt yourself, the chalice needs your energy, it's your friend.";
|
||||
else if (level < levelCap)
|
||||
desc += "The chalice is getting pretty full, and the life force it's feeding you is stronger than " +
|
||||
"ever. You should give it more energy, you need too, your friend needs your energy, it needs " +
|
||||
"your help. Your friend knows you have limits though, it doesn't want you to die, just bleed.";
|
||||
else
|
||||
desc += "The chalice is filled to the brim with your life essence. You can feel the chalice pouring " +
|
||||
"life energy back into you. It's your best friend. It's happy with you. So happy. " +
|
||||
"You've done well. So well. You're being rewarded. You don't need to touch the sharp gems anymore.";
|
||||
}
|
||||
|
||||
return desc;
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
|
||||
public class chaliceRegen extends ArtifactBuff {
|
||||
public class chaliceRegen extends ArtifactBuff {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+196
-199
@@ -16,251 +16,248 @@ import com.watabou.utils.Bundle;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by debenhame on 25/08/2014.
|
||||
*/
|
||||
public class CloakOfShadows extends Artifact {
|
||||
|
||||
{
|
||||
name = "Cloak of Shadows";
|
||||
image = ItemSpriteSheet.ARTIFACT_CLOAK;
|
||||
{
|
||||
name = "Cloak of Shadows";
|
||||
image = ItemSpriteSheet.ARTIFACT_CLOAK;
|
||||
|
||||
level = 0;
|
||||
exp = 0;
|
||||
levelCap = 15;
|
||||
level = 0;
|
||||
exp = 0;
|
||||
levelCap = 15;
|
||||
|
||||
charge = level+5;
|
||||
partialCharge = 0;
|
||||
chargeCap = level+5;
|
||||
charge = level+5;
|
||||
partialCharge = 0;
|
||||
chargeCap = level+5;
|
||||
|
||||
cooldown = 0;
|
||||
cooldown = 0;
|
||||
|
||||
defaultAction = AC_STEALTH;
|
||||
defaultAction = AC_STEALTH;
|
||||
|
||||
unique = true;
|
||||
bones = false;
|
||||
}
|
||||
unique = true;
|
||||
bones = false;
|
||||
}
|
||||
|
||||
private boolean stealthed = false;
|
||||
private boolean stealthed = false;
|
||||
|
||||
public static final String AC_STEALTH = "STEALTH";
|
||||
public static final String AC_STEALTH = "STEALTH";
|
||||
|
||||
@Override
|
||||
public ArrayList<String> actions( Hero hero ) {
|
||||
ArrayList<String> actions = super.actions( hero );
|
||||
if (isEquipped( hero ) && charge > 1)
|
||||
actions.add(AC_STEALTH);
|
||||
return actions;
|
||||
}
|
||||
@Override
|
||||
public ArrayList<String> actions( Hero hero ) {
|
||||
ArrayList<String> actions = super.actions( hero );
|
||||
if (isEquipped( hero ) && charge > 1)
|
||||
actions.add(AC_STEALTH);
|
||||
return actions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute( Hero hero, String action ) {
|
||||
if (action.equals( AC_STEALTH )) {
|
||||
@Override
|
||||
public void execute( Hero hero, String action ) {
|
||||
if (action.equals( AC_STEALTH )) {
|
||||
|
||||
if (!stealthed){
|
||||
if (!isEquipped(hero)) GLog.i("You need to equip your cloak to do that.");
|
||||
else if (cooldown > 0) GLog.i("Your cloak needs " + cooldown + " more rounds to re-energize.");
|
||||
else if (charge <= 1) GLog.i("Your cloak hasn't recharged enough to be usable yet.");
|
||||
else {
|
||||
stealthed = true;
|
||||
hero.spend( 1f );
|
||||
hero.busy();
|
||||
Sample.INSTANCE.play(Assets.SND_MELD);
|
||||
activeBuff = activeBuff();
|
||||
activeBuff.attachTo(hero);
|
||||
if (hero.sprite.parent != null) {
|
||||
hero.sprite.parent.add(new AlphaTweener(hero.sprite, 0.4f, 0.4f));
|
||||
} else {
|
||||
hero.sprite.alpha(0.4f);
|
||||
}
|
||||
hero.sprite.operate(hero.pos);
|
||||
GLog.i("Your cloak blends you into the shadows.");
|
||||
}
|
||||
} else {
|
||||
stealthed = false;
|
||||
activeBuff.detach();
|
||||
activeBuff = null;
|
||||
hero.sprite.operate( hero.pos );
|
||||
GLog.i("You return from underneath your cloak.");
|
||||
}
|
||||
if (!stealthed){
|
||||
if (!isEquipped(hero)) GLog.i("You need to equip your cloak to do that.");
|
||||
else if (cooldown > 0) GLog.i("Your cloak needs " + cooldown + " more rounds to re-energize.");
|
||||
else if (charge <= 1) GLog.i("Your cloak hasn't recharged enough to be usable yet.");
|
||||
else {
|
||||
stealthed = true;
|
||||
hero.spend( 1f );
|
||||
hero.busy();
|
||||
Sample.INSTANCE.play(Assets.SND_MELD);
|
||||
activeBuff = activeBuff();
|
||||
activeBuff.attachTo(hero);
|
||||
if (hero.sprite.parent != null) {
|
||||
hero.sprite.parent.add(new AlphaTweener(hero.sprite, 0.4f, 0.4f));
|
||||
} else {
|
||||
hero.sprite.alpha(0.4f);
|
||||
}
|
||||
hero.sprite.operate(hero.pos);
|
||||
GLog.i("Your cloak blends you into the shadows.");
|
||||
}
|
||||
} else {
|
||||
stealthed = false;
|
||||
activeBuff.detach();
|
||||
activeBuff = null;
|
||||
hero.sprite.operate( hero.pos );
|
||||
GLog.i("You return from underneath your cloak.");
|
||||
}
|
||||
|
||||
} else
|
||||
super.execute(hero, action);
|
||||
}
|
||||
} else
|
||||
super.execute(hero, action);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void activate(Char ch){
|
||||
super.activate(ch);
|
||||
if (stealthed){
|
||||
activeBuff = activeBuff();
|
||||
activeBuff.attachTo(ch);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void activate(Char ch){
|
||||
super.activate(ch);
|
||||
if (stealthed){
|
||||
activeBuff = activeBuff();
|
||||
activeBuff.attachTo(ch);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doUnequip(Hero hero, boolean collect, boolean single) {
|
||||
if (super.doUnequip(hero, collect, single)){
|
||||
stealthed = false;
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean doUnequip(Hero hero, boolean collect, boolean single) {
|
||||
if (super.doUnequip(hero, collect, single)){
|
||||
stealthed = false;
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ArtifactBuff passiveBuff() {
|
||||
return new cloakRecharge();
|
||||
}
|
||||
@Override
|
||||
protected ArtifactBuff passiveBuff() {
|
||||
return new cloakRecharge();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ArtifactBuff activeBuff( ) {
|
||||
return new cloakStealth();
|
||||
}
|
||||
@Override
|
||||
protected ArtifactBuff activeBuff( ) {
|
||||
return new cloakStealth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item upgrade() {
|
||||
chargeCap++;
|
||||
return super.upgrade();
|
||||
}
|
||||
@Override
|
||||
public Item upgrade() {
|
||||
chargeCap++;
|
||||
return super.upgrade();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
String desc = "This light silken cloak shimmers in and out of your vision as it sways in the air. When worn, " +
|
||||
"it can be used to hide your presence for a short time.\n\n";
|
||||
@Override
|
||||
public String desc() {
|
||||
String desc = "This light silken cloak shimmers in and out of your vision as it sways in the air. When worn, " +
|
||||
"it can be used to hide your presence for a short time.\n\n";
|
||||
|
||||
if (level < 5)
|
||||
desc += "The cloak's magic has faded and it is not very powerful, perhaps it will regain strength through use.";
|
||||
else if (level < 10)
|
||||
desc += "The cloak's power has begun to return.";
|
||||
else if (level < 15)
|
||||
desc += "The cloak has almost returned to full strength.";
|
||||
else
|
||||
desc += "The cloak is at full potential and will work for extended durations.";
|
||||
if (level < 5)
|
||||
desc += "The cloak's magic has faded and it is not very powerful, perhaps it will regain strength through use.";
|
||||
else if (level < 10)
|
||||
desc += "The cloak's power has begun to return.";
|
||||
else if (level < 15)
|
||||
desc += "The cloak has almost returned to full strength.";
|
||||
else
|
||||
desc += "The cloak is at full potential and will work for extended durations.";
|
||||
|
||||
|
||||
if ( isEquipped (Dungeon.hero) )
|
||||
desc += "\n\nThe cloak rests around your shoulders.";
|
||||
if ( isEquipped (Dungeon.hero) )
|
||||
desc += "\n\nThe cloak rests around your shoulders.";
|
||||
|
||||
|
||||
return desc;
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
|
||||
private static final String STEALTHED = "stealthed";
|
||||
private static final String COOLDOWN = "cooldown";
|
||||
private static final String STEALTHED = "stealthed";
|
||||
private static final String COOLDOWN = "cooldown";
|
||||
|
||||
@Override
|
||||
public void storeInBundle( Bundle bundle ) {
|
||||
super.storeInBundle(bundle);
|
||||
bundle.put( STEALTHED, stealthed );
|
||||
bundle.put( COOLDOWN, cooldown );
|
||||
}
|
||||
@Override
|
||||
public void storeInBundle( Bundle bundle ) {
|
||||
super.storeInBundle(bundle);
|
||||
bundle.put( STEALTHED, stealthed );
|
||||
bundle.put( COOLDOWN, cooldown );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreFromBundle( Bundle bundle ) {
|
||||
super.restoreFromBundle(bundle);
|
||||
stealthed = bundle.getBoolean( STEALTHED );
|
||||
cooldown = bundle.getInt( COOLDOWN );
|
||||
}
|
||||
@Override
|
||||
public void restoreFromBundle( Bundle bundle ) {
|
||||
super.restoreFromBundle(bundle);
|
||||
stealthed = bundle.getBoolean( STEALTHED );
|
||||
cooldown = bundle.getInt( COOLDOWN );
|
||||
}
|
||||
|
||||
public class cloakRecharge extends ArtifactBuff{
|
||||
@Override
|
||||
public boolean act() {
|
||||
if (charge < chargeCap) {
|
||||
if (!stealthed)
|
||||
partialCharge += (1f / (60 - (chargeCap-charge)*2));
|
||||
public class cloakRecharge extends ArtifactBuff{
|
||||
@Override
|
||||
public boolean act() {
|
||||
if (charge < chargeCap) {
|
||||
if (!stealthed)
|
||||
partialCharge += (1f / (60 - (chargeCap-charge)*2));
|
||||
|
||||
if (partialCharge >= 1) {
|
||||
charge++;
|
||||
partialCharge -= 1;
|
||||
if (charge == chargeCap){
|
||||
partialCharge = 0;
|
||||
}
|
||||
if (partialCharge >= 1) {
|
||||
charge++;
|
||||
partialCharge -= 1;
|
||||
if (charge == chargeCap){
|
||||
partialCharge = 0;
|
||||
}
|
||||
|
||||
}
|
||||
} else
|
||||
partialCharge = 0;
|
||||
}
|
||||
} else
|
||||
partialCharge = 0;
|
||||
|
||||
if (cooldown > 0)
|
||||
cooldown --;
|
||||
if (cooldown > 0)
|
||||
cooldown --;
|
||||
|
||||
updateQuickslot();
|
||||
updateQuickslot();
|
||||
|
||||
spend( TICK );
|
||||
spend( TICK );
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class cloakStealth extends ArtifactBuff{
|
||||
@Override
|
||||
public int icon() {
|
||||
return BuffIndicator.INVISIBLE;
|
||||
}
|
||||
public class cloakStealth extends ArtifactBuff{
|
||||
@Override
|
||||
public int icon() {
|
||||
return BuffIndicator.INVISIBLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean attachTo( Char target ) {
|
||||
if (super.attachTo( target )) {
|
||||
target.invisible++;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean attachTo( Char target ) {
|
||||
if (super.attachTo( target )) {
|
||||
target.invisible++;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean act(){
|
||||
charge--;
|
||||
if (charge <= 0) {
|
||||
detach();
|
||||
GLog.w("Your cloak has run out of energy.");
|
||||
((Hero)target).interrupt();
|
||||
}
|
||||
@Override
|
||||
public boolean act(){
|
||||
charge--;
|
||||
if (charge <= 0) {
|
||||
detach();
|
||||
GLog.w("Your cloak has run out of energy.");
|
||||
((Hero)target).interrupt();
|
||||
}
|
||||
|
||||
exp += 10 + ((Hero)target).lvl;
|
||||
exp += 10 + ((Hero)target).lvl;
|
||||
|
||||
if (exp >= (level+1)*50 && level < levelCap) {
|
||||
upgrade();
|
||||
exp -= level*50;
|
||||
GLog.p("Your cloak grows stronger!");
|
||||
}
|
||||
if (exp >= (level+1)*50 && level < levelCap) {
|
||||
upgrade();
|
||||
exp -= level*50;
|
||||
GLog.p("Your cloak grows stronger!");
|
||||
}
|
||||
|
||||
updateQuickslot();
|
||||
updateQuickslot();
|
||||
|
||||
spend( TICK );
|
||||
spend( TICK );
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fx(boolean on) {
|
||||
if (on) target.sprite.add( CharSprite.State.INVISIBLE );
|
||||
else if (target.invisible == 0) target.sprite.remove( CharSprite.State.INVISIBLE );
|
||||
}
|
||||
@Override
|
||||
public void fx(boolean on) {
|
||||
if (on) target.sprite.add( CharSprite.State.INVISIBLE );
|
||||
else if (target.invisible == 0) target.sprite.remove( CharSprite.State.INVISIBLE );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Cloaked";
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Cloaked";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
return "Your cloak of shadows is granting you invisibility while you are shrouded by it.\n" +
|
||||
"\n" +
|
||||
"While you are invisible enemies are unable to attack or follow you. " +
|
||||
"Most physical attacks and magical effects (such as scrolls and wands) will immediately cancel invisibility.\n" +
|
||||
"\n" +
|
||||
"You will remain cloaked until it is cancelled or your cloak runs out of charge.";
|
||||
}
|
||||
@Override
|
||||
public String desc() {
|
||||
return "Your cloak of shadows is granting you invisibility while you are shrouded by it.\n" +
|
||||
"\n" +
|
||||
"While you are invisible enemies are unable to attack or follow you. " +
|
||||
"Most physical attacks and magical effects (such as scrolls and wands) will immediately cancel invisibility.\n" +
|
||||
"\n" +
|
||||
"You will remain cloaked until it is cancelled or your cloak runs out of charge.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detach() {
|
||||
if (target.invisible > 0)
|
||||
target.invisible--;
|
||||
stealthed = false;
|
||||
cooldown = 10 - (level / 3);
|
||||
@Override
|
||||
public void detach() {
|
||||
if (target.invisible > 0)
|
||||
target.invisible--;
|
||||
stealthed = false;
|
||||
cooldown = 10 - (level / 3);
|
||||
|
||||
updateQuickslot();
|
||||
super.detach();
|
||||
}
|
||||
}
|
||||
updateQuickslot();
|
||||
super.detach();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -20,9 +20,6 @@ import com.watabou.utils.Random;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by Evan on 23/05/2015.
|
||||
*/
|
||||
public class EtherealChains extends Artifact {
|
||||
|
||||
public static final String AC_CAST = "CAST";
|
||||
|
||||
@@ -21,200 +21,197 @@ import com.watabou.noosa.audio.Sample;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by debenhame on 26/08/2014.
|
||||
*/
|
||||
public class HornOfPlenty extends Artifact {
|
||||
|
||||
|
||||
{
|
||||
name = "Horn of Plenty";
|
||||
image = ItemSpriteSheet.ARTIFACT_HORN1;
|
||||
{
|
||||
name = "Horn of Plenty";
|
||||
image = ItemSpriteSheet.ARTIFACT_HORN1;
|
||||
|
||||
level = 0;
|
||||
levelCap = 30;
|
||||
level = 0;
|
||||
levelCap = 30;
|
||||
|
||||
charge = 0;
|
||||
partialCharge = 0;
|
||||
chargeCap = 10;
|
||||
charge = 0;
|
||||
partialCharge = 0;
|
||||
chargeCap = 10;
|
||||
|
||||
defaultAction = AC_EAT;
|
||||
}
|
||||
defaultAction = AC_EAT;
|
||||
}
|
||||
|
||||
private static final float TIME_TO_EAT = 3f;
|
||||
private static final float TIME_TO_EAT = 3f;
|
||||
|
||||
private float energy = 36f;
|
||||
private float energy = 36f;
|
||||
|
||||
public static final String AC_EAT = "EAT";
|
||||
public static final String AC_STORE = "STORE";
|
||||
public static final String AC_EAT = "EAT";
|
||||
public static final String AC_STORE = "STORE";
|
||||
|
||||
protected String inventoryTitle = "Select a piece of food";
|
||||
protected WndBag.Mode mode = WndBag.Mode.FOOD;
|
||||
protected String inventoryTitle = "Select a piece of food";
|
||||
protected WndBag.Mode mode = WndBag.Mode.FOOD;
|
||||
|
||||
@Override
|
||||
public ArrayList<String> actions( Hero hero ) {
|
||||
ArrayList<String> actions = super.actions( hero );
|
||||
if (isEquipped( hero ) && charge > 0)
|
||||
actions.add(AC_EAT);
|
||||
if (isEquipped( hero ) && level < 30 && !cursed)
|
||||
actions.add(AC_STORE);
|
||||
return actions;
|
||||
}
|
||||
@Override
|
||||
public ArrayList<String> actions( Hero hero ) {
|
||||
ArrayList<String> actions = super.actions( hero );
|
||||
if (isEquipped( hero ) && charge > 0)
|
||||
actions.add(AC_EAT);
|
||||
if (isEquipped( hero ) && level < 30 && !cursed)
|
||||
actions.add(AC_STORE);
|
||||
return actions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute( Hero hero, String action ) {
|
||||
super.execute(hero, action);
|
||||
@Override
|
||||
public void execute( Hero hero, String action ) {
|
||||
super.execute(hero, action);
|
||||
|
||||
if (action.equals(AC_EAT)){
|
||||
if (action.equals(AC_EAT)){
|
||||
|
||||
if (!isEquipped(hero)) GLog.i("You need to equip your horn to do that.");
|
||||
else if (charge == 0) GLog.i("Your horn has no food in it to eat!");
|
||||
else {
|
||||
((Hunger) hero.buff(Hunger.class)).satisfy(energy * charge);
|
||||
if (!isEquipped(hero)) GLog.i("You need to equip your horn to do that.");
|
||||
else if (charge == 0) GLog.i("Your horn has no food in it to eat!");
|
||||
else {
|
||||
((Hunger) hero.buff(Hunger.class)).satisfy(energy * charge);
|
||||
|
||||
//if you get at least 100 food energy from the horn
|
||||
if (charge >= 3) {
|
||||
switch (hero.heroClass) {
|
||||
case WARRIOR:
|
||||
if (hero.HP < hero.HT) {
|
||||
hero.HP = Math.min(hero.HP + 5, hero.HT);
|
||||
hero.sprite.emitter().burst(Speck.factory(Speck.HEALING), 1);
|
||||
}
|
||||
break;
|
||||
case MAGE:
|
||||
//1 charge
|
||||
Buff.affect( hero, ScrollOfRecharging.Recharging.class, 4f );
|
||||
ScrollOfRecharging.charge(hero);
|
||||
break;
|
||||
case ROGUE:
|
||||
case HUNTRESS:
|
||||
break;
|
||||
}
|
||||
//if you get at least 100 food energy from the horn
|
||||
if (charge >= 3) {
|
||||
switch (hero.heroClass) {
|
||||
case WARRIOR:
|
||||
if (hero.HP < hero.HT) {
|
||||
hero.HP = Math.min(hero.HP + 5, hero.HT);
|
||||
hero.sprite.emitter().burst(Speck.factory(Speck.HEALING), 1);
|
||||
}
|
||||
break;
|
||||
case MAGE:
|
||||
//1 charge
|
||||
Buff.affect( hero, ScrollOfRecharging.Recharging.class, 4f );
|
||||
ScrollOfRecharging.charge(hero);
|
||||
break;
|
||||
case ROGUE:
|
||||
case HUNTRESS:
|
||||
break;
|
||||
}
|
||||
|
||||
Statistics.foodEaten++;
|
||||
}
|
||||
charge = 0;
|
||||
Statistics.foodEaten++;
|
||||
}
|
||||
charge = 0;
|
||||
|
||||
hero.sprite.operate(hero.pos);
|
||||
hero.busy();
|
||||
SpellSprite.show(hero, SpellSprite.FOOD);
|
||||
Sample.INSTANCE.play(Assets.SND_EAT);
|
||||
GLog.i("You eat from the horn.");
|
||||
hero.sprite.operate(hero.pos);
|
||||
hero.busy();
|
||||
SpellSprite.show(hero, SpellSprite.FOOD);
|
||||
Sample.INSTANCE.play(Assets.SND_EAT);
|
||||
GLog.i("You eat from the horn.");
|
||||
|
||||
hero.spend(TIME_TO_EAT);
|
||||
hero.spend(TIME_TO_EAT);
|
||||
|
||||
Badges.validateFoodEaten();
|
||||
Badges.validateFoodEaten();
|
||||
|
||||
image = ItemSpriteSheet.ARTIFACT_HORN1;
|
||||
image = ItemSpriteSheet.ARTIFACT_HORN1;
|
||||
|
||||
updateQuickslot();
|
||||
}
|
||||
updateQuickslot();
|
||||
}
|
||||
|
||||
} else if (action.equals(AC_STORE)){
|
||||
} else if (action.equals(AC_STORE)){
|
||||
|
||||
GameScene.selectItem(itemSelector, mode, inventoryTitle);
|
||||
}
|
||||
}
|
||||
GameScene.selectItem(itemSelector, mode, inventoryTitle);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ArtifactBuff passiveBuff() {
|
||||
return new hornRecharge();
|
||||
}
|
||||
@Override
|
||||
protected ArtifactBuff passiveBuff() {
|
||||
return new hornRecharge();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
String desc = "This horn can't be blown into, but instead seems to fill up with food over time.\n\n";
|
||||
@Override
|
||||
public String desc() {
|
||||
String desc = "This horn can't be blown into, but instead seems to fill up with food over time.\n\n";
|
||||
|
||||
if (charge == 0)
|
||||
desc += "The horn is completely empty.";
|
||||
else if (charge < 3)
|
||||
desc += "The horn is almost empty, a few small fruits and berries sit in the back.";
|
||||
else if (charge < 7)
|
||||
desc += "The horn is partially filled, you can see several fruits & vegetables inside.";
|
||||
else if (charge < 10)
|
||||
desc += "The horn is getting quite full, several pieces of fresh produce are poking up towards the front.";
|
||||
else
|
||||
desc += "The horn is overflowing! A delicious array of fruit and veg is filling the horn up to its brim.";
|
||||
if (charge == 0)
|
||||
desc += "The horn is completely empty.";
|
||||
else if (charge < 3)
|
||||
desc += "The horn is almost empty, a few small fruits and berries sit in the back.";
|
||||
else if (charge < 7)
|
||||
desc += "The horn is partially filled, you can see several fruits & vegetables inside.";
|
||||
else if (charge < 10)
|
||||
desc += "The horn is getting quite full, several pieces of fresh produce are poking up towards the front.";
|
||||
else
|
||||
desc += "The horn is overflowing! A delicious array of fruit and veg is filling the horn up to its brim.";
|
||||
|
||||
if ( isEquipped( Dungeon.hero ) ){
|
||||
if (!cursed) {
|
||||
desc += "\n\nThe horn rests at your side and is surprisingly lightweight, even with food in it.";
|
||||
if ( isEquipped( Dungeon.hero ) ){
|
||||
if (!cursed) {
|
||||
desc += "\n\nThe horn rests at your side and is surprisingly lightweight, even with food in it.";
|
||||
|
||||
if (level < 15)
|
||||
desc += " Perhaps there is a way to increase the horn's power by giving it food energy.";
|
||||
} else {
|
||||
desc += "\n\nThe cursed horn has bound itself to your side, " +
|
||||
"it seems to be eager to take food rather than produce it.";
|
||||
}
|
||||
}
|
||||
if (level < 15)
|
||||
desc += " Perhaps there is a way to increase the horn's power by giving it food energy.";
|
||||
} else {
|
||||
desc += "\n\nThe cursed horn has bound itself to your side, " +
|
||||
"it seems to be eager to take food rather than produce it.";
|
||||
}
|
||||
}
|
||||
|
||||
return desc;
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
|
||||
public class hornRecharge extends ArtifactBuff{
|
||||
public class hornRecharge extends ArtifactBuff{
|
||||
|
||||
@Override
|
||||
public boolean act() {
|
||||
if (charge < chargeCap && !cursed) {
|
||||
@Override
|
||||
public boolean act() {
|
||||
if (charge < chargeCap && !cursed) {
|
||||
|
||||
//generates 0.25 food value every round, +0.015 value per level
|
||||
//to a max of 0.70 food value per round (0.25+0.5, at level 30)
|
||||
partialCharge += 0.25f + (0.015f*level);
|
||||
//generates 0.25 food value every round, +0.015 value per level
|
||||
//to a max of 0.70 food value per round (0.25+0.5, at level 30)
|
||||
partialCharge += 0.25f + (0.015f*level);
|
||||
|
||||
//charge is in increments of 36 food value.
|
||||
if (partialCharge >= 36) {
|
||||
charge++;
|
||||
partialCharge -= 36;
|
||||
//charge is in increments of 36 food value.
|
||||
if (partialCharge >= 36) {
|
||||
charge++;
|
||||
partialCharge -= 36;
|
||||
|
||||
if (charge == chargeCap)
|
||||
image = ItemSpriteSheet.ARTIFACT_HORN4;
|
||||
else if (charge >= 7)
|
||||
image = ItemSpriteSheet.ARTIFACT_HORN3;
|
||||
else if (charge >= 3)
|
||||
image = ItemSpriteSheet.ARTIFACT_HORN2;
|
||||
else
|
||||
image = ItemSpriteSheet.ARTIFACT_HORN1;
|
||||
if (charge == chargeCap)
|
||||
image = ItemSpriteSheet.ARTIFACT_HORN4;
|
||||
else if (charge >= 7)
|
||||
image = ItemSpriteSheet.ARTIFACT_HORN3;
|
||||
else if (charge >= 3)
|
||||
image = ItemSpriteSheet.ARTIFACT_HORN2;
|
||||
else
|
||||
image = ItemSpriteSheet.ARTIFACT_HORN1;
|
||||
|
||||
if (charge == chargeCap){
|
||||
GLog.p("Your horn is full of food!");
|
||||
partialCharge = 0;
|
||||
}
|
||||
if (charge == chargeCap){
|
||||
GLog.p("Your horn is full of food!");
|
||||
partialCharge = 0;
|
||||
}
|
||||
|
||||
updateQuickslot();
|
||||
}
|
||||
} else
|
||||
partialCharge = 0;
|
||||
updateQuickslot();
|
||||
}
|
||||
} else
|
||||
partialCharge = 0;
|
||||
|
||||
spend( TICK );
|
||||
spend( TICK );
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected static WndBag.Listener itemSelector = new WndBag.Listener() {
|
||||
@Override
|
||||
public void onSelect( Item item ) {
|
||||
if (item != null && item instanceof Food) {
|
||||
if (item instanceof Blandfruit && ((Blandfruit) item).potionAttrib == null){
|
||||
GLog.w("your horn rejects the unprepared blandfruit.");
|
||||
} else {
|
||||
Hero hero = Dungeon.hero;
|
||||
hero.sprite.operate( hero.pos );
|
||||
hero.busy();
|
||||
hero.spend( TIME_TO_EAT );
|
||||
protected static WndBag.Listener itemSelector = new WndBag.Listener() {
|
||||
@Override
|
||||
public void onSelect( Item item ) {
|
||||
if (item != null && item instanceof Food) {
|
||||
if (item instanceof Blandfruit && ((Blandfruit) item).potionAttrib == null){
|
||||
GLog.w("your horn rejects the unprepared blandfruit.");
|
||||
} else {
|
||||
Hero hero = Dungeon.hero;
|
||||
hero.sprite.operate( hero.pos );
|
||||
hero.busy();
|
||||
hero.spend( TIME_TO_EAT );
|
||||
|
||||
curItem.upgrade(((Food)item).hornValue);
|
||||
if (curItem.level >= 30){
|
||||
curItem.level = 30;
|
||||
GLog.p("your horn has consumed all the food it can!");
|
||||
} else
|
||||
GLog.p("the horn consumes your food offering and grows in strength!");
|
||||
item.detach(hero.belongings.backpack);
|
||||
}
|
||||
curItem.upgrade(((Food)item).hornValue);
|
||||
if (curItem.level >= 30){
|
||||
curItem.level = 30;
|
||||
GLog.p("your horn has consumed all the food it can!");
|
||||
} else
|
||||
GLog.p("the horn consumes your food offering and grows in strength!");
|
||||
item.detach(hero.belongings.backpack);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -47,13 +47,13 @@ import java.util.ArrayList;
|
||||
|
||||
public class LloydsBeacon extends Artifact {
|
||||
|
||||
private static final String TXT_PREVENTING =
|
||||
private static final String TXT_PREVENTING =
|
||||
"Strong magic aura of this place prevents you from using the lloyd's beacon!";
|
||||
|
||||
private static final String TXT_CREATURES =
|
||||
private static final String TXT_CREATURES =
|
||||
"Psychic aura of neighbouring creatures doesn't allow you to use the lloyd's beacon at this moment.";
|
||||
|
||||
private static final String TXT_RETURN =
|
||||
private static final String TXT_RETURN =
|
||||
"The lloyd's beacon is successfully set at your current location, now you can return here anytime.";
|
||||
|
||||
private static final String TXT_INFO =
|
||||
@@ -62,7 +62,7 @@ public class LloydsBeacon extends Artifact {
|
||||
"The beacon can be used to return to a set location, but can also expel bursts of random teleportation " +
|
||||
"magic once it has charged from being equipped. This magic can be directed at a target or at the user themselves.";
|
||||
|
||||
private static final String TXT_SET =
|
||||
private static final String TXT_SET =
|
||||
"\n\nThis beacon was set somewhere on the level %d of Pixel Dungeon.";
|
||||
|
||||
public static final float TIME_TO_USE = 1;
|
||||
@@ -171,8 +171,8 @@ public class LloydsBeacon extends Artifact {
|
||||
Buff buff = Dungeon.hero.buff(TimekeepersHourglass.timeFreeze.class);
|
||||
if (buff != null) buff.detach();
|
||||
|
||||
for (Mob mob : Dungeon.level.mobs.toArray( new Mob[0] ))
|
||||
if (mob instanceof DriedRose.GhostHero) mob.destroy();
|
||||
for (Mob mob : Dungeon.level.mobs.toArray( new Mob[0] ))
|
||||
if (mob instanceof DriedRose.GhostHero) mob.destroy();
|
||||
|
||||
InterlevelScene.mode = InterlevelScene.Mode.RETURN;
|
||||
InterlevelScene.returnDepth = returnDepth;
|
||||
|
||||
+60
-63
@@ -4,81 +4,78 @@ import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
/**
|
||||
* Created by debenhame on 03/09/2014.
|
||||
*/
|
||||
public class MasterThievesArmband extends Artifact {
|
||||
|
||||
{
|
||||
name = "Master Thieves' Armband";
|
||||
image = ItemSpriteSheet.ARTIFACT_ARMBAND;
|
||||
{
|
||||
name = "Master Thieves' Armband";
|
||||
image = ItemSpriteSheet.ARTIFACT_ARMBAND;
|
||||
|
||||
level = 0;
|
||||
levelCap = 10;
|
||||
level = 0;
|
||||
levelCap = 10;
|
||||
|
||||
charge = 0;
|
||||
}
|
||||
charge = 0;
|
||||
}
|
||||
|
||||
private int exp = 0;
|
||||
private int exp = 0;
|
||||
|
||||
@Override
|
||||
protected ArtifactBuff passiveBuff() {
|
||||
return new Thievery();
|
||||
}
|
||||
@Override
|
||||
protected ArtifactBuff passiveBuff() {
|
||||
return new Thievery();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
String desc = "This purple velvet armband bears the mark of a master thief. This doesn't belong to you, but " +
|
||||
"you doubt it belonged to the person you took it from either.";
|
||||
@Override
|
||||
public String desc() {
|
||||
String desc = "This purple velvet armband bears the mark of a master thief. This doesn't belong to you, but " +
|
||||
"you doubt it belonged to the person you took it from either.";
|
||||
|
||||
if ( isEquipped (Dungeon.hero) )
|
||||
desc += "\n\nWith the armband around your wrist you feel more dexterous and cunning. Every piece of gold " +
|
||||
"you find makes you desire others property more. " +
|
||||
"You wonder if Pixel Mart accepts the five finger discount...";
|
||||
if ( isEquipped (Dungeon.hero) )
|
||||
desc += "\n\nWith the armband around your wrist you feel more dexterous and cunning. Every piece of gold " +
|
||||
"you find makes you desire others property more. " +
|
||||
"You wonder if Pixel Mart accepts the five finger discount...";
|
||||
|
||||
return desc;
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
|
||||
public class Thievery extends ArtifactBuff{
|
||||
public void collect(int gold){
|
||||
charge += gold/2;
|
||||
}
|
||||
public class Thievery extends ArtifactBuff{
|
||||
public void collect(int gold){
|
||||
charge += gold/2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detach() {
|
||||
charge *= 0.95;
|
||||
super.detach();
|
||||
}
|
||||
@Override
|
||||
public void detach() {
|
||||
charge *= 0.95;
|
||||
super.detach();
|
||||
}
|
||||
|
||||
public boolean steal(int value){
|
||||
if (value <= charge){
|
||||
charge -= value;
|
||||
exp += value;
|
||||
} else {
|
||||
float chance = stealChance(value);
|
||||
if (Random.Float() > chance)
|
||||
return false;
|
||||
else {
|
||||
if (chance <= 1)
|
||||
charge = 0;
|
||||
else
|
||||
//removes the charge it took you to reach 100%
|
||||
charge -= charge/chance;
|
||||
exp += value;
|
||||
}
|
||||
}
|
||||
while(exp >= 600 && level < levelCap) {
|
||||
exp -= 600;
|
||||
upgrade();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public boolean steal(int value){
|
||||
if (value <= charge){
|
||||
charge -= value;
|
||||
exp += value;
|
||||
} else {
|
||||
float chance = stealChance(value);
|
||||
if (Random.Float() > chance)
|
||||
return false;
|
||||
else {
|
||||
if (chance <= 1)
|
||||
charge = 0;
|
||||
else
|
||||
//removes the charge it took you to reach 100%
|
||||
charge -= charge/chance;
|
||||
exp += value;
|
||||
}
|
||||
}
|
||||
while(exp >= 600 && level < levelCap) {
|
||||
exp -= 600;
|
||||
upgrade();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public float stealChance(int value){
|
||||
//get lvl*100 gold or lvl*5% item value of free charge, whichever is less.
|
||||
int chargeBonus = Math.min(level*100, (value*level)/20);
|
||||
public float stealChance(int value){
|
||||
//get lvl*100 gold or lvl*5% item value of free charge, whichever is less.
|
||||
int chargeBonus = Math.min(level*100, (value*level)/20);
|
||||
|
||||
return (((float)charge + chargeBonus)/value);
|
||||
}
|
||||
}
|
||||
return (((float)charge + chargeBonus)/value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+158
-161
@@ -21,196 +21,193 @@ import com.watabou.utils.Bundle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* Created by debenhame on 08/09/2014.
|
||||
*/
|
||||
public class SandalsOfNature extends Artifact {
|
||||
|
||||
{
|
||||
name = "Sandals of Nature";
|
||||
image = ItemSpriteSheet.ARTIFACT_SANDALS;
|
||||
{
|
||||
name = "Sandals of Nature";
|
||||
image = ItemSpriteSheet.ARTIFACT_SANDALS;
|
||||
|
||||
level = 0;
|
||||
levelCap = 3;
|
||||
level = 0;
|
||||
levelCap = 3;
|
||||
|
||||
charge = 0;
|
||||
charge = 0;
|
||||
|
||||
defaultAction = AC_ROOT;
|
||||
}
|
||||
defaultAction = AC_ROOT;
|
||||
}
|
||||
|
||||
public static final String[] NAMES = {"Sandals of Nature", "Shoes of Nature",
|
||||
"Boots of Nature", "Greaves of Nature"};
|
||||
public static final String[] NAMES = {"Sandals of Nature", "Shoes of Nature",
|
||||
"Boots of Nature", "Greaves of Nature"};
|
||||
|
||||
public static final String AC_FEED = "FEED";
|
||||
public static final String AC_ROOT = "ROOT";
|
||||
public static final String AC_FEED = "FEED";
|
||||
public static final String AC_ROOT = "ROOT";
|
||||
|
||||
protected String inventoryTitle = "Select a seed";
|
||||
protected WndBag.Mode mode = WndBag.Mode.SEED;
|
||||
protected String inventoryTitle = "Select a seed";
|
||||
protected WndBag.Mode mode = WndBag.Mode.SEED;
|
||||
|
||||
public ArrayList<String> seeds = new ArrayList<String>();
|
||||
public ArrayList<String> seeds = new ArrayList<String>();
|
||||
|
||||
@Override
|
||||
public ArrayList<String> actions( Hero hero ) {
|
||||
ArrayList<String> actions = super.actions( hero );
|
||||
if (isEquipped( hero ) && level < 3 && !cursed)
|
||||
actions.add(AC_FEED);
|
||||
if (isEquipped( hero ) && charge > 0)
|
||||
actions.add(AC_ROOT);
|
||||
return actions;
|
||||
}
|
||||
@Override
|
||||
public ArrayList<String> actions( Hero hero ) {
|
||||
ArrayList<String> actions = super.actions( hero );
|
||||
if (isEquipped( hero ) && level < 3 && !cursed)
|
||||
actions.add(AC_FEED);
|
||||
if (isEquipped( hero ) && charge > 0)
|
||||
actions.add(AC_ROOT);
|
||||
return actions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute( Hero hero, String action ) {
|
||||
super.execute(hero, action);
|
||||
if (action.equals(AC_FEED)){
|
||||
GameScene.selectItem(itemSelector, mode, inventoryTitle);
|
||||
} else if (action.equals(AC_ROOT) && level > 0){
|
||||
@Override
|
||||
public void execute( Hero hero, String action ) {
|
||||
super.execute(hero, action);
|
||||
if (action.equals(AC_FEED)){
|
||||
GameScene.selectItem(itemSelector, mode, inventoryTitle);
|
||||
} else if (action.equals(AC_ROOT) && level > 0){
|
||||
|
||||
if (!isEquipped( hero )) GLog.i("You need to equip them to do that.");
|
||||
else if (charge == 0) GLog.i("They have no energy right now.");
|
||||
else {
|
||||
Buff.prolong(hero, Roots.class, 5);
|
||||
Buff.affect(hero, Earthroot.Armor.class).level(charge);
|
||||
CellEmitter.bottom(hero.pos).start(EarthParticle.FACTORY, 0.05f, 8);
|
||||
Camera.main.shake(1, 0.4f);
|
||||
charge = 0;
|
||||
updateQuickslot();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isEquipped( hero )) GLog.i("You need to equip them to do that.");
|
||||
else if (charge == 0) GLog.i("They have no energy right now.");
|
||||
else {
|
||||
Buff.prolong(hero, Roots.class, 5);
|
||||
Buff.affect(hero, Earthroot.Armor.class).level(charge);
|
||||
CellEmitter.bottom(hero.pos).start(EarthParticle.FACTORY, 0.05f, 8);
|
||||
Camera.main.shake(1, 0.4f);
|
||||
charge = 0;
|
||||
updateQuickslot();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ArtifactBuff passiveBuff() {
|
||||
return new Naturalism();
|
||||
}
|
||||
@Override
|
||||
protected ArtifactBuff passiveBuff() {
|
||||
return new Naturalism();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
String desc = "";
|
||||
if (level == 0)
|
||||
desc += "What initially seem like sandals made of twine are actually two plants! The footwear moves ever " +
|
||||
"so slightly when being held. They seem very weak and pale, perhaps they need to be given nutrients?";
|
||||
else if (level == 1)
|
||||
desc += "The footwear has grown and now more closely resemble two tailored shoes. They seem to match the " +
|
||||
"contours of your feet exactly. Some colour has returned to them, perhaps they can still grow further?";
|
||||
else if (level == 2)
|
||||
desc += "The plants have grown again and now resembles a pair of solid tall boots. They appear to be made" +
|
||||
" of solid bark more than vine now, yet are still very flexible. The plants seem to have " +
|
||||
"regained their strength, but perhaps they can still grow further";
|
||||
else
|
||||
desc += "Now almost tall enough to make full pants, the bark-mesh artifact seems to have reached its " +
|
||||
"maximum size. Perhaps the two plants don't want to merge together? The greaves are a deep brown " +
|
||||
"and resemble a very sturdy tree.";
|
||||
@Override
|
||||
public String desc() {
|
||||
String desc = "";
|
||||
if (level == 0)
|
||||
desc += "What initially seem like sandals made of twine are actually two plants! The footwear moves ever " +
|
||||
"so slightly when being held. They seem very weak and pale, perhaps they need to be given nutrients?";
|
||||
else if (level == 1)
|
||||
desc += "The footwear has grown and now more closely resemble two tailored shoes. They seem to match the " +
|
||||
"contours of your feet exactly. Some colour has returned to them, perhaps they can still grow further?";
|
||||
else if (level == 2)
|
||||
desc += "The plants have grown again and now resembles a pair of solid tall boots. They appear to be made" +
|
||||
" of solid bark more than vine now, yet are still very flexible. The plants seem to have " +
|
||||
"regained their strength, but perhaps they can still grow further";
|
||||
else
|
||||
desc += "Now almost tall enough to make full pants, the bark-mesh artifact seems to have reached its " +
|
||||
"maximum size. Perhaps the two plants don't want to merge together? The greaves are a deep brown " +
|
||||
"and resemble a very sturdy tree.";
|
||||
|
||||
if ( isEquipped ( Dungeon.hero ) ){
|
||||
desc += "\n\n";
|
||||
if (level == 0) {
|
||||
if (!cursed)
|
||||
desc += "The sandals wrap snugly around your feet, they seem happy to be worn.";
|
||||
else
|
||||
desc += "The cursed sandals wrap tightly around your feet.";
|
||||
}
|
||||
else if (level == 1)
|
||||
desc += "The shoes fit on loosely but quickly tighten to make a perfect fit.";
|
||||
else if (level == 2)
|
||||
desc += "The boots fit snugly and add a nice heft to your step.";
|
||||
else
|
||||
desc += "The greaves are thick and weighty, but very easy to move in, as if they are moving with you.";
|
||||
if ( isEquipped ( Dungeon.hero ) ){
|
||||
desc += "\n\n";
|
||||
if (level == 0) {
|
||||
if (!cursed)
|
||||
desc += "The sandals wrap snugly around your feet, they seem happy to be worn.";
|
||||
else
|
||||
desc += "The cursed sandals wrap tightly around your feet.";
|
||||
}
|
||||
else if (level == 1)
|
||||
desc += "The shoes fit on loosely but quickly tighten to make a perfect fit.";
|
||||
else if (level == 2)
|
||||
desc += "The boots fit snugly and add a nice heft to your step.";
|
||||
else
|
||||
desc += "The greaves are thick and weighty, but very easy to move in, as if they are moving with you.";
|
||||
|
||||
if (!cursed)
|
||||
desc += " You feel more attuned with nature while wearing them.";
|
||||
else
|
||||
desc += " They are blocking any attunement with nature.";
|
||||
if (!cursed)
|
||||
desc += " You feel more attuned with nature while wearing them.";
|
||||
else
|
||||
desc += " They are blocking any attunement with nature.";
|
||||
|
||||
if (level > 0)
|
||||
desc += "\n\nThe footwear has gained the ability to form up into a sort of immobile natural armour, " +
|
||||
"but will need to charge up for it.";
|
||||
}
|
||||
if (level > 0)
|
||||
desc += "\n\nThe footwear has gained the ability to form up into a sort of immobile natural armour, " +
|
||||
"but will need to charge up for it.";
|
||||
}
|
||||
|
||||
if (!seeds.isEmpty()){
|
||||
desc += "\n\nRecently Fed Seeds:";
|
||||
String[] seedsArray = seeds.toArray(new String[seeds.size()]);
|
||||
if (!seeds.isEmpty()){
|
||||
desc += "\n\nRecently Fed Seeds:";
|
||||
String[] seedsArray = seeds.toArray(new String[seeds.size()]);
|
||||
|
||||
for (int i = 0; i < seedsArray.length-1; i++)
|
||||
desc += " " + seedsArray[i].substring(8) + ",";
|
||||
for (int i = 0; i < seedsArray.length-1; i++)
|
||||
desc += " " + seedsArray[i].substring(8) + ",";
|
||||
|
||||
desc += " " + seedsArray[seedsArray.length-1].substring(8) + ".";
|
||||
}
|
||||
desc += " " + seedsArray[seedsArray.length-1].substring(8) + ".";
|
||||
}
|
||||
|
||||
return desc;
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item upgrade() {
|
||||
if (level < 0)
|
||||
image = ItemSpriteSheet.ARTIFACT_SANDALS;
|
||||
else if (level == 0)
|
||||
image = ItemSpriteSheet.ARTIFACT_SHOES;
|
||||
else if (level == 1)
|
||||
image = ItemSpriteSheet.ARTIFACT_BOOTS;
|
||||
else if (level >= 2)
|
||||
image = ItemSpriteSheet.ARTIFACT_GREAVES;
|
||||
name = NAMES[level+1];
|
||||
return super.upgrade();
|
||||
}
|
||||
@Override
|
||||
public Item upgrade() {
|
||||
if (level < 0)
|
||||
image = ItemSpriteSheet.ARTIFACT_SANDALS;
|
||||
else if (level == 0)
|
||||
image = ItemSpriteSheet.ARTIFACT_SHOES;
|
||||
else if (level == 1)
|
||||
image = ItemSpriteSheet.ARTIFACT_BOOTS;
|
||||
else if (level >= 2)
|
||||
image = ItemSpriteSheet.ARTIFACT_GREAVES;
|
||||
name = NAMES[level+1];
|
||||
return super.upgrade();
|
||||
}
|
||||
|
||||
|
||||
private static final String SEEDS = "seeds";
|
||||
private static final String NAME = "name";
|
||||
private static final String SEEDS = "seeds";
|
||||
private static final String NAME = "name";
|
||||
|
||||
@Override
|
||||
public void storeInBundle( Bundle bundle ) {
|
||||
super.storeInBundle(bundle);
|
||||
bundle.put(NAME, name);
|
||||
bundle.put(SEEDS, seeds.toArray(new String[seeds.size()]));
|
||||
}
|
||||
@Override
|
||||
public void storeInBundle( Bundle bundle ) {
|
||||
super.storeInBundle(bundle);
|
||||
bundle.put(NAME, name);
|
||||
bundle.put(SEEDS, seeds.toArray(new String[seeds.size()]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreFromBundle( Bundle bundle ) {
|
||||
super.restoreFromBundle(bundle);
|
||||
name = bundle.getString( NAME );
|
||||
if (bundle.contains(SEEDS))
|
||||
Collections.addAll(seeds , bundle.getStringArray(SEEDS));
|
||||
}
|
||||
@Override
|
||||
public void restoreFromBundle( Bundle bundle ) {
|
||||
super.restoreFromBundle(bundle);
|
||||
name = bundle.getString( NAME );
|
||||
if (bundle.contains(SEEDS))
|
||||
Collections.addAll(seeds , bundle.getStringArray(SEEDS));
|
||||
}
|
||||
|
||||
public class Naturalism extends ArtifactBuff{
|
||||
public void charge() {
|
||||
if (charge < target.HT){
|
||||
//gain 1+(1*level)% of the difference between current charge and max HP.
|
||||
charge+= (Math.round( (target.HT-charge) * (.01+ level*0.01) ));
|
||||
updateQuickslot();
|
||||
}
|
||||
}
|
||||
}
|
||||
public class Naturalism extends ArtifactBuff{
|
||||
public void charge() {
|
||||
if (charge < target.HT){
|
||||
//gain 1+(1*level)% of the difference between current charge and max HP.
|
||||
charge+= (Math.round( (target.HT-charge) * (.01+ level*0.01) ));
|
||||
updateQuickslot();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected WndBag.Listener itemSelector = new WndBag.Listener() {
|
||||
@Override
|
||||
public void onSelect( Item item ) {
|
||||
if (item != null && item instanceof Plant.Seed) {
|
||||
if (seeds.contains(item.name())){
|
||||
GLog.w("Your " + name + " have already gained nutrients from that seed recently.");
|
||||
} else {
|
||||
seeds.add(item.name());
|
||||
protected WndBag.Listener itemSelector = new WndBag.Listener() {
|
||||
@Override
|
||||
public void onSelect( Item item ) {
|
||||
if (item != null && item instanceof Plant.Seed) {
|
||||
if (seeds.contains(item.name())){
|
||||
GLog.w("Your " + name + " have already gained nutrients from that seed recently.");
|
||||
} else {
|
||||
seeds.add(item.name());
|
||||
|
||||
Hero hero = Dungeon.hero;
|
||||
hero.sprite.operate( hero.pos );
|
||||
Sample.INSTANCE.play( Assets.SND_PLANT );
|
||||
hero.busy();
|
||||
hero.spend( 2f );
|
||||
if (seeds.size() >= 5+(level*2)){
|
||||
seeds.clear();
|
||||
upgrade();
|
||||
if (level >= 1 && level <= 3) {
|
||||
GLog.p("Your " + NAMES[level-1] + " surge in size, they are now " + NAMES[level] + "!");
|
||||
}
|
||||
Hero hero = Dungeon.hero;
|
||||
hero.sprite.operate( hero.pos );
|
||||
Sample.INSTANCE.play( Assets.SND_PLANT );
|
||||
hero.busy();
|
||||
hero.spend( 2f );
|
||||
if (seeds.size() >= 5+(level*2)){
|
||||
seeds.clear();
|
||||
upgrade();
|
||||
if (level >= 1 && level <= 3) {
|
||||
GLog.p("Your " + NAMES[level-1] + " surge in size, they are now " + NAMES[level] + "!");
|
||||
}
|
||||
|
||||
} else {
|
||||
GLog.i("Your " + name + " absorb the seed, they seem healthier.");
|
||||
}
|
||||
item.detach(hero.belongings.backpack);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
} else {
|
||||
GLog.i("Your " + name + " absorb the seed, they seem healthier.");
|
||||
}
|
||||
item.detach(hero.belongings.backpack);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
+148
-151
@@ -15,187 +15,184 @@ import com.watabou.noosa.audio.Sample;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by debenhame on 08/09/2014.
|
||||
*/
|
||||
public class TalismanOfForesight extends Artifact {
|
||||
|
||||
{
|
||||
name = "Talisman of Foresight";
|
||||
image = ItemSpriteSheet.ARTIFACT_TALISMAN;
|
||||
{
|
||||
name = "Talisman of Foresight";
|
||||
image = ItemSpriteSheet.ARTIFACT_TALISMAN;
|
||||
|
||||
level = 0;
|
||||
exp = 0;
|
||||
levelCap = 10;
|
||||
level = 0;
|
||||
exp = 0;
|
||||
levelCap = 10;
|
||||
|
||||
charge = 0;
|
||||
partialCharge = 0;
|
||||
chargeCap = 100;
|
||||
charge = 0;
|
||||
partialCharge = 0;
|
||||
chargeCap = 100;
|
||||
|
||||
defaultAction = AC_SCRY;
|
||||
}
|
||||
defaultAction = AC_SCRY;
|
||||
}
|
||||
|
||||
public static final String AC_SCRY = "SCRY";
|
||||
public static final String AC_SCRY = "SCRY";
|
||||
|
||||
@Override
|
||||
public ArrayList<String> actions( Hero hero ) {
|
||||
ArrayList<String> actions = super.actions( hero );
|
||||
if (isEquipped( hero ) && charge == 100 && !cursed)
|
||||
actions.add(AC_SCRY);
|
||||
return actions;
|
||||
}
|
||||
@Override
|
||||
public ArrayList<String> actions( Hero hero ) {
|
||||
ArrayList<String> actions = super.actions( hero );
|
||||
if (isEquipped( hero ) && charge == 100 && !cursed)
|
||||
actions.add(AC_SCRY);
|
||||
return actions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute( Hero hero, String action ) {
|
||||
super.execute(hero, action);
|
||||
if (action.equals(AC_SCRY)){
|
||||
@Override
|
||||
public void execute( Hero hero, String action ) {
|
||||
super.execute(hero, action);
|
||||
if (action.equals(AC_SCRY)){
|
||||
|
||||
if (!isEquipped(hero)) GLog.i("You need to equip your talisman to do that.");
|
||||
else if (charge != chargeCap) GLog.i("Your talisman isn't full charged yet.");
|
||||
else {
|
||||
hero.sprite.operate(hero.pos);
|
||||
hero.busy();
|
||||
Sample.INSTANCE.play(Assets.SND_BEACON);
|
||||
charge = 0;
|
||||
for (int i = 0; i < Level.LENGTH; i++) {
|
||||
if (!isEquipped(hero)) GLog.i("You need to equip your talisman to do that.");
|
||||
else if (charge != chargeCap) GLog.i("Your talisman isn't full charged yet.");
|
||||
else {
|
||||
hero.sprite.operate(hero.pos);
|
||||
hero.busy();
|
||||
Sample.INSTANCE.play(Assets.SND_BEACON);
|
||||
charge = 0;
|
||||
for (int i = 0; i < Level.LENGTH; i++) {
|
||||
|
||||
int terr = Dungeon.level.map[i];
|
||||
if ((Terrain.flags[terr] & Terrain.SECRET) != 0) {
|
||||
int terr = Dungeon.level.map[i];
|
||||
if ((Terrain.flags[terr] & Terrain.SECRET) != 0) {
|
||||
|
||||
GameScene.updateMap(i);
|
||||
GameScene.updateMap(i);
|
||||
|
||||
if (Dungeon.visible[i]) {
|
||||
GameScene.discoverTile(i, terr);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Dungeon.visible[i]) {
|
||||
GameScene.discoverTile(i, terr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GLog.p("The Talisman floods your mind with knowledge about the current floor.");
|
||||
GLog.p("The Talisman floods your mind with knowledge about the current floor.");
|
||||
|
||||
Buff.affect(hero, Awareness.class, Awareness.DURATION);
|
||||
Dungeon.observe();
|
||||
}
|
||||
}
|
||||
}
|
||||
Buff.affect(hero, Awareness.class, Awareness.DURATION);
|
||||
Dungeon.observe();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ArtifactBuff passiveBuff() {
|
||||
return new Foresight();
|
||||
}
|
||||
@Override
|
||||
protected ArtifactBuff passiveBuff() {
|
||||
return new Foresight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
String desc = "A smooth stone, almost too big for your pocket or hand, with strange engravings on it. " +
|
||||
"You feel like it's watching you, assessing your every move.";
|
||||
if ( isEquipped( Dungeon.hero ) ){
|
||||
if (!cursed) {
|
||||
desc += "\n\nWhen you hold the talisman you feel like your senses are heightened.";
|
||||
if (charge == 100)
|
||||
desc += "\n\nThe talisman is radiating energy, prodding at your mind. You wonder what would " +
|
||||
"happen if you let it in.";
|
||||
} else {
|
||||
desc += "\n\nThe cursed talisman is intently staring into you, making it impossible to concentrate.";
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public String desc() {
|
||||
String desc = "A smooth stone, almost too big for your pocket or hand, with strange engravings on it. " +
|
||||
"You feel like it's watching you, assessing your every move.";
|
||||
if ( isEquipped( Dungeon.hero ) ){
|
||||
if (!cursed) {
|
||||
desc += "\n\nWhen you hold the talisman you feel like your senses are heightened.";
|
||||
if (charge == 100)
|
||||
desc += "\n\nThe talisman is radiating energy, prodding at your mind. You wonder what would " +
|
||||
"happen if you let it in.";
|
||||
} else {
|
||||
desc += "\n\nThe cursed talisman is intently staring into you, making it impossible to concentrate.";
|
||||
}
|
||||
}
|
||||
|
||||
return desc;
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
|
||||
public class Foresight extends ArtifactBuff{
|
||||
private int warn = 0;
|
||||
public class Foresight extends ArtifactBuff{
|
||||
private int warn = 0;
|
||||
|
||||
@Override
|
||||
public boolean act() {
|
||||
spend( TICK );
|
||||
@Override
|
||||
public boolean act() {
|
||||
spend( TICK );
|
||||
|
||||
boolean smthFound = false;
|
||||
boolean smthFound = false;
|
||||
|
||||
int distance = 3;
|
||||
int distance = 3;
|
||||
|
||||
int cx = target.pos % Level.WIDTH;
|
||||
int cy = target.pos / Level.WIDTH;
|
||||
int ax = cx - distance;
|
||||
if (ax < 0) {
|
||||
ax = 0;
|
||||
}
|
||||
int bx = cx + distance;
|
||||
if (bx >= Level.WIDTH) {
|
||||
bx = Level.WIDTH - 1;
|
||||
}
|
||||
int ay = cy - distance;
|
||||
if (ay < 0) {
|
||||
ay = 0;
|
||||
}
|
||||
int by = cy + distance;
|
||||
if (by >= Level.HEIGHT) {
|
||||
by = Level.HEIGHT - 1;
|
||||
}
|
||||
int cx = target.pos % Level.WIDTH;
|
||||
int cy = target.pos / Level.WIDTH;
|
||||
int ax = cx - distance;
|
||||
if (ax < 0) {
|
||||
ax = 0;
|
||||
}
|
||||
int bx = cx + distance;
|
||||
if (bx >= Level.WIDTH) {
|
||||
bx = Level.WIDTH - 1;
|
||||
}
|
||||
int ay = cy - distance;
|
||||
if (ay < 0) {
|
||||
ay = 0;
|
||||
}
|
||||
int by = cy + distance;
|
||||
if (by >= Level.HEIGHT) {
|
||||
by = Level.HEIGHT - 1;
|
||||
}
|
||||
|
||||
for (int y = ay; y <= by; y++) {
|
||||
for (int x = ax, p = ax + y * Level.WIDTH; x <= bx; x++, p++) {
|
||||
for (int y = ay; y <= by; y++) {
|
||||
for (int x = ax, p = ax + y * Level.WIDTH; x <= bx; x++, p++) {
|
||||
|
||||
if (Dungeon.visible[p] && Level.secret[p] && Dungeon.level.map[p] != Terrain.SECRET_DOOR)
|
||||
smthFound = true;
|
||||
}
|
||||
}
|
||||
if (Dungeon.visible[p] && Level.secret[p] && Dungeon.level.map[p] != Terrain.SECRET_DOOR)
|
||||
smthFound = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (smthFound == true && !cursed){
|
||||
if (warn == 0){
|
||||
GLog.w("You feel uneasy.");
|
||||
if (target instanceof Hero){
|
||||
((Hero)target).interrupt();
|
||||
}
|
||||
}
|
||||
warn = 3;
|
||||
} else {
|
||||
if (warn > 0){
|
||||
warn --;
|
||||
}
|
||||
}
|
||||
BuffIndicator.refreshHero();
|
||||
if (smthFound == true && !cursed){
|
||||
if (warn == 0){
|
||||
GLog.w("You feel uneasy.");
|
||||
if (target instanceof Hero){
|
||||
((Hero)target).interrupt();
|
||||
}
|
||||
}
|
||||
warn = 3;
|
||||
} else {
|
||||
if (warn > 0){
|
||||
warn --;
|
||||
}
|
||||
}
|
||||
BuffIndicator.refreshHero();
|
||||
|
||||
//fully charges in 2500 turns at lvl=0, scaling to 1000 turns at lvl = 10.
|
||||
if (charge < 100 && !cursed) {
|
||||
partialCharge += 0.04+(level*0.006);
|
||||
//fully charges in 2500 turns at lvl=0, scaling to 1000 turns at lvl = 10.
|
||||
if (charge < 100 && !cursed) {
|
||||
partialCharge += 0.04+(level*0.006);
|
||||
|
||||
if (partialCharge > 1 && charge < 100) {
|
||||
partialCharge--;
|
||||
charge++;
|
||||
} else if (charge >= 100) {
|
||||
partialCharge = 0;
|
||||
GLog.p("Your Talisman is fully charged!");
|
||||
}
|
||||
}
|
||||
if (partialCharge > 1 && charge < 100) {
|
||||
partialCharge--;
|
||||
charge++;
|
||||
} else if (charge >= 100) {
|
||||
partialCharge = 0;
|
||||
GLog.p("Your Talisman is fully charged!");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void charge(){
|
||||
charge = Math.min(charge+(2+(level/3)), chargeCap);
|
||||
exp++;
|
||||
if (exp >= 4 && level < levelCap) {
|
||||
upgrade();
|
||||
GLog.p("Your Talisman grows stronger!");
|
||||
exp -= 4;
|
||||
}
|
||||
}
|
||||
public void charge(){
|
||||
charge = Math.min(charge+(2+(level/3)), chargeCap);
|
||||
exp++;
|
||||
if (exp >= 4 && level < levelCap) {
|
||||
upgrade();
|
||||
GLog.p("Your Talisman grows stronger!");
|
||||
exp -= 4;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Foresight";
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Foresight";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
return "You feel very nervous, as if there is nearby unseen danger.";
|
||||
}
|
||||
@Override
|
||||
public String desc() {
|
||||
return "You feel very nervous, as if there is nearby unseen danger.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int icon() {
|
||||
if (warn == 0)
|
||||
return BuffIndicator.NONE;
|
||||
else
|
||||
return BuffIndicator.FORESIGHT;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public int icon() {
|
||||
if (warn == 0)
|
||||
return BuffIndicator.NONE;
|
||||
else
|
||||
return BuffIndicator.FORESIGHT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+343
-346
@@ -18,354 +18,351 @@ import com.watabou.utils.Random;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by debenhame on 01/12/2014.
|
||||
*/
|
||||
public class TimekeepersHourglass extends Artifact {
|
||||
|
||||
private static final String TXT_HGLASS = "Timekeeper's Hourglass";
|
||||
private static final String TXT_STASIS = "Put myself in stasis";
|
||||
private static final String TXT_FREEZE = "Freeze time around me";
|
||||
private static final String TXT_DESC =
|
||||
"How would you like to use the hourglass's magic?\n\n" +
|
||||
"While in stasis, time will move normally while you are frozen and completely invulnerable.\n\n" +
|
||||
"When time is frozen, you can move as if your actions take no time. Note that attacking will break this.";
|
||||
|
||||
{
|
||||
name = "Timekeeper's Hourglass";
|
||||
image = ItemSpriteSheet.ARTIFACT_HOURGLASS;
|
||||
|
||||
level = 0;
|
||||
levelCap = 5;
|
||||
|
||||
charge = 10+level*2;
|
||||
partialCharge = 0;
|
||||
chargeCap = 10+level*2;
|
||||
|
||||
defaultAction = AC_ACTIVATE;
|
||||
}
|
||||
|
||||
public static final String AC_ACTIVATE = "ACTIVATE";
|
||||
|
||||
//keeps track of generated sandbags.
|
||||
public int sandBags = 0;
|
||||
|
||||
@Override
|
||||
public ArrayList<String> actions( Hero hero ) {
|
||||
ArrayList<String> actions = super.actions( hero );
|
||||
if (isEquipped( hero ) && charge > 0 && !cursed)
|
||||
actions.add(AC_ACTIVATE);
|
||||
return actions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute( Hero hero, String action ) {
|
||||
if (action.equals(AC_ACTIVATE)){
|
||||
|
||||
if (!isEquipped( hero )) GLog.i("You need to equip your hourglass to do that.");
|
||||
else if (activeBuff != null) GLog.i("Your hourglass is already in use.");
|
||||
else if (charge <= 1) GLog.i("Your hourglass hasn't recharged enough to be usable yet.");
|
||||
else if (cursed) GLog.i("You cannot use a cursed hourglass.");
|
||||
else GameScene.show(
|
||||
new WndOptions(TXT_HGLASS, TXT_DESC, TXT_STASIS, TXT_FREEZE) {
|
||||
@Override
|
||||
protected void onSelect(int index) {
|
||||
if (index == 0) {
|
||||
GLog.i("The world seems to shift around you in an instant.");
|
||||
GameScene.flash(0xFFFFFF);
|
||||
Sample.INSTANCE.play(Assets.SND_TELEPORT);
|
||||
|
||||
activeBuff = new timeStasis();
|
||||
activeBuff.attachTo(Dungeon.hero);
|
||||
} else if (index == 1) {
|
||||
GLog.i("everything around you suddenly freezes.");
|
||||
GameScene.flash(0xFFFFFF);
|
||||
Sample.INSTANCE.play(Assets.SND_TELEPORT);
|
||||
|
||||
activeBuff = new timeFreeze();
|
||||
activeBuff.attachTo(Dungeon.hero);
|
||||
}
|
||||
};
|
||||
}
|
||||
);
|
||||
} else
|
||||
super.execute(hero, action);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void activate(Char ch) {
|
||||
super.activate(ch);
|
||||
if (activeBuff != null)
|
||||
activeBuff.attachTo(ch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doUnequip(Hero hero, boolean collect, boolean single) {
|
||||
if (super.doUnequip(hero, collect, single)){
|
||||
if (activeBuff != null){
|
||||
activeBuff.detach();
|
||||
activeBuff = null;
|
||||
}
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ArtifactBuff passiveBuff() {
|
||||
return new hourglassRecharge();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item upgrade() {
|
||||
chargeCap+= 2;
|
||||
|
||||
//for artifact transmutation.
|
||||
while (level+1 > sandBags)
|
||||
sandBags ++;
|
||||
|
||||
return super.upgrade();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
String desc =
|
||||
"This large ornate hourglass looks fairly unassuming, but you feel a great power in its finely carved" +
|
||||
" frame. As you rotate the hourglass and watch the sand pour you can feel its magic tugging at you, " +
|
||||
"surely invoking this magic would give you some power over time.";
|
||||
|
||||
if (isEquipped( Dungeon.hero )){
|
||||
if (!cursed) {
|
||||
desc += "\n\nThe hourglass rests at your side, the whisper of steadily pouring sand is reassuring.";
|
||||
|
||||
if (level < levelCap )
|
||||
desc +=
|
||||
"\n\nThe hourglass seems to have lost some sand with age. While there are no cracks, " +
|
||||
"there is a port on the top of the hourglass to pour sand in, if only you could find some...";
|
||||
}else
|
||||
desc += "\n\nThe cursed hourglass is locked to your side, " +
|
||||
"you can feel it trying to manipulate your flow of time.";
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
|
||||
|
||||
private static final String SANDBAGS = "sandbags";
|
||||
private static final String BUFF = "buff";
|
||||
|
||||
@Override
|
||||
public void storeInBundle( Bundle bundle ) {
|
||||
super.storeInBundle(bundle);
|
||||
bundle.put( SANDBAGS, sandBags );
|
||||
|
||||
if (activeBuff != null)
|
||||
bundle.put( BUFF , activeBuff );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreFromBundle( Bundle bundle ) {
|
||||
super.restoreFromBundle(bundle);
|
||||
sandBags = bundle.getInt( SANDBAGS );
|
||||
|
||||
//these buffs belong to hourglass, need to handle unbundling within the hourglass class.
|
||||
if (bundle.contains( BUFF )){
|
||||
Bundle buffBundle = bundle.getBundle( BUFF );
|
||||
|
||||
if (buffBundle.contains( timeFreeze.PARTIALTIME ))
|
||||
activeBuff = new timeFreeze();
|
||||
else
|
||||
activeBuff = new timeStasis();
|
||||
|
||||
activeBuff.restoreFromBundle(buffBundle);
|
||||
}
|
||||
}
|
||||
|
||||
public class hourglassRecharge extends ArtifactBuff {
|
||||
@Override
|
||||
public boolean act() {
|
||||
if (charge < chargeCap && !cursed) {
|
||||
partialCharge += 1 / (60f - (chargeCap - charge)*2f);
|
||||
|
||||
if (partialCharge >= 1) {
|
||||
partialCharge --;
|
||||
charge ++;
|
||||
|
||||
if (charge == chargeCap){
|
||||
partialCharge = 0;
|
||||
}
|
||||
}
|
||||
} else if (cursed && Random.Int(10) == 0)
|
||||
((Hero) target).spend( TICK );
|
||||
|
||||
updateQuickslot();
|
||||
|
||||
spend( TICK );
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class timeStasis extends ArtifactBuff {
|
||||
|
||||
@Override
|
||||
public boolean attachTo(Char target) {
|
||||
//buffs always act last, so the stasis buff should end a turn early.
|
||||
spend(charge-1);
|
||||
((Hero)target).spendAndNext(charge);
|
||||
|
||||
//shouldn't punish the player for going into stasis frequently
|
||||
Hunger hunger = target.buff(Hunger.class);
|
||||
if (hunger != null && !hunger.isStarving())
|
||||
hunger.satisfy(charge);
|
||||
|
||||
charge = 0;
|
||||
|
||||
target.invisible++;
|
||||
|
||||
updateQuickslot();
|
||||
|
||||
Dungeon.observe();
|
||||
|
||||
return super.attachTo(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean act() {
|
||||
detach();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detach() {
|
||||
if (target.invisible > 0)
|
||||
target.invisible --;
|
||||
super.detach();
|
||||
activeBuff = null;
|
||||
Dungeon.observe();
|
||||
}
|
||||
}
|
||||
|
||||
public class timeFreeze extends ArtifactBuff {
|
||||
|
||||
float partialTime = 0f;
|
||||
|
||||
ArrayList<Integer> presses = new ArrayList<Integer>();
|
||||
|
||||
public boolean processTime(float time){
|
||||
partialTime += time;
|
||||
|
||||
while (partialTime >= 1f){
|
||||
partialTime --;
|
||||
charge --;
|
||||
}
|
||||
|
||||
updateQuickslot();
|
||||
|
||||
if (charge <= 0){
|
||||
detach();
|
||||
return false;
|
||||
} else
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public void setDelayedPress(int cell){
|
||||
if (!presses.contains(cell))
|
||||
presses.add(cell);
|
||||
}
|
||||
|
||||
public void triggerPresses(){
|
||||
for (int cell : presses)
|
||||
Dungeon.level.press(cell, null);
|
||||
|
||||
presses = new ArrayList<Integer>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean attachTo(Char target) {
|
||||
if (Dungeon.level != null)
|
||||
for (Mob mob : Dungeon.level.mobs.toArray(new Mob[0]))
|
||||
mob.sprite.add(CharSprite.State.PARALYSED);
|
||||
GameScene.freezeEmitters = true;
|
||||
return super.attachTo(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detach(){
|
||||
triggerPresses();
|
||||
for (Mob mob : Dungeon.level.mobs.toArray(new Mob[0]))
|
||||
mob.sprite.remove(CharSprite.State.PARALYSED);
|
||||
GameScene.freezeEmitters = false;
|
||||
|
||||
charge = 0;
|
||||
updateQuickslot();
|
||||
super.detach();
|
||||
activeBuff = null;
|
||||
}
|
||||
|
||||
private static final String PRESSES = "presses";
|
||||
private static final String PARTIALTIME = "partialtime";
|
||||
|
||||
@Override
|
||||
public void storeInBundle(Bundle bundle) {
|
||||
super.storeInBundle(bundle);
|
||||
|
||||
int[] values = new int[presses.size()];
|
||||
for (int i = 0; i < values.length; i ++)
|
||||
values[i] = presses.get(i);
|
||||
bundle.put( PRESSES , values );
|
||||
|
||||
bundle.put( PARTIALTIME , partialTime );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreFromBundle(Bundle bundle) {
|
||||
super.restoreFromBundle(bundle);
|
||||
|
||||
int[] values = bundle.getIntArray( PRESSES );
|
||||
for (int value : values)
|
||||
presses.add(value);
|
||||
|
||||
partialTime = bundle.getFloat( PARTIALTIME );
|
||||
}
|
||||
}
|
||||
|
||||
public static class sandBag extends Item {
|
||||
|
||||
{
|
||||
name = "bag of magic sand";
|
||||
image = ItemSpriteSheet.SANDBAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doPickUp( Hero hero ) {
|
||||
TimekeepersHourglass hourglass = hero.belongings.getItem( TimekeepersHourglass.class );
|
||||
if (hourglass != null && !hourglass.cursed) {
|
||||
hourglass.upgrade();
|
||||
Sample.INSTANCE.play( Assets.SND_DEWDROP );
|
||||
if (hourglass.level == hourglass.levelCap)
|
||||
GLog.p("Your hourglass is filled with magical sand!");
|
||||
else
|
||||
GLog.i("you add the sand to your hourglass.");
|
||||
hero.spendAndNext(TIME_TO_PICK_UP);
|
||||
return true;
|
||||
} else {
|
||||
GLog.w("You have no hourglass to place this sand into.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc(){
|
||||
return "This small bag of finely ground sand should work perfectly with your hourglass.\n\n" +
|
||||
"It seems odd that the shopkeeper would have this specific item right when you need it.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int price() {
|
||||
return 20;
|
||||
}
|
||||
}
|
||||
private static final String TXT_HGLASS = "Timekeeper's Hourglass";
|
||||
private static final String TXT_STASIS = "Put myself in stasis";
|
||||
private static final String TXT_FREEZE = "Freeze time around me";
|
||||
private static final String TXT_DESC =
|
||||
"How would you like to use the hourglass's magic?\n\n" +
|
||||
"While in stasis, time will move normally while you are frozen and completely invulnerable.\n\n" +
|
||||
"When time is frozen, you can move as if your actions take no time. Note that attacking will break this.";
|
||||
|
||||
{
|
||||
name = "Timekeeper's Hourglass";
|
||||
image = ItemSpriteSheet.ARTIFACT_HOURGLASS;
|
||||
|
||||
level = 0;
|
||||
levelCap = 5;
|
||||
|
||||
charge = 10+level*2;
|
||||
partialCharge = 0;
|
||||
chargeCap = 10+level*2;
|
||||
|
||||
defaultAction = AC_ACTIVATE;
|
||||
}
|
||||
|
||||
public static final String AC_ACTIVATE = "ACTIVATE";
|
||||
|
||||
//keeps track of generated sandbags.
|
||||
public int sandBags = 0;
|
||||
|
||||
@Override
|
||||
public ArrayList<String> actions( Hero hero ) {
|
||||
ArrayList<String> actions = super.actions( hero );
|
||||
if (isEquipped( hero ) && charge > 0 && !cursed)
|
||||
actions.add(AC_ACTIVATE);
|
||||
return actions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute( Hero hero, String action ) {
|
||||
if (action.equals(AC_ACTIVATE)){
|
||||
|
||||
if (!isEquipped( hero )) GLog.i("You need to equip your hourglass to do that.");
|
||||
else if (activeBuff != null) GLog.i("Your hourglass is already in use.");
|
||||
else if (charge <= 1) GLog.i("Your hourglass hasn't recharged enough to be usable yet.");
|
||||
else if (cursed) GLog.i("You cannot use a cursed hourglass.");
|
||||
else GameScene.show(
|
||||
new WndOptions(TXT_HGLASS, TXT_DESC, TXT_STASIS, TXT_FREEZE) {
|
||||
@Override
|
||||
protected void onSelect(int index) {
|
||||
if (index == 0) {
|
||||
GLog.i("The world seems to shift around you in an instant.");
|
||||
GameScene.flash(0xFFFFFF);
|
||||
Sample.INSTANCE.play(Assets.SND_TELEPORT);
|
||||
|
||||
activeBuff = new timeStasis();
|
||||
activeBuff.attachTo(Dungeon.hero);
|
||||
} else if (index == 1) {
|
||||
GLog.i("everything around you suddenly freezes.");
|
||||
GameScene.flash(0xFFFFFF);
|
||||
Sample.INSTANCE.play(Assets.SND_TELEPORT);
|
||||
|
||||
activeBuff = new timeFreeze();
|
||||
activeBuff.attachTo(Dungeon.hero);
|
||||
}
|
||||
};
|
||||
}
|
||||
);
|
||||
} else
|
||||
super.execute(hero, action);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void activate(Char ch) {
|
||||
super.activate(ch);
|
||||
if (activeBuff != null)
|
||||
activeBuff.attachTo(ch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doUnequip(Hero hero, boolean collect, boolean single) {
|
||||
if (super.doUnequip(hero, collect, single)){
|
||||
if (activeBuff != null){
|
||||
activeBuff.detach();
|
||||
activeBuff = null;
|
||||
}
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ArtifactBuff passiveBuff() {
|
||||
return new hourglassRecharge();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item upgrade() {
|
||||
chargeCap+= 2;
|
||||
|
||||
//for artifact transmutation.
|
||||
while (level+1 > sandBags)
|
||||
sandBags ++;
|
||||
|
||||
return super.upgrade();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
String desc =
|
||||
"This large ornate hourglass looks fairly unassuming, but you feel a great power in its finely carved" +
|
||||
" frame. As you rotate the hourglass and watch the sand pour you can feel its magic tugging at you, " +
|
||||
"surely invoking this magic would give you some power over time.";
|
||||
|
||||
if (isEquipped( Dungeon.hero )){
|
||||
if (!cursed) {
|
||||
desc += "\n\nThe hourglass rests at your side, the whisper of steadily pouring sand is reassuring.";
|
||||
|
||||
if (level < levelCap )
|
||||
desc +=
|
||||
"\n\nThe hourglass seems to have lost some sand with age. While there are no cracks, " +
|
||||
"there is a port on the top of the hourglass to pour sand in, if only you could find some...";
|
||||
}else
|
||||
desc += "\n\nThe cursed hourglass is locked to your side, " +
|
||||
"you can feel it trying to manipulate your flow of time.";
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
|
||||
|
||||
private static final String SANDBAGS = "sandbags";
|
||||
private static final String BUFF = "buff";
|
||||
|
||||
@Override
|
||||
public void storeInBundle( Bundle bundle ) {
|
||||
super.storeInBundle(bundle);
|
||||
bundle.put( SANDBAGS, sandBags );
|
||||
|
||||
if (activeBuff != null)
|
||||
bundle.put( BUFF , activeBuff );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreFromBundle( Bundle bundle ) {
|
||||
super.restoreFromBundle(bundle);
|
||||
sandBags = bundle.getInt( SANDBAGS );
|
||||
|
||||
//these buffs belong to hourglass, need to handle unbundling within the hourglass class.
|
||||
if (bundle.contains( BUFF )){
|
||||
Bundle buffBundle = bundle.getBundle( BUFF );
|
||||
|
||||
if (buffBundle.contains( timeFreeze.PARTIALTIME ))
|
||||
activeBuff = new timeFreeze();
|
||||
else
|
||||
activeBuff = new timeStasis();
|
||||
|
||||
activeBuff.restoreFromBundle(buffBundle);
|
||||
}
|
||||
}
|
||||
|
||||
public class hourglassRecharge extends ArtifactBuff {
|
||||
@Override
|
||||
public boolean act() {
|
||||
if (charge < chargeCap && !cursed) {
|
||||
partialCharge += 1 / (60f - (chargeCap - charge)*2f);
|
||||
|
||||
if (partialCharge >= 1) {
|
||||
partialCharge --;
|
||||
charge ++;
|
||||
|
||||
if (charge == chargeCap){
|
||||
partialCharge = 0;
|
||||
}
|
||||
}
|
||||
} else if (cursed && Random.Int(10) == 0)
|
||||
((Hero) target).spend( TICK );
|
||||
|
||||
updateQuickslot();
|
||||
|
||||
spend( TICK );
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class timeStasis extends ArtifactBuff {
|
||||
|
||||
@Override
|
||||
public boolean attachTo(Char target) {
|
||||
//buffs always act last, so the stasis buff should end a turn early.
|
||||
spend(charge-1);
|
||||
((Hero)target).spendAndNext(charge);
|
||||
|
||||
//shouldn't punish the player for going into stasis frequently
|
||||
Hunger hunger = target.buff(Hunger.class);
|
||||
if (hunger != null && !hunger.isStarving())
|
||||
hunger.satisfy(charge);
|
||||
|
||||
charge = 0;
|
||||
|
||||
target.invisible++;
|
||||
|
||||
updateQuickslot();
|
||||
|
||||
Dungeon.observe();
|
||||
|
||||
return super.attachTo(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean act() {
|
||||
detach();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detach() {
|
||||
if (target.invisible > 0)
|
||||
target.invisible --;
|
||||
super.detach();
|
||||
activeBuff = null;
|
||||
Dungeon.observe();
|
||||
}
|
||||
}
|
||||
|
||||
public class timeFreeze extends ArtifactBuff {
|
||||
|
||||
float partialTime = 0f;
|
||||
|
||||
ArrayList<Integer> presses = new ArrayList<Integer>();
|
||||
|
||||
public boolean processTime(float time){
|
||||
partialTime += time;
|
||||
|
||||
while (partialTime >= 1f){
|
||||
partialTime --;
|
||||
charge --;
|
||||
}
|
||||
|
||||
updateQuickslot();
|
||||
|
||||
if (charge <= 0){
|
||||
detach();
|
||||
return false;
|
||||
} else
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public void setDelayedPress(int cell){
|
||||
if (!presses.contains(cell))
|
||||
presses.add(cell);
|
||||
}
|
||||
|
||||
public void triggerPresses(){
|
||||
for (int cell : presses)
|
||||
Dungeon.level.press(cell, null);
|
||||
|
||||
presses = new ArrayList<Integer>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean attachTo(Char target) {
|
||||
if (Dungeon.level != null)
|
||||
for (Mob mob : Dungeon.level.mobs.toArray(new Mob[0]))
|
||||
mob.sprite.add(CharSprite.State.PARALYSED);
|
||||
GameScene.freezeEmitters = true;
|
||||
return super.attachTo(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detach(){
|
||||
triggerPresses();
|
||||
for (Mob mob : Dungeon.level.mobs.toArray(new Mob[0]))
|
||||
mob.sprite.remove(CharSprite.State.PARALYSED);
|
||||
GameScene.freezeEmitters = false;
|
||||
|
||||
charge = 0;
|
||||
updateQuickslot();
|
||||
super.detach();
|
||||
activeBuff = null;
|
||||
}
|
||||
|
||||
private static final String PRESSES = "presses";
|
||||
private static final String PARTIALTIME = "partialtime";
|
||||
|
||||
@Override
|
||||
public void storeInBundle(Bundle bundle) {
|
||||
super.storeInBundle(bundle);
|
||||
|
||||
int[] values = new int[presses.size()];
|
||||
for (int i = 0; i < values.length; i ++)
|
||||
values[i] = presses.get(i);
|
||||
bundle.put( PRESSES , values );
|
||||
|
||||
bundle.put( PARTIALTIME , partialTime );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreFromBundle(Bundle bundle) {
|
||||
super.restoreFromBundle(bundle);
|
||||
|
||||
int[] values = bundle.getIntArray( PRESSES );
|
||||
for (int value : values)
|
||||
presses.add(value);
|
||||
|
||||
partialTime = bundle.getFloat( PARTIALTIME );
|
||||
}
|
||||
}
|
||||
|
||||
public static class sandBag extends Item {
|
||||
|
||||
{
|
||||
name = "bag of magic sand";
|
||||
image = ItemSpriteSheet.SANDBAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doPickUp( Hero hero ) {
|
||||
TimekeepersHourglass hourglass = hero.belongings.getItem( TimekeepersHourglass.class );
|
||||
if (hourglass != null && !hourglass.cursed) {
|
||||
hourglass.upgrade();
|
||||
Sample.INSTANCE.play( Assets.SND_DEWDROP );
|
||||
if (hourglass.level == hourglass.levelCap)
|
||||
GLog.p("Your hourglass is filled with magical sand!");
|
||||
else
|
||||
GLog.i("you add the sand to your hourglass.");
|
||||
hero.spendAndNext(TIME_TO_PICK_UP);
|
||||
return true;
|
||||
} else {
|
||||
GLog.w("You have no hourglass to place this sand into.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc(){
|
||||
return "This small bag of finely ground sand should work perfectly with your hourglass.\n\n" +
|
||||
"It seems odd that the shopkeeper would have this specific item right when you need it.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int price() {
|
||||
return 20;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+159
-162
@@ -22,210 +22,207 @@ import com.watabou.utils.Random;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* Created by debenhame on 26/11/2014.
|
||||
*/
|
||||
public class UnstableSpellbook extends Artifact {
|
||||
|
||||
{
|
||||
name = "Unstable Spellbook";
|
||||
image = ItemSpriteSheet.ARTIFACT_SPELLBOOK;
|
||||
{
|
||||
name = "Unstable Spellbook";
|
||||
image = ItemSpriteSheet.ARTIFACT_SPELLBOOK;
|
||||
|
||||
level = 0;
|
||||
levelCap = 10;
|
||||
level = 0;
|
||||
levelCap = 10;
|
||||
|
||||
charge = ((level/2)+3);
|
||||
partialCharge = 0;
|
||||
chargeCap = ((level/2)+3);
|
||||
charge = ((level/2)+3);
|
||||
partialCharge = 0;
|
||||
chargeCap = ((level/2)+3);
|
||||
|
||||
defaultAction = AC_READ;
|
||||
}
|
||||
defaultAction = AC_READ;
|
||||
}
|
||||
|
||||
public static final String AC_READ = "READ";
|
||||
public static final String AC_ADD = "ADD";
|
||||
public static final String AC_READ = "READ";
|
||||
public static final String AC_ADD = "ADD";
|
||||
|
||||
private final ArrayList<String> scrolls = new ArrayList<String>();
|
||||
private final ArrayList<String> scrolls = new ArrayList<String>();
|
||||
|
||||
protected String inventoryTitle = "Select a scroll";
|
||||
protected WndBag.Mode mode = WndBag.Mode.SCROLL;
|
||||
protected String inventoryTitle = "Select a scroll";
|
||||
protected WndBag.Mode mode = WndBag.Mode.SCROLL;
|
||||
|
||||
public UnstableSpellbook() {
|
||||
super();
|
||||
public UnstableSpellbook() {
|
||||
super();
|
||||
|
||||
Class<?>[] scrollClasses = Generator.Category.SCROLL.classes;
|
||||
float[] probs = Generator.Category.SCROLL.probs.clone(); //array of primitives, clone gives deep copy.
|
||||
int i = Random.chances(probs);
|
||||
Class<?>[] scrollClasses = Generator.Category.SCROLL.classes;
|
||||
float[] probs = Generator.Category.SCROLL.probs.clone(); //array of primitives, clone gives deep copy.
|
||||
int i = Random.chances(probs);
|
||||
|
||||
while (i != -1){
|
||||
scrolls.add(convertName(scrollClasses[i].getSimpleName()));
|
||||
probs[i] = 0;
|
||||
while (i != -1){
|
||||
scrolls.add(convertName(scrollClasses[i].getSimpleName()));
|
||||
probs[i] = 0;
|
||||
|
||||
i = Random.chances(probs);
|
||||
};
|
||||
}
|
||||
i = Random.chances(probs);
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> actions( Hero hero ) {
|
||||
ArrayList<String> actions = super.actions( hero );
|
||||
if (isEquipped( hero ) && charge > 0 && !cursed)
|
||||
actions.add(AC_READ);
|
||||
if (isEquipped( hero ) && level < levelCap && !cursed)
|
||||
actions.add(AC_ADD);
|
||||
return actions;
|
||||
}
|
||||
@Override
|
||||
public ArrayList<String> actions( Hero hero ) {
|
||||
ArrayList<String> actions = super.actions( hero );
|
||||
if (isEquipped( hero ) && charge > 0 && !cursed)
|
||||
actions.add(AC_READ);
|
||||
if (isEquipped( hero ) && level < levelCap && !cursed)
|
||||
actions.add(AC_ADD);
|
||||
return actions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute( Hero hero, String action ) {
|
||||
if (action.equals( AC_READ )) {
|
||||
@Override
|
||||
public void execute( Hero hero, String action ) {
|
||||
if (action.equals( AC_READ )) {
|
||||
|
||||
if (hero.buff( Blindness.class ) != null) GLog.w("You cannot read from the book while blinded.");
|
||||
else if (!isEquipped( hero )) GLog.i("You need to equip your spellbook to do that.");
|
||||
else if (charge == 0) GLog.i("Your spellbook is out of energy for now.");
|
||||
else if (cursed) GLog.i("Your cannot read from a cursed spellbook.");
|
||||
else {
|
||||
charge--;
|
||||
if (hero.buff( Blindness.class ) != null) GLog.w("You cannot read from the book while blinded.");
|
||||
else if (!isEquipped( hero )) GLog.i("You need to equip your spellbook to do that.");
|
||||
else if (charge == 0) GLog.i("Your spellbook is out of energy for now.");
|
||||
else if (cursed) GLog.i("Your cannot read from a cursed spellbook.");
|
||||
else {
|
||||
charge--;
|
||||
|
||||
Scroll scroll;
|
||||
do {
|
||||
scroll = (Scroll) Generator.random(Generator.Category.SCROLL);
|
||||
} while (scroll == null ||
|
||||
//gotta reduce the rate on these scrolls or that'll be all the item does.
|
||||
((scroll instanceof ScrollOfIdentify ||
|
||||
scroll instanceof ScrollOfRemoveCurse ||
|
||||
scroll instanceof ScrollOfMagicMapping) && Random.Int(2) == 0));
|
||||
Scroll scroll;
|
||||
do {
|
||||
scroll = (Scroll) Generator.random(Generator.Category.SCROLL);
|
||||
} while (scroll == null ||
|
||||
//gotta reduce the rate on these scrolls or that'll be all the item does.
|
||||
((scroll instanceof ScrollOfIdentify ||
|
||||
scroll instanceof ScrollOfRemoveCurse ||
|
||||
scroll instanceof ScrollOfMagicMapping) && Random.Int(2) == 0));
|
||||
|
||||
scroll.ownedByBook = true;
|
||||
scroll.execute(hero, AC_READ);
|
||||
}
|
||||
scroll.ownedByBook = true;
|
||||
scroll.execute(hero, AC_READ);
|
||||
}
|
||||
|
||||
} else if (action.equals( AC_ADD )) {
|
||||
GameScene.selectItem(itemSelector, mode, inventoryTitle);
|
||||
} else
|
||||
super.execute( hero, action );
|
||||
}
|
||||
} else if (action.equals( AC_ADD )) {
|
||||
GameScene.selectItem(itemSelector, mode, inventoryTitle);
|
||||
} else
|
||||
super.execute( hero, action );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ArtifactBuff passiveBuff() {
|
||||
return new bookRecharge();
|
||||
}
|
||||
@Override
|
||||
protected ArtifactBuff passiveBuff() {
|
||||
return new bookRecharge();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item upgrade() {
|
||||
chargeCap = (((level+1)/2)+3);
|
||||
@Override
|
||||
public Item upgrade() {
|
||||
chargeCap = (((level+1)/2)+3);
|
||||
|
||||
//for artifact transmutation.
|
||||
while (scrolls.size() > (levelCap-1-level))
|
||||
scrolls.remove(0);
|
||||
//for artifact transmutation.
|
||||
while (scrolls.size() > (levelCap-1-level))
|
||||
scrolls.remove(0);
|
||||
|
||||
return super.upgrade();
|
||||
}
|
||||
return super.upgrade();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
String desc = "This Tome is in surprising good condition given its age. ";
|
||||
@Override
|
||||
public String desc() {
|
||||
String desc = "This Tome is in surprising good condition given its age. ";
|
||||
|
||||
if (level < 3)
|
||||
desc += "It emanates a strange chaotic energy. ";
|
||||
else if (level < 7)
|
||||
desc += "It glows with a strange chaotic energy. ";
|
||||
else
|
||||
desc += "It fizzes and crackles as you move the pages, surging with unstable energy. ";
|
||||
if (level < 3)
|
||||
desc += "It emanates a strange chaotic energy. ";
|
||||
else if (level < 7)
|
||||
desc += "It glows with a strange chaotic energy. ";
|
||||
else
|
||||
desc += "It fizzes and crackles as you move the pages, surging with unstable energy. ";
|
||||
|
||||
desc += "It seems to contains a list of spells, but the order and position of them in the index is " +
|
||||
"constantly shifting. If you read from this book, there's no telling what spell you might cast.";
|
||||
desc += "It seems to contains a list of spells, but the order and position of them in the index is " +
|
||||
"constantly shifting. If you read from this book, there's no telling what spell you might cast.";
|
||||
|
||||
desc += "\n\n";
|
||||
desc += "\n\n";
|
||||
|
||||
if (isEquipped (Dungeon.hero)) {
|
||||
if (isEquipped (Dungeon.hero)) {
|
||||
|
||||
if (!cursed)
|
||||
desc += "The book fits firmly at your side, sending you the occasional zip of static energy.";
|
||||
else
|
||||
desc += "The cursed book has bound itself to you, it is inhibiting your ability to use most scrolls.";
|
||||
if (!cursed)
|
||||
desc += "The book fits firmly at your side, sending you the occasional zip of static energy.";
|
||||
else
|
||||
desc += "The cursed book has bound itself to you, it is inhibiting your ability to use most scrolls.";
|
||||
|
||||
desc += "\n\n";
|
||||
desc += "\n\n";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (level < levelCap)
|
||||
if (scrolls.size() > 1)
|
||||
desc += "The book's index points to some pages which are blank. " +
|
||||
"Those pages are listed as: " + scrolls.get(0) + " and "
|
||||
+ scrolls.get(1) + ". Perhaps adding to the book will increase its power";
|
||||
else
|
||||
desc += "The book's index has one remaining blank page. " +
|
||||
"That page is listed as " + scrolls.get(0) + ".";
|
||||
else
|
||||
desc += "The book's index is full, it doesn't look like you can add anything more to it.";
|
||||
if (level < levelCap)
|
||||
if (scrolls.size() > 1)
|
||||
desc += "The book's index points to some pages which are blank. " +
|
||||
"Those pages are listed as: " + scrolls.get(0) + " and "
|
||||
+ scrolls.get(1) + ". Perhaps adding to the book will increase its power";
|
||||
else
|
||||
desc += "The book's index has one remaining blank page. " +
|
||||
"That page is listed as " + scrolls.get(0) + ".";
|
||||
else
|
||||
desc += "The book's index is full, it doesn't look like you can add anything more to it.";
|
||||
|
||||
return desc;
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
|
||||
private static final String SCROLLS = "scrolls";
|
||||
private static final String SCROLLS = "scrolls";
|
||||
|
||||
@Override
|
||||
public void storeInBundle( Bundle bundle ) {
|
||||
super.storeInBundle(bundle);
|
||||
bundle.put( SCROLLS, scrolls.toArray(new String[scrolls.size()]) );
|
||||
}
|
||||
@Override
|
||||
public void storeInBundle( Bundle bundle ) {
|
||||
super.storeInBundle(bundle);
|
||||
bundle.put( SCROLLS, scrolls.toArray(new String[scrolls.size()]) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreFromBundle( Bundle bundle ) {
|
||||
super.restoreFromBundle(bundle);
|
||||
scrolls.clear();
|
||||
Collections.addAll(scrolls, bundle.getStringArray(SCROLLS));
|
||||
}
|
||||
@Override
|
||||
public void restoreFromBundle( Bundle bundle ) {
|
||||
super.restoreFromBundle(bundle);
|
||||
scrolls.clear();
|
||||
Collections.addAll(scrolls, bundle.getStringArray(SCROLLS));
|
||||
}
|
||||
|
||||
public class bookRecharge extends ArtifactBuff{
|
||||
@Override
|
||||
public boolean act() {
|
||||
if (charge < chargeCap && !cursed) {
|
||||
partialCharge += 1 / (150f - (chargeCap - charge)*15f);
|
||||
public class bookRecharge extends ArtifactBuff{
|
||||
@Override
|
||||
public boolean act() {
|
||||
if (charge < chargeCap && !cursed) {
|
||||
partialCharge += 1 / (150f - (chargeCap - charge)*15f);
|
||||
|
||||
if (partialCharge >= 1) {
|
||||
partialCharge --;
|
||||
charge ++;
|
||||
if (partialCharge >= 1) {
|
||||
partialCharge --;
|
||||
charge ++;
|
||||
|
||||
if (charge == chargeCap){
|
||||
partialCharge = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (charge == chargeCap){
|
||||
partialCharge = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updateQuickslot();
|
||||
updateQuickslot();
|
||||
|
||||
spend( TICK );
|
||||
spend( TICK );
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
protected WndBag.Listener itemSelector = new WndBag.Listener() {
|
||||
@Override
|
||||
public void onSelect(Item item) {
|
||||
if (item != null && item instanceof Scroll && item.isIdentified()){
|
||||
String scroll = convertName(item.getClass().getSimpleName());
|
||||
Hero hero = Dungeon.hero;
|
||||
for (int i = 0; ( i <= 1 && i < scrolls.size() ); i++){
|
||||
if (scrolls.get(i).equals(scroll)){
|
||||
hero.sprite.operate( hero.pos );
|
||||
hero.busy();
|
||||
hero.spend( 2f );
|
||||
Sample.INSTANCE.play(Assets.SND_BURNING);
|
||||
hero.sprite.emitter().burst( ElmoParticle.FACTORY, 12 );
|
||||
protected WndBag.Listener itemSelector = new WndBag.Listener() {
|
||||
@Override
|
||||
public void onSelect(Item item) {
|
||||
if (item != null && item instanceof Scroll && item.isIdentified()){
|
||||
String scroll = convertName(item.getClass().getSimpleName());
|
||||
Hero hero = Dungeon.hero;
|
||||
for (int i = 0; ( i <= 1 && i < scrolls.size() ); i++){
|
||||
if (scrolls.get(i).equals(scroll)){
|
||||
hero.sprite.operate( hero.pos );
|
||||
hero.busy();
|
||||
hero.spend( 2f );
|
||||
Sample.INSTANCE.play(Assets.SND_BURNING);
|
||||
hero.sprite.emitter().burst( ElmoParticle.FACTORY, 12 );
|
||||
|
||||
scrolls.remove(i);
|
||||
item.detach(hero.belongings.backpack);
|
||||
scrolls.remove(i);
|
||||
item.detach(hero.belongings.backpack);
|
||||
|
||||
upgrade();
|
||||
GLog.i("You infuse the scroll's energy into the book.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (item != null)
|
||||
GLog.w("You are unable to add this scroll to the book.");
|
||||
} else if (item instanceof Scroll && !item.isIdentified())
|
||||
GLog.w("You're not sure what type of scroll this is yet.");
|
||||
}
|
||||
};
|
||||
upgrade();
|
||||
GLog.i("You infuse the scroll's energy into the book.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (item != null)
|
||||
GLog.w("You are unable to add this scroll to the book.");
|
||||
} else if (item instanceof Scroll && !item.isIdentified())
|
||||
GLog.w("You're not sure what type of scroll this is yet.");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user