Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented Potion Belt and associated features #25

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Binary file modified assets/icons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/items.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions src/com/watabou/pixeldungeon/actors/buffs/Frost.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@
import com.watabou.pixeldungeon.items.Item;
import com.watabou.pixeldungeon.items.food.FrozenCarpaccio;
import com.watabou.pixeldungeon.items.food.MysteryMeat;
import com.watabou.pixeldungeon.items.potions.Potion;
import com.watabou.pixeldungeon.items.rings.RingOfElements.Resistance;
import com.watabou.pixeldungeon.ui.BuffIndicator;
import com.watabou.pixeldungeon.utils.GLog;

public class Frost extends FlavourBuff {

private static final String TXT_SHATTERS = "The cold causes %s to shatter!";
private static final float DURATION = 5f;

@Override
Expand All @@ -47,6 +50,11 @@ public boolean attachTo( Char target ) {
if (!carpaccio.collect( hero.belongings.backpack )) {
Dungeon.level.drop( carpaccio, target.pos ).sprite.drop();
}
} else if(item instanceof Potion) {

item = item.detach( hero.belongings.backpack );
GLog.w( TXT_SHATTERS, item.toString() );
((Potion) item).shatter( target.pos );
}
}

Expand Down
32 changes: 32 additions & 0 deletions src/com/watabou/pixeldungeon/items/bags/PotionBelt.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.watabou.pixeldungeon.items.bags;

import com.watabou.pixeldungeon.items.Item;
import com.watabou.pixeldungeon.items.potions.Potion;
import com.watabou.pixeldungeon.sprites.ItemSpriteSheet;

public class PotionBelt extends Bag {

{
name = "potion belt";
image = ItemSpriteSheet.BELT;

size = 12;
}

@Override
public boolean grab( Item item ) {
return item instanceof Potion;
}

@Override
public int price() {
return 50;
}

@Override
public String info() {
return
"This strong lether belt is capable of storing all your potions while protecting them from shattering due to frost";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some typos here!

}

}
12 changes: 6 additions & 6 deletions src/com/watabou/pixeldungeon/items/potions/Potion.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@ protected void onSelect(int index) {
}
}

public void shatter( int cell ) {
GLog.i( "The flask shatters and " + color() + " liquid splashes harmlessly" );
Sample.INSTANCE.play( Assets.SND_SHATTER );
splash( cell );
}

protected void drink( Hero hero ) {

detach( hero.belongings.backpack );
Expand Down Expand Up @@ -212,12 +218,6 @@ 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 );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class PotionOfFrost extends Potion {
}

