v0.6.1: finished implementing ring of wealth rework (for now)

This commit is contained in:
Evan Debenham 2017-07-01 05:14:30 -04:00
parent e07098a580
commit b31fc10136
3 changed files with 56 additions and 7 deletions

View File

@ -55,6 +55,7 @@ import com.watabou.utils.Bundle;
import com.watabou.utils.GameMath;
import com.watabou.utils.Random;
import java.util.ArrayList;
import java.util.HashSet;
public abstract class Mob extends Char {
@ -570,9 +571,9 @@ public abstract class Mob extends Char {
int rolls = 1;
if (properties.contains(Property.BOSS)) rolls = 15;
else if (properties.contains(Property.MINIBOSS)) rolls = 5;
Item bonus = RingOfWealth.tryRareDrop(Dungeon.hero, rolls);
ArrayList<Item> bonus = RingOfWealth.tryRareDrop(Dungeon.hero, rolls);
if (bonus != null){
Dungeon.level.drop( bonus , pos ).sprite.drop();
for (Item b : bonus) Dungeon.level.drop( b , pos ).sprite.drop();
new Flare(8, 32).color(0xFFFF00, true).show(sprite, 2f);
}
}

View File

@ -65,6 +65,7 @@ import com.watabou.utils.Bundlable;
import com.watabou.utils.Bundle;
import com.watabou.utils.Random;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
@ -151,9 +152,9 @@ public class Heap implements Bundlable {
if (type != Type.MIMIC) {
type = Type.HEAP;
Item bonus = RingOfWealth.tryRareDrop(hero, 1);
ArrayList<Item> bonus = RingOfWealth.tryRareDrop(hero, 1);
if (bonus != null){
items.addFirst(bonus);
items.addAll(0, bonus);
new Flare(8, 32).color(0xFFFF00, true).show(sprite, 2f);
}
sprite.link();

View File

@ -22,10 +22,14 @@
package com.shatteredpixel.shatteredpixeldungeon.items.rings;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.items.Bomb;
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
import com.shatteredpixel.shatteredpixeldungeon.items.Gold;
import com.shatteredpixel.shatteredpixeldungeon.items.Honeypot;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.watabou.utils.Random;
import java.util.ArrayList;
import java.util.HashSet;
public class RingOfWealth extends Ring {
@ -41,7 +45,7 @@ public class RingOfWealth extends Ring {
return (float)Math.pow(1.15, getBonus(target, Wealth.class));
}
public static Item tryRareDrop(Char target, int tries ){
public static ArrayList<Item> tryRareDrop(Char target, int tries ){
if (getBonus(target, Wealth.class) <= 0) return null;
HashSet<Wealth> buffs = target.buffs(Wealth.class);
@ -63,14 +67,57 @@ public class RingOfWealth extends Ring {
//now handle reward logic
if (triesToDrop <= 0){
//TODO more drops, gold is very boring
return new Gold().random();
return generateRareDrop();
} else {
return null;
}
}
//TODO this is a start, but i'm sure this could be made more interesting...
private static ArrayList<Item> generateRareDrop(){
float roll = Random.Float();
ArrayList<Item> items = new ArrayList<>();
if (roll < 0.6f){
switch (Random.Int(3)){
case 0:
items.add(new Gold().random());
break;
case 1:
items.add(Generator.random(Generator.Category.POTION));
break;
case 2:
items.add(Generator.random(Generator.Category.SCROLL));
break;
}
} else if (roll < 0.9f){
switch (Random.Int(3)){
case 0:
items.add(Generator.random(Generator.Category.SEED));
items.add(Generator.random(Generator.Category.SEED));
items.add(Generator.random(Generator.Category.SEED));
items.add(Generator.random(Generator.Category.SEED));
items.add(Generator.random(Generator.Category.SEED));
break;
case 1:
items.add(Generator.random(Random.Int(2) == 0 ? Generator.Category.POTION : Generator.Category.SCROLL ));
items.add(Generator.random(Random.Int(2) == 0 ? Generator.Category.POTION : Generator.Category.SCROLL ));
items.add(Generator.random(Random.Int(2) == 0 ? Generator.Category.POTION : Generator.Category.SCROLL ));
break;
case 2:
items.add(new Bomb().random());
items.add(new Honeypot());
break;
}
} else {
Gold g = new Gold();
g.random();
g.quantity(g.quantity()*5);
items.add(g);
}
return items;
}
//caps at a 50% bonus
private static float dropProgression( Char target, int tries ){
return tries * (float)Math.pow(1.25f, getBonus(target, Wealth.class) -1 );