v0.3.5: some code cleanup & bugfixes to pincushion

This commit is contained in:
Evan Debenham 2016-03-07 00:02:54 -05:00
parent fae5fc7c6c
commit bc463a0a7c
2 changed files with 17 additions and 9 deletions

View File

@ -27,14 +27,19 @@ import com.watabou.utils.Bundle;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
public class PinCushion extends Buff {
private ArrayList<MissileWeapon> items = new ArrayList<MissileWeapon>();
public void stick(MissileWeapon item){
items.add(item);
public void stick(MissileWeapon projectile){
for (Item item : items){
if (item.isSimilar(projectile)){
item.quantity(item.quantity() + projectile.quantity());
return;
}
}
items.add(projectile);
}
@Override

View File

@ -20,8 +20,6 @@
*/
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles;
import java.util.ArrayList;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
@ -33,10 +31,10 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfSharpshooting;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions;
import com.watabou.utils.Random;
import java.util.ArrayList;
abstract public class MissileWeapon extends Weapon {
{
@ -74,8 +72,13 @@ abstract public class MissileWeapon extends Weapon {
if (curUser.heroClass == HeroClass.HUNTRESS && enemy.buff(PinCushion.class) == null)
bonus += 3;
if (Random.Float() > Math.pow(0.7, bonus))
if (Random.Float() > Math.pow(0.7, bonus)){
if (enemy.isAlive())
Buff.affect(enemy, PinCushion.class).stick(this);
else
Dungeon.level.drop( this, enemy.pos).sprite.drop();
}
}
}
}