V0.2.0: Partially implemented armband.
This commit is contained in:
parent
0f9854d40a
commit
e650767d29
|
@ -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;
|
||||
|
@ -65,6 +66,10 @@ public class Gold extends Item {
|
|||
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 );
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user