cleaned up formatting:

- removed trailing whitespace
- changed all leading whitespace to tabs
- removed IDE created author comments
This commit is contained in:
Evan Debenham
2015-06-12 16:22:26 -04:00
parent baa83b7e43
commit cebdff0221
335 changed files with 8555 additions and 8714 deletions
@@ -97,7 +97,7 @@ public class Amulet extends Item {
@Override
public String info() {
return
return
"The Amulet of Yendor is the most powerful known artifact of unknown origin. It is said that the amulet " +
"is able to fulfil any wish if its owner's will-power is strong enough to \"persuade\" it to do it.";
}
@@ -31,28 +31,28 @@ import java.util.ArrayList;
public class Ankh extends Item {
public static final String AC_BLESS = "BLESS";
public static final String AC_BLESS = "BLESS";
public static final String TXT_DESC_NOBLESS = "Upon resurrection all non-equipped items are lost. " +
"Using a full dew vial, the ankh can be blessed with extra strength.";
public static final String TXT_DESC_BLESSED = "The ankh has been blessed and is now much stronger. " +
"The Ankh will sacrifice itself to save you in a moment of deadly peril.";
public static final String TXT_DESC_NOBLESS = "Upon resurrection all non-equipped items are lost. " +
"Using a full dew vial, the ankh can be blessed with extra strength.";
public static final String TXT_DESC_BLESSED = "The ankh has been blessed and is now much stronger. " +
"The Ankh will sacrifice itself to save you in a moment of deadly peril.";
public static final String TXT_BLESS = "You bless the ankh with clean water.";
public static final String TXT_REVIVE = "The ankh explodes with life-giving energy!";
public static final String TXT_BLESS = "You bless the ankh with clean water.";
public static final String TXT_REVIVE = "The ankh explodes with life-giving energy!";
{
{
name = "Ankh";
image = ItemSpriteSheet.ANKH;
//You tell the ankh no, don't revive me, and then it comes back to revive you again in another run.
//I'm not sure if that's enthusiasm or passive-aggression.
bones = true;
}
//You tell the ankh no, don't revive me, and then it comes back to revive you again in another run.
//I'm not sure if that's enthusiasm or passive-aggression.
bones = true;
}
private Boolean blessed = false;
private Boolean blessed = false;
@Override
public boolean isUpgradable() {
@@ -64,76 +64,76 @@ public class Ankh extends Item {
return true;
}
@Override
public ArrayList<String> actions( Hero hero ) {
ArrayList<String> actions = super.actions(hero);
DewVial vial = hero.belongings.getItem(DewVial.class);
if (vial != null && vial.isFull() && !blessed)
actions.add( AC_BLESS );
return actions;
}
@Override
public ArrayList<String> actions( Hero hero ) {
ArrayList<String> actions = super.actions(hero);
DewVial vial = hero.belongings.getItem(DewVial.class);
if (vial != null && vial.isFull() && !blessed)
actions.add( AC_BLESS );
return actions;
}
@Override
public void execute( final Hero hero, String action ) {
if (action.equals( AC_BLESS )) {
@Override
public void execute( final Hero hero, String action ) {
if (action.equals( AC_BLESS )) {
DewVial vial = hero.belongings.getItem(DewVial.class);
if (vial != null){
blessed = true;
vial.empty();
GLog.p( TXT_BLESS );
hero.spend( 1f );
hero.busy();
DewVial vial = hero.belongings.getItem(DewVial.class);
if (vial != null){
blessed = true;
vial.empty();
GLog.p( TXT_BLESS );
hero.spend( 1f );
hero.busy();
Sample.INSTANCE.play( Assets.SND_DRINK );
CellEmitter.get(hero.pos).start(Speck.factory(Speck.LIGHT), 0.2f, 3);
hero.sprite.operate( hero.pos );
}
} else {
Sample.INSTANCE.play( Assets.SND_DRINK );
CellEmitter.get(hero.pos).start(Speck.factory(Speck.LIGHT), 0.2f, 3);
hero.sprite.operate( hero.pos );
}
} else {
super.execute( hero, action );
super.execute( hero, action );
}
}
}
}
@Override
public String info() {
if (blessed)
return
"This ancient symbol of immortality grants the ability to return to life after death. " +
TXT_DESC_BLESSED;
else
return
return
"This ancient symbol of immortality grants the ability to return to life after death. " +
TXT_DESC_NOBLESS;
TXT_DESC_BLESSED;
else
return
"This ancient symbol of immortality grants the ability to return to life after death. " +
TXT_DESC_NOBLESS;
}
public Boolean isBlessed(){
return blessed;
}
public Boolean isBlessed(){
return blessed;
}
private static final Glowing WHITE = new Glowing( 0xFFFFCC );
private static final Glowing WHITE = new Glowing( 0xFFFFCC );
@Override
public Glowing glowing() {
return isBlessed() ? WHITE : null;
}
@Override
public Glowing glowing() {
return isBlessed() ? WHITE : null;
}
private static final String BLESSED = "blessed";
private static final String BLESSED = "blessed";
@Override
public void storeInBundle( Bundle bundle ) {
super.storeInBundle( bundle );
bundle.put( BLESSED, blessed );
}
@Override
public void storeInBundle( Bundle bundle ) {
super.storeInBundle( bundle );
bundle.put( BLESSED, blessed );
}
@Override
public void restoreFromBundle( Bundle bundle ) {
super.restoreFromBundle( bundle );
blessed = bundle.getBoolean( BLESSED );
}
@Override
public void restoreFromBundle( Bundle bundle ) {
super.restoreFromBundle( bundle );
blessed = bundle.getBoolean( BLESSED );
}
@Override
public int price() {
@@ -53,48 +53,48 @@ public class Bomb extends Item {
public Fuse fuse;
//FIXME using a static variable for this is kinda gross, should be a better way
private static boolean lightingFuse = false;
//FIXME using a static variable for this is kinda gross, should be a better way
private static boolean lightingFuse = false;
private static final String AC_LIGHTTHROW = "Light & Throw";
@Override
public boolean isSimilar(Item item) {
return item instanceof Bomb && this.fuse == ((Bomb) item).fuse;
}
@Override
public boolean isSimilar(Item item) {
return item instanceof Bomb && this.fuse == ((Bomb) item).fuse;
}
@Override
public ArrayList<String> actions(Hero hero) {
ArrayList<String> actions = super.actions( hero );
actions.add ( AC_LIGHTTHROW );
return actions;
}
@Override
public ArrayList<String> actions(Hero hero) {
ArrayList<String> actions = super.actions( hero );
actions.add ( AC_LIGHTTHROW );
return actions;
}
@Override
public void execute(Hero hero, String action) {
if (action.equals( AC_LIGHTTHROW )){
lightingFuse = true;
action = AC_THROW;
} else
lightingFuse = false;
@Override
public void execute(Hero hero, String action) {
if (action.equals( AC_LIGHTTHROW )){
lightingFuse = true;
action = AC_THROW;
} else
lightingFuse = false;
super.execute(hero, action);
}
super.execute(hero, action);
}
@Override
@Override
protected void onThrow( int cell ) {
if (!Level.pit[ cell ] && lightingFuse) {
Actor.addDelayed(fuse = new Fuse().ignite(this), 2);
}
if (Actor.findChar( cell ) != null && !(Actor.findChar( cell ) instanceof Hero) ){
ArrayList<Integer> candidates = new ArrayList<>();
for (int i : Level.NEIGHBOURS8)
if (Level.passable[cell + i])
candidates.add(cell + i);
int newCell = candidates.isEmpty() ? cell : Random.element(candidates);
Dungeon.level.drop( this, newCell ).sprite.drop( cell );
} else
super.onThrow( cell );
if (!Level.pit[ cell ] && lightingFuse) {
Actor.addDelayed(fuse = new Fuse().ignite(this), 2);
}
if (Actor.findChar( cell ) != null && !(Actor.findChar( cell ) instanceof Hero) ){
ArrayList<Integer> candidates = new ArrayList<>();
for (int i : Level.NEIGHBOURS8)
if (Level.passable[cell + i])
candidates.add(cell + i);
int newCell = candidates.isEmpty() ? cell : Random.element(candidates);
Dungeon.level.drop( this, newCell ).sprite.drop( cell );
} else
super.onThrow( cell );
}
@Override
@@ -138,8 +138,8 @@ public class Bomb extends Item {
Char ch = Actor.findChar( c );
if (ch != null) {
//those not at the center of the blast take damage less consistently.
int minDamage = c == cell ? Dungeon.depth+5 : 1;
int maxDamage = 10 + Dungeon.depth * 2;
int minDamage = c == cell ? Dungeon.depth+5 : 1;
int maxDamage = 10 + Dungeon.depth * 2;
int dmg = Random.NormalIntRange( minDamage, maxDamage ) - Random.Int( ch.dr() );
if (dmg > 0) {
@@ -87,12 +87,12 @@ public class DewVial extends Item {
if (volume > 0) {
int value = 1 + (Dungeon.depth - 1) / 5;
if (hero.heroClass == HeroClass.HUNTRESS) {
value++;
}
value *= volume;
value = (int)Math.max(volume*volume*.01*hero.HT, value);
int value = 1 + (Dungeon.depth - 1) / 5;
if (hero.heroClass == HeroClass.HUNTRESS) {
value++;
}
value *= volume;
value = (int)Math.max(volume*volume*.01*hero.HT, value);
int effect = Math.min( hero.HT - hero.HP, value );
if (effect > 0) {
hero.HP += effect;
@@ -100,7 +100,7 @@ public class DewVial extends Item {
hero.sprite.showStatus( CharSprite.POSITIVE, TXT_VALUE, effect );
}
volume = 0;
volume = 0;
hero.spend( TIME_TO_DRINK );
hero.busy();
@@ -122,7 +122,7 @@ public class DewVial extends Item {
}
}
public void empty() {volume = 0; updateQuickslot();}
public void empty() {volume = 0; updateQuickslot();}
@Override
public boolean isUpgradable() {
@@ -156,7 +156,7 @@ public class DewVial extends Item {
}
//removed as people need a bigger distinction to realize the dew vial doesn't revive.
/*
/*
private static final Glowing WHITE = new Glowing( 0xFFFFCC );
@Override
@@ -174,10 +174,10 @@ public class DewVial extends Item {
return
"You can store excess dew in this tiny vessel for drinking it later. " +
"The more full the vial is, the more each dew drop will heal you. " +
"A full vial is as strong as a potion of healing." +
"\n\nVials like this one used to be imbued with revival magic, " +
"but that power has faded. There still seems to be some residual power " +
"left, perhaps a full vial can bless another revival item.";
"A full vial is as strong as a potion of healing." +
"\n\nVials like this one used to be imbued with revival magic, " +
"but that power has faded. There still seems to be some residual power " +
"left, perhaps a full vial can bless another revival item.";
}
@Override
@@ -26,84 +26,84 @@ import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ShadowParticle
public abstract class EquipableItem extends Item {
private static final String TXT_UNEQUIP_CURSED = "You can't remove cursed %s!";
private static final String TXT_UNEQUIP_CURSED = "You can't remove cursed %s!";
public static final String AC_EQUIP = "EQUIP";
public static final String AC_UNEQUIP = "UNEQUIP";
public static final String AC_EQUIP = "EQUIP";
public static final String AC_UNEQUIP = "UNEQUIP";
{
bones = true;
}
{
bones = true;
}
@Override
public void execute( Hero hero, String action ) {
if (action.equals( AC_EQUIP )) {
//In addition to equipping itself, item reassigns itself to the quickslot
//This is a special case as the item is being removed from inventory, but is staying with the hero.
int slot = Dungeon.quickslot.getSlot( this );
doEquip(hero);
if (slot != -1) {
Dungeon.quickslot.setSlot( slot, this );
updateQuickslot();
}
} else if (action.equals( AC_UNEQUIP )) {
doUnequip( hero, true );
} else {
super.execute( hero, action );
}
}
@Override
public void execute( Hero hero, String action ) {
if (action.equals( AC_EQUIP )) {
//In addition to equipping itself, item reassigns itself to the quickslot
//This is a special case as the item is being removed from inventory, but is staying with the hero.
int slot = Dungeon.quickslot.getSlot( this );
doEquip(hero);
if (slot != -1) {
Dungeon.quickslot.setSlot( slot, this );
updateQuickslot();
}
} else if (action.equals( AC_UNEQUIP )) {
doUnequip( hero, true );
} else {
super.execute( hero, action );
}
}
@Override
public void doDrop( Hero hero ) {
if (!isEquipped( hero ) || doUnequip( hero, false, false )) {
super.doDrop( hero );
}
}
@Override
public void doDrop( Hero hero ) {
if (!isEquipped( hero ) || doUnequip( hero, false, false )) {
super.doDrop( hero );
}
}
@Override
public void cast( final Hero user, int dst ) {
@Override
public void cast( final Hero user, int dst ) {
if (isEquipped( user )) {
if (quantity == 1 && !this.doUnequip( user, false, false )) {
return;
}
}
if (isEquipped( user )) {
if (quantity == 1 && !this.doUnequip( user, false, false )) {
return;
}
}
super.cast( user, dst );
}
super.cast( user, dst );
}
public static void equipCursed( Hero hero ) {
hero.sprite.emitter().burst( ShadowParticle.CURSE, 6 );
Sample.INSTANCE.play( Assets.SND_CURSED );
}
public static void equipCursed( Hero hero ) {
hero.sprite.emitter().burst( ShadowParticle.CURSE, 6 );
Sample.INSTANCE.play( Assets.SND_CURSED );
}
protected float time2equip( Hero hero ) {
return 1;
}
protected float time2equip( Hero hero ) {
return 1;
}
public abstract boolean doEquip( Hero hero );
public abstract boolean doEquip( Hero hero );
public boolean doUnequip( Hero hero, boolean collect, boolean single ) {
public boolean doUnequip( Hero hero, boolean collect, boolean single ) {
if (cursed) {
GLog.w(TXT_UNEQUIP_CURSED, name());
return false;
}
if (cursed) {
GLog.w(TXT_UNEQUIP_CURSED, name());
return false;
}
if (single) {
hero.spendAndNext( time2equip( hero ) );
} else {
hero.spend( time2equip( hero ) );
}
if (single) {
hero.spendAndNext( time2equip( hero ) );
} else {
hero.spend( time2equip( hero ) );
}
if (collect && !collect( hero.belongings.backpack )) {
Dungeon.level.drop( this, hero.pos );
}
if (collect && !collect( hero.belongings.backpack )) {
Dungeon.level.drop( this, hero.pos );
}
return true;
}
return true;
}
final public boolean doUnequip( Hero hero, boolean collect ) {
return doUnequip( hero, collect, true );
}
final public boolean doUnequip( Hero hero, boolean collect ) {
return doUnequip( hero, collect, true );
}
}
@@ -50,7 +50,7 @@ public class Generator {
SCROLL ( 400, Scroll.class ),
WAND ( 40, Wand.class ),
RING ( 15, Ring.class ),
ARTIFACT( 15, Artifact.class),
ARTIFACT( 15, Artifact.class),
SEED ( 50, Plant.Seed.class ),
FOOD ( 0, Food.class ),
GOLD ( 500, Gold.class );
@@ -81,14 +81,14 @@ public class Generator {
static {
Category.GOLD.classes = new Class<?>[]{
Category.GOLD.classes = new Class<?>[]{
Gold.class };
Category.GOLD.probs = new float[]{ 1 };
Category.SCROLL.classes = new Class<?>[]{
ScrollOfIdentify.class,
ScrollOfTeleportation.class,
ScrollOfRemoveCurse.class,
Category.SCROLL.classes = new Class<?>[]{
ScrollOfIdentify.class,
ScrollOfTeleportation.class,
ScrollOfRemoveCurse.class,
ScrollOfUpgrade.class,
ScrollOfRecharging.class,
ScrollOfMagicMapping.class,
@@ -100,10 +100,10 @@ public class Generator {
ScrollOfMirrorImage.class };
Category.SCROLL.probs = new float[]{ 30, 10, 15, 0, 15, 15, 12, 8, 8, 0, 4, 10 };
Category.POTION.classes = new Class<?>[]{
PotionOfHealing.class,
Category.POTION.classes = new Class<?>[]{
PotionOfHealing.class,
PotionOfExperience.class,
PotionOfToxicGas.class,
PotionOfToxicGas.class,
PotionOfParalyticGas.class,
PotionOfLiquidFlame.class,
PotionOfLevitation.class,
@@ -132,16 +132,16 @@ public class Generator {
WandOfRegrowth.class };
Category.WAND.probs = new float[]{ 4, 4, 4, 4, 4, 3, /*3,*/ 3, 3, /*3,*/ 3, 3, 3 };
Category.WEAPON.classes = new Class<?>[]{
Dagger.class,
Category.WEAPON.classes = new Class<?>[]{
Dagger.class,
Knuckles.class,
Quarterstaff.class,
Spear.class,
Mace.class,
Sword.class,
Quarterstaff.class,
Spear.class,
Mace.class,
Sword.class,
Longsword.class,
BattleAxe.class,
WarHammer.class,
WarHammer.class,
Glaive.class,
ShortSword.class,
Dart.class,
@@ -153,52 +153,52 @@ public class Generator {
Tamahawk.class };
Category.WEAPON.probs = new float[]{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1 };
Category.ARMOR.classes = new Class<?>[]{
ClothArmor.class,
LeatherArmor.class,
MailArmor.class,
ScaleArmor.class,
Category.ARMOR.classes = new Class<?>[]{
ClothArmor.class,
LeatherArmor.class,
MailArmor.class,
ScaleArmor.class,
PlateArmor.class };
Category.ARMOR.probs = new float[]{ 1, 1, 1, 1, 1 };
Category.FOOD.classes = new Class<?>[]{
Food.class,
Category.FOOD.classes = new Class<?>[]{
Food.class,
Pasty.class,
MysteryMeat.class };
Category.FOOD.probs = new float[]{ 4, 1, 0 };
Category.RING.classes = new Class<?>[]{
RingOfAccuracy.class,
RingOfEvasion.class,
RingOfElements.class,
RingOfForce.class,
RingOfFuror.class,
RingOfHaste.class,
RingOfMagic.class, //currently removed from drop tables, pending rework
RingOfMight.class,
RingOfSharpshooting.class,
RingOfTenacity.class,
RingOfWealth.class};
RingOfAccuracy.class,
RingOfEvasion.class,
RingOfElements.class,
RingOfForce.class,
RingOfFuror.class,
RingOfHaste.class,
RingOfMagic.class, //currently removed from drop tables, pending rework
RingOfMight.class,
RingOfSharpshooting.class,
RingOfTenacity.class,
RingOfWealth.class};
Category.RING.probs = new float[]{ 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1 };
Category.ARTIFACT.classes = new Class<?>[]{
CapeOfThorns.class,
ChaliceOfBlood.class,
CloakOfShadows.class,
HornOfPlenty.class,
MasterThievesArmband.class,
SandalsOfNature.class,
TalismanOfForesight.class,
TimekeepersHourglass.class,
UnstableSpellbook.class,
AlchemistsToolkit.class, //currently removed from drop tables, pending rework.
DriedRose.class, //starts with no chance of spawning, chance is set directly after beating ghost quest.
LloydsBeacon.class,
EtherealChains.class
};
Category.ARTIFACT.probs = new float[]{ 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1};
Category.ARTIFACT.classes = new Class<?>[]{
CapeOfThorns.class,
ChaliceOfBlood.class,
CloakOfShadows.class,
HornOfPlenty.class,
MasterThievesArmband.class,
SandalsOfNature.class,
TalismanOfForesight.class,
TimekeepersHourglass.class,
UnstableSpellbook.class,
AlchemistsToolkit.class, //currently removed from drop tables, pending rework.
DriedRose.class, //starts with no chance of spawning, chance is set directly after beating ghost quest.
LloydsBeacon.class,
EtherealChains.class
};
Category.ARTIFACT.probs = new float[]{ 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1};
Category.SEED.classes = new Class<?>[]{
Category.SEED.classes = new Class<?>[]{
Firebloom.Seed.class,
Icecap.Seed.class,
Sorrowmoss.Seed.class,
@@ -206,10 +206,10 @@ public class Generator {
Sungrass.Seed.class,
Earthroot.Seed.class,
Fadeleaf.Seed.class,
Rotberry.Seed.class,
Rotberry.Seed.class,
BlandfruitBush.Seed.class,
Dreamfoil.Seed.class,
Stormvine.Seed.class,
Dreamfoil.Seed.class,
Stormvine.Seed.class,
Starflower.Seed.class};
Category.SEED.probs = new float[]{ 12, 12, 12, 12, 12, 12, 12, 0, 4, 12, 12, 1 };
}
@@ -234,10 +234,10 @@ public class Generator {
return randomArmor();
case WEAPON:
return randomWeapon();
case ARTIFACT:
Item item = randomArtifact();
//if we're out of artifacts, return a ring instead.
return item != null ? item : random(Category.RING);
case ARTIFACT:
Item item = randomArtifact();
//if we're out of artifacts, return a ring instead.
return item != null ? item : random(Category.RING);
default:
return ((Item)cat.classes[Random.chances( cat.probs )].newInstance()).random();
}
@@ -261,124 +261,124 @@ public class Generator {
}
}
public static Armor randomArmor(){
int curStr = Hero.STARTING_STR + Dungeon.limitedDrops.strengthPotions.count;
public static Armor randomArmor(){
int curStr = Hero.STARTING_STR + Dungeon.limitedDrops.strengthPotions.count;
return randomArmor(curStr);
}
return randomArmor(curStr);
}
public static Armor randomArmor(int targetStr) {
Category cat = Category.ARMOR;
try {
Armor a1 = (Armor) cat.classes[Random.chances(cat.probs)].newInstance();
Armor a2 = (Armor) cat.classes[Random.chances(cat.probs)].newInstance();
try {
Armor a1 = (Armor) cat.classes[Random.chances(cat.probs)].newInstance();
Armor a2 = (Armor) cat.classes[Random.chances(cat.probs)].newInstance();
a1.random();
a2.random();
a1.random();
a2.random();
return Math.abs(targetStr - a1.STR) < Math.abs(targetStr - a2.STR) ? a1 : a2;
} catch (Exception e) {
return null;
}
return Math.abs(targetStr - a1.STR) < Math.abs(targetStr - a2.STR) ? a1 : a2;
} catch (Exception e) {
return null;
}
}
public static Weapon randomWeapon(){
int curStr = Hero.STARTING_STR + Dungeon.limitedDrops.strengthPotions.count;
public static Weapon randomWeapon(){
int curStr = Hero.STARTING_STR + Dungeon.limitedDrops.strengthPotions.count;
return randomWeapon(curStr);
}
return randomWeapon(curStr);
}
public static Weapon randomWeapon(int targetStr) {
try {
Category cat = Category.WEAPON;
try {
Category cat = Category.WEAPON;
Weapon w1 = (Weapon)cat.classes[Random.chances( cat.probs )].newInstance();
Weapon w2 = (Weapon)cat.classes[Random.chances( cat.probs )].newInstance();
Weapon w1 = (Weapon)cat.classes[Random.chances( cat.probs )].newInstance();
Weapon w2 = (Weapon)cat.classes[Random.chances( cat.probs )].newInstance();
w1.random();
w2.random();
w1.random();
w2.random();
return Math.abs( targetStr - w1.STR ) < Math.abs( targetStr - w2.STR ) ? w1 : w2;
} catch (Exception e) {
return null;
}
return Math.abs( targetStr - w1.STR ) < Math.abs( targetStr - w2.STR ) ? w1 : w2;
} catch (Exception e) {
return null;
}
}
//enforces uniqueness of artifacts throughout a run.
public static Artifact randomArtifact() {
//enforces uniqueness of artifacts throughout a run.
public static Artifact randomArtifact() {
try {
Category cat = Category.ARTIFACT;
int i = Random.chances( cat.probs );
try {
Category cat = Category.ARTIFACT;
int i = Random.chances( cat.probs );
//if no artifacts are left, return null
if (i == -1){
return null;
}
//if no artifacts are left, return null
if (i == -1){
return null;
}
Artifact artifact = (Artifact)cat.classes[i].newInstance();
Artifact artifact = (Artifact)cat.classes[i].newInstance();
//remove the chance of spawning this artifact.
cat.probs[i] = 0;
spawnedArtifacts.add(cat.classes[i].getSimpleName());
//remove the chance of spawning this artifact.
cat.probs[i] = 0;
spawnedArtifacts.add(cat.classes[i].getSimpleName());
artifact.random();
artifact.random();
return artifact;
return artifact;
} catch (Exception e) {
return null;
}
}
} catch (Exception e) {
return null;
}
}
public static boolean removeArtifact(Artifact artifact) {
if (spawnedArtifacts.contains(artifact.getClass().getSimpleName()))
return false;
public static boolean removeArtifact(Artifact artifact) {
if (spawnedArtifacts.contains(artifact.getClass().getSimpleName()))
return false;
Category cat = Category.ARTIFACT;
for (int i = 0; i < cat.classes.length; i++)
if (cat.classes[i].equals(artifact.getClass())) {
if (cat.probs[i] == 1){
Category cat = Category.ARTIFACT;
for (int i = 0; i < cat.classes.length; i++)
if (cat.classes[i].equals(artifact.getClass())) {
if (cat.probs[i] == 1){
cat.probs[i] = 0;
spawnedArtifacts.add(artifact.getClass().getSimpleName());
return true;
} else
return false;
}
}
return false;
}
return false;
}
//resets artifact probabilities, for new dungeons
public static void initArtifacts() {
//FIXME: the duplicated logic here has caused 1 bug so far, should refactor.
Category.ARTIFACT.probs = new float[]{ 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1};
spawnedArtifacts = new ArrayList<String>();
}
//resets artifact probabilities, for new dungeons
public static void initArtifacts() {
//FIXME: the duplicated logic here has caused 1 bug so far, should refactor.
Category.ARTIFACT.probs = new float[]{ 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1};
spawnedArtifacts = new ArrayList<String>();
}
private static ArrayList<String> spawnedArtifacts = new ArrayList<String>();
private static ArrayList<String> spawnedArtifacts = new ArrayList<String>();
private static final String ARTIFACTS = "artifacts";
private static final String ARTIFACTS = "artifacts";
//used to store information on which artifacts have been spawned.
public static void storeInBundle(Bundle bundle) {
bundle.put( ARTIFACTS, spawnedArtifacts.toArray(new String[spawnedArtifacts.size()]));
}
//used to store information on which artifacts have been spawned.
public static void storeInBundle(Bundle bundle) {
bundle.put( ARTIFACTS, spawnedArtifacts.toArray(new String[spawnedArtifacts.size()]));
}
public static void restoreFromBundle(Bundle bundle) {
initArtifacts();
public static void restoreFromBundle(Bundle bundle) {
initArtifacts();
if (bundle.contains(ARTIFACTS)) {
Collections.addAll(spawnedArtifacts, bundle.getStringArray(ARTIFACTS));
Category cat = Category.ARTIFACT;
if (bundle.contains(ARTIFACTS)) {
Collections.addAll(spawnedArtifacts, bundle.getStringArray(ARTIFACTS));
Category cat = Category.ARTIFACT;
for (String artifact : spawnedArtifacts)
for (int i = 0; i < cat.classes.length; i++)
if (cat.classes[i].getSimpleName().equals(artifact))
cat.probs[i] = 0;
}
}
for (String artifact : spawnedArtifacts)
for (int i = 0; i < cat.classes.length; i++)
if (cat.classes[i].getSimpleName().equals(artifact))
cat.probs[i] = 0;
}
}
}
@@ -66,9 +66,9 @@ public class Gold extends Item {
Statistics.goldCollected += quantity;
Badges.validateGoldCollected();
MasterThievesArmband.Thievery thievery = hero.buff(MasterThievesArmband.Thievery.class);
MasterThievesArmband.Thievery thievery = hero.buff(MasterThievesArmband.Thievery.class);
if (thievery != null)
thievery.collect(quantity);
thievery.collect(quantity);
GameScene.pickUp( this );
hero.sprite.showStatus( CharSprite.NEUTRAL, TXT_VALUE, quantity );
@@ -64,14 +64,14 @@ public class Heap implements Bundlable {
private static final int SEEDS_TO_POTION = 3;
public enum Type {
HEAP,
FOR_SALE,
CHEST,
LOCKED_CHEST,
HEAP,
FOR_SALE,
CHEST,
LOCKED_CHEST,
CRYSTAL_CHEST,
TOMB,
TOMB,
SKELETON,
REMAINS,
REMAINS,
MIMIC
}
public Type type = Type.HEAP;
@@ -98,8 +98,8 @@ public class Heap implements Bundlable {
return ItemSpriteSheet.TOMB;
case SKELETON:
return ItemSpriteSheet.BONES;
case REMAINS:
return ItemSpriteSheet.REMAINS;
case REMAINS:
return ItemSpriteSheet.REMAINS;
default:
return 0;
}
@@ -123,7 +123,7 @@ public class Heap implements Bundlable {
Wraith.spawnAround( hero.pos );
break;
case SKELETON:
case REMAINS:
case REMAINS:
CellEmitter.center( pos ).start( Speck.factory( Speck.RATTLE ), 0.1f, 3 );
for (Item item : items) {
if (item.cursed) {
@@ -261,12 +261,12 @@ public class Heap implements Bundlable {
//Note: should not be called to initiate an explosion, but rather by an explosion that is happening.
public void explode() {
//breaks open most standard containers, mimics die.
//breaks open most standard containers, mimics die.
if (type == Type.MIMIC || type == Type.CHEST || type == Type.SKELETON) {
type = Type.HEAP;
sprite.link();
sprite.drop();
return;
type = Type.HEAP;
sprite.link();
sprite.drop();
return;
}
if (type != Type.HEAP) {
@@ -294,7 +294,7 @@ public class Heap implements Bundlable {
}
if (items.isEmpty())
destroy();
destroy();
}
}
@@ -318,7 +318,7 @@ public class Heap implements Bundlable {
replace( item, FrozenCarpaccio.cook( (MysteryMeat)item ) );
frozen = true;
} else if (item instanceof Potion) {
items.remove(item);
items.remove(item);
((Potion) item).shatter(pos);
frozen = true;
} else if (item instanceof Bomb){
@@ -332,7 +332,7 @@ public class Heap implements Bundlable {
destroy();
} else if (sprite != null) {
sprite.view( image(), glowing() );
}
}
}
}
@@ -345,19 +345,19 @@ public class Heap implements Bundlable {
int count = 0;
if (items.size() == 2 && items.get(0) instanceof Seed && items.get(1) instanceof Blandfruit ) {
if (items.size() == 2 && items.get(0) instanceof Seed && items.get(1) instanceof Blandfruit ) {
Sample.INSTANCE.play( Assets.SND_PUFF );
CellEmitter.center( pos ).burst( Speck.factory( Speck.EVOKE ), 3 );
Sample.INSTANCE.play( Assets.SND_PUFF );
CellEmitter.center( pos ).burst( Speck.factory( Speck.EVOKE ), 3 );
Blandfruit result = new Blandfruit();
result.cook((Seed)items.get(0));
Blandfruit result = new Blandfruit();
result.cook((Seed)items.get(0));
destroy();
destroy();
return result;
return result;
}
}
int index = 0;
for (Item item : items) {
@@ -379,7 +379,7 @@ public class Heap implements Bundlable {
CellEmitter.get( pos ).burst( Speck.factory( Speck.WOOL ), 6 );
Sample.INSTANCE.play( Assets.SND_PUFF );
Item potion;
Item potion;
if (Random.Int( count + bonus ) == 0) {
@@ -390,7 +390,7 @@ public class Heap implements Bundlable {
Statistics.potionsCooked++;
Badges.validatePotionsCooked();
potion = Generator.random( Generator.Category.POTION );
potion = Generator.random( Generator.Category.POTION );
} else {
@@ -403,10 +403,10 @@ public class Heap implements Bundlable {
Badges.validatePotionsCooked();
if (itemClass == null) {
potion = Generator.random( Generator.Category.POTION );
potion = Generator.random( Generator.Category.POTION );
} else {
try {
potion = itemClass.newInstance();
potion = itemClass.newInstance();
} catch (Exception e) {
return null;
}
@@ -418,13 +418,13 @@ public class Heap implements Bundlable {
if (Random.Int(1000/bonus) == 0)
return new PotionOfExperience();
while (potion instanceof PotionOfHealing && Random.Int(15) - Dungeon.limitedDrops.cookingHP.count >= 0)
potion = Generator.random( Generator.Category.POTION );
while (potion instanceof PotionOfHealing && Random.Int(15) - Dungeon.limitedDrops.cookingHP.count >= 0)
potion = Generator.random( Generator.Category.POTION );
if (potion instanceof PotionOfHealing)
Dungeon.limitedDrops.cookingHP.count++;
if (potion instanceof PotionOfHealing)
Dungeon.limitedDrops.cookingHP.count++;
return potion;
return potion;
} else {
return null;
@@ -462,8 +462,8 @@ public class Heap implements Bundlable {
public void restoreFromBundle( Bundle bundle ) {
pos = bundle.getInt( POS );
type = Type.valueOf( bundle.getString( TYPE ) );
items = new LinkedList<Item>( (Collection<Item>) ((Collection<?>) bundle.getCollection( ITEMS )) );
items.removeAll(Collections.singleton(null));
items = new LinkedList<Item>( (Collection<Item>) ((Collection<?>) bundle.getCollection( ITEMS )) );
items.removeAll(Collections.singleton(null));
}
@Override
@@ -61,9 +61,9 @@ public class Honeypot extends Item {
detach( hero.belongings.backpack );
shatter( hero, hero.pos ).collect();
shatter( hero, hero.pos ).collect();
hero.next();
hero.next();
} else {
super.execute( hero, action );
@@ -82,7 +82,7 @@ public class Honeypot extends Item {
public Item shatter( Char owner, int pos ) {
if (Dungeon.visible[pos]) {
Sample.INSTANCE.play( Assets.SND_SHATTER );
Sample.INSTANCE.play( Assets.SND_SHATTER );
Splash.at( pos, 0xffd500, 5 );
}
@@ -129,7 +129,7 @@ public class Honeypot extends Item {
@Override
public boolean isIdentified() {
return true;
}
}
@Override
public int price() {
@@ -161,7 +161,7 @@ public class Honeypot extends Item {
public Item setBee(Char bee){
myBee = bee.id();
beeDepth = Dungeon.depth;
return this;
return this;
}
@Override
@@ -227,20 +227,20 @@ public class Honeypot extends Item {
}
private static final String MYBEE = "mybee";
private static final String BEEDEPTH = "beedepth";
private static final String BEEDEPTH = "beedepth";
@Override
public void storeInBundle(Bundle bundle) {
super.storeInBundle(bundle);
bundle.put( MYBEE, myBee );
bundle.put( BEEDEPTH, beeDepth );
bundle.put( BEEDEPTH, beeDepth );
}
@Override
public void restoreFromBundle(Bundle bundle) {
super.restoreFromBundle(bundle);
myBee = bundle.getInt( MYBEE );
beeDepth = bundle.getInt( BEEDEPTH );
beeDepth = bundle.getInt( BEEDEPTH );
}
}
}
@@ -79,10 +79,10 @@ public class Item implements Bundlable {
// Unique items persist through revival
public boolean unique = false;
// whether an item can be included in heroes remains
public boolean bones = false;
// whether an item can be included in heroes remains
public boolean bones = false;
private static Comparator<Item> itemComparator = new Comparator<Item>() {
private static Comparator<Item> itemComparator = new Comparator<Item>() {
@Override
public int compare( Item lhs, Item rhs ) {
return Generator.Category.order( lhs ) - Generator.Category.order( rhs );
@@ -109,16 +109,16 @@ public class Item implements Bundlable {
}
}
public void doDrop( Hero hero ) {
hero.spendAndNext( TIME_TO_DROP );
Dungeon.level.drop( detachAll( hero.belongings.backpack ), hero.pos ).sprite.drop( hero.pos );
public void doDrop( Hero hero ) {
hero.spendAndNext( TIME_TO_DROP );
Dungeon.level.drop( detachAll( hero.belongings.backpack ), hero.pos ).sprite.drop( hero.pos );
}
public void syncVisuals(){
//do nothing by default, as most items need no visual syncing.
}
public void syncVisuals(){
//do nothing by default, as most items need no visual syncing.
}
public void doThrow( Hero hero ) {
public void doThrow( Hero hero ) {
GameScene.selectCell( thrower );
}
@@ -170,7 +170,7 @@ public class Item implements Bundlable {
item.updateQuickslot();
return true;
}
}
}
}
if (items.size() < container.size) {
@@ -219,15 +219,15 @@ public class Item implements Bundlable {
try {
//pssh, who needs copy constructors?
Item detached = getClass().newInstance();
Bundle copy = new Bundle();
this.storeInBundle(copy);
detached.restoreFromBundle(copy);
detached.quantity(1);
//pssh, who needs copy constructors?
Item detached = getClass().newInstance();
Bundle copy = new Bundle();
this.storeInBundle(copy);
detached.restoreFromBundle(copy);
detached.quantity(1);
detached.onDetach( );
return detached;
detached.onDetach( );
return detached;
} catch (Exception e) {
return null;
}
@@ -239,17 +239,17 @@ public class Item implements Bundlable {
updateQuickslot();
for (Item item : container.items) {
if (item == this) {
container.items.remove(this);
item.onDetach();
return this;
} else if (item instanceof Bag) {
Bag bag = (Bag)item;
if (bag.contains( this )) {
return detachAll( bag );
}
}
}
if (item == this) {
container.items.remove(this);
item.onDetach();
return this;
} else if (item instanceof Bag) {
Bag bag = (Bag)item;
if (bag.contains( this )) {
return detachAll( bag );
}
}
}
return this;
}
@@ -258,7 +258,7 @@ public class Item implements Bundlable {
return getClass() == item.getClass();
}
protected void onDetach(){}
protected void onDetach(){}
public Item upgrade() {
@@ -481,7 +481,7 @@ public class Item implements Bundlable {
final float finalDelay = delay;
((MissileSprite)user.sprite.parent.recycle( MissileSprite.class )).
reset( user.pos, cell, this, new Callback() {
reset( user.pos, cell, this, new Callback() {
@Override
public void call() {
Item.this.detach( user.belongings.backpack ).onThrow( cell );
@@ -492,7 +492,7 @@ public class Item implements Bundlable {
protected static Hero curUser = null;
protected static Item curItem = null;
protected static CellSelector.Listener thrower = new CellSelector.Listener() {
protected static CellSelector.Listener thrower = new CellSelector.Listener() {
@Override
public void onSelect( Integer target ) {
if (target != null) {
@@ -107,8 +107,8 @@ public class ItemStatusHandler<T extends Item> {
known.add( item );
}
//if there's a new item, give it a random image
//or.. if we're loading from an untrusted version, randomize the image to be safe.
//if there's a new item, give it a random image
//or.. if we're loading from an untrusted version, randomize the image to be safe.
} else {
int index = Random.Int( labelsLeft.size() );
@@ -119,9 +119,9 @@ public class ItemStatusHandler<T extends Item> {
images.put( item, imagesLeft.get( index ) );
imagesLeft.remove( index );
if (bundle.contains( itemName + PFX_KNOWN ) && bundle.getBoolean( itemName + PFX_KNOWN )) {
known.add( item );
}
if (bundle.contains( itemName + PFX_KNOWN ) && bundle.getBoolean( itemName + PFX_KNOWN )) {
known.add( item );
}
}
}
}
@@ -74,19 +74,19 @@ public class KindOfWeapon extends EquipableItem {
}
}
@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 )) {
hero.belongings.weapon = null;
return true;
hero.belongings.weapon = null;
return true;
} else {
} else {
return false;
return false;
}
}
}
}
public void activate( Hero hero ) {
}
@@ -3,10 +3,7 @@ package com.shatteredpixel.shatteredpixeldungeon.items;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem;
/**
* Created by Evan on 24/08/2014.
*/
public abstract class KindofMisc extends EquipableItem {
public abstract void activate(Char ch);
public abstract void activate(Char ch);
}
@@ -8,9 +8,6 @@ import com.watabou.noosa.audio.Sample;
import java.util.ArrayList;
/**
* Created by debenhame on 16/03/2015.
*/
public class MerchantsBeacon extends Item {
private static final String AC_USE = "USE";
@@ -44,7 +44,7 @@ public class Stylus extends Item {
stackable = true;
bones = true;
bones = true;
}
@Override
@@ -116,7 +116,7 @@ public class TomeOfMastery extends Item {
@Override
public String info() {
return
return
"This worn leather book is not that thick, but you feel somehow, " +
"that you can gather a lot from it. Remember though that reading " +
"this tome may require some time.";
@@ -36,163 +36,163 @@ import java.util.ArrayList;
public class Weightstone extends Item {
private static final String TXT_SELECT_WEAPON = "Select a weapon to balance";
private static final String TXT_LIGHT = "you balanced your %s to make it lighter";
private static final String TXT_HEAVY = "you balanced your %s to make it heavier";
private static final String TXT_SELECT_WEAPON = "Select a weapon to balance";
private static final String TXT_LIGHT = "you balanced your %s to make it lighter";
private static final String TXT_HEAVY = "you balanced your %s to make it heavier";
private static final float TIME_TO_APPLY = 2;
private static final float TIME_TO_APPLY = 2;
private static final String AC_APPLY = "APPLY";
private static final String AC_APPLY = "APPLY";
{
name = "weightstone";
image = ItemSpriteSheet.WEIGHT;
{
name = "weightstone";
image = ItemSpriteSheet.WEIGHT;
stackable = true;
stackable = true;
bones = true;
}
bones = true;
}
@Override
public ArrayList<String> actions( Hero hero ) {
ArrayList<String> actions = super.actions( hero );
actions.add( AC_APPLY );
return actions;
}
@Override
public ArrayList<String> actions( Hero hero ) {
ArrayList<String> actions = super.actions( hero );
actions.add( AC_APPLY );
return actions;
}
@Override
public void execute( Hero hero, String action ) {
if (action == AC_APPLY) {
@Override
public void execute( Hero hero, String action ) {
if (action == AC_APPLY) {
curUser = hero;
GameScene.selectItem( itemSelector, WndBag.Mode.WEAPON, TXT_SELECT_WEAPON );
curUser = hero;
GameScene.selectItem( itemSelector, WndBag.Mode.WEAPON, TXT_SELECT_WEAPON );
} else {
} else {
super.execute( hero, action );
super.execute( hero, action );
}
}
}
}
@Override
public boolean isUpgradable() {
return false;
}
@Override
public boolean isUpgradable() {
return false;
}
@Override
public boolean isIdentified() {
return true;
}
@Override
public boolean isIdentified() {
return true;
}
private void apply( Weapon weapon, boolean forSpeed ) {
private void apply( Weapon weapon, boolean forSpeed ) {
detach( curUser.belongings.backpack );
detach( curUser.belongings.backpack );
if (forSpeed) {
weapon.imbue = Weapon.Imbue.LIGHT;
GLog.p( TXT_LIGHT, weapon.name() );
} else {
weapon.imbue = Weapon.Imbue.HEAVY;
GLog.p( TXT_HEAVY, weapon.name() );
}
if (forSpeed) {
weapon.imbue = Weapon.Imbue.LIGHT;
GLog.p( TXT_LIGHT, weapon.name() );
} else {
weapon.imbue = Weapon.Imbue.HEAVY;
GLog.p( TXT_HEAVY, weapon.name() );
}
curUser.sprite.operate( curUser.pos );
Sample.INSTANCE.play( Assets.SND_MISS );
curUser.sprite.operate( curUser.pos );
Sample.INSTANCE.play( Assets.SND_MISS );
curUser.spend( TIME_TO_APPLY );
curUser.busy();
}
curUser.spend( TIME_TO_APPLY );
curUser.busy();
}
@Override
public int price() {
return 40 * quantity;
}
@Override
public int price() {
return 40 * quantity;
}
@Override
public String info() {
return
"Using a weightstone, you can balance your melee weapon to make it lighter or heavier, " +
"increasing either speed or damage at the expense of the other.";
}
@Override
public String info() {
return
"Using a weightstone, you can balance your melee weapon to make it lighter or heavier, " +
"increasing either speed or damage at the expense of the other.";
}
private final WndBag.Listener itemSelector = new WndBag.Listener() {
@Override
public void onSelect( Item item ) {
if (item != null) {
GameScene.show( new WndBalance( (Weapon)item ) );
}
}
};
private final WndBag.Listener itemSelector = new WndBag.Listener() {
@Override
public void onSelect( Item item ) {
if (item != null) {
GameScene.show( new WndBalance( (Weapon)item ) );
}
}
};
public class WndBalance extends Window {
public class WndBalance extends Window {
private static final String TXT_CHOICE = "How would you like to balance your %s?";
private static final String TXT_CHOICE = "How would you like to balance your %s?";
private static final String TXT_LIGHT = "Lighter";
private static final String TXT_HEAVY = "Heavier";
private static final String TXT_CANCEL = "Never mind";
private static final String TXT_LIGHT = "Lighter";
private static final String TXT_HEAVY = "Heavier";
private static final String TXT_CANCEL = "Never mind";
private static final int WIDTH = 120;
private static final int MARGIN = 2;
private static final int BUTTON_WIDTH = WIDTH - MARGIN * 2;
private static final int BUTTON_HEIGHT = 20;
private static final int WIDTH = 120;
private static final int MARGIN = 2;
private static final int BUTTON_WIDTH = WIDTH - MARGIN * 2;
private static final int BUTTON_HEIGHT = 20;
public WndBalance( final Weapon weapon ) {
super();
public WndBalance( final Weapon weapon ) {
super();
IconTitle titlebar = new IconTitle( weapon );
titlebar.setRect( 0, 0, WIDTH, 0 );
add( titlebar );
IconTitle titlebar = new IconTitle( weapon );
titlebar.setRect( 0, 0, WIDTH, 0 );
add( titlebar );
BitmapTextMultiline tfMesage = PixelScene.createMultiline( Utils.format( TXT_CHOICE, weapon.name() ), 8 );
tfMesage.maxWidth = WIDTH - MARGIN * 2;
tfMesage.measure();
tfMesage.x = MARGIN;
tfMesage.y = titlebar.bottom() + MARGIN;
add( tfMesage );
BitmapTextMultiline tfMesage = PixelScene.createMultiline( Utils.format( TXT_CHOICE, weapon.name() ), 8 );
tfMesage.maxWidth = WIDTH - MARGIN * 2;
tfMesage.measure();
tfMesage.x = MARGIN;
tfMesage.y = titlebar.bottom() + MARGIN;
add( tfMesage );
float pos = tfMesage.y + tfMesage.height();
float pos = tfMesage.y + tfMesage.height();
if (weapon.imbue != Weapon.Imbue.LIGHT) {
RedButton btnSpeed = new RedButton( TXT_LIGHT ) {
@Override
protected void onClick() {
hide();
Weightstone.this.apply( weapon, true );
}
};
btnSpeed.setRect( MARGIN, pos + MARGIN, BUTTON_WIDTH, BUTTON_HEIGHT );
add( btnSpeed );
if (weapon.imbue != Weapon.Imbue.LIGHT) {
RedButton btnSpeed = new RedButton( TXT_LIGHT ) {
@Override
protected void onClick() {
hide();
Weightstone.this.apply( weapon, true );
}
};
btnSpeed.setRect( MARGIN, pos + MARGIN, BUTTON_WIDTH, BUTTON_HEIGHT );
add( btnSpeed );
pos = btnSpeed.bottom();
}
pos = btnSpeed.bottom();
}
if (weapon.imbue != Weapon.Imbue.HEAVY) {
RedButton btnAccuracy = new RedButton( TXT_HEAVY ) {
@Override
protected void onClick() {
hide();
Weightstone.this.apply( weapon, false );
}
};
btnAccuracy.setRect( MARGIN, pos + MARGIN, BUTTON_WIDTH, BUTTON_HEIGHT );
add( btnAccuracy );
if (weapon.imbue != Weapon.Imbue.HEAVY) {
RedButton btnAccuracy = new RedButton( TXT_HEAVY ) {
@Override
protected void onClick() {
hide();
Weightstone.this.apply( weapon, false );
}
};
btnAccuracy.setRect( MARGIN, pos + MARGIN, BUTTON_WIDTH, BUTTON_HEIGHT );
add( btnAccuracy );
pos = btnAccuracy.bottom();
}
pos = btnAccuracy.bottom();
}
RedButton btnCancel = new RedButton( TXT_CANCEL ) {
@Override
protected void onClick() {
hide();
}
};
btnCancel.setRect( MARGIN, pos + MARGIN, BUTTON_WIDTH, BUTTON_HEIGHT );
add( btnCancel );
RedButton btnCancel = new RedButton( TXT_CANCEL ) {
@Override
protected void onClick() {
hide();
}
};
btnCancel.setRect( MARGIN, pos + MARGIN, BUTTON_WIDTH, BUTTON_HEIGHT );
add( btnCancel );
resize( WIDTH, (int)btnCancel.bottom() + MARGIN );
}
resize( WIDTH, (int)btnCancel.bottom() + MARGIN );
}
protected void onSelect( int index ) {};
}
protected void onSelect( int index ) {};
}
}
@@ -45,7 +45,7 @@ public class Armor extends EquipableItem {
private static final String TXT_TO_STRING = "%s :%d";
private static final String TXT_INCOMPATIBLE =
private static final String TXT_INCOMPATIBLE =
"Interaction of different types of magic has erased the glyph on this armor!";
public int tier;
@@ -107,7 +107,7 @@ public class Armor extends EquipableItem {
((HeroSprite)hero.sprite).updateArmor();
hero.spendAndNext( 2 * time2equip( hero ) );
hero.spendAndNext( 2 * time2equip( hero ) );
return true;
} else {
@@ -118,26 +118,26 @@ public class Armor extends EquipableItem {
}
}
@Override
protected float time2equip( Hero hero ) {
return hero.speed();
}
@Override
protected float time2equip( Hero hero ) {
return hero.speed();
}
@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 )) {
hero.belongings.armor = null;
((HeroSprite)hero.sprite).updateArmor();
hero.belongings.armor = null;
((HeroSprite)hero.sprite).updateArmor();
return true;
return true;
} else {
} else {
return false;
return false;
}
}
}
}
@Override
public boolean isEquipped( Hero hero ) {
@@ -209,25 +209,25 @@ public class Armor extends EquipableItem {
StringBuilder info = new StringBuilder( desc() );
if (levelKnown) {
info.append(
info.append(
"\n\nThis " + name + " provides damage absorption up to " +
"" + Math.max( DR, 0 ) + " points per attack. " );
if (STR > Dungeon.hero.STR()) {
if (isEquipped( Dungeon.hero )) {
info.append(
info.append(
"\n\nBecause of your inadequate strength your " +
"movement speed and defense skill is decreased. " );
} else {
info.append(
info.append(
"\n\nBecause of your inadequate strength wearing this armor " +
"will decrease your movement speed and defense skill. " );
}
}
} else {
info.append(
info.append(
"\n\nTypical " + name + " provides damage absorption up to " + typicalDR() + " points per attack " +
" and requires " + typicalSTR() + " points of strength. " );
if (typicalSTR() > Dungeon.hero.STR()) {
@@ -240,8 +240,8 @@ public class Armor extends EquipableItem {
}
if (isEquipped( Dungeon.hero )) {
info.append( "\n\nYou are wearing the " + name +
(cursed ? ", and because it is cursed, you are powerless to remove it." : ".") );
info.append( "\n\nYou are wearing the " + name +
(cursed ? ", and because it is cursed, you are powerless to remove it." : ".") );
} else {
if (cursedKnown && cursed) {
info.append( "\n\nYou can feel a malevolent magic lurking within the " + name + "." );
@@ -306,18 +306,18 @@ public class Armor extends EquipableItem {
return price;
}
public Armor inscribe( Glyph glyph ) {
public Armor inscribe( Glyph glyph ) {
if (glyph != null && this.glyph == null) {
DR += tier;
} else if (glyph == null && this.glyph != null) {
DR -= tier;
}
if (glyph != null && this.glyph == null) {
DR += tier;
} else if (glyph == null && this.glyph != null) {
DR -= tier;
}
this.glyph = glyph;
this.glyph = glyph;
return this;
}
return this;
}
public Armor inscribe() {
@@ -341,8 +341,8 @@ public class Armor extends EquipableItem {
public static abstract class Glyph implements Bundlable {
private static final Class<?>[] glyphs = new Class<?>[]{
Bounce.class, Affection.class, AntiEntropy.class, Multiplicity.class,
private static final Class<?>[] glyphs = new Class<?>[]{
Bounce.class, Affection.class, AntiEntropy.class, Multiplicity.class,
Potential.class, Metabolism.class, Stench.class, Viscosity.class,
Displacement.class, Entanglement.class };
@@ -359,11 +359,11 @@ public class Armor extends EquipableItem {
}
@Override
public void restoreFromBundle( Bundle bundle ) {
public void restoreFromBundle( Bundle bundle ) {
}
@Override
public void storeInBundle( Bundle bundle ) {
public void storeInBundle( Bundle bundle ) {
}
public ItemSprite.Glowing glowing() {
@@ -34,7 +34,7 @@ abstract public class ClassArmor extends Armor {
cursedKnown = true;
defaultAction = special();
bones = false;
bones = false;
}
public ClassArmor() {
@@ -108,8 +108,8 @@ abstract public class ClassArmor extends Armor {
doSpecial();
}
} else {
super.execute( hero, action );
} else {
super.execute( hero, action );
}
}
@@ -22,11 +22,11 @@ import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
public class ClothArmor extends Armor {
{
{
name = "cloth armor";
image = ItemSpriteSheet.ARMOR_CLOTH;
bones = false; //Finding them in bones would be semi-frequent and disappointing.
bones = false; //Finding them in bones would be semi-frequent and disappointing.
}
public ClothArmor() {
@@ -36,7 +36,7 @@ public class HuntressArmor extends ClassArmor {
private static final String TXT_NO_ENEMIES = "No enemies in sight";
private static final String TXT_NOT_HUNTRESS = "Only huntresses can use this armor!";
private static final String AC_SPECIAL = "SPECTRAL BLADES";
private static final String AC_SPECIAL = "SPECTRAL BLADES";
{
name = "huntress cloak";
@@ -58,7 +58,7 @@ public class HuntressArmor extends ClassArmor {
for (Mob mob : Dungeon.level.mobs) {
if (Level.fieldOfView[mob.pos]) {
Callback callback = new Callback() {
Callback callback = new Callback() {
@Override
public void call() {
curUser.attack( targets.get( this ) );
@@ -22,7 +22,7 @@ import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
public class LeatherArmor extends Armor {
{
{
name = "leather armor";
image = ItemSpriteSheet.ARMOR_LEATHER;
}
@@ -32,9 +32,9 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
public class MageArmor extends ClassArmor {
public class MageArmor extends ClassArmor {
private static final String AC_SPECIAL = "MOLTEN EARTH";
private static final String AC_SPECIAL = "MOLTEN EARTH";
private static final String TXT_NOT_MAGE = "Only mages can use this armor!";
@@ -56,7 +56,7 @@ public class MageArmor extends ClassArmor {
}
@Override
public void doSpecial() {
public void doSpecial() {
for (Mob mob : Dungeon.level.mobs) {
if (Level.fieldOfView[mob.pos]) {
@@ -65,7 +65,7 @@ public class MageArmor extends ClassArmor {
}
}
curUser.HP -= (curUser.HP / 3);
curUser.HP -= (curUser.HP / 3);
curUser.spend( Actor.TICK );
curUser.sprite.operate( curUser.pos );
@@ -33,7 +33,7 @@ public class MailArmor extends Armor {
@Override
public String desc() {
return
return
"Interlocking metal links make for a tough but flexible suit of armor.";
}
}
@@ -33,7 +33,7 @@ public class PlateArmor extends Armor {
@Override
public String desc() {
return
return
"Enormous plates of metal are joined together into a suit that provides " +
"unmatched protection to any adventurer strong enough to bear its staggering weight.";
}
@@ -40,7 +40,7 @@ public class RogueArmor extends ClassArmor {
private static final String TXT_FOV = "You can only jump to an empty location in your field of view";
private static final String TXT_NOT_ROGUE = "Only rogues can use this armor!";
private static final String AC_SPECIAL = "SMOKE BOMB";
private static final String AC_SPECIAL = "SMOKE BOMB";
{
name = "rogue garb";
@@ -53,7 +53,7 @@ public class RogueArmor extends ClassArmor {
}
@Override
public void doSpecial() {
public void doSpecial() {
GameScene.selectCell( teleporter );
}
@@ -69,7 +69,7 @@ public class RogueArmor extends ClassArmor {
@Override
public String desc() {
return
return
"Wearing this dark garb, a rogue can perform a trick, that is called \"smoke bomb\" " +
"(though no real explosives are used): he blinds enemies who could see him and jumps aside.";
}
@@ -80,15 +80,15 @@ public class RogueArmor extends ClassArmor {
public void onSelect( Integer target ) {
if (target != null) {
if (!Level.fieldOfView[target] ||
!(Level.passable[target] || Level.avoid[target]) ||
if (!Level.fieldOfView[target] ||
!(Level.passable[target] || Level.avoid[target]) ||
Actor.findChar( target ) != null) {
GLog.w( TXT_FOV );
return;
}
curUser.HP -= (curUser.HP / 3);
curUser.HP -= (curUser.HP / 3);
for (Mob mob : Dungeon.level.mobs) {
if (Level.fieldOfView[mob.pos]) {
@@ -33,7 +33,7 @@ public class ScaleArmor extends Armor {
@Override
public String desc() {
return
return
"The metal scales sewn onto a leather vest create a flexible, yet protective armor.";
}
}
@@ -41,7 +41,7 @@ public class WarriorArmor extends ClassArmor {
private static int LEAP_TIME = 1;
private static int SHOCK_TIME = 3;
private static final String AC_SPECIAL = "HEROIC LEAP";
private static final String AC_SPECIAL = "HEROIC LEAP";
private static final String TXT_NOT_WARRIOR = "Only warriors can use this armor!";
@@ -91,35 +91,35 @@ public class WarriorArmor extends ClassArmor {
cell = route.path.get(route.dist-1);
curUser.HP -= (curUser.HP / 3);
curUser.HP -= (curUser.HP / 3);
if (curUser.subClass == HeroSubClass.BERSERKER && curUser.HP <= curUser.HT * Fury.LEVEL) {
Buff.affect( curUser, Fury.class );
}
final int dest = cell;
curUser.busy();
curUser.sprite.jump(curUser.pos, cell, new Callback() {
@Override
public void call() {
curUser.move(dest);
Dungeon.level.press(dest, curUser);
Dungeon.observe();
final int dest = cell;
curUser.busy();
curUser.sprite.jump(curUser.pos, cell, new Callback() {
@Override
public void call() {
curUser.move(dest);
Dungeon.level.press(dest, curUser);
Dungeon.observe();
for (int i = 0; i < Level.NEIGHBOURS8.length; i++) {
Char mob = Actor.findChar(curUser.pos + Level.NEIGHBOURS8[i]);
if (mob != null && mob != curUser) {
Buff.prolong(mob, Paralysis.class, SHOCK_TIME);
}
}
for (int i = 0; i < Level.NEIGHBOURS8.length; i++) {
Char mob = Actor.findChar(curUser.pos + Level.NEIGHBOURS8[i]);
if (mob != null && mob != curUser) {
Buff.prolong(mob, Paralysis.class, SHOCK_TIME);
}
}
CellEmitter.center(dest).burst(Speck.factory(Speck.DUST), 10);
Camera.main.shake(2, 0.5f);
CellEmitter.center(dest).burst(Speck.factory(Speck.DUST), 10);
Camera.main.shake(2, 0.5f);
curUser.spendAndNext(LEAP_TIME);
}
});
curUser.spendAndNext(LEAP_TIME);
}
});
}
}
@@ -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();
}
}
}
}
@@ -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 {
}
}
}
@@ -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;
@@ -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);
}
}
}
@@ -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);
}
}
}
};
}
@@ -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;
}
}
}
@@ -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;
}
}
}
@@ -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.");
}
};
}
@@ -42,7 +42,7 @@ public class Bag extends Item implements Iterable<Item> {
public Char owner;
public ArrayList<Item> items = new ArrayList<Item>();
public ArrayList<Item> items = new ArrayList<Item>();
public int size = 1;
@@ -61,7 +61,7 @@ public class Bag extends Item implements Iterable<Item> {
@Override
public boolean collect( Bag container ) {
if (super.collect( container )) {
if (super.collect( container )) {
owner = container.owner;
@@ -82,9 +82,9 @@ public class Bag extends Item implements Iterable<Item> {
@Override
public void onDetach( ) {
this.owner = null;
for (Item item : items)
Dungeon.quickslot.clearItem(item);
this.owner = null;
for (Item item : items)
Dungeon.quickslot.clearItem(item);
updateQuickslot();
}
@@ -178,6 +178,6 @@ public class Bag extends Item implements Iterable<Item> {
} else {
items.remove( index );
}
}
}
}
}
@@ -4,9 +4,6 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
/**
* Created by debenhame on 05/02/2015.
*/
public class PotionBandolier extends Bag {
{
@@ -51,12 +51,12 @@ public class WandHolster extends Bag {
}
@Override
public void onDetach( ) {
public void onDetach( ) {
super.onDetach();
for (Item item : items) {
((Wand)item).stopCharging();
}
}
for (Item item : items) {
((Wand)item).stopCharging();
}
}
@Override
public int price() {
@@ -38,298 +38,295 @@ import com.watabou.noosa.audio.Sample;
import com.watabou.utils.Bundle;
import com.watabou.utils.Random;
/**
* Created by debenhame on 12/08/2014.
*/
public class Blandfruit extends Food {
public String message = "You eat the Blandfruit, bleugh!";
public String info = "So dry and insubstantial, perhaps stewing it with another ingredient would improve it.";
public String message = "You eat the Blandfruit, bleugh!";
public String info = "So dry and insubstantial, perhaps stewing it with another ingredient would improve it.";
public Potion potionAttrib = null;
public ItemSprite.Glowing potionGlow = null;
public Potion potionAttrib = null;
public ItemSprite.Glowing potionGlow = null;
{
name = "Blandfruit";
stackable = true;
image = ItemSpriteSheet.BLANDFRUIT;
energy = (Hunger.STARVING - Hunger.HUNGRY)/2;
hornValue = 6; //only applies when blandfruit is cooked
{
name = "Blandfruit";
stackable = true;
image = ItemSpriteSheet.BLANDFRUIT;
energy = (Hunger.STARVING - Hunger.HUNGRY)/2;
hornValue = 6; //only applies when blandfruit is cooked
bones = true;
}
bones = true;
}
@Override
public boolean isSimilar( Item item ) {
if (item instanceof Blandfruit){
if (potionAttrib == null){
if (((Blandfruit)item).potionAttrib == null)
return true;
} else if (((Blandfruit)item).potionAttrib != null){
if (((Blandfruit)item).potionAttrib.getClass() == potionAttrib.getClass())
return true;
}
}
return false;
}
@Override
public boolean isSimilar( Item item ) {
if (item instanceof Blandfruit){
if (potionAttrib == null){
if (((Blandfruit)item).potionAttrib == null)
return true;
} else if (((Blandfruit)item).potionAttrib != null){
if (((Blandfruit)item).potionAttrib.getClass() == potionAttrib.getClass())
return true;
}
}
return false;
}
@Override
public void execute( Hero hero, String action ) {
if (action.equals( AC_EAT )){
@Override
public void execute( Hero hero, String action ) {
if (action.equals( AC_EAT )){
if (potionAttrib == null) {
if (potionAttrib == null) {
detach(hero.belongings.backpack);
detach(hero.belongings.backpack);
((Hunger) hero.buff(Hunger.class)).satisfy(energy);
GLog.i(message);
((Hunger) hero.buff(Hunger.class)).satisfy(energy);
GLog.i(message);
hero.sprite.operate(hero.pos);
hero.busy();
SpellSprite.show(hero, SpellSprite.FOOD);
Sample.INSTANCE.play(Assets.SND_EAT);
hero.sprite.operate(hero.pos);
hero.busy();
SpellSprite.show(hero, SpellSprite.FOOD);
Sample.INSTANCE.play(Assets.SND_EAT);
hero.spend(1f);
hero.spend(1f);
Statistics.foodEaten++;
Badges.validateFoodEaten();
} else {
Statistics.foodEaten++;
Badges.validateFoodEaten();
} else {
((Hunger) hero.buff(Hunger.class)).satisfy(Hunger.HUNGRY);
((Hunger) hero.buff(Hunger.class)).satisfy(Hunger.HUNGRY);
detach(hero.belongings.backpack);
detach(hero.belongings.backpack);
hero.spend(1f);
hero.busy();
hero.spend(1f);
hero.busy();
if (potionAttrib instanceof PotionOfFrost) {
GLog.i("the Icefruit tastes a bit like Frozen Carpaccio.");
switch (Random.Int(5)) {
case 0:
GLog.i("You see your hands turn invisible!");
Buff.affect(hero, Invisibility.class, Invisibility.DURATION);
break;
case 1:
GLog.i("You feel your skin harden!");
Buff.affect(hero, Barkskin.class).level(hero.HT / 4);
break;
case 2:
GLog.i("Refreshing!");
Buff.detach(hero, Poison.class);
Buff.detach(hero, Cripple.class);
Buff.detach(hero, Weakness.class);
Buff.detach(hero, Bleeding.class);
break;
case 3:
GLog.i("You feel better!");
if (hero.HP < hero.HT) {
hero.HP = Math.min(hero.HP + hero.HT / 4, hero.HT);
hero.sprite.emitter().burst(Speck.factory(Speck.HEALING), 1);
}
break;
}
} else if (potionAttrib instanceof PotionOfLiquidFlame){
GLog.i("You feel a great fire burning within you!");
Buff.affect(hero, FireImbue.class).set(FireImbue.DURATION);
} else if (potionAttrib instanceof PotionOfToxicGas) {
GLog.i("You are imbued with vile toxic power!");
Buff.affect(hero, ToxicImbue.class).set(ToxicImbue.DURATION);
} else if (potionAttrib instanceof PotionOfParalyticGas) {
GLog.i("You feel the power of the earth coursing through you!");
Buff.affect(hero, EarthImbue.class, EarthImbue.DURATION);
} else
potionAttrib.apply(hero);
if (potionAttrib instanceof PotionOfFrost) {
GLog.i("the Icefruit tastes a bit like Frozen Carpaccio.");
switch (Random.Int(5)) {
case 0:
GLog.i("You see your hands turn invisible!");
Buff.affect(hero, Invisibility.class, Invisibility.DURATION);
break;
case 1:
GLog.i("You feel your skin harden!");
Buff.affect(hero, Barkskin.class).level(hero.HT / 4);
break;
case 2:
GLog.i("Refreshing!");
Buff.detach(hero, Poison.class);
Buff.detach(hero, Cripple.class);
Buff.detach(hero, Weakness.class);
Buff.detach(hero, Bleeding.class);
break;
case 3:
GLog.i("You feel better!");
if (hero.HP < hero.HT) {
hero.HP = Math.min(hero.HP + hero.HT / 4, hero.HT);
hero.sprite.emitter().burst(Speck.factory(Speck.HEALING), 1);
}
break;
}
} else if (potionAttrib instanceof PotionOfLiquidFlame){
GLog.i("You feel a great fire burning within you!");
Buff.affect(hero, FireImbue.class).set(FireImbue.DURATION);
} else if (potionAttrib instanceof PotionOfToxicGas) {
GLog.i("You are imbued with vile toxic power!");
Buff.affect(hero, ToxicImbue.class).set(ToxicImbue.DURATION);
} else if (potionAttrib instanceof PotionOfParalyticGas) {
GLog.i("You feel the power of the earth coursing through you!");
Buff.affect(hero, EarthImbue.class, EarthImbue.DURATION);
} else
potionAttrib.apply(hero);
Sample.INSTANCE.play( Assets.SND_EAT );
SpellSprite.show(hero, SpellSprite.FOOD);
hero.sprite.operate(hero.pos);
Sample.INSTANCE.play( Assets.SND_EAT );
SpellSprite.show(hero, SpellSprite.FOOD);
hero.sprite.operate(hero.pos);
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;
}
}
} else {
super.execute(hero, action);
}
}
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;
}
}
} else {
super.execute(hero, action);
}
}
@Override
public String info() {
return info;
}
@Override
public String info() {
return info;
}
@Override
public int price() {
return 20 * quantity;
}
@Override
public int price() {
return 20 * quantity;
}
public Item cook(Seed seed){
public Item cook(Seed seed){
try {
return imbuePotion((Potion)seed.alchemyClass.newInstance());
} catch (Exception e) {
return null;
}
try {
return imbuePotion((Potion)seed.alchemyClass.newInstance());
} catch (Exception e) {
return null;
}
}
}
public Item imbuePotion(Potion potion){
public Item imbuePotion(Potion potion){
potionAttrib = potion;
potionAttrib.ownedByFruit = true;
potionAttrib = potion;
potionAttrib.ownedByFruit = true;
potionAttrib.image = ItemSpriteSheet.BLANDFRUIT;
potionAttrib.image = ItemSpriteSheet.BLANDFRUIT;
info = "The fruit has plumped up from its time soaking in the pot and has even absorbed the properties "+
"of the seed it was cooked with.\n\n";
info = "The fruit has plumped up from its time soaking in the pot and has even absorbed the properties "+
"of the seed it was cooked with.\n\n";
if (potionAttrib instanceof PotionOfHealing){
if (potionAttrib instanceof PotionOfHealing){
name = "Sunfruit";
potionGlow = new ItemSprite.Glowing( 0x2EE62E );
info += "It looks delicious and hearty, ready to be eaten!";
name = "Sunfruit";
potionGlow = new ItemSprite.Glowing( 0x2EE62E );
info += "It looks delicious and hearty, ready to be eaten!";
} else if (potionAttrib instanceof PotionOfStrength){
} else if (potionAttrib instanceof PotionOfStrength){
name = "Rotfruit";
potionGlow = new ItemSprite.Glowing( 0xCC0022 );
info += "It looks delicious and powerful, ready to be eaten!";
name = "Rotfruit";
potionGlow = new ItemSprite.Glowing( 0xCC0022 );
info += "It looks delicious and powerful, ready to be eaten!";
} else if (potionAttrib instanceof PotionOfParalyticGas){
} else if (potionAttrib instanceof PotionOfParalyticGas){
name = "Earthfruit";
potionGlow = new ItemSprite.Glowing( 0x67583D );
info += "It looks delicious and firm, ready to be eaten!";
name = "Earthfruit";
potionGlow = new ItemSprite.Glowing( 0x67583D );
info += "It looks delicious and firm, ready to be eaten!";
} else if (potionAttrib instanceof PotionOfInvisibility){
} else if (potionAttrib instanceof PotionOfInvisibility){
name = "Blindfruit";
potionGlow = new ItemSprite.Glowing( 0xE5D273 );
info += "It looks delicious and shiny, ready to be eaten!";
name = "Blindfruit";
potionGlow = new ItemSprite.Glowing( 0xE5D273 );
info += "It looks delicious and shiny, ready to be eaten!";
} else if (potionAttrib instanceof PotionOfLiquidFlame){
} else if (potionAttrib instanceof PotionOfLiquidFlame){
name = "Firefruit";
potionGlow = new ItemSprite.Glowing( 0xFF7F00 );
info += "It looks delicious and spicy, ready to be eaten!";
name = "Firefruit";
potionGlow = new ItemSprite.Glowing( 0xFF7F00 );
info += "It looks delicious and spicy, ready to be eaten!";
} else if (potionAttrib instanceof PotionOfFrost){
} else if (potionAttrib instanceof PotionOfFrost){
name = "Icefruit";
potionGlow = new ItemSprite.Glowing( 0x66B3FF );
info += "It looks delicious and refreshing, ready to be eaten!";
name = "Icefruit";
potionGlow = new ItemSprite.Glowing( 0x66B3FF );
info += "It looks delicious and refreshing, ready to be eaten!";
} else if (potionAttrib instanceof PotionOfMindVision){
} else if (potionAttrib instanceof PotionOfMindVision){
name = "Fadefruit";
potionGlow = new ItemSprite.Glowing( 0xB8E6CF );
info += "It looks delicious and shadowy, ready to be eaten!";
name = "Fadefruit";
potionGlow = new ItemSprite.Glowing( 0xB8E6CF );
info += "It looks delicious and shadowy, ready to be eaten!";
} else if (potionAttrib instanceof PotionOfToxicGas){
} else if (potionAttrib instanceof PotionOfToxicGas){
name = "Sorrowfruit";
potionGlow = new ItemSprite.Glowing( 0xA15CE5 );
info += "It looks delicious and crisp, ready to be eaten!";
name = "Sorrowfruit";
potionGlow = new ItemSprite.Glowing( 0xA15CE5 );
info += "It looks delicious and crisp, ready to be eaten!";
} else if (potionAttrib instanceof PotionOfLevitation) {
} else if (potionAttrib instanceof PotionOfLevitation) {
name = "Stormfruit";
potionGlow = new ItemSprite.Glowing( 0x1C3A57 );
info += "It looks delicious and lightweight, ready to be eaten!";
name = "Stormfruit";
potionGlow = new ItemSprite.Glowing( 0x1C3A57 );
info += "It looks delicious and lightweight, ready to be eaten!";
} else if (potionAttrib instanceof PotionOfPurity) {
} else if (potionAttrib instanceof PotionOfPurity) {
name = "Dreamfruit";
potionGlow = new ItemSprite.Glowing( 0x8E2975 );
info += "It looks delicious and clean, ready to be eaten!";
name = "Dreamfruit";
potionGlow = new ItemSprite.Glowing( 0x8E2975 );
info += "It looks delicious and clean, ready to be eaten!";
} else if (potionAttrib instanceof PotionOfExperience) {
} else if (potionAttrib instanceof PotionOfExperience) {
name = "Starfruit";
potionGlow = new ItemSprite.Glowing( 0xA79400 );
info += "It looks delicious and glorious, ready to be eaten!";
name = "Starfruit";
potionGlow = new ItemSprite.Glowing( 0xA79400 );
info += "It looks delicious and glorious, ready to be eaten!";
}
}
return this;
}
return this;
}
public static final String POTIONATTRIB = "potionattrib";
public static final String POTIONATTRIB = "potionattrib";
@Override
public void cast( final Hero user, int dst ) {
if (potionAttrib instanceof PotionOfLiquidFlame ||
potionAttrib instanceof PotionOfToxicGas ||
potionAttrib instanceof PotionOfParalyticGas ||
potionAttrib instanceof PotionOfFrost ||
potionAttrib instanceof PotionOfLevitation ||
potionAttrib instanceof PotionOfPurity) {
potionAttrib.cast(user, dst);
detach( user.belongings.backpack );
} else {
super.cast(user, dst);
}
@Override
public void cast( final Hero user, int dst ) {
if (potionAttrib instanceof PotionOfLiquidFlame ||
potionAttrib instanceof PotionOfToxicGas ||
potionAttrib instanceof PotionOfParalyticGas ||
potionAttrib instanceof PotionOfFrost ||
potionAttrib instanceof PotionOfLevitation ||
potionAttrib instanceof PotionOfPurity) {
potionAttrib.cast(user, dst);
detach( user.belongings.backpack );
} else {
super.cast(user, dst);
}
}
}
@Override
public void storeInBundle(Bundle bundle){
super.storeInBundle(bundle);
bundle.put( POTIONATTRIB , potionAttrib);
}
@Override
public void storeInBundle(Bundle bundle){
super.storeInBundle(bundle);
bundle.put( POTIONATTRIB , potionAttrib);
}
@Override
public void restoreFromBundle(Bundle bundle){
super.restoreFromBundle(bundle);
if (bundle.contains( POTIONATTRIB )) {
imbuePotion( (Potion)bundle.get( POTIONATTRIB ) );
@Override
public void restoreFromBundle(Bundle bundle){
super.restoreFromBundle(bundle);
if (bundle.contains( POTIONATTRIB )) {
imbuePotion( (Potion)bundle.get( POTIONATTRIB ) );
//TODO: legacy code for pre-v0.2.3, remove when saves from that version are no longer supported.
} else if (bundle.contains("name")) {
name = bundle.getString("name");
//TODO: legacy code for pre-v0.2.3, remove when saves from that version are no longer supported.
} else if (bundle.contains("name")) {
name = bundle.getString("name");
if (name.equals("Healthfruit"))
cook(new Sungrass.Seed());
else if (name.equals("Powerfruit"))
cook(new Wandmaker.Rotberry.Seed());
else if (name.equals("Paralyzefruit"))
cook(new Earthroot.Seed());
else if (name.equals("Invisifruit"))
cook(new Blindweed.Seed());
else if (name.equals("Flamefruit"))
cook(new Firebloom.Seed());
else if (name.equals("Frostfruit"))
cook(new Icecap.Seed());
else if (name.equals("Visionfruit"))
cook(new Fadeleaf.Seed());
else if (name.equals("Toxicfruit"))
cook(new Sorrowmoss.Seed());
else if (name.equals("Floatfruit"))
cook(new Stormvine.Seed());
else if (name.equals("Purefruit"))
cook(new Dreamfoil.Seed());
}
if (name.equals("Healthfruit"))
cook(new Sungrass.Seed());
else if (name.equals("Powerfruit"))
cook(new Wandmaker.Rotberry.Seed());
else if (name.equals("Paralyzefruit"))
cook(new Earthroot.Seed());
else if (name.equals("Invisifruit"))
cook(new Blindweed.Seed());
else if (name.equals("Flamefruit"))
cook(new Firebloom.Seed());
else if (name.equals("Frostfruit"))
cook(new Icecap.Seed());
else if (name.equals("Visionfruit"))
cook(new Fadeleaf.Seed());
else if (name.equals("Toxicfruit"))
cook(new Sorrowmoss.Seed());
else if (name.equals("Floatfruit"))
cook(new Stormvine.Seed());
else if (name.equals("Purefruit"))
cook(new Dreamfoil.Seed());
}
}
}
@Override
public ItemSprite.Glowing glowing() {
return potionGlow;
}
@Override
public ItemSprite.Glowing glowing() {
return potionGlow;
}
}
@@ -26,7 +26,7 @@ public class ChargrilledMeat extends Food {
name = "chargrilled meat";
image = ItemSpriteSheet.STEAK;
energy = Hunger.STARVING - Hunger.HUNGRY;
hornValue = 1;
hornValue = 1;
}
@Override
@@ -42,14 +42,14 @@ public class Food extends Item {
public float energy = Hunger.HUNGRY;
public String message = "That food tasted delicious!";
public int hornValue = 3;
public int hornValue = 3;
{
stackable = true;
name = "ration of food";
image = ItemSpriteSheet.RATION;
bones = true;
bones = true;
}
@Override
@@ -102,9 +102,9 @@ public class Food extends Item {
}
}
@Override
@Override
public String info() {
return
return
"Nothing fancy here: dried meat, " +
"some biscuits - things like that.";
}
@@ -40,7 +40,7 @@ public class FrozenCarpaccio extends Food {
name = "frozen carpaccio";
image = ItemSpriteSheet.CARPACCIO;
energy = Hunger.STARVING - Hunger.HUNGRY;
hornValue = 1;
hornValue = 1;
}
@Override
@@ -61,13 +61,13 @@ public class FrozenCarpaccio extends Food {
break;
case 2:
GLog.i( "Refreshing!" );
Buff.detach( hero, Poison.class );
Buff.detach( hero, Cripple.class );
Buff.detach( hero, Weakness.class );
Buff.detach( hero, Bleeding.class );
Buff.detach( hero, Drowsy.class );
Buff.detach( hero, Slow.class );
Buff.detach( hero, Vertigo.class);
Buff.detach( hero, Poison.class );
Buff.detach( hero, Cripple.class );
Buff.detach( hero, Weakness.class );
Buff.detach( hero, Bleeding.class );
Buff.detach( hero, Drowsy.class );
Buff.detach( hero, Slow.class );
Buff.detach( hero, Vertigo.class);
break;
case 3:
GLog.i( "You feel better!" );
@@ -82,7 +82,7 @@ public class FrozenCarpaccio extends Food {
@Override
public String info() {
return
return
"It's a piece of frozen raw meat. The only way to eat it is " +
"by cutting thin slices of it. And this way it's suprisingly good.";
}
@@ -36,7 +36,7 @@ public class MysteryMeat extends Food {
image = ItemSpriteSheet.MEAT;
energy = Hunger.STARVING - Hunger.HUNGRY;
message = "That food tasted... strange.";
hornValue = 1;
hornValue = 1;
}
@Override
@@ -27,7 +27,7 @@ public class OverpricedRation extends Food {
image = ItemSpriteSheet.OVERPRICED;
energy = Hunger.STARVING - Hunger.HUNGRY;
message = "That food tasted ok.";
hornValue = 1;
hornValue = 1;
}
@Override
@@ -26,9 +26,9 @@ public class Pasty extends Food {
name = "pasty";
image = ItemSpriteSheet.PASTY;
energy = Hunger.STARVING;
hornValue = 5;
hornValue = 5;
bones = true;
bones = true;
}
@Override
@@ -37,7 +37,7 @@ public class GoldenKey extends Key {
@Override
public String info() {
return
return
"The notches on this golden key are tiny and intricate. " +
"Maybe it can open some chest lock?";
}
@@ -52,12 +52,12 @@ public class IronKey extends Key {
return result;
}
@Override
public void onDetach( ) {
if (depth == Dungeon.depth) {
Dungeon.hero.belongings.countIronKeys();
}
}
@Override
public void onDetach( ) {
if (depth == Dungeon.depth) {
Dungeon.hero.belongings.countIronKeys();
}
}
@Override
public String toString() {
@@ -66,7 +66,7 @@ public class IronKey extends Key {
@Override
public String info() {
return
return
"The notches on this ancient iron key are well worn; its leather lanyard " +
"is battered by age. What door might it open?";
}
@@ -44,7 +44,7 @@ public class SkeletonKey extends Key {
@Override
public String info() {
return
return
"This key looks serious: its head is shaped like a skull. Probably it can open some serious door.";
}
}
@@ -50,9 +50,9 @@ public class Potion extends Item {
private static final String TXT_BENEFICIAL = "Beneficial potion";
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_R_U_SURE_DRINK =
private static final String TXT_R_U_SURE_DRINK =
"Are you sure you want to drink it? In most cases you should throw such potions at your enemies.";
private static final String TXT_R_U_SURE_THROW =
private static final String TXT_R_U_SURE_THROW =
"Are you sure you want to throw it? In most cases it makes sense to drink it.";
private static final float TIME_TO_DRINK = 1f;
@@ -60,44 +60,44 @@ public class Potion extends Item {
protected String initials;
private static final Class<?>[] potions = {
PotionOfHealing.class,
PotionOfExperience.class,
PotionOfToxicGas.class,
PotionOfHealing.class,
PotionOfExperience.class,
PotionOfToxicGas.class,
PotionOfLiquidFlame.class,
PotionOfStrength.class,
PotionOfParalyticGas.class,
PotionOfLevitation.class,
PotionOfMindVision.class,
PotionOfMindVision.class,
PotionOfPurity.class,
PotionOfInvisibility.class,
PotionOfMight.class,
PotionOfFrost.class
};
private static final String[] colors = {
"turquoise", "crimson", "azure", "jade", "golden", "magenta",
"turquoise", "crimson", "azure", "jade", "golden", "magenta",
"charcoal", "ivory", "amber", "bistre", "indigo", "silver"};
private static final Integer[] images = {
ItemSpriteSheet.POTION_TURQUOISE,
ItemSpriteSheet.POTION_CRIMSON,
ItemSpriteSheet.POTION_AZURE,
ItemSpriteSheet.POTION_JADE,
ItemSpriteSheet.POTION_GOLDEN,
ItemSpriteSheet.POTION_MAGENTA,
ItemSpriteSheet.POTION_CHARCOAL,
ItemSpriteSheet.POTION_IVORY,
ItemSpriteSheet.POTION_AMBER,
ItemSpriteSheet.POTION_BISTRE,
ItemSpriteSheet.POTION_INDIGO,
ItemSpriteSheet.POTION_TURQUOISE,
ItemSpriteSheet.POTION_CRIMSON,
ItemSpriteSheet.POTION_AZURE,
ItemSpriteSheet.POTION_JADE,
ItemSpriteSheet.POTION_GOLDEN,
ItemSpriteSheet.POTION_MAGENTA,
ItemSpriteSheet.POTION_CHARCOAL,
ItemSpriteSheet.POTION_IVORY,
ItemSpriteSheet.POTION_AMBER,
ItemSpriteSheet.POTION_BISTRE,
ItemSpriteSheet.POTION_INDIGO,
ItemSpriteSheet.POTION_SILVER};
private static ItemStatusHandler<Potion> handler;
private String color;
public boolean ownedByFruit = false;
public boolean ownedByFruit = false;
{
stackable = true;
{
stackable = true;
defaultAction = AC_DRINK;
}
@@ -120,11 +120,11 @@ public class Potion extends Item {
syncVisuals();
}
@Override
public void syncVisuals(){
image = handler.image( this );
color = handler.label( this );
};
@Override
public void syncVisuals(){
image = handler.image( this );
color = handler.label( this );
};
@Override
public ArrayList<String> actions( Hero hero ) {
@@ -138,11 +138,11 @@ public class Potion extends Item {
if (action.equals( AC_DRINK )) {
if (isKnown() && (
this instanceof PotionOfLiquidFlame ||
this instanceof PotionOfToxicGas ||
this instanceof PotionOfLiquidFlame ||
this instanceof PotionOfToxicGas ||
this instanceof PotionOfParalyticGas)) {
GameScene.show(
GameScene.show(
new WndOptions( TXT_HARMFUL, TXT_R_U_SURE_DRINK, TXT_YES, TXT_NO ) {
@Override
protected void onSelect(int index) {
@@ -168,14 +168,14 @@ public class Potion extends Item {
public void doThrow( final Hero hero ) {
if (isKnown() && (
this instanceof PotionOfExperience ||
this instanceof PotionOfExperience ||
this instanceof PotionOfHealing ||
this instanceof PotionOfMindVision ||
this instanceof PotionOfStrength ||
this instanceof PotionOfInvisibility ||
this instanceof PotionOfInvisibility ||
this instanceof PotionOfMight)) {
GameScene.show(
GameScene.show(
new WndOptions( TXT_BENEFICIAL, TXT_R_U_SURE_THROW, TXT_YES, TXT_NO ) {
@Override
protected void onSelect(int index) {
@@ -229,23 +229,23 @@ public class Potion extends Item {
}
}
@Override
public void cast( final Hero user, int dst ) {
super.cast(user, dst);
}
@Override
public void cast( final Hero user, int dst ) {
super.cast(user, dst);
}
public boolean isKnown() {
return handler.isKnown( this );
}
public void setKnown() {
if (!ownedByFruit) {
if (!isKnown()) {
handler.know(this);
}
if (!ownedByFruit) {
if (!isKnown()) {
handler.know(this);
}
Badges.validateAllPotionsIdentified();
}
Badges.validateAllPotionsIdentified();
}
}
@Override
@@ -302,14 +302,14 @@ public class Potion extends Item {
final int color = ItemSprite.pick( image, 8, 10 );
Splash.at( cell, color, 5 );
Fire fire = (Fire)Dungeon.level.blobs.get( Fire.class );
if (fire != null)
fire.clear( cell );
Fire fire = (Fire)Dungeon.level.blobs.get( Fire.class );
if (fire != null)
fire.clear( cell );
Char ch = Actor.findChar(cell);
if (ch != null)
Buff.detach( ch, Burning.class );
}
Char ch = Actor.findChar(cell);
if (ch != null)
Buff.detach( ch, Burning.class );
}
@Override
public int price() {
@@ -25,7 +25,7 @@ public class PotionOfExperience extends Potion {
name = "Potion of Experience";
initials = "Ex";
bones = true;
bones = true;
}
@Override
@@ -59,10 +59,10 @@ public class PotionOfFrost extends Potion {
@Override
public String desc() {
return
return
"Upon exposure to open air this chemical will evaporate into a freezing cloud, causing " +
"any creature that contacts it to be frozen in place unable to act and move. " +
"The freezing effect is much stronger if the environment is wet.";
"The freezing effect is much stronger if the environment is wet.";
}
@Override
@@ -33,7 +33,7 @@ public class PotionOfHealing extends Potion {
name = "Potion of Healing";
initials = "He";
bones = true;
bones = true;
}
@Override
@@ -35,18 +35,18 @@ public class PotionOfLevitation extends Potion {
initials = "Le";
}
@Override
public void shatter( int cell ) {
@Override
public void shatter( int cell ) {
if (Dungeon.visible[cell]) {
setKnown();
if (Dungeon.visible[cell]) {
setKnown();
splash( cell );
Sample.INSTANCE.play( Assets.SND_SHATTER );
}
splash( cell );
Sample.INSTANCE.play( Assets.SND_SHATTER );
}
GameScene.add( Blob.seed( cell, 1000, ConfusionGas.class ) );
}
GameScene.add( Blob.seed( cell, 1000, ConfusionGas.class ) );
}
@Override
public void apply( Hero hero ) {
@@ -60,7 +60,7 @@ public class PotionOfLevitation extends Potion {
return
"Drinking this curious liquid will cause you to hover in the air, " +
"able to drift effortlessly over traps and pits. Throwing this potion " +
"will create a cloud of unrefined gas, disorienting anything caught in it.";
"will create a cloud of unrefined gas, disorienting anything caught in it.";
}
@Override
@@ -45,19 +45,19 @@ public class PotionOfLiquidFlame extends Potion {
Sample.INSTANCE.play( Assets.SND_SHATTER );
}
for (int offset : Level.NEIGHBOURS9){
if (Level.flamable[cell+offset]
|| Actor.findChar(cell+offset) != null
|| Dungeon.level.heaps.get(cell+offset) != null) {
for (int offset : Level.NEIGHBOURS9){
if (Level.flamable[cell+offset]
|| Actor.findChar(cell+offset) != null
|| Dungeon.level.heaps.get(cell+offset) != null) {
GameScene.add(Blob.seed(cell + offset, 2, Fire.class));
GameScene.add(Blob.seed(cell + offset, 2, Fire.class));
} else {
} else {
CellEmitter.get(cell+offset).burst(FlameParticle.FACTORY, 2);
CellEmitter.get(cell+offset).burst(FlameParticle.FACTORY, 2);
}
}
}
}
}
@Override
@@ -28,7 +28,7 @@ public class PotionOfMight extends PotionOfStrength {
name = "Potion of Might";
initials = "Mi";
bones = true;
bones = true;
}
@Override
@@ -41,7 +41,7 @@ public class PotionOfMight extends PotionOfStrength {
hero.sprite.showStatus( CharSprite.POSITIVE, "+1 str, +5 ht" );
GLog.p( "Newfound strength surges through your body." );
Badges.validateStrengthAttained();
Badges.validateStrengthAttained();
}
@Override
@@ -56,10 +56,10 @@ public class PotionOfPurity extends Potion {
boolean procd = false;
Blob[] blobs = {
Dungeon.level.blobs.get( ToxicGas.class ),
Dungeon.level.blobs.get( ToxicGas.class ),
Dungeon.level.blobs.get( ParalyticGas.class ),
Dungeon.level.blobs.get( ConfusionGas.class ),
Dungeon.level.blobs.get( StenchGas.class ),
Dungeon.level.blobs.get( ConfusionGas.class ),
Dungeon.level.blobs.get( StenchGas.class ),
Dungeon.level.blobs.get( VenomGas.class )
};
@@ -73,7 +73,7 @@ public class PotionOfPurity extends Potion {
for (int i=0; i < Level.LENGTH; i++) {
if (PathFinder.distance[i] < Integer.MAX_VALUE) {
int value = blob.cur[i];
int value = blob.cur[i];
if (value > 0) {
blob.cur[i] = 0;
@@ -125,7 +125,7 @@ public class PotionOfPurity extends Potion {
@Override
public String desc() {
return
return
"This reagent will quickly neutralize all harmful gases in the area of effect. " +
"Drinking it will give you a temporary immunity to such gases.";
}
@@ -28,7 +28,7 @@ public class PotionOfStrength extends Potion {
name = "Potion of Strength";
initials = "St";
bones = true;
bones = true;
}
@Override
@@ -39,38 +39,38 @@ public class Ring extends KindofMisc {
private static final float TIME_TO_EQUIP = 1f;
private static final String TXT_IDENTIFY =
private static final String TXT_IDENTIFY =
"you are now familiar enough with your %s to identify it. It is %s.";
protected Buff buff;
private static final Class<?>[] rings = {
RingOfAccuracy.class,
RingOfEvasion.class,
RingOfElements.class,
RingOfForce.class,
RingOfFuror.class,
RingOfHaste.class,
RingOfAccuracy.class,
RingOfEvasion.class,
RingOfElements.class,
RingOfForce.class,
RingOfFuror.class,
RingOfHaste.class,
RingOfMagic.class,
RingOfMight.class,
RingOfSharpshooting.class,
RingOfTenacity.class,
RingOfWealth.class,
RingOfSharpshooting.class,
RingOfTenacity.class,
RingOfWealth.class,
};
private static final String[] gems =
private static final String[] gems =
{"diamond", "opal", "garnet", "ruby", "amethyst", "topaz", "onyx", "tourmaline", "emerald", "sapphire", "quartz", "agate"};
private static final Integer[] images = {
ItemSpriteSheet.RING_DIAMOND,
ItemSpriteSheet.RING_OPAL,
ItemSpriteSheet.RING_GARNET,
ItemSpriteSheet.RING_RUBY,
ItemSpriteSheet.RING_AMETHYST,
ItemSpriteSheet.RING_TOPAZ,
ItemSpriteSheet.RING_ONYX,
ItemSpriteSheet.RING_TOURMALINE,
ItemSpriteSheet.RING_EMERALD,
ItemSpriteSheet.RING_SAPPHIRE,
ItemSpriteSheet.RING_QUARTZ,
ItemSpriteSheet.RING_DIAMOND,
ItemSpriteSheet.RING_OPAL,
ItemSpriteSheet.RING_GARNET,
ItemSpriteSheet.RING_RUBY,
ItemSpriteSheet.RING_AMETHYST,
ItemSpriteSheet.RING_TOPAZ,
ItemSpriteSheet.RING_ONYX,
ItemSpriteSheet.RING_TOURMALINE,
ItemSpriteSheet.RING_EMERALD,
ItemSpriteSheet.RING_SAPPHIRE,
ItemSpriteSheet.RING_QUARTZ,
ItemSpriteSheet.RING_AGATE};
private static ItemStatusHandler<Ring> handler;
@@ -95,7 +95,7 @@ public class Ring extends KindofMisc {
public Ring() {
super();
syncVisuals();
syncVisuals();
}
public void syncVisuals() {
@@ -148,27 +148,27 @@ public class Ring extends KindofMisc {
buff.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;
}
hero.remove( buff );
buff = null;
hero.remove( buff );
buff = null;
return true;
return true;
} else {
} else {
return false;
return false;
}
}
}
}
@Override
public boolean isEquipped( Hero hero ) {
@@ -211,7 +211,7 @@ public class Ring extends KindofMisc {
@Override
public String desc() {
return
return
"This metal band is adorned with a large " + gem + " gem " +
"that glitters in the darkness. Who knows what effect it has when worn?";
}
@@ -220,7 +220,7 @@ public class Ring extends KindofMisc {
public String info() {
if (isEquipped( Dungeon.hero )) {
return desc() + "\n\n" + "The " + name() + " is on your finger" +
return desc() + "\n\n" + "The " + name() + " is on your finger" +
(cursed ? ", and because it is cursed, you are powerless to remove it." : "." );
} else if (cursed && cursedKnown) {
@@ -259,7 +259,7 @@ public class Ring extends KindofMisc {
level = -n;
cursed = true;
} else
level = n;
level = n;
return this;
}
@@ -309,7 +309,7 @@ public class Ring extends KindofMisc {
public class RingBuff extends Buff {
private static final String TXT_KNOWN = "This is a %s";
private static final String TXT_KNOWN = "This is a %s";
public int level;
public RingBuff() {
@@ -32,7 +32,7 @@ public class RingOfAccuracy extends Ring {
public String desc() {
return isKnown() ?
"This ring increases your focus, reducing your enemy's ability to dodge your attacks. "+
"A degraded ring will instead make you easier to evade.":
"A degraded ring will instead make you easier to evade.":
super.desc();
}
@@ -36,46 +36,46 @@ public class RingOfEvasion extends Ring {
public String desc() {
return isKnown() ?
"This ring obfuscates the true position of the wearer, making them harder to detect and attack. " +
"This ring is much stronger while the user remains undetected, and if the user is targeted the power of " +
"evasion will slowly fade away, remaining undetected will restore the ring's effectiveness. " +
"A degraded ring will instead make the user easier to detect and strike.":
"This ring is much stronger while the user remains undetected, and if the user is targeted the power of " +
"evasion will slowly fade away, remaining undetected will restore the ring's effectiveness. " +
"A degraded ring will instead make the user easier to detect and strike.":
super.desc();
}
//yup, the only ring in the game with logic inside of its class
//yup, the only ring in the game with logic inside of its class
public class Evasion extends RingBuff {
public int effectiveLevel;
private int pos;
public int effectiveLevel;
private int pos;
@Override
public boolean attachTo( Char target ) {
@Override
public boolean attachTo( Char target ) {
pos = target.pos;
effectiveLevel = Math.min(0, level);
return super.attachTo(target);
}
pos = target.pos;
effectiveLevel = Math.min(0, level);
return super.attachTo(target);
}
@Override
public boolean act() {
@Override
public boolean act() {
boolean seen = false;
boolean seen = false;
for (Mob enemy : Dungeon.level.mobs.toArray(new Mob[0])){
if (enemy.focusingHero()) {
seen = true;
break;
}
}
for (Mob enemy : Dungeon.level.mobs.toArray(new Mob[0])){
if (enemy.focusingHero()) {
seen = true;
break;
}
}
if (level < 1){
effectiveLevel = level;
} else if (seen) {
effectiveLevel = Math.max(effectiveLevel - 1, 0);
} else {
effectiveLevel = Math.min(effectiveLevel + 1, level);
}
if (level < 1){
effectiveLevel = level;
} else if (seen) {
effectiveLevel = Math.max(effectiveLevel - 1, 0);
} else {
effectiveLevel = Math.min(effectiveLevel + 1, level);
}
return super.act();
}
return super.act();
}
}
}
@@ -2,39 +2,36 @@ package com.shatteredpixel.shatteredpixeldungeon.items.rings;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
/**
* Created by debenhame on 10/09/2014.
*/
public class RingOfForce extends Ring {
{
name = "Ring of Force";
}
{
name = "Ring of Force";
}
@Override
protected RingBuff buff( ) {
return new Force();
}
@Override
protected RingBuff buff( ) {
return new Force();
}
@Override
public String desc() {
if (isKnown()){
String desc = "This ring enhances the force of the wearer's blows. " +
"This extra power is largely wasted when wielding weapons, " +
"but an unarmed attack will be made much stronger. " +
"A degraded ring will instead weaken the wearer's blows.\n\n" +
"When unarmed, at your current strength, ";
int str = Dungeon.hero.STR() - 8;
desc += levelKnown ?
"average damage with this ring is " + (str/2+level + (int)(str*0.5f*level) + str*2)/2 + " points per hit.":
"typical average damage with this ring is" + (str/2+1 + (int)(str*0.5f) + str*2)/2 + " points per hit.";
desc += " Wearing a second ring of force would enhance this.";
return desc;
} else
return super.desc();
}
@Override
public String desc() {
if (isKnown()){
String desc = "This ring enhances the force of the wearer's blows. " +
"This extra power is largely wasted when wielding weapons, " +
"but an unarmed attack will be made much stronger. " +
"A degraded ring will instead weaken the wearer's blows.\n\n" +
"When unarmed, at your current strength, ";
int str = Dungeon.hero.STR() - 8;
desc += levelKnown ?
"average damage with this ring is " + (str/2+level + (int)(str*0.5f*level) + str*2)/2 + " points per hit.":
"typical average damage with this ring is" + (str/2+1 + (int)(str*0.5f) + str*2)/2 + " points per hit.";
desc += " Wearing a second ring of force would enhance this.";
return desc;
} else
return super.desc();
}
public class Force extends RingBuff {
}
public class Force extends RingBuff {
}
}
@@ -1,28 +1,25 @@
package com.shatteredpixel.shatteredpixeldungeon.items.rings;
/**
* Created by debenhame on 10/09/2014.
*/
public class RingOfFuror extends Ring {
{
name = "Ring of Furor";
}
{
name = "Ring of Furor";
}
@Override
protected RingBuff buff( ) {
return new Furor();
}
@Override
protected RingBuff buff( ) {
return new Furor();
}
@Override
public String desc() {
return isKnown() ?
"This ring grants the wearer an inner fury, allowing them to attack more rapidly. " +
"This fury works best in large bursts, so slow weapons benefit far more than fast ones. " +
"A degraded ring will instead slow the wearer's speed of attack." :
super.desc();
}
@Override
public String desc() {
return isKnown() ?
"This ring grants the wearer an inner fury, allowing them to attack more rapidly. " +
"This fury works best in large bursts, so slow weapons benefit far more than fast ones. " +
"A degraded ring will instead slow the wearer's speed of attack." :
super.desc();
}
public class Furor extends RingBuff {
}
public class Furor extends RingBuff {
}
}
@@ -32,7 +32,7 @@ public class RingOfHaste extends Ring {
public String desc() {
return isKnown() ?
"This ring reduces the stress of movement on the wearer, allowing them to run " +
"at superhuman speeds. A degraded ring will instead weigh the wearer down.":
"at superhuman speeds. A degraded ring will instead weigh the wearer down.":
super.desc();
}
@@ -1,30 +1,27 @@
package com.shatteredpixel.shatteredpixeldungeon.items.rings;
/**
* Created by debenhame on 10/09/2014.
*/
public class RingOfMight extends Ring {
{
name = "Ring of Might";
}
{
name = "Ring of Might";
}
@Override
protected RingBuff buff( ) {
return new Might();
}
@Override
protected RingBuff buff( ) {
return new Might();
}
@Override
public String desc() {
return isKnown() ?
"This ring enhances the physical traits of the wearer, " +
"granting them greater physical strength and constitution. " +
"A degraded ring will weaken the wearer." :
super.desc();
}
@Override
public String desc() {
return isKnown() ?
"This ring enhances the physical traits of the wearer, " +
"granting them greater physical strength and constitution. " +
"A degraded ring will weaken the wearer." :
super.desc();
}
public class Might extends RingBuff {
}
public class Might extends RingBuff {
}
}
@@ -1,28 +1,25 @@
package com.shatteredpixel.shatteredpixeldungeon.items.rings;
/**
* Created by debenhame on 10/09/2014.
*/
public class RingOfSharpshooting extends Ring {
{
name = "Ring of Sharpshooting";
}
{
name = "Ring of Sharpshooting";
}
@Override
protected RingBuff buff( ) {
return new Aim();
}
@Override
protected RingBuff buff( ) {
return new Aim();
}
@Override
public String desc() {
return isKnown() ?
"This ring enhances the wearer's precision and aim, which will " +
"make all projectile weapons more accurate and durable. " +
"A degraded ring will have the opposite effect.":
super.desc();
}
@Override
public String desc() {
return isKnown() ?
"This ring enhances the wearer's precision and aim, which will " +
"make all projectile weapons more accurate and durable. " +
"A degraded ring will have the opposite effect.":
super.desc();
}
public class Aim extends RingBuff {
}
public class Aim extends RingBuff {
}
}
@@ -1,29 +1,26 @@
package com.shatteredpixel.shatteredpixeldungeon.items.rings;
/**
* Created by debenhame on 10/09/2014.
*/
public class RingOfTenacity extends Ring {
{
name = "Ring of Tenacity";
}
{
name = "Ring of Tenacity";
}
@Override
protected RingBuff buff( ) {
return new Tenacity();
}
@Override
protected RingBuff buff( ) {
return new Tenacity();
}
@Override
public String desc() {
return isKnown() ?
"When worn, this ring will allow the wearer to resist normally mortal strikes. " +
"The more injured the user is, the more resistant they will be to damage. " +
"A degraded ring will instead make it easier for enemies to execute the wearer." :
super.desc();
}
@Override
public String desc() {
return isKnown() ?
"When worn, this ring will allow the wearer to resist normally mortal strikes. " +
"The more injured the user is, the more resistant they will be to damage. " +
"A degraded ring will instead make it easier for enemies to execute the wearer." :
super.desc();
}
public class Tenacity extends RingBuff {
}
public class Tenacity extends RingBuff {
}
}
@@ -1,28 +1,25 @@
package com.shatteredpixel.shatteredpixeldungeon.items.rings;
/**
* Created by debenhame on 10/09/2014.
*/
public class RingOfWealth extends Ring {
{
name = "Ring of Wealth";
}
{
name = "Ring of Wealth";
}
@Override
protected RingBuff buff( ) {
return new Wealth();
}
@Override
protected RingBuff buff( ) {
return new Wealth();
}
@Override
public String desc() {
return isKnown() ?
"It's not clear what this ring does exactly, good luck may influence " +
"the life an an adventurer in many subtle ways. " +
"Naturally a degraded ring would give bad luck." :
super.desc();
}
@Override
public String desc() {
return isKnown() ?
"It's not clear what this ring does exactly, good luck may influence " +
"the life an an adventurer in many subtle ways. " +
"Naturally a degraded ring would give bad luck." :
super.desc();
}
public class Wealth extends RingBuff {
}
public class Wealth extends RingBuff {
}
}
@@ -30,7 +30,7 @@ public abstract class InventoryScroll extends Scroll {
protected String inventoryTitle = "Select an item";
protected WndBag.Mode mode = WndBag.Mode.ALL;
private static final String TXT_WARNING =
private static final String TXT_WARNING =
"Do you really want to cancel this scroll usage? " +
"It will be consumed anyway.";
private static final String TXT_YES = "Yes, I'm positive";
@@ -44,12 +44,12 @@ public abstract class Scroll extends Item {
protected String initials;
private static final Class<?>[] scrolls = {
ScrollOfIdentify.class,
ScrollOfMagicMapping.class,
ScrollOfRecharging.class,
ScrollOfRemoveCurse.class,
ScrollOfTeleportation.class,
ScrollOfUpgrade.class,
ScrollOfIdentify.class,
ScrollOfMagicMapping.class,
ScrollOfRecharging.class,
ScrollOfRemoveCurse.class,
ScrollOfTeleportation.class,
ScrollOfUpgrade.class,
ScrollOfRage.class,
ScrollOfTerror.class,
ScrollOfLullaby.class,
@@ -57,20 +57,20 @@ public abstract class Scroll extends Item {
ScrollOfPsionicBlast.class,
ScrollOfMirrorImage.class
};
private static final String[] runes =
private static final String[] runes =
{"KAUNAN", "SOWILO", "LAGUZ", "YNGVI", "GYFU", "RAIDO", "ISAZ", "MANNAZ", "NAUDIZ", "BERKANAN", "ODAL", "TIWAZ"};
private static final Integer[] images = {
ItemSpriteSheet.SCROLL_KAUNAN,
ItemSpriteSheet.SCROLL_SOWILO,
ItemSpriteSheet.SCROLL_LAGUZ,
ItemSpriteSheet.SCROLL_YNGVI,
ItemSpriteSheet.SCROLL_GYFU,
ItemSpriteSheet.SCROLL_RAIDO,
ItemSpriteSheet.SCROLL_ISAZ,
ItemSpriteSheet.SCROLL_MANNAZ,
ItemSpriteSheet.SCROLL_NAUDIZ,
ItemSpriteSheet.SCROLL_BERKANAN,
ItemSpriteSheet.SCROLL_ODAL,
ItemSpriteSheet.SCROLL_KAUNAN,
ItemSpriteSheet.SCROLL_SOWILO,
ItemSpriteSheet.SCROLL_LAGUZ,
ItemSpriteSheet.SCROLL_YNGVI,
ItemSpriteSheet.SCROLL_GYFU,
ItemSpriteSheet.SCROLL_RAIDO,
ItemSpriteSheet.SCROLL_ISAZ,
ItemSpriteSheet.SCROLL_MANNAZ,
ItemSpriteSheet.SCROLL_NAUDIZ,
ItemSpriteSheet.SCROLL_BERKANAN,
ItemSpriteSheet.SCROLL_ODAL,
ItemSpriteSheet.SCROLL_TIWAZ};
private static ItemStatusHandler<Scroll> handler;
@@ -80,7 +80,7 @@ public abstract class Scroll extends Item {
public boolean ownedByBook = false;
{
stackable = true;
stackable = true;
defaultAction = AC_READ;
}
@@ -103,11 +103,11 @@ public abstract class Scroll extends Item {
syncVisuals();
}
@Override
public void syncVisuals(){
image = handler.image( this );
rune = handler.label( this );
};
@Override
public void syncVisuals(){
image = handler.image( this );
rune = handler.label( this );
};
@Override
public ArrayList<String> actions( Hero hero ) {
@@ -32,7 +32,7 @@ public class ScrollOfIdentify extends InventoryScroll {
inventoryTitle = "Select an item to identify";
mode = WndBag.Mode.UNIDENTIFED;
bones = true;
bones = true;
}
@Override
@@ -45,11 +45,11 @@ public class ScrollOfLullaby extends Scroll {
for (Mob mob : Dungeon.level.mobs.toArray( new Mob[0] )) {
if (Level.fieldOfView[mob.pos]) {
Buff.affect( mob, Drowsy.class );
mob.sprite.centerEmitter().start( Speck.factory( Speck.NOTE ), 0.3f, 5 );
mob.sprite.centerEmitter().start( Speck.factory( Speck.NOTE ), 0.3f, 5 );
}
}
Buff.affect( curUser, Drowsy.class );
Buff.affect( curUser, Drowsy.class );
GLog.i( "The scroll utters a soothing melody. You feel very sleepy." );
@@ -37,7 +37,7 @@ public class ScrollOfMagicalInfusion extends InventoryScroll {
inventoryTitle = "Select an item to infuse";
mode = WndBag.Mode.ENCHANTABLE;
bones = true;
bones = true;
}
@Override
@@ -74,7 +74,7 @@ public class ScrollOfMirrorImage extends Scroll {
@Override
public String desc() {
return
return
"The incantation on this scroll will create illusionary twins of the reader, which will chase his enemies.";
}
}
@@ -38,7 +38,7 @@ public class ScrollOfPsionicBlast extends Scroll {
name = "Scroll of Psionic Blast";
initials = "PB";
bones = true;
bones = true;
}
@Override
@@ -56,7 +56,7 @@ public class ScrollOfPsionicBlast extends Scroll {
}
curUser.damage(Math.max(curUser.HT/5, curUser.HP/2), this);
Buff.prolong( curUser, Paralysis.class, Random.Int( 4, 6 ) );
Buff.prolong( curUser, Paralysis.class, Random.Int( 4, 6 ) );
Buff.prolong( curUser, Blindness.class, Random.Int( 6, 9 ) );
Dungeon.observe();
@@ -64,10 +64,10 @@ public class ScrollOfPsionicBlast extends Scroll {
curUser.spendAndNext( TIME_TO_READ );
if (!curUser.isAlive()) {
Dungeon.fail( Utils.format(ResultDescriptions.ITEM, name ));
GLog.n("The Psionic Blast tears your mind apart...");
}
if (!curUser.isAlive()) {
Dungeon.fail( Utils.format(ResultDescriptions.ITEM, name ));
GLog.n("The Psionic Blast tears your mind apart...");
}
}
@Override
@@ -40,12 +40,12 @@ public class ScrollOfRage extends Scroll {
@Override
protected void doRead() {
for (Mob mob : Dungeon.level.mobs.toArray( new Mob[0] )) {
mob.beckon( curUser.pos );
if (Level.fieldOfView[mob.pos]) {
Buff.prolong(mob, Amok.class, 5f);
}
}
for (Mob mob : Dungeon.level.mobs.toArray( new Mob[0] )) {
mob.beckon( curUser.pos );
if (Level.fieldOfView[mob.pos]) {
Buff.prolong(mob, Amok.class, 5f);
}
}
for (Heap heap : Dungeon.level.heaps.values()) {
if (heap.type == Heap.Type.MIMIC) {
@@ -60,7 +60,7 @@ public class ScrollOfRage extends Scroll {
GLog.w( "The scroll emits an enraging roar that echoes throughout the dungeon!" );
setKnown();
curUser.sprite.centerEmitter().start( Speck.factory( Speck.SCREAM ), 0.3f, 3 );
curUser.sprite.centerEmitter().start( Speck.factory( Speck.SCREAM ), 0.3f, 3 );
Sample.INSTANCE.play( Assets.SND_CHALLENGE );
Invisibility.dispel();
@@ -69,7 +69,7 @@ public class ScrollOfRage extends Scroll {
@Override
public String desc() {
return
return
"When read aloud, this scroll will unleash a great roar " +
"that draws all enemies to the reader, and enrages nearby ones.";
}
@@ -30,9 +30,9 @@ import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
public class ScrollOfRemoveCurse extends Scroll {
private static final String TXT_PROCCED =
private static final String TXT_PROCCED =
"Your pack glows with a cleansing light, and a malevolent energy disperses.";
private static final String TXT_NOT_PROCCED =
private static final String TXT_NOT_PROCCED =
"Your pack glows with a cleansing light, but nothing happens.";
{
@@ -47,19 +47,19 @@ public class ScrollOfRemoveCurse extends Scroll {
Sample.INSTANCE.play( Assets.SND_READ );
Invisibility.dispel();
boolean procced = uncurse( curUser, curUser.belongings.backpack.items.toArray( new Item[0] ) );
procced = uncurse( curUser,
curUser.belongings.weapon,
curUser.belongings.armor,
boolean procced = uncurse( curUser, curUser.belongings.backpack.items.toArray( new Item[0] ) );
procced = uncurse( curUser,
curUser.belongings.weapon,
curUser.belongings.armor,
curUser.belongings.misc1,
curUser.belongings.misc2) || procced;
Weakness.detach( curUser, Weakness.class );
if (procced) {
GLog.p( TXT_PROCCED );
} else {
GLog.i( TXT_NOT_PROCCED );
GLog.p( TXT_PROCCED );
} else {
GLog.i( TXT_NOT_PROCCED );
}
setKnown();
@@ -29,10 +29,10 @@ import com.watabou.noosa.tweeners.AlphaTweener;
public class ScrollOfTeleportation extends Scroll {
public static final String TXT_TELEPORTED =
public static final String TXT_TELEPORTED =
"In a blink of an eye you were teleported to another location of the level.";
public static final String TXT_NO_TELEPORT =
public static final String TXT_NO_TELEPORT =
"Strong magic aura of this place prevents you from teleporting!";
{
@@ -36,7 +36,7 @@ public class ScrollOfUpgrade extends InventoryScroll {
inventoryTitle = "Select an item to upgrade";
mode = WndBag.Mode.UPGRADEABLE;
bones = true;
bones = true;
}
@Override
@@ -62,7 +62,7 @@ public abstract class Wand extends Item {
public int maxCharges = initialCharges();
public int curCharges = maxCharges;
public float partialCharge = 0f;
public float partialCharge = 0f;
protected Charger charger;
@@ -128,10 +128,10 @@ public abstract class Wand extends Item {
charger.setScaleFactor( chargeScaleFactor );
}
@Override
public void onDetach( ) {
stopCharging();
}
@Override
public void onDetach( ) {
stopCharging();
}
public void stopCharging() {
if (charger != null) {
@@ -27,9 +27,6 @@ import com.watabou.utils.Callback;
import com.watabou.utils.PointF;
import com.watabou.utils.Random;
/**
* Created by debenhame on 05/05/2015.
*/
public class WandOfBlastWave extends Wand {
{
@@ -24,9 +24,6 @@ import com.watabou.utils.Random;
import java.util.Arrays;
import java.util.HashSet;
/**
* Created by Evan on 14/05/2015.
*/
//TODO: balancing
public class WandOfCorruption extends Wand {
@@ -19,9 +19,6 @@ import com.watabou.utils.Callback;
import com.watabou.utils.PointF;
import com.watabou.utils.Random;
/**
* Created by debenhame on 23/04/2015.
*/
public class WandOfFrost extends Wand {
{
@@ -32,132 +32,129 @@ import com.watabou.utils.Random;
import java.util.Arrays;
import java.util.HashSet;
/**
* Created by Evan on 10/04/2015.
*/
public class WandOfPrismaticLight extends Wand {
{
name = "Wand of Prismatic Light";
image = ItemSpriteSheet.WAND_PRISMATIC_LIGHT;
{
name = "Wand of Prismatic Light";
image = ItemSpriteSheet.WAND_PRISMATIC_LIGHT;
collisionProperties = Ballistica.MAGIC_BOLT;
}
collisionProperties = Ballistica.MAGIC_BOLT;
}
//FIXME: this is sloppy
private static HashSet<Class> evilMobs = new HashSet<Class>(Arrays.asList(
//Any Location
Mimic.class, Wraith.class,
//Sewers
Ghost.FetidRat.class,
Goo.class,
//Prison
Skeleton.class , Thief.class, Bandit.class,
//Caves
//FIXME: this is sloppy
private static HashSet<Class> evilMobs = new HashSet<Class>(Arrays.asList(
//Any Location
Mimic.class, Wraith.class,
//Sewers
Ghost.FetidRat.class,
Goo.class,
//Prison
Skeleton.class , Thief.class, Bandit.class,
//Caves
//City
Warlock.class, Monk.class, Senior.class,
King.class, King.Undead.class,
//Halls
Succubus.class, Eye.class, Scorpio.class, Acidic.class,
Yog.class, Yog.RottingFist.class, Yog.BurningFist.class, Yog.Larva.class
));
//City
Warlock.class, Monk.class, Senior.class,
King.class, King.Undead.class,
//Halls
Succubus.class, Eye.class, Scorpio.class, Acidic.class,
Yog.class, Yog.RottingFist.class, Yog.BurningFist.class, Yog.Larva.class
));
@Override
protected void onZap(Ballistica beam) {
Char ch = Actor.findChar(beam.collisionPos);
if (ch != null){
affectTarget(ch);
}
affectMap(beam);
@Override
protected void onZap(Ballistica beam) {
Char ch = Actor.findChar(beam.collisionPos);
if (ch != null){
affectTarget(ch);
}
affectMap(beam);
if (curUser.viewDistance < 4)
Buff.prolong( curUser, Light.class, 10f+level*5);
}
if (curUser.viewDistance < 4)
Buff.prolong( curUser, Light.class, 10f+level*5);
}
private void affectTarget(Char ch){
int dmg = Random.NormalIntRange(level, (int) (8+(level*(level/5f))));
private void affectTarget(Char ch){
int dmg = Random.NormalIntRange(level, (int) (8+(level*(level/5f))));
//three in (5+lvl) chance of failing
if (Random.Int(5+level) >= 3) {
Buff.prolong(ch, Blindness.class, 2f + (level * 0.34f));
ch.sprite.emitter().burst(Speck.factory(Speck.LIGHT), 6 );
}
//three in (5+lvl) chance of failing
if (Random.Int(5+level) >= 3) {
Buff.prolong(ch, Blindness.class, 2f + (level * 0.34f));
ch.sprite.emitter().burst(Speck.factory(Speck.LIGHT), 6 );
}
if (evilMobs.contains(ch.getClass())){
ch.sprite.emitter().start( ShadowParticle.UP, 0.05f, 10+level );
Sample.INSTANCE.play(Assets.SND_BURNING);
if (evilMobs.contains(ch.getClass())){
ch.sprite.emitter().start( ShadowParticle.UP, 0.05f, 10+level );
Sample.INSTANCE.play(Assets.SND_BURNING);
ch.damage((int)(dmg*1.5), this);
} else {
ch.sprite.centerEmitter().burst( RainbowParticle.BURST, 10+level );
ch.damage((int)(dmg*1.5), this);
} else {
ch.sprite.centerEmitter().burst( RainbowParticle.BURST, 10+level );
ch.damage(dmg, this);
}
ch.damage(dmg, this);
}
}
}
private void affectMap(Ballistica beam){
boolean noticed = false;
for (int c: beam.subPath(0, beam.dist)){
for (int n : Level.NEIGHBOURS9DIST2){
int cell = c+n;
if (!Level.insideMap(cell))
continue;
private void affectMap(Ballistica beam){
boolean noticed = false;
for (int c: beam.subPath(0, beam.dist)){
for (int n : Level.NEIGHBOURS9DIST2){
int cell = c+n;
if (!Level.insideMap(cell))
continue;
if (Level.discoverable[cell])
Dungeon.level.mapped[cell] = true;
if (Level.discoverable[cell])
Dungeon.level.mapped[cell] = true;
int terr = Dungeon.level.map[cell];
if ((Terrain.flags[terr] & Terrain.SECRET) != 0) {
int terr = Dungeon.level.map[cell];
if ((Terrain.flags[terr] & Terrain.SECRET) != 0) {
Dungeon.level.discover( cell );
Dungeon.level.discover( cell );
GameScene.discoverTile( cell, terr );
ScrollOfMagicMapping.discover(cell);
GameScene.discoverTile( cell, terr );
ScrollOfMagicMapping.discover(cell);
noticed = true;
}
}
noticed = true;
}
}
CellEmitter.center(c).burst( RainbowParticle.BURST, Random.IntRange( 1, 2 ) );
}
if (noticed)
Sample.INSTANCE.play( Assets.SND_SECRET );
CellEmitter.center(c).burst( RainbowParticle.BURST, Random.IntRange( 1, 2 ) );
}
if (noticed)
Sample.INSTANCE.play( Assets.SND_SECRET );
Dungeon.observe();
}
Dungeon.observe();
}
@Override
protected void fx( Ballistica beam, Callback callback ) {
curUser.sprite.parent.add(
new Beam.LightRay(curUser.sprite.center(), DungeonTilemap.tileCenterToWorld(beam.collisionPos)));
callback.call();
}
@Override
protected void fx( Ballistica beam, Callback callback ) {
curUser.sprite.parent.add(
new Beam.LightRay(curUser.sprite.center(), DungeonTilemap.tileCenterToWorld(beam.collisionPos)));
callback.call();
}
@Override
public void onHit(MagesStaff staff, Char attacker, Char defender, int damage) {
//cripples enemy
Buff.prolong( defender, Cripple.class, 1f+staff.level);
}
@Override
public void onHit(MagesStaff staff, Char attacker, Char defender, int damage) {
//cripples enemy
Buff.prolong( defender, Cripple.class, 1f+staff.level);
}
@Override
public void staffFx(MagesStaff.StaffParticle particle) {
particle.color( Random.Int( 0x1000000 ) );
particle.am = 0.3f;
particle.setLifespan(1f);
particle.speed.polar(Random.Float(PointF.PI2), 2f);
particle.setSize( 1f, 2.5f);
particle.radiateXY(1f);
}
@Override
public void staffFx(MagesStaff.StaffParticle particle) {
particle.color( Random.Int( 0x1000000 ) );
particle.am = 0.3f;
particle.setLifespan(1f);
particle.speed.polar(Random.Float(PointF.PI2), 2f);
particle.setSize( 1f, 2.5f);
particle.radiateXY(1f);
}
@Override
public String desc() {
return
"This wand is made of a solid piece of translucent crystal, like a long chunk of smooth glass. " +
"It becomes clear towards the tip, where you can see colorful lights dancing around inside it.\n\n" +
"This wand shoots rays of light which damage and blind enemies and cut through the darkness of the dungeon, " +
"revealing hidden areas and traps. Evildoers, demons, and the undead will burn in the bright light " +
"of the wand, taking significant bonus damage.";
}
@Override
public String desc() {
return
"This wand is made of a solid piece of translucent crystal, like a long chunk of smooth glass. " +
"It becomes clear towards the tip, where you can see colorful lights dancing around inside it.\n\n" +
"This wand shoots rays of light which damage and blind enemies and cut through the darkness of the dungeon, " +
"revealing hidden areas and traps. Evildoers, demons, and the undead will burn in the bright light " +
"of the wand, taking significant bonus damage.";
}
}
@@ -39,9 +39,6 @@ import com.watabou.utils.Random;
import java.util.Arrays;
import java.util.HashSet;
/**
* Created by debenhame on 13/05/2015.
*/
public class WandOfTransfusion extends Wand {
{
@@ -13,51 +13,48 @@ import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.watabou.noosa.audio.Sample;
import com.watabou.utils.Callback;
/**
* Created by Evan on 12/04/2015.
*/
public class WandOfVenom extends Wand {
{
name = "Wand of Venom";
image = ItemSpriteSheet.WAND_VENOM;
{
name = "Wand of Venom";
image = ItemSpriteSheet.WAND_VENOM;
collisionProperties = Ballistica.STOP_TARGET | Ballistica.STOP_TERRAIN;
}
collisionProperties = Ballistica.STOP_TARGET | Ballistica.STOP_TERRAIN;
}
@Override
protected void onZap(Ballistica bolt) {
Blob venomGas = Blob.seed(bolt.collisionPos, 50 + 10 * level, VenomGas.class);
((VenomGas)venomGas).setStrength(level+1);
GameScene.add(venomGas);
}
@Override
protected void onZap(Ballistica bolt) {
Blob venomGas = Blob.seed(bolt.collisionPos, 50 + 10 * level, VenomGas.class);
((VenomGas)venomGas).setStrength(level+1);
GameScene.add(venomGas);
}
@Override
protected void fx(Ballistica bolt, Callback callback) {
MagicMissile.poison(curUser.sprite.parent, bolt.sourcePos, bolt.collisionPos, callback);
Sample.INSTANCE.play(Assets.SND_ZAP);
}
@Override
protected void fx(Ballistica bolt, Callback callback) {
MagicMissile.poison(curUser.sprite.parent, bolt.sourcePos, bolt.collisionPos, callback);
Sample.INSTANCE.play(Assets.SND_ZAP);
}
@Override
public void onHit(MagesStaff staff, Char attacker, Char defender, int damage) {
new Poison().proc(staff, attacker, defender, damage);
}
@Override
public void onHit(MagesStaff staff, Char attacker, Char defender, int damage) {
new Poison().proc(staff, attacker, defender, damage);
}
@Override
public void staffFx(MagesStaff.StaffParticle particle) {
particle.color( 0x8844FF ); particle.am = 0.6f;
particle.setLifespan(0.6f);
particle.acc.set(0, 40);
particle.setSize( 0f, 3f);
particle.shuffleXY(2f);
}
@Override
public void staffFx(MagesStaff.StaffParticle particle) {
particle.color( 0x8844FF ); particle.am = 0.6f;
particle.setLifespan(0.6f);
particle.acc.set(0, 40);
particle.setSize( 0f, 3f);
particle.shuffleXY(2f);
}
@Override
public String desc() {
return
"This wand has a purple body which opens to a brilliant green gem. " +
"A small amount of foul smelling gas leaks from the gem.\n\n" +
"This wand shoots a bolt which explodes into a cloud of vile venomous gas at a targeted location. " +
"Anything caught inside this cloud will take continual damage, increasing with time.";
}
@Override
public String desc() {
return
"This wand has a purple body which opens to a brilliant green gem. " +
"A small amount of foul smelling gas leaks from the gem.\n\n" +
"This wand shoots a bolt which explodes into a cloud of vile venomous gas at a targeted location. " +
"Anything caught inside this cloud will take continual damage, increasing with time.";
}
}
@@ -42,7 +42,7 @@ public class Weapon extends KindOfWeapon {
private static final String TXT_IDENTIFY =
"You are now familiar enough with your %s to identify it. It is %s.";
private static final String TXT_INCOMPATIBLE =
private static final String TXT_INCOMPATIBLE =
"Interaction of different types of magic has negated the enchantment on this weapon!";
private static final String TXT_TO_STRING = "%s :%d";
@@ -50,10 +50,10 @@ public class Weapon extends KindOfWeapon {
public float ACU = 1; // Accuracy modifier
public float DLY = 1f; // Speed modifier
public enum Imbue {
NONE, LIGHT, HEAVY
}
public Imbue imbue = Imbue.NONE;
public enum Imbue {
NONE, LIGHT, HEAVY
}
public Imbue imbue = Imbue.NONE;
private int hitsToKnow = HITS_TO_KNOW;
@@ -84,7 +84,7 @@ public class Weapon extends KindOfWeapon {
super.storeInBundle( bundle );
bundle.put( UNFAMILIRIARITY, hitsToKnow );
bundle.put( ENCHANTMENT, enchantment );
bundle.put( IMBUE, imbue );
bundle.put( IMBUE, imbue );
}
@Override
@@ -94,7 +94,7 @@ public class Weapon extends KindOfWeapon {
hitsToKnow = HITS_TO_KNOW;
}
enchantment = (Enchantment)bundle.get( ENCHANTMENT );
imbue = bundle.getEnum( IMBUE, Imbue.class );
imbue = bundle.getEnum( IMBUE, Imbue.class );
}
@Override
@@ -102,7 +102,7 @@ public class Weapon extends KindOfWeapon {
int encumbrance = STR - hero.STR();
float ACU = this.ACU;
float ACU = this.ACU;
if (this instanceof MissileWeapon) {
switch (hero.heroClass) {
@@ -114,14 +114,14 @@ public class Weapon extends KindOfWeapon {
break;
default:
}
int bonus = 0;
for (Buff buff : hero.buffs(RingOfSharpshooting.Aim.class)) {
bonus += ((RingOfSharpshooting.Aim)buff).level;
}
ACU *= (float)(Math.pow(1.1, bonus));
int bonus = 0;
for (Buff buff : hero.buffs(RingOfSharpshooting.Aim.class)) {
bonus += ((RingOfSharpshooting.Aim)buff).level;
}
ACU *= (float)(Math.pow(1.1, bonus));
}
return encumbrance > 0 ? (float)(ACU / Math.pow( 1.5, encumbrance )) : ACU;
return encumbrance > 0 ? (float)(ACU / Math.pow( 1.5, encumbrance )) : ACU;
}
@Override
@@ -132,17 +132,17 @@ public class Weapon extends KindOfWeapon {
encumrance -= 2;
}
float DLY = this.DLY * (imbue == Imbue.LIGHT ? 0.667f : (imbue == Imbue.HEAVY ? 1.667f : 1.0f));
float DLY = this.DLY * (imbue == Imbue.LIGHT ? 0.667f : (imbue == Imbue.HEAVY ? 1.667f : 1.0f));
int bonus = 0;
for (Buff buff : hero.buffs(RingOfFuror.Furor.class)) {
bonus += ((RingOfFuror.Furor)buff).level;
}
int bonus = 0;
for (Buff buff : hero.buffs(RingOfFuror.Furor.class)) {
bonus += ((RingOfFuror.Furor)buff).level;
}
DLY = (float)(0.25 + (DLY - 0.25)*Math.pow(0.8, bonus));
DLY = (float)(0.25 + (DLY - 0.25)*Math.pow(0.8, bonus));
return
(encumrance > 0 ? (float)(DLY * Math.pow( 1.2, encumrance )) : DLY);
return
(encumrance > 0 ? (float)(DLY * Math.pow( 1.2, encumrance )) : DLY);
}
@Override
@@ -160,7 +160,7 @@ public class Weapon extends KindOfWeapon {
return Math.round(damage * (imbue == Imbue.LIGHT ? 0.7f : (imbue == Imbue.HEAVY ? 1.5f : 1f)));
}
public Item upgrade( boolean enchant ) {
public Item upgrade( boolean enchant ) {
if (enchantment != null) {
if (!enchant && Random.Int( level ) > 0) {
GLog.w( TXT_INCOMPATIBLE );
@@ -233,8 +233,8 @@ public class Weapon extends KindOfWeapon {
//FIXME: most enchantment names are pretty broken, should refactor
public static abstract class Enchantment implements Bundlable {
private static final Class<?>[] enchants = new Class<?>[]{
Fire.class, Poison.class, Death.class, Paralysis.class, Leech.class,
private static final Class<?>[] enchants = new Class<?>[]{
Fire.class, Poison.class, Death.class, Paralysis.class, Leech.class,
Slow.class, Shock.class, Instability.class, Horror.class, Luck.class };
private static final float[] chances= new float[]{ 10, 10, 1, 2, 1, 2, 6, 3, 2, 2 };
@@ -245,11 +245,11 @@ public class Weapon extends KindOfWeapon {
}
@Override
public void restoreFromBundle( Bundle bundle ) {
public void restoreFromBundle( Bundle bundle ) {
}
@Override
public void storeInBundle( Bundle bundle ) {
public void storeInBundle( Bundle bundle ) {
}
public ItemSprite.Glowing glowing() {
@@ -42,9 +42,9 @@ public class Horror extends Weapon.Enchantment {
if (Random.Int( level + 5 ) >= 4) {
if (defender == Dungeon.hero) {
Buff.affect( defender, Vertigo.class, Vertigo.duration(defender) );
} else {
if (defender == Dungeon.hero) {
Buff.affect( defender, Vertigo.class, Vertigo.duration(defender) );
} else {
Buff.affect( defender, Terror.class, Terror.DURATION ).object = attacker.id();
}
@@ -25,9 +25,6 @@ import com.watabou.utils.Random;
import java.util.ArrayList;
/**
* Created by debenhame on 13/03/2015.
*/
public class MagesStaff extends MeleeWeapon {
private Wand wand;
@@ -61,8 +58,8 @@ public class MagesStaff extends MeleeWeapon {
public MagesStaff(Wand wand){
this();
wand.identify();
wand.cursed = false;
wand.identify();
wand.cursed = false;
this.wand = wand;
wand.maxCharges = Math.min(wand.maxCharges + 1, 10);
wand.curCharges = wand.maxCharges;
@@ -55,7 +55,7 @@ public class MeleeWeapon extends Weapon {
}
public Item upgrade( boolean enchant ) {
STR--;
STR--;
MIN++;
MAX += tier;
@@ -67,7 +67,7 @@ public class MeleeWeapon extends Weapon {
}
@Override
public Item degrade() {
public Item degrade() {
STR++;
MIN--;
MAX -= tier;
@@ -92,10 +92,10 @@ public class MeleeWeapon extends Weapon {
if (levelKnown) {
info.append( "Its average damage is " +
Math.round((MIN + (MAX - MIN) / 2)*(imbue == Imbue.LIGHT ? 0.75f : (imbue == Imbue.HEAVY ? 1.5f : 1)))
+ " points per hit. " );
Math.round((MIN + (MAX - MIN) / 2)*(imbue == Imbue.LIGHT ? 0.75f : (imbue == Imbue.HEAVY ? 1.5f : 1)))
+ " points per hit. " );
} else {
info.append(
info.append(
"Its typical average damage is " + (min() + (max() - min()) / 2) + " points per hit " +
"and usually it requires " + typicalSTR() + " points of strength. " );
if (typicalSTR() > Dungeon.hero.STR()) {
@@ -116,16 +116,16 @@ public class MeleeWeapon extends Weapon {
info.append( " weapon. ");
} else if (ACU != 1f) {
info.append( "This is a rather " + (ACU > 1f ? "accurate" : "inaccurate") + " weapon. " );
}
switch (imbue) {
case LIGHT:
info.append( "It was balanced to be lighter. " );
break;
case HEAVY:
info.append( "It was balanced to be heavier. " );
break;
case NONE:
}
}
switch (imbue) {
case LIGHT:
info.append( "It was balanced to be lighter. " );
break;
case HEAVY:
info.append( "It was balanced to be heavier. " );
break;
case NONE:
}
if (enchantment != null) {
info.append( "It is enchanted." );
@@ -134,13 +134,13 @@ public class MeleeWeapon extends Weapon {
if (levelKnown && Dungeon.hero.belongings.backpack.items.contains( this )) {
if (STR > Dungeon.hero.STR()) {
info.append( p );
info.append(
info.append(
"Because of your inadequate strength the accuracy and speed " +
"of your attack with this " + name + " is decreased." );
}
if (STR < Dungeon.hero.STR()) {
info.append( p );
info.append(
info.append(
"Because of your excess strength the damage " +
"of your attack with this " + name + " is increased." );
}
@@ -148,8 +148,8 @@ public class MeleeWeapon extends Weapon {
if (isEquipped( Dungeon.hero )) {
info.append( p );
info.append( "You hold the " + name + " at the ready" +
(cursed ? ", and because it is cursed, you are powerless to let go." : ".") );
info.append( "You hold the " + name + " at the ready" +
(cursed ? ", and because it is cursed, you are powerless to let go." : ".") );
} else {
if (cursedKnown && cursed) {
info.append( p );
@@ -37,9 +37,9 @@ public class ShortSword extends MeleeWeapon {
private static final String TXT_SELECT_WEAPON = "Select a weapon to upgrade";
private static final String TXT_REFORGED =
private static final String TXT_REFORGED =
"you reforged the short sword to upgrade your %s";
private static final String TXT_NOT_BOOMERANG =
private static final String TXT_NOT_BOOMERANG =
"you can't upgrade a boomerang this way";
private static final float TIME_TO_REFORGE = 2f;
@@ -51,7 +51,7 @@ public class ShortSword extends MeleeWeapon {
image = ItemSpriteSheet.SHORT_SWORD;
unique = true;
bones = false;
bones = false;
}
public ShortSword() {
@@ -95,7 +95,7 @@ public class ShortSword extends MeleeWeapon {
@Override
public String desc() {
return
return
"It is indeed quite short, just a few inches longer, than a dagger.";
}
@@ -32,7 +32,7 @@ public class WarHammer extends MeleeWeapon {
@Override
public String desc() {
return
return
"Few creatures can withstand the crushing blow of this towering mass of lead and steel, " +
"but only the strongest of adventurers can use it effectively.";
}
@@ -37,8 +37,8 @@ public class Boomerang extends MissileWeapon {
stackable = false;
unique = true;
bones = false;
unique = true;
bones = false;
}
@Override
@@ -69,56 +69,56 @@ public class Boomerang extends MissileWeapon {
return super.degrade();
}
@Override
public void proc( Char attacker, Char defender, int damage ) {
super.proc( attacker, defender, damage );
if (attacker instanceof Hero && ((Hero)attacker).rangedWeapon == this) {
circleBack( defender.pos, (Hero)attacker );
}
}
@Override
public void proc( Char attacker, Char defender, int damage ) {
super.proc( attacker, defender, damage );
if (attacker instanceof Hero && ((Hero)attacker).rangedWeapon == this) {
circleBack( defender.pos, (Hero)attacker );
}
}
@Override
protected void miss( int cell ) {
circleBack( cell, curUser );
}
@Override
protected void miss( int cell ) {
circleBack( cell, curUser );
}
private void circleBack( int from, Hero owner ) {
private void circleBack( int from, Hero owner ) {
((MissileSprite)curUser.sprite.parent.recycle( MissileSprite.class )).
reset( from, curUser.pos, curItem, null );
((MissileSprite)curUser.sprite.parent.recycle( MissileSprite.class )).
reset( from, curUser.pos, curItem, null );
if (throwEquiped) {
owner.belongings.weapon = this;
owner.spend( -TIME_TO_EQUIP );
if (throwEquiped) {
owner.belongings.weapon = this;
owner.spend( -TIME_TO_EQUIP );
Dungeon.quickslot.replaceSimilar(this);
updateQuickslot();
} else
if (!collect( curUser.belongings.backpack )) {
Dungeon.level.drop( this, owner.pos ).sprite.drop();
}
}
} else
if (!collect( curUser.belongings.backpack )) {
Dungeon.level.drop( this, owner.pos ).sprite.drop();
}
}
private boolean throwEquiped;
private boolean throwEquiped;
@Override
public void cast( Hero user, int dst ) {
throwEquiped = isEquipped( user );
super.cast( user, dst );
}
@Override
public void cast( Hero user, int dst ) {
throwEquiped = isEquipped( user );
super.cast( user, dst );
}
@Override
public String desc() {
String info =
"Thrown to the enemy this flat curved wooden missile will return to the hands of its thrower.";
switch (imbue) {
case LIGHT:
info += "\n\nIt was balanced to be lighter. ";
break;
case HEAVY:
info += "\n\nIt was balanced to be heavier. ";
break;
case NONE:
}
return info;
switch (imbue) {
case LIGHT:
info += "\n\nIt was balanced to be lighter. ";
break;
case HEAVY:
info += "\n\nIt was balanced to be heavier. ";
break;
case NONE:
}
return info;
}
}
@@ -55,7 +55,7 @@ public class CurareDart extends MissileWeapon {
@Override
public String desc() {
return
return
"These little evil darts don't do much damage but they can paralyze " +
"the target leaving it helpless and motionless for some time.";
}

Some files were not shown because too many files have changed in this diff Show More