From e650767d2910f1a857e45e0cf4e307c09de0988f Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Fri, 5 Sep 2014 16:29:57 -0400 Subject: [PATCH] V0.2.0: Partially implemented armband. --- .../shatteredpixeldungeon/items/Gold.java | 7 ++- .../items/artifacts/MasterThievesArmband.java | 43 ++++++++++++++++++- 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/Gold.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/Gold.java index d4d344c0c..96b79079d 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/Gold.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/Gold.java @@ -19,6 +19,7 @@ package com.shatteredpixel.shatteredpixeldungeon.items; import java.util.ArrayList; +import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.MasterThievesArmband; import com.watabou.noosa.audio.Sample; import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Badges; @@ -64,7 +65,11 @@ public class Gold extends Item { Dungeon.gold += quantity; Statistics.goldCollected += quantity; Badges.validateGoldCollected(); - + + MasterThievesArmband.Thievery thievery = hero.buffs(MasterThievesArmband.Thievery.class) + if (thievery != null) + thievery.collect(quantity); + GameScene.pickUp( this ); hero.sprite.showStatus( CharSprite.NEUTRAL, TXT_VALUE, quantity ); hero.spendAndNext( TIME_TO_PICK_UP ); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/MasterThievesArmband.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/MasterThievesArmband.java index 37a3e9d68..bfd1a20fe 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/MasterThievesArmband.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/MasterThievesArmband.java @@ -1,6 +1,10 @@ package com.shatteredpixel.shatteredpixeldungeon.items.artifacts; +import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Shopkeeper; +import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; +import com.shatteredpixel.shatteredpixeldungeon.utils.Utils; +import com.watabou.utils.Random; /** * Created by debenhame on 03/09/2014. @@ -13,12 +17,47 @@ public class MasterThievesArmband extends Artifact { level = 0; levelCap = 10; charge = 0; - chargeCap = 100; - //partialcharge is unused + //partialcharge and chargeCap are unused } + @Override + public String status() { + if (charge > 0) + return Utils.format("%d", charge); + } public class Thievery extends ArtifactBuff{ + public void collect(int gold){ + charge += gold/2; + } + public boolean steal(Item item){ + if (item.price() <= charge){ + charge -= item.price(); + //gainExp(item.price()); + return true; + } else { + float chance = stealChance(item.price()); + 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; + //gainExp(item.price()); + 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); + + return (((float)charge + chargebonus)/value); + } + } } }