v0.6.1: Catalogs now keep track of whether items have been seen

Currently does not persist between game sessions
This commit is contained in:
Evan Debenham 2017-07-07 13:56:19 -04:00
parent d975f3c8d5
commit 41b3c903c6
16 changed files with 272 additions and 163 deletions

View File

@ -123,7 +123,7 @@ public enum HeroClass {
Dungeon.quickslot.setSlot(1, darts); Dungeon.quickslot.setSlot(1, darts);
} }
new PotionOfHealing().setKnown(); new PotionOfHealing().identify();
} }
private static void initMage( Hero hero ) { private static void initMage( Hero hero ) {
@ -141,7 +141,7 @@ public enum HeroClass {
Dungeon.quickslot.setSlot(0, staff); Dungeon.quickslot.setSlot(0, staff);
new ScrollOfUpgrade().setKnown(); new ScrollOfUpgrade().identify();
} }
private static void initRogue( Hero hero ) { private static void initRogue( Hero hero ) {
@ -157,7 +157,7 @@ public enum HeroClass {
Dungeon.quickslot.setSlot(0, cloak); Dungeon.quickslot.setSlot(0, cloak);
Dungeon.quickslot.setSlot(1, darts); Dungeon.quickslot.setSlot(1, darts);
new ScrollOfMagicMapping().setKnown(); new ScrollOfMagicMapping().identify();
} }
private static void initHuntress( Hero hero ) { private static void initHuntress( Hero hero ) {
@ -168,7 +168,7 @@ public enum HeroClass {
Dungeon.quickslot.setSlot(0, boomerang); Dungeon.quickslot.setSlot(0, boomerang);
new PotionOfMindVision().setKnown(); new PotionOfMindVision().identify();
} }
public String title() { public String title() {

View File

@ -57,7 +57,6 @@ public class Statue extends Mob {
weapon = (Weapon)Generator.random( Generator.Category.WEAPON ); weapon = (Weapon)Generator.random( Generator.Category.WEAPON );
} while (!(weapon instanceof MeleeWeapon) || weapon.cursed); } while (!(weapon instanceof MeleeWeapon) || weapon.cursed);
weapon.identify();
weapon.enchant( Enchantment.random() ); weapon.enchant( Enchantment.random() );
HP = HT = 15 + Dungeon.depth * 5; HP = HT = 15 + Dungeon.depth * 5;
@ -133,6 +132,7 @@ public class Statue extends Mob {
@Override @Override
public void die( Object cause ) { public void die( Object cause ) {
weapon.identify();
Dungeon.level.drop( weapon, pos ).sprite.drop(); Dungeon.level.drop( weapon, pos ).sprite.drop();
super.die( cause ); super.die( cause );
} }

View File

@ -52,7 +52,8 @@ public class Thief extends Mob {
EXP = 5; EXP = 5;
maxLvl = 10; maxLvl = 10;
loot = new MasterThievesArmband().identify(); //see createloot
loot = null;
lootChance = 0.01f; lootChance = 0.01f;
FLEEING = new Fleeing(); FLEEING = new Fleeing();
@ -106,7 +107,7 @@ public class Thief extends Mob {
protected Item createLoot(){ protected Item createLoot(){
if (!Dungeon.limitedDrops.armband.dropped()) { if (!Dungeon.limitedDrops.armband.dropped()) {
Dungeon.limitedDrops.armband.drop(); Dungeon.limitedDrops.armband.drop();
return super.createLoot(); return new MasterThievesArmband().identify();
} else } else
return new Gold(Random.NormalIntRange(100, 250)); return new Gold(Random.NormalIntRange(100, 250));
} }

View File

@ -326,8 +326,6 @@ public class Ghost extends NPC {
armor.inscribe(); armor.inscribe();
} }
weapon.identify();
armor.identify();
} }
} }

View File

@ -266,14 +266,12 @@ public class Wandmaker extends NPC {
given = false; given = false;
wand1 = (Wand) Generator.random(Generator.Category.WAND); wand1 = (Wand) Generator.random(Generator.Category.WAND);
wand1.cursed = false; wand1.cursed = false;
wand1.identify();
wand1.upgrade(); wand1.upgrade();
do { do {
wand2 = (Wand) Generator.random(Generator.Category.WAND); wand2 = (Wand) Generator.random(Generator.Category.WAND);
} while (wand2.getClass().equals(wand1.getClass())); } while (wand2.getClass().equals(wand1.getClass()));
wand2.cursed = false; wand2.cursed = false;
wand2.identify();
wand2.upgrade(); wand2.upgrade();
} }

View File

@ -34,6 +34,7 @@ import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.items.bags.Bag; import com.shatteredpixel.shatteredpixeldungeon.items.bags.Bag;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.Boomerang; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.Boomerang;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.MissileWeapon; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.MissileWeapon;
import com.shatteredpixel.shatteredpixeldungeon.journal.Catalogs;
import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica; import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.CellSelector; import com.shatteredpixel.shatteredpixeldungeon.scenes.CellSelector;
@ -337,6 +338,8 @@ public class Item implements Bundlable {
levelKnown = true; levelKnown = true;
cursedKnown = true; cursedKnown = true;
Catalogs.setSeen(getClass());
return this; return this;
} }