@Override
protected void shatter( int cell ) {
public void shatter( int cell ) {

PathFinder.buildDistanceMap( cell, BArray.not( Level.losBlocking, null ), DISTANCE );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class PotionOfLiquidFlame extends Potion {
}

@Override
protected void shatter( int cell ) {
public void shatter( int cell ) {

setKnown();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class PotionOfParalyticGas extends Potion {
}

@Override
protected void shatter( int cell ) {
public void shatter( int cell ) {

setKnown();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class PotionOfPurity extends Potion {
}

@Override
protected void shatter( int cell ) {
public void shatter( int cell ) {

PathFinder.buildDistanceMap( cell, BArray.not( Level.losBlocking, null ), DISTANCE );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class PotionOfToxicGas extends Potion {
}

@Override
protected void shatter( int cell ) {
public void shatter( int cell ) {

setKnown();

Expand Down
8 changes: 5 additions & 3 deletions src/com/watabou/pixeldungeon/levels/painters/ShopPainter.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.watabou.pixeldungeon.items.Torch;
import com.watabou.pixeldungeon.items.Weightstone;
import com.watabou.pixeldungeon.items.armor.*;
import com.watabou.pixeldungeon.items.bags.PotionBelt;
import com.watabou.pixeldungeon.items.bags.ScrollHolder;
import com.watabou.pixeldungeon.items.bags.SeedPouch;
import com.watabou.pixeldungeon.items.bags.WandHolster;
Expand Down Expand Up @@ -95,21 +96,21 @@ private static Item[] range() {
case 6:
items.add( (Random.Int( 2 ) == 0 ? new Quarterstaff() : new Spear()).identify() );
items.add( new LeatherArmor().identify() );
items.add( new SeedPouch() );
items.add( new PotionBelt() );
items.add( new Weightstone() );
break;

case 11:
items.add( (Random.Int( 2 ) == 0 ? new Sword() : new Mace()).identify() );
items.add( new MailArmor().identify() );
items.add( new ScrollHolder() );
items.add( new SeedPouch() );
items.add( new Weightstone() );
break;

case 16:
items.add( (Random.Int( 2 ) == 0 ? new Longsword() : new BattleAxe()).identify() );
items.add( new ScaleArmor().identify() );
items.add( new WandHolster() );
items.add( new ScrollHolder() );
items.add( new Weightstone() );
break;

Expand All @@ -125,6 +126,7 @@ private static Item[] range() {
items.add( new PlateArmor().identify() );
break;
}
items.add( new WandHolster() );
items.add( new Torch() );
items.add( new Torch() );
break;
Expand Down
1 change: 1 addition & 0 deletions src/com/watabou/pixeldungeon/sprites/ItemSpriteSheet.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ public class ItemSpriteSheet {
public static final int POUCH = 83;
public static final int HOLDER = 104;
public static final int HOLSTER = 111;
public static final int BELT = 124;

// Misc
public static final int ANKH = 1;
Expand Down
6 changes: 5 additions & 1 deletion src/com/watabou/pixeldungeon/ui/Icons.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public enum Icons {
SEED_POUCH,
SCROLL_HOLDER,
WAND_HOLSTER,
POTIONS_BELT,
CHECKED,
UNCHECKED,
EXIT,
Expand Down Expand Up @@ -120,14 +121,17 @@ public static Image get( Icons type ) {
case WAND_HOLSTER:
icon.frame( icon.texture.uvRect( 88, 0, 98, 10 ) );
break;
case POTIONS_BELT:
icon.frame( icon.texture.uvRect( 98, 0, 108, 10 ) );
break;
case CHECKED:
icon.frame( icon.texture.uvRect( 54, 12, 66, 24 ) );
break;
case UNCHECKED:
icon.frame( icon.texture.uvRect( 66, 12, 78, 24 ) );
break;
case EXIT:
icon.frame( icon.texture.uvRect( 98, 0, 114, 16 ) );
icon.frame( icon.texture.uvRect( 108, 0, 124, 16 ) );
break;
case CHALLENGE_OFF:
icon.frame( icon.texture.uvRect( 78, 16, 102, 40 ) );
Expand Down
6 changes: 5 additions & 1 deletion src/com/watabou/pixeldungeon/windows/WndBag.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.watabou.pixeldungeon.items.Item;
import com.watabou.pixeldungeon.items.armor.Armor;
import com.watabou.pixeldungeon.items.bags.Bag;
import com.watabou.pixeldungeon.items.bags.PotionBelt;
import com.watabou.pixeldungeon.items.bags.ScrollHolder;
import com.watabou.pixeldungeon.items.bags.SeedPouch;
import com.watabou.pixeldungeon.items.bags.WandHolster;
Expand Down Expand Up @@ -66,7 +67,7 @@ public static enum Mode {
protected static final int SLOT_SIZE = 28;
protected static final int SLOT_MARGIN = 1;

protected static final int TAB_WIDTH = 30;
protected static final int TAB_WIDTH = 24;

protected static final int TITLE_HEIGHT = 12;

Expand Down Expand Up @@ -112,6 +113,7 @@ public WndBag( Bag bag, Listener listener, Mode mode, String title ) {
Belongings stuff = Dungeon.hero.belongings;
Bag[] bags = {
stuff.backpack,
stuff.getItem( PotionBelt.class ),
stuff.getItem( SeedPouch.class ),
stuff.getItem( ScrollHolder.class ),
stuff.getItem( WandHolster.class )};
Expand Down Expand Up @@ -259,6 +261,8 @@ private Image icon() {
return Icons.get( Icons.SCROLL_HOLDER );
} else if (bag instanceof WandHolster) {
return Icons.get( Icons.WAND_HOLSTER );
} else if (bag instanceof PotionBelt) {
return Icons.get( Icons.POTIONS_BELT );
} else {
return Icons.get( Icons.BACKPACK );
}
Expand Down