v0.2.3: artifact refactoring, changed how new artifacts deal with collections of items.
This commit is contained in:
parent
e359b5f9ef
commit
1104f6473b
|
@ -6,7 +6,6 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
|
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion;
|
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfExperience;
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
||||||
|
@ -51,12 +50,14 @@ public class AlchemistsToolkit extends Artifact {
|
||||||
public AlchemistsToolkit() {
|
public AlchemistsToolkit() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
Generator.Category cat = Generator.Category.POTION;
|
||||||
for (int i = 1; i <= 3; i++){
|
for (int i = 1; i <= 3; i++){
|
||||||
Potion potion;
|
String potion;
|
||||||
do{
|
do{
|
||||||
potion = (Potion)Generator.random(Generator.Category.POTION);
|
potion = convertName(cat.classes[Random.chances(cat.probs)].getSimpleName());
|
||||||
} while (combination.contains(potion.trueName()) || potion instanceof PotionOfExperience);
|
//forcing the player to use experience potions would be completely unfair.
|
||||||
combination.add(potion.trueName());
|
} while (combination.contains(potion) || potion.equals("Experience"));
|
||||||
|
combination.add(potion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,7 +243,7 @@ public class AlchemistsToolkit extends Artifact {
|
||||||
@Override
|
@Override
|
||||||
public void onSelect(Item item) {
|
public void onSelect(Item item) {
|
||||||
if (item != null && item instanceof Potion && item.isIdentified()){
|
if (item != null && item instanceof Potion && item.isIdentified()){
|
||||||
if (!curGuess.contains(item.name())) {
|
if (!curGuess.contains(convertName(item.getClass().getSimpleName()))) {
|
||||||
|
|
||||||
Hero hero = Dungeon.hero;
|
Hero hero = Dungeon.hero;
|
||||||
hero.sprite.operate( hero.pos );
|
hero.sprite.operate( hero.pos );
|
||||||
|
@ -252,7 +253,7 @@ public class AlchemistsToolkit extends Artifact {
|
||||||
|
|
||||||
item.detach(hero.belongings.backpack);
|
item.detach(hero.belongings.backpack);
|
||||||
|
|
||||||
curGuess.add(item.name());
|
curGuess.add(convertName(item.getClass().getSimpleName()));
|
||||||
if (curGuess.size() == 3){
|
if (curGuess.size() == 3){
|
||||||
guessBrew();
|
guessBrew();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -205,6 +205,17 @@ public class Artifact extends KindofMisc {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//converts class names to be more concise and readable.
|
||||||
|
protected String convertName(String className){
|
||||||
|
//removes known redundant parts of names.
|
||||||
|
className.replaceFirst("ScrollOf|PotionOf", "");
|
||||||
|
|
||||||
|
//inserts a space infront of every uppercase character
|
||||||
|
className.replaceAll("(\\p{Ll})(\\p{Lu})", "$1 $2");
|
||||||
|
|
||||||
|
return className;
|
||||||
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Item random() {
|
public Item random() {
|
||||||
if (Random.Float() < 0.3f) {
|
if (Random.Float() < 0.3f) {
|
||||||
|
|
|
@ -55,11 +55,11 @@ public class UnstableSpellbook extends Artifact {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
Class<?>[] scrollClasses = Generator.Category.SCROLL.classes;
|
Class<?>[] scrollClasses = Generator.Category.SCROLL.classes;
|
||||||
float[] probs = Generator.Category.SCROLL.probs.clone();
|
float[] probs = Generator.Category.SCROLL.probs.clone(); //array of primitives, clone gives deep copy.
|
||||||
int i = Random.chances(probs);
|
int i = Random.chances(probs);
|
||||||
|
|
||||||
while (i != -1){
|
while (i != -1){
|
||||||
scrolls.add(scrollClasses[i].getSimpleName());
|
scrolls.add(convertName(scrollClasses[i].getSimpleName()));
|
||||||
probs[i] = 0;
|
probs[i] = 0;
|
||||||
|
|
||||||
i = Random.chances(probs);
|
i = Random.chances(probs);
|
||||||
|
@ -207,7 +207,7 @@ public class UnstableSpellbook extends Artifact {
|
||||||
@Override
|
@Override
|
||||||
public void onSelect(Item item) {
|
public void onSelect(Item item) {
|
||||||
if (item != null && item instanceof Scroll && item.isIdentified()){
|
if (item != null && item instanceof Scroll && item.isIdentified()){
|
||||||
String scroll = item.getClass().getSimpleName();
|
String scroll = convertName(item.getClass().getSimpleName());
|
||||||
Hero hero = Dungeon.hero;
|
Hero hero = Dungeon.hero;
|
||||||
for (int i = 0; ( i <= 1 && i < scrolls.size() ); i++){
|
for (int i = 0; ( i <= 1 && i < scrolls.size() ); i++){
|
||||||
if (scrolls.get(i).equals(scroll)){
|
if (scrolls.get(i).equals(scroll)){
|
||||||
|
|
Loading…
Reference in New Issue
Block a user