View File

@ -268,7 +268,7 @@ public class Armor extends EquipableItem {
if (!levelKnown) { if (!levelKnown) {
if (--hitsToKnow <= 0) { if (--hitsToKnow <= 0) {
levelKnown = true; identify();
GLog.w( Messages.get(Armor.class, "identify") ); GLog.w( Messages.get(Armor.class, "identify") );
Badges.validateItemLevelAquired( this ); Badges.validateItemLevelAquired( this );
} }

View File

@ -74,6 +74,7 @@ abstract public class ClassArmor extends Armor {
classArmor.level(armor.level()); classArmor.level(armor.level());
classArmor.armorTier = armor.tier; classArmor.armorTier = armor.tier;
classArmor.inscribe( armor.glyph ); classArmor.inscribe( armor.glyph );
classArmor.identify();
return classArmor; return classArmor;
} }

View File

@ -34,6 +34,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.effects.Splash; import com.shatteredpixel.shatteredpixeldungeon.effects.Splash;
import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.ItemStatusHandler; import com.shatteredpixel.shatteredpixeldungeon.items.ItemStatusHandler;
import com.shatteredpixel.shatteredpixeldungeon.journal.Catalogs;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
@ -253,6 +254,7 @@ public class Potion extends Item {
updateQuickslot(); updateQuickslot();
} }
Catalogs.setSeen(getClass());
Badges.validateAllPotionsIdentified(); Badges.validateAllPotionsIdentified();
} }
} }
@ -261,7 +263,7 @@ public class Potion extends Item {
public Item identify() { public Item identify() {
setKnown(); setKnown();
return this; return super.identify();
} }
@Override @Override

View File

@ -142,6 +142,8 @@ public class Ring extends KindofMisc {
handler.know( this ); handler.know( this );
} }
//Player has to fully identify a ring first
//Catalogs.setSeen(getClass());
Badges.validateAllRingsIdentified(); Badges.validateAllRingsIdentified();
} }

View File

@ -27,6 +27,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.ItemStatusHandler; import com.shatteredpixel.shatteredpixeldungeon.items.ItemStatusHandler;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.UnstableSpellbook; import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.UnstableSpellbook;
import com.shatteredpixel.shatteredpixeldungeon.journal.Catalogs;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.sprites.HeroSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.HeroSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
@ -163,12 +164,15 @@ public abstract class Scroll extends Item {
} }
public void setKnown() { public void setKnown() {
if (!isKnown() && !ownedByBook) { if (!ownedByBook) {
handler.know( this ); if (!isKnown()) {
updateQuickslot(); handler.know(this);
} updateQuickslot();
}
Badges.validateAllScrollsIdentified(); Catalogs.setSeen(getClass());
Badges.validateAllScrollsIdentified();
}
} }
@Override @Override

