v0.2.2a: refactored and tweaked placement of key items in rooms.

This commit is contained in:
Evan Debenham
2014-11-05 16:50:08 -05:00
parent fd81d67616
commit dc4232de2a
7 changed files with 74 additions and 61 deletions
@@ -447,16 +447,27 @@ public abstract class Level implements Bundlable {
}
}
//TODO: this results in lots of empty rooms that could otherwise have a prize, should rework, also fix typo.
public Item itemToSpanAsPrize() {
if (Random.Int( itemsToSpawn.size() + 1 ) > 0) {
Item item = Random.element( itemsToSpawn );
itemsToSpawn.remove( item );
return item;
} else {
return null;
}
}
public Item findPrizeItem(){ return findPrizeItem(null); }
public Item findPrizeItem(Class<?extends Item> match){
if (itemsToSpawn.size() == 0)
return null;
if (match == null){
Item item = Random.element(itemsToSpawn);
itemsToSpawn.remove(item);
return item;
}
for (Item item : itemsToSpawn){
if (match.isInstance(item)){
itemsToSpawn.remove( item );
return item;
}
}
return null;
}
private void buildFlagMaps() {