V0.2.0: Lots of Armband implementation
This commit is contained in:
parent
1338cabf67
commit
5e038f5c5d
|
@ -28,6 +28,8 @@ import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
|
|||
public class ImpShopkeeper extends Shopkeeper {
|
||||
|
||||
private static final String TXT_GREETINGS = "Hello, friend!";
|
||||
public static final String TXT_THIEF = "I thought I could trust you!";
|
||||
|
||||
|
||||
{
|
||||
name = "ambitious imp";
|
||||
|
@ -48,7 +50,7 @@ public class ImpShopkeeper extends Shopkeeper {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void flee() {
|
||||
public void flee() {
|
||||
for (Heap heap: Dungeon.level.heaps.values()) {
|
||||
if (heap.type == Heap.Type.FOR_SALE) {
|
||||
CellEmitter.get( heap.pos ).burst( ElmoParticle.FACTORY, 4 );
|
||||
|
|
|
@ -31,6 +31,8 @@ import com.shatteredpixel.shatteredpixeldungeon.windows.WndTradeItem;
|
|||
|
||||
public class Shopkeeper extends Mob.NPC {
|
||||
|
||||
public static final String TXT_THIEF = "Thief, Thief!";
|
||||
|
||||
{
|
||||
name = "shopkeeper";
|
||||
spriteClass = ShopkeeperSprite.class;
|
||||
|
@ -56,7 +58,7 @@ public class Shopkeeper extends Mob.NPC {
|
|||
flee();
|
||||
}
|
||||
|
||||
protected void flee() {
|
||||
public void flee() {
|
||||
for (Heap heap: Dungeon.level.heaps.values()) {
|
||||
if (heap.type == Heap.Type.FOR_SALE) {
|
||||
CellEmitter.get( heap.pos ).burst( ElmoParticle.FACTORY, 4 );
|
||||
|
|
|
@ -66,7 +66,7 @@ public class Gold extends Item {
|
|||
Statistics.goldCollected += quantity;
|
||||
Badges.validateGoldCollected();
|
||||
|
||||
MasterThievesArmband.Thievery thievery = hero.buffs(MasterThievesArmband.Thievery.class)
|
||||
MasterThievesArmband.Thievery thievery = hero.buff(MasterThievesArmband.Thievery.class);
|
||||
if (thievery != null)
|
||||
thievery.collect(quantity);
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import com.watabou.utils.Random;
|
|||
* Created by debenhame on 03/09/2014.
|
||||
*/
|
||||
public class MasterThievesArmband extends Artifact {
|
||||
//TODO: polish, numbers tweaking
|
||||
|
||||
{
|
||||
name = "Master Thieves' Armband";
|
||||
|
@ -47,12 +48,12 @@ public class MasterThievesArmband extends Artifact {
|
|||
charge += gold/2;
|
||||
}
|
||||
|
||||
public boolean steal(Item item){
|
||||
if (item.price() <= charge){
|
||||
charge -= item.price();
|
||||
exp += item.price();
|
||||
public boolean steal(int value){
|
||||
if (value <= charge){
|
||||
charge -= value;
|
||||
exp += value;
|
||||
} else {
|
||||
float chance = stealChance(item.price());
|
||||
float chance = stealChance(value);
|
||||
if (Random.Float() > chance)
|
||||
return false;
|
||||
else {
|
||||
|
@ -61,11 +62,11 @@ public class MasterThievesArmband extends Artifact {
|
|||
else
|
||||
//removes the charge it took you to reach 100%
|
||||
charge -= charge/chance;
|
||||
exp += item.price();
|
||||
exp += value;
|
||||
}
|
||||
}
|
||||
while(exp >= 1000 && level < levelCap) {
|
||||
exp -= 1000;
|
||||
while(exp >= 500 && level < levelCap) {
|
||||
exp -= 500;
|
||||
level++;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -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) {
|
||||
|
||||
|
@ -135,13 +139,47 @@ public class WndTradeItem extends Window {
|
|||
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() );
|
||||
|
|
Loading…
Reference in New Issue
Block a user