V0.1.0 Partial Commit

changed package and application names to differentiate from main PD
release
This commit is contained in:
Evan Debenham
2014-08-03 14:46:22 -04:00
parent 65dd9c2dc0
commit aed303672a
474 changed files with 3468 additions and 3458 deletions
@@ -0,0 +1,287 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.potions;
import java.util.ArrayList;
import java.util.HashSet;
import com.watabou.noosa.audio.Sample;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.effects.Splash;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.ItemStatusHandler;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions;
import com.watabou.utils.Bundle;
public class Potion extends Item {
public static final String AC_DRINK = "DRINK";
private static final String TXT_HARMFUL = "Harmful potion!";
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 =
"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 =
"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;
private static final Class<?>[] potions = {
PotionOfHealing.class,
PotionOfExperience.class,
PotionOfToxicGas.class,
PotionOfLiquidFlame.class,
PotionOfStrength.class,
PotionOfParalyticGas.class,
PotionOfLevitation.class,
PotionOfMindVision.class,
PotionOfPurity.class,
PotionOfInvisibility.class,
PotionOfMight.class,
PotionOfFrost.class
};
private static final String[] colors = {
"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_SILVER};
private static ItemStatusHandler<Potion> handler;
private String color;
{
stackable = true;
defaultAction = AC_DRINK;
}
@SuppressWarnings("unchecked")
public static void initColors() {
handler = new ItemStatusHandler<Potion>( (Class<? extends Potion>[])potions, colors, images );
}
public static void save( Bundle bundle ) {
handler.save( bundle );
}
@SuppressWarnings("unchecked")
public static void restore( Bundle bundle ) {
handler = new ItemStatusHandler<Potion>( (Class<? extends Potion>[])potions, colors, images, bundle );
}
public Potion() {
super();
image = handler.image( this );
color = handler.label( this );
}
@Override
public ArrayList<String> actions( Hero hero ) {
ArrayList<String> actions = super.actions( hero );
actions.add( AC_DRINK );
return actions;
}
@Override
public void execute( final Hero hero, String action ) {
if (action.equals( AC_DRINK )) {
if (isKnown() && (
this instanceof PotionOfLiquidFlame ||
this instanceof PotionOfToxicGas ||
this instanceof PotionOfParalyticGas)) {
GameScene.show(
new WndOptions( TXT_HARMFUL, TXT_R_U_SURE_DRINK, TXT_YES, TXT_NO ) {
@Override
protected void onSelect(int index) {
if (index == 0) {
drink( hero );
}
};
}
);
} else {
drink( hero );
}
} else {
super.execute( hero, action );
}
}
@Override
public void doThrow( final Hero hero ) {
if (isKnown() && (
this instanceof PotionOfExperience ||
this instanceof PotionOfHealing ||
this instanceof PotionOfLevitation ||
this instanceof PotionOfMindVision ||
this instanceof PotionOfStrength ||
this instanceof PotionOfInvisibility ||
this instanceof PotionOfMight)) {
GameScene.show(
new WndOptions( TXT_BENEFICIAL, TXT_R_U_SURE_THROW, TXT_YES, TXT_NO ) {
@Override
protected void onSelect(int index) {
if (index == 0) {
Potion.super.doThrow( hero );
}
};
}
);
} else {
super.doThrow( hero );
}
}
protected void drink( Hero hero ) {
detach( hero.belongings.backpack );
hero.spend( TIME_TO_DRINK );
hero.busy();
onThrow( hero.pos );
Sample.INSTANCE.play( Assets.SND_DRINK );
hero.sprite.operate( hero.pos );
}
@Override
protected void onThrow( int cell ) {
if (Dungeon.hero.pos == cell) {
apply( Dungeon.hero );
} else if (Dungeon.level.map[cell] == Terrain.WELL || Level.pit[cell]) {
super.onThrow( cell );
} else {
shatter( cell );
}
}
protected void apply( Hero hero ) {
shatter( hero.pos );
}
protected void shatter( int cell ) {
GLog.i( "The flask shatters and " + color() + " liquid splashes harmlessly" );
Sample.INSTANCE.play( Assets.SND_SHATTER );
splash( cell );
}
public boolean isKnown() {
return handler.isKnown( this );
}
public void setKnown() {
if (!isKnown()) {
handler.know( this );
}
Badges.validateAllPotionsIdentified();
}
@Override
public Item identify() {
setKnown();
return this;
}
protected String color() {
return color;
}
@Override
public String name() {
return isKnown() ? name : color + " potion";
}
@Override
public String info() {
return isKnown() ?
desc() :
"This flask contains a swirling " + color + " liquid. " +
"Who knows what it will do when drunk or thrown?";
}
@Override
public boolean isIdentified() {
return isKnown();
}
@Override
public boolean isUpgradable() {
return false;
}
public static HashSet<Class<? extends Potion>> getKnown() {
return handler.known();
}
public static HashSet<Class<? extends Potion>> getUnknown() {
return handler.unknown();
}
public static boolean allKnown() {
return handler.known().size() == potions.length;
}
protected void splash( int cell ) {
final int color = ItemSprite.pick( image, 8, 10 );
Splash.at( cell, color, 5 );
}
@Override
public int price() {
return 20 * quantity;
}
}
@@ -0,0 +1,45 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.potions;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
public class PotionOfExperience extends Potion {
{
name = "Potion of Experience";
}
@Override
protected void apply( Hero hero ) {
setKnown();
hero.earnExp( hero.maxExp() - hero.exp );
}
@Override
public String desc() {
return
"The storied experiences of multitudes of battles reduced to liquid form, " +
"this draught will instantly raise your experience level.";
}
@Override
public int price() {
return isKnown() ? 80 * quantity : super.price();
}
}
@@ -0,0 +1,67 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.potions;
import com.watabou.noosa.audio.Sample;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Fire;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Freezing;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.utils.BArray;
import com.watabou.utils.PathFinder;
public class PotionOfFrost extends Potion {
private static final int DISTANCE = 2;
{
name = "Potion of Frost";
}
@Override
protected void shatter( int cell ) {
PathFinder.buildDistanceMap( cell, BArray.not( Level.losBlocking, null ), DISTANCE );
Fire fire = (Fire)Dungeon.level.blobs.get( Fire.class );
for (int i=0; i < Level.LENGTH; i++) {
if (PathFinder.distance[i] < Integer.MAX_VALUE) {
Freezing.affect( i, fire );
}
}
splash( cell );
Sample.INSTANCE.play( Assets.SND_SHATTER );
setKnown();
}
@Override
public String desc() {
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.";
}
@Override
public int price() {
return isKnown() ? 50 * quantity : super.price();
}
}
@@ -0,0 +1,64 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.potions;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Bleeding;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Cripple;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Poison;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Weakness;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
public class PotionOfHealing extends Potion {
{
name = "Potion of Healing";
}
@Override
protected void apply( Hero hero ) {
setKnown();
heal( Dungeon.hero );
GLog.p( "Your wounds heal completely." );
}
public static void heal( Hero hero ) {
hero.HP = hero.HT;
Buff.detach( hero, Poison.class );
Buff.detach( hero, Cripple.class );
Buff.detach( hero, Weakness.class );
Buff.detach( hero, Bleeding.class );
hero.sprite.emitter().start( Speck.factory( Speck.HEALING ), 0.4f, 4 );
}
@Override
public String desc() {
return
"An elixir that will instantly return you to full health and cure poison.";
}
@Override
public int price() {
return isKnown() ? 30 * quantity : super.price();
}
}
@@ -0,0 +1,65 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.potions;
import com.watabou.noosa.audio.Sample;
import com.watabou.noosa.tweeners.AlphaTweener;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Invisibility;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
public class PotionOfInvisibility extends Potion {
private static final float ALPHA = 0.4f;
{
name = "Potion of Invisibility";
}
@Override
protected void apply( Hero hero ) {
setKnown();
Buff.affect( hero, Invisibility.class, Invisibility.DURATION );
GLog.i( "You see your hands turn invisible!" );
Sample.INSTANCE.play( Assets.SND_MELD );
}
@Override
public String desc() {
return
"Drinking this potion will render you temporarily invisible. While invisible, " +
"enemies will be unable to see you. Attacking an enemy, as well as using a wand or a scroll " +
"before enemy's eyes, will dispel the effect.";
}
@Override
public int price() {
return isKnown() ? 40 * quantity : super.price();
}
public static void melt( Char ch ) {
if (ch.sprite.parent != null) {
ch.sprite.parent.add( new AlphaTweener( ch.sprite, ALPHA, 0.4f ) );
} else {
ch.sprite.alpha( ALPHA );
}
}
}
@@ -0,0 +1,50 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.potions;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Levitation;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
public class PotionOfLevitation extends Potion {
{
name = "Potion of Levitation";
}
@Override
protected void apply( Hero hero ) {
setKnown();
Buff.affect( hero, Levitation.class, Levitation.DURATION );
GLog.i( "You float into the air!" );
}
@Override
public String desc() {
return
"Drinking this curious liquid will cause you to hover in the air, " +
"able to drift effortlessly over traps. Flames and gases " +
"fill the air, however, and cannot be bypassed while airborne.";
}
@Override
public int price() {
return isKnown() ? 35 * quantity : super.price();
}
}
@@ -0,0 +1,55 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.potions;
import com.watabou.noosa.audio.Sample;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Fire;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
public class PotionOfLiquidFlame extends Potion {
{
name = "Potion of Liquid Flame";
}
@Override
protected void shatter( int cell ) {
setKnown();
splash( cell );
Sample.INSTANCE.play( Assets.SND_SHATTER );
Fire fire = Blob.seed( cell, 2, Fire.class );
GameScene.add( fire );
}
@Override
public String desc() {
return
"This flask contains an unstable compound which will burst " +
"violently into flame upon exposure to open air.";
}
@Override
public int price() {
return isKnown() ? 40 * quantity : super.price();
}
}
@@ -0,0 +1,52 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.potions;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
public class PotionOfMight extends PotionOfStrength {
{
name = "Potion of Might";
}
@Override
protected void apply( Hero hero ) {
setKnown();
hero.STR++;
hero.HT += 5;
hero.HP += 5;
hero.sprite.showStatus( CharSprite.POSITIVE, "+1 str, +5 ht" );
GLog.p( "Newfound strength surges through your body." );
}
@Override
public String desc() {
return
"This powerful liquid will course through your muscles, permanently " +
"increasing your strength by one point and health by five points.";
}
@Override
public int price() {
return isKnown() ? 200 * quantity : super.price();
}
}
@@ -0,0 +1,57 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.potions;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.MindVision;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
public class PotionOfMindVision extends Potion {
{
name = "Potion of Mind Vision";
}
@Override
protected void apply( Hero hero ) {
setKnown();
Buff.affect( hero, MindVision.class, MindVision.DURATION );
Dungeon.observe();
if (Dungeon.level.mobs.size() > 0) {
GLog.i( "You can somehow feel the presence of other creatures' minds!" );
} else {
GLog.i( "You can somehow tell that you are alone on this level at the moment." );
}
}
@Override
public String desc() {
return
"After drinking this, your mind will become attuned to the psychic signature " +
"of distant creatures, enabling you to sense biological presences through walls. " +
"Also this potion will permit you to see through nearby walls and doors.";
}
@Override
public int price() {
return isKnown() ? 35 * quantity : super.price();
}
}
@@ -0,0 +1,56 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.potions;
import com.watabou.noosa.audio.Sample;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.ParalyticGas;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
public class PotionOfParalyticGas extends Potion {
{
name = "Potion of Paralytic Gas";
}
@Override
protected void shatter( int cell ) {
setKnown();
splash( cell );
Sample.INSTANCE.play( Assets.SND_SHATTER );
GameScene.add( Blob.seed( cell, 1000, ParalyticGas.class ) );
}
@Override
public String desc() {
return
"Upon exposure to open air, the liquid in this flask will vaporize " +
"into a numbing yellow haze. Anyone who inhales the cloud will be paralyzed " +
"instantly, unable to move for some time after the cloud dissipates. This " +
"item can be thrown at distant enemies to catch them within the effect of the gas.";
}
@Override
public int price() {
return isKnown() ? 40 * quantity : super.price();
}
}
@@ -0,0 +1,126 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.potions;
import com.watabou.noosa.audio.Sample;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.ParalyticGas;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.ToxicGas;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.GasesImmunity;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.utils.BArray;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.watabou.utils.PathFinder;
public class PotionOfPurity extends Potion {
private static final String TXT_FRESHNESS = "You feel uncommon freshness in the air.";
private static final String TXT_NO_SMELL = "You've stopped sensing any smells!";
private static final int DISTANCE = 2;
{
name = "Potion of Purification";
}
@Override
protected void shatter( int cell ) {
PathFinder.buildDistanceMap( cell, BArray.not( Level.losBlocking, null ), DISTANCE );
boolean procd = false;
Blob[] blobs = {
Dungeon.level.blobs.get( ToxicGas.class ),
Dungeon.level.blobs.get( ParalyticGas.class )
};
for (int j=0; j < blobs.length; j++) {
Blob blob = blobs[j];
if (blob == null) {
continue;
}
for (int i=0; i < Level.LENGTH; i++) {
if (PathFinder.distance[i] < Integer.MAX_VALUE) {
int value = blob.cur[i];
if (value > 0) {
blob.cur[i] = 0;
blob.volume -= value;
procd = true;
CellEmitter.get( i ).burst( Speck.factory( Speck.DISCOVER ), 1 );
}
}
}
}
boolean heroAffected = PathFinder.distance[Dungeon.hero.pos] < Integer.MAX_VALUE;
if (procd) {
splash( cell );
Sample.INSTANCE.play( Assets.SND_SHATTER );
setKnown();
if (heroAffected) {
GLog.p( TXT_FRESHNESS );
}
} else {
super.shatter( cell );
if (heroAffected) {
GLog.i( TXT_FRESHNESS );
setKnown();
}
}
}
@Override
protected void apply( Hero hero ) {
GLog.w( TXT_NO_SMELL );
Buff.prolong( hero, GasesImmunity.class, GasesImmunity.DURATION );
setKnown();
}
@Override
public String desc() {
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.";
}
@Override
public int price() {
return isKnown() ? 50 * quantity : super.price();
}
}
@@ -0,0 +1,53 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.potions;
import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
public class PotionOfStrength extends Potion {
{
name = "Potion of Strength";
}
@Override
protected void apply( Hero hero ) {
setKnown();
hero.STR++;
hero.sprite.showStatus( CharSprite.POSITIVE, "+1 str" );
GLog.p( "Newfound strength surges through your body." );
Badges.validateStrengthAttained();
}
@Override
public String desc() {
return
"This powerful liquid will course through your muscles, " +
"permanently increasing your strength by one point.";
}
@Override
public int price() {
return isKnown() ? 100 * quantity : super.price();
}
}
@@ -0,0 +1,59 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.items.potions;
import com.watabou.noosa.audio.Sample;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.ToxicGas;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
public class PotionOfToxicGas extends Potion {
{
name = "Potion of Toxic Gas";
}
@Override
protected void shatter( int cell ) {
setKnown();
splash( cell );
Sample.INSTANCE.play( Assets.SND_SHATTER );
ToxicGas gas = Blob.seed( cell, 1000, ToxicGas.class );
Actor.add( gas );
GameScene.add( gas );
}
@Override
public String desc() {
return
"Uncorking or shattering this pressurized glass will cause " +
"its contents to explode into a deadly cloud of toxic green gas. " +
"You might choose to fling this potion at distant enemies " +
"instead of uncorking it by hand.";
}
@Override
public int price() {
return isKnown() ? 40 * quantity : super.price();
}
}