View File

@ -104,7 +104,7 @@ abstract public class Weapon extends KindOfWeapon {
if (!levelKnown) { if (!levelKnown) {
if (--hitsToKnow <= 0) { if (--hitsToKnow <= 0) {
levelKnown = true; identify();
GLog.i( Messages.get(Weapon.class, "identify") ); GLog.i( Messages.get(Weapon.class, "identify") );
Badges.validateItemLevelAquired( this ); Badges.validateItemLevelAquired( this );
} }

View File

@ -21,6 +21,7 @@
package com.shatteredpixel.shatteredpixeldungeon.journal; package com.shatteredpixel.shatteredpixeldungeon.journal;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.ClothArmor; import com.shatteredpixel.shatteredpixeldungeon.items.armor.ClothArmor;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.HuntressArmor; import com.shatteredpixel.shatteredpixeldungeon.items.armor.HuntressArmor;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.LeatherArmor; import com.shatteredpixel.shatteredpixeldungeon.items.armor.LeatherArmor;
@ -114,122 +115,191 @@ import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Whip;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.WornShortsword; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.WornShortsword;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.Boomerang; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.Boomerang;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashMap;
public class Catalogs { public class Catalogs {
public static final Class<?>[] weapons = new Class<?>[]{ private static final LinkedHashMap<Class<? extends Item>, Boolean> weapons = new LinkedHashMap<>();
WornShortsword.class, static {
Knuckles.class, weapons.put( WornShortsword.class, false);
Dagger.class, weapons.put( Knuckles.class, false);
MagesStaff.class, weapons.put( Dagger.class, false);
Boomerang.class, weapons.put( MagesStaff.class, false);
Shortsword.class, weapons.put( Boomerang.class, false);
HandAxe.class, weapons.put( Shortsword.class, false);
Spear.class, weapons.put( HandAxe.class, false);
Quarterstaff.class, weapons.put( Spear.class, false);
Dirk.class, weapons.put( Quarterstaff.class, false);
Sword.class, weapons.put( Dirk.class, false);
Mace.class, weapons.put( Sword.class, false);
Scimitar.class, weapons.put( Mace.class, false);
RoundShield.class, weapons.put( Scimitar.class, false);
Sai.class, weapons.put( RoundShield.class, false);
Whip.class, weapons.put( Sai.class, false);
Longsword.class, weapons.put( Whip.class, false);
BattleAxe.class, weapons.put( Longsword.class, false);
Flail.class, weapons.put( BattleAxe.class, false);
RunicBlade.class, weapons.put( Flail.class, false);
AssassinsBlade.class, weapons.put( RunicBlade.class, false);
Greatsword.class, weapons.put( AssassinsBlade.class, false);
WarHammer.class, weapons.put( Greatsword.class, false);
Glaive.class, weapons.put( WarHammer.class, false);
Greataxe.class, weapons.put( Glaive.class, false);
Greatshield.class weapons.put( Greataxe.class, false);
}; weapons.put( Greatshield.class, false);
}
public static final Class<?>[] armor = new Class<?>[]{ public static Collection<Class<? extends Item>> weapons(){
ClothArmor.class, return weapons.keySet();
LeatherArmor.class, }
MailArmor.class,
ScaleArmor.class,
PlateArmor.class,
WarriorArmor.class,
MageArmor.class,
RogueArmor.class,
HuntressArmor.class,
};
public static final Class<?>[] wands = new Class<?>[]{ private static final LinkedHashMap<Class<? extends Item>, Boolean> armors = new LinkedHashMap<>();
WandOfMagicMissile.class, static {
WandOfLightning.class, armors.put( ClothArmor.class, false);
WandOfDisintegration.class, armors.put( LeatherArmor.class, false);
WandOfFireblast.class, armors.put( MailArmor.class, false);
WandOfVenom.class, armors.put( ScaleArmor.class, false);
WandOfBlastWave.class, armors.put( PlateArmor.class, false);
//WandOfLivingEarth.class, armors.put( WarriorArmor.class, false);
WandOfFrost.class, armors.put( MageArmor.class, false);
WandOfPrismaticLight.class, armors.put( RogueArmor.class, false);
//WandOfWarding.class, armors.put( HuntressArmor.class, false);
WandOfTransfusion.class, }
WandOfCorruption.class,
WandOfRegrowth.class
};
public static final Class<?>[] rings = new Class<?>[]{ public static Collection<Class<? extends Item>> armors(){
RingOfAccuracy.class, return armors.keySet();
RingOfEvasion.class, }
RingOfElements.class,
RingOfForce.class,
RingOfFuror.class,
RingOfHaste.class,
//RingOfMagic.class,
RingOfMight.class,
RingOfSharpshooting.class,
RingOfTenacity.class,
RingOfWealth.class
};
public static final Class<?>[] artifacts = new Class<?>[]{ private static final LinkedHashMap<Class<? extends Item>, Boolean> wands = new LinkedHashMap<>();
//AlchemistsToolkit.class, static {
CapeOfThorns.class, wands.put( WandOfMagicMissile.class, false);
ChaliceOfBlood.class, wands.put( WandOfLightning.class, false);
CloakOfShadows.class, wands.put( WandOfDisintegration.class, false);
DriedRose.class, wands.put( WandOfFireblast.class, false);
EtherealChains.class, wands.put( WandOfVenom.class, false);
HornOfPlenty.class, wands.put( WandOfBlastWave.class, false);
LloydsBeacon.class, //wands.put( WandOfLivingEarth.class, false);
MasterThievesArmband.class, wands.put( WandOfFrost.class, false);
SandalsOfNature.class, wands.put( WandOfPrismaticLight.class, false);
TalismanOfForesight.class, //wands.put( WandOfWarding.class, false);
TimekeepersHourglass.class, wands.put( WandOfTransfusion.class, false);
UnstableSpellbook.class wands.put( WandOfCorruption.class, false);
}; wands.put( WandOfRegrowth.class, false);
}
public static Collection<Class<? extends Item>> wands(){
return wands.keySet();
}
private static final LinkedHashMap<Class<? extends Item>, Boolean> rings = new LinkedHashMap<>();
static {
rings.put( RingOfAccuracy.class, false);
rings.put( RingOfElements.class, false);
rings.put( RingOfEvasion.class, false);
rings.put( RingOfForce.class, false);
rings.put( RingOfFuror.class, false);
rings.put( RingOfHaste.class, false);
//rings.put( RingOfMagic.class, false);
rings.put( RingOfMight.class, false);
rings.put( RingOfSharpshooting.class, false);
rings.put( RingOfTenacity.class, false);
rings.put( RingOfWealth.class, false);
}
public static Collection<Class<? extends Item>> rings(){
return rings.keySet();
}
private static final LinkedHashMap<Class<? extends Item>, Boolean> artifacts = new LinkedHashMap<>();
static{
//artifacts.put( AlchemistsToolkit.class, false);
artifacts.put( CapeOfThorns.class, false);
artifacts.put( ChaliceOfBlood.class, false);
artifacts.put( CloakOfShadows.class, false);
artifacts.put( DriedRose.class, false);
artifacts.put( EtherealChains.class, false);
artifacts.put( HornOfPlenty.class, false);
artifacts.put( LloydsBeacon.class, false);
artifacts.put( MasterThievesArmband.class, false);
artifacts.put( SandalsOfNature.class, false);
artifacts.put( TalismanOfForesight.class, false);
artifacts.put( TimekeepersHourglass.class, false);
artifacts.put(UnstableSpellbook.class, false);
}
public static Collection<Class<? extends Item>> artifacts(){
return artifacts.keySet();
}
private static final LinkedHashMap<Class<? extends Item>, Boolean> potions = new LinkedHashMap<>();
static {
potions.put( PotionOfHealing.class, false);
potions.put( PotionOfStrength.class, false);
potions.put( PotionOfLiquidFlame.class, false);
potions.put( PotionOfFrost.class, false);
potions.put( PotionOfToxicGas.class, false);
potions.put( PotionOfParalyticGas.class, false);
potions.put( PotionOfPurity.class, false);
potions.put( PotionOfLevitation.class, false);
potions.put( PotionOfMindVision.class, false);
potions.put( PotionOfInvisibility.class, false);
potions.put( PotionOfExperience.class, false);
potions.put( PotionOfMight.class, false);
}
public static Collection<Class<? extends Item>> potions(){
return potions.keySet();
}
private static final LinkedHashMap<Class<? extends Item>, Boolean> scrolls = new LinkedHashMap<>();
static {
scrolls.put( ScrollOfIdentify.class, false);
scrolls.put( ScrollOfUpgrade.class, false);
scrolls.put( ScrollOfRemoveCurse.class, false);
scrolls.put( ScrollOfMagicMapping.class, false);
scrolls.put( ScrollOfTeleportation.class, false);
scrolls.put( ScrollOfRecharging.class, false);
scrolls.put( ScrollOfMirrorImage.class, false);
scrolls.put( ScrollOfTerror.class, false);
scrolls.put( ScrollOfLullaby.class, false);
scrolls.put( ScrollOfRage.class, false);
scrolls.put( ScrollOfPsionicBlast.class, false);
scrolls.put( ScrollOfMagicalInfusion.class, false);
}
public static Collection<Class<? extends Item>> scrolls(){
return scrolls.keySet();
}
public static final ArrayList<LinkedHashMap<Class<? extends Item>, Boolean>> allCatalogs = new ArrayList<>();
static{
allCatalogs.add(weapons);
allCatalogs.add(armors);
allCatalogs.add(wands);
allCatalogs.add(rings);
allCatalogs.add(artifacts);
allCatalogs.add(potions);
allCatalogs.add(scrolls);
}
public static boolean isSeen(Class<? extends Item> itemClass){
for (LinkedHashMap<Class<? extends Item>, Boolean> catalog : allCatalogs) {
if (catalog.containsKey(itemClass)) {
return catalog.get(itemClass);
}
}
return false;
}
public static void setSeen(Class<? extends Item> itemClass){
for (LinkedHashMap<Class<? extends Item>, Boolean> catalog : allCatalogs) {
if (catalog.containsKey(itemClass)) {
catalog.put(itemClass, true);
}
}
}
public static final Class<?>[] potions = new Class<?>[]{
PotionOfHealing.class,
PotionOfStrength.class,
PotionOfLiquidFlame.class,
PotionOfFrost.class,
PotionOfToxicGas.class,
PotionOfParalyticGas.class,
PotionOfPurity.class,
PotionOfLevitation.class,
PotionOfMindVision.class,
PotionOfInvisibility.class,
PotionOfExperience.class,
PotionOfMight.class,
};
public static final Class<?>[] scrolls = new Class<?>[]{
ScrollOfIdentify.class,
ScrollOfUpgrade.class,
ScrollOfRemoveCurse.class,
ScrollOfMagicMapping.class,
ScrollOfTeleportation.class,
ScrollOfRecharging.class,
ScrollOfMirrorImage.class,
ScrollOfTerror.class,
ScrollOfLullaby.class,
ScrollOfRage.class,
ScrollOfPsionicBlast.class,
ScrollOfMagicalInfusion.class
};
} }

View File

@ -275,10 +275,10 @@ public class ShopRoom extends SpecialRoom {
break; break;
case 1: case 1:
rare = Generator.random(Generator.Category.RING); rare = Generator.random(Generator.Category.RING);
rare.level( 1 ); rare.level( 0 );
break; break;
case 2: case 2:
rare = Generator.random( Generator.Category.ARTIFACT ).identify(); rare = Generator.random( Generator.Category.ARTIFACT );
break; break;
default: default:
rare = new Stylus(); rare = new Stylus();

View File

@ -47,8 +47,8 @@ import com.watabou.noosa.Image;
import com.watabou.noosa.ui.Component; import com.watabou.noosa.ui.Component;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
//FIXME a lot of cleanup and improvements to do here //FIXME a lot of cleanup and improvements to do here
@ -256,7 +256,15 @@ public class WndJournal extends WndTabbed {
private RedButton[] itemButtons; private RedButton[] itemButtons;
private static final int NUM_BUTTONS = 7; private static final int NUM_BUTTONS = 7;
private static int currentItemIdx = 0; private static int currentItemIdx = 0;
private static final int WEAPON_IDX = 0;
private static final int ARMOR_IDX = 1;
private static final int WAND_IDX = 2;
private static final int RING_IDX = 3;
private static final int ARTIF_IDX = 4;
private static final int POTION_IDX = 5;
private static final int SCROLL_IDX = 6;
private ScrollPane list; private ScrollPane list;
@ -329,37 +337,52 @@ public class WndJournal extends WndTabbed {
content.clear(); content.clear();
list.scrollTo( 0, 0 ); list.scrollTo( 0, 0 );
ArrayList<Class<?>> itemClasses; ArrayList<Class<? extends Item>> itemClasses;
HashMap<Class<?>, Boolean> known = new HashMap<>(); final HashMap<Class<? extends Item>, Boolean> known = new HashMap<>();
if (currentItemIdx == 0) { if (currentItemIdx == WEAPON_IDX) {
itemClasses = new ArrayList<>(Arrays.asList(Catalogs.weapons)); itemClasses = new ArrayList<>(Catalogs.weapons());
for (Class<?> cls : itemClasses) known.put(cls, true); for (Class<? extends Item> cls : itemClasses) known.put(cls, true);
} else if (currentItemIdx == 1){ } else if (currentItemIdx == ARMOR_IDX){
itemClasses = new ArrayList<>(Arrays.asList(Catalogs.armor)); itemClasses = new ArrayList<>(Catalogs.armors());
for (Class<?> cls : itemClasses) known.put(cls, true); for (Class<? extends Item> cls : itemClasses) known.put(cls, true);
} else if (currentItemIdx == 2){ } else if (currentItemIdx == WAND_IDX){
itemClasses = new ArrayList<>(Arrays.asList(Catalogs.wands)); itemClasses = new ArrayList<>(Catalogs.wands());
for (Class<?> cls : itemClasses) known.put(cls, true); for (Class<? extends Item> cls : itemClasses) known.put(cls, true);
} else if (currentItemIdx == 3){ } else if (currentItemIdx == RING_IDX){
itemClasses = new ArrayList<>(Arrays.asList(Catalogs.rings)); itemClasses = new ArrayList<>(Catalogs.rings());
for (Class<?> cls : itemClasses) known.put(cls, Ring.getKnown().contains(cls)); for (Class<? extends Item> cls : itemClasses) known.put(cls, Ring.getKnown().contains(cls));
} else if (currentItemIdx == 4){ } else if (currentItemIdx == ARTIF_IDX){
itemClasses = new ArrayList<>(Arrays.asList(Catalogs.artifacts)); itemClasses = new ArrayList<>(Catalogs.artifacts());
for (Class<?> cls : itemClasses) known.put(cls, true); for (Class<? extends Item> cls : itemClasses) known.put(cls, true);
} else if (currentItemIdx == 5){ } else if (currentItemIdx == POTION_IDX){
itemClasses = new ArrayList<>(Arrays.asList(Catalogs.potions)); itemClasses = new ArrayList<>(Catalogs.potions());
for (Class<?> cls : itemClasses) known.put(cls, Potion.getKnown().contains(cls)); for (Class<? extends Item> cls : itemClasses) known.put(cls, Potion.getKnown().contains(cls));
} else if (currentItemIdx == 6) { } else if (currentItemIdx == SCROLL_IDX) {
itemClasses = new ArrayList<>(Arrays.asList(Catalogs.scrolls)); itemClasses = new ArrayList<>(Catalogs.scrolls());
for (Class<?> cls : itemClasses) known.put(cls, Scroll.getKnown().contains(cls)); for (Class<? extends Item> cls : itemClasses) known.put(cls, Scroll.getKnown().contains(cls));
} else { } else {
itemClasses = new ArrayList<>(); itemClasses = new ArrayList<>();
} }
Collections.sort(itemClasses, new Comparator<Class<? extends Item>>() {
@Override
public int compare(Class<? extends Item> a, Class<? extends Item> b) {
int result = 0;
//specifically known items appear first, then seen items, then unknown items.
if (known.get(a)) result -= 2;
if (known.get(b)) result += 2;
if (Catalogs.isSeen(a)) result --;
if (Catalogs.isSeen(b)) result ++;
return result;
}
});
float pos = 0; float pos = 0;
for (Class<?> itemClass : itemClasses) { for (Class<? extends Item> itemClass : itemClasses) {
try{ try{
CatalogItem item = new CatalogItem((Item) itemClass.newInstance(), known.get(itemClass)); CatalogItem item = new CatalogItem(itemClass.newInstance(), known.get(itemClass), Catalogs.isSeen(itemClass));
item.setRect( 0, pos, width, ITEM_HEIGHT ); item.setRect( 0, pos, width, ITEM_HEIGHT );
content.add( item ); content.add( item );
items.add( item ); items.add( item );
@ -377,13 +400,19 @@ public class WndJournal extends WndTabbed {
private static class CatalogItem extends ListItem { private static class CatalogItem extends ListItem {
private Item item; private Item item;
private boolean seen;
public CatalogItem(Item item, boolean IDed ) { public CatalogItem(Item item, boolean IDed, boolean seen ) {
super( new ItemSprite(item), Messages.titleCase(item.trueName())); super( new ItemSprite(item), Messages.titleCase(item.trueName()));
this.item = item; this.item = item;
this.seen = seen;
if (!IDed) { if (!seen) {
icon.copy( new ItemSprite( ItemSpriteSheet.WEAPON_HOLDER + currentItemIdx, null) );
label.text("???");
label.hardlight( 0x999999 );
} else if (!IDed) {
icon.copy( new ItemSprite( ItemSpriteSheet.WEAPON_HOLDER + currentItemIdx, null) ); icon.copy( new ItemSprite( ItemSpriteSheet.WEAPON_HOLDER + currentItemIdx, null) );
label.hardlight( 0xCCCCCC ); label.hardlight( 0xCCCCCC );
} }
@ -391,7 +420,7 @@ public class WndJournal extends WndTabbed {
} }
public boolean onClick( float x, float y ) { public boolean onClick( float x, float y ) {
if (inside( x, y )) { if (inside( x, y ) && seen) {
GameScene.show(new WndTitledMessage( new Image(icon), GameScene.show(new WndTitledMessage( new Image(icon),
Messages.titleCase(item.trueName()), item.desc() )); Messages.titleCase(item.trueName()), item.desc() ));
return true; return true;

View File

@ -102,6 +102,7 @@ public class WndSadGhost extends Window {
hide(); hide();
reward.identify();
if (reward.doPickUp( Dungeon.hero )) { if (reward.doPickUp( Dungeon.hero )) {
GLog.i( Messages.get(Dungeon.hero, "you_now_have", reward.name()) ); GLog.i( Messages.get(Dungeon.hero, "you_now_have", reward.name()) );
} else { } else {