V0.2.0: Lots of Armband implementation

This commit is contained in:
Evan Debenham
2014-09-07 17:13:52 -04:00
parent 1338cabf67
commit 5e038f5c5d
5 changed files with 63 additions and 20 deletions
@@ -17,6 +17,8 @@
*/
package com.shatteredpixel.shatteredpixeldungeon.windows;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.MasterThievesArmband;
import com.watabou.noosa.BitmapTextMultiline;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
@@ -42,6 +44,7 @@ public class WndTradeItem extends Window {
private static final String TXT_SALE = "FOR SALE: %s - %dg";
private static final String TXT_BUY = "Buy for %dg";
private static final String TXT_STEAL = "Steal with %d%% chance";
private static final String TXT_SELL = "Sell for %dg";
private static final String TXT_SELL_1 = "Sell 1 for %dg";
private static final String TXT_SELL_ALL = "Sell all for %dg";
@@ -49,6 +52,7 @@ public class WndTradeItem extends Window {
private static final String TXT_SOLD = "You've sold your %s for %dg";
private static final String TXT_BOUGHT = "You've bought %s for %dg";
private static final String TXT_STOLE = "You've stolen the %s";
private WndBag owner;
@@ -120,7 +124,7 @@ public class WndTradeItem extends Window {
float pos = createDescription( item, true );
int price = price( item );
final int price = price( item );
if (canBuy) {
@@ -134,14 +138,48 @@ public class WndTradeItem extends Window {
btnBuy.setRect( 0, pos + GAP, WIDTH, BTN_HEIGHT );
btnBuy.enable( price <= Dungeon.gold );
add( btnBuy );
RedButton btnCancel = new RedButton( TXT_CANCEL ) {
@Override
protected void onClick() {
hide();
}
};
btnCancel.setRect( 0, btnBuy.bottom() + GAP, WIDTH, BTN_HEIGHT );
RedButton btnCancel = new RedButton( TXT_CANCEL ) {
@Override
protected void onClick() {
hide();
}
};
final MasterThievesArmband.Thievery thievery = Dungeon.hero.buff(MasterThievesArmband.Thievery.class);
if (thievery != null) {
final float chance = thievery.stealChance(price);
RedButton btnSteal = new RedButton(Utils.format(TXT_STEAL, Math.min(100, (int)(chance*100)))) {
@Override
protected void onClick() {
if(thievery.steal(price)){
Hero hero = Dungeon.hero;
Item item = heap.pickUp();
GLog.i( TXT_STOLE, item.name());
hide();
if (!item.doPickUp( hero )) {
Dungeon.level.drop( item, heap.pos ).sprite.drop();
}
} else {
for (Mob mob : Dungeon.level.mobs){
if (mob instanceof Shopkeeper) {
mob.yell(((Shopkeeper) mob).TXT_THIEF);
((Shopkeeper) mob).flee();
break;
}
}
hide();
}
}
};
btnSteal.setRect(0, btnBuy.bottom() + GAP, WIDTH, BTN_HEIGHT);
add(btnSteal);
btnCancel.setRect( 0, btnSteal.bottom() + GAP, WIDTH, BTN_HEIGHT );
} else
btnCancel.setRect( 0, btnBuy.bottom() + GAP, WIDTH, BTN_HEIGHT );
add( btnCancel );
resize( WIDTH, (int)btnCancel.bottom() );