V0.2.0: Partially implemented armband.

This commit is contained in:
Evan Debenham 2014-09-05 16:29:57 -04:00
parent 0f9854d40a
commit e650767d29
2 changed files with 47 additions and 3 deletions

View File

@ -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 );

View File

@ -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);
}
}
}
}