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:
parent
d975f3c8d5
commit
41b3c903c6
|
@ -123,7 +123,7 @@ public enum HeroClass {
|
|||
Dungeon.quickslot.setSlot(1, darts);
|
||||
}
|
||||
|
||||
new PotionOfHealing().setKnown();
|
||||
new PotionOfHealing().identify();
|
||||
}
|
||||
|
||||
private static void initMage( Hero hero ) {
|
||||
|
@ -141,7 +141,7 @@ public enum HeroClass {
|
|||
|
||||
Dungeon.quickslot.setSlot(0, staff);
|
||||
|
||||
new ScrollOfUpgrade().setKnown();
|
||||
new ScrollOfUpgrade().identify();
|
||||
}
|
||||
|
||||
private static void initRogue( Hero hero ) {
|
||||
|
@ -157,7 +157,7 @@ public enum HeroClass {
|
|||
Dungeon.quickslot.setSlot(0, cloak);
|
||||
Dungeon.quickslot.setSlot(1, darts);
|
||||
|
||||
new ScrollOfMagicMapping().setKnown();
|
||||
new ScrollOfMagicMapping().identify();
|
||||
}
|
||||
|
||||
private static void initHuntress( Hero hero ) {
|
||||
|
@ -168,7 +168,7 @@ public enum HeroClass {
|
|||
|
||||
Dungeon.quickslot.setSlot(0, boomerang);
|
||||
|
||||
new PotionOfMindVision().setKnown();
|
||||
new PotionOfMindVision().identify();
|
||||
}
|
||||
|
||||
public String title() {
|
||||
|
|
|
@ -57,7 +57,6 @@ public class Statue extends Mob {
|
|||
weapon = (Weapon)Generator.random( Generator.Category.WEAPON );
|
||||
} while (!(weapon instanceof MeleeWeapon) || weapon.cursed);
|
||||
|
||||
weapon.identify();
|
||||
weapon.enchant( Enchantment.random() );
|
||||
|
||||
HP = HT = 15 + Dungeon.depth * 5;
|
||||
|
@ -133,6 +132,7 @@ public class Statue extends Mob {
|
|||
|
||||
@Override
|
||||
public void die( Object cause ) {
|
||||
weapon.identify();
|
||||
Dungeon.level.drop( weapon, pos ).sprite.drop();
|
||||
super.die( cause );
|
||||
}
|
||||
|
|
|
@ -52,7 +52,8 @@ public class Thief extends Mob {
|
|||
EXP = 5;
|
||||
maxLvl = 10;
|
||||
|
||||
loot = new MasterThievesArmband().identify();
|
||||
//see createloot
|
||||
loot = null;
|
||||
lootChance = 0.01f;
|
||||
|
||||
FLEEING = new Fleeing();
|
||||
|
@ -106,7 +107,7 @@ public class Thief extends Mob {
|
|||
protected Item createLoot(){
|
||||
if (!Dungeon.limitedDrops.armband.dropped()) {
|
||||
Dungeon.limitedDrops.armband.drop();
|
||||
return super.createLoot();
|
||||
return new MasterThievesArmband().identify();
|
||||
} else
|
||||
return new Gold(Random.NormalIntRange(100, 250));
|
||||
}
|
||||
|
|
|
@ -326,8 +326,6 @@ public class Ghost extends NPC {
|
|||
armor.inscribe();
|
||||
}
|
||||
|
||||
weapon.identify();
|
||||
armor.identify();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -266,14 +266,12 @@ public class Wandmaker extends NPC {
|
|||
given = false;
|
||||
wand1 = (Wand) Generator.random(Generator.Category.WAND);
|
||||
wand1.cursed = false;
|
||||
wand1.identify();
|
||||
wand1.upgrade();
|
||||
|
||||
do {
|
||||
wand2 = (Wand) Generator.random(Generator.Category.WAND);
|
||||
} while (wand2.getClass().equals(wand1.getClass()));
|
||||
wand2.cursed = false;
|
||||
wand2.identify();
|
||||
wand2.upgrade();
|
||||
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.items.bags.Bag;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.Boomerang;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.MissileWeapon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.journal.Catalogs;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.CellSelector;
|
||||
|
@ -337,6 +338,8 @@ public class Item implements Bundlable {
|
|||
levelKnown = true;
|
||||
cursedKnown = true;
|
||||
|
||||
Catalogs.setSeen(getClass());
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -268,7 +268,7 @@ public class Armor extends EquipableItem {
|
|||
|
||||
if (!levelKnown) {
|
||||
if (--hitsToKnow <= 0) {
|
||||
levelKnown = true;
|
||||
identify();
|
||||
GLog.w( Messages.get(Armor.class, "identify") );
|
||||
Badges.validateItemLevelAquired( this );
|
||||
}
|
||||
|
|
|
@ -70,10 +70,11 @@ abstract public class ClassArmor extends Armor {
|
|||
classArmor = new HuntressArmor();
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
classArmor.level(armor.level());
|
||||
classArmor.armorTier = armor.tier;
|
||||
classArmor.inscribe( armor.glyph );
|
||||
classArmor.identify();
|
||||
|
||||
return classArmor;
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.effects.Splash;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.ItemStatusHandler;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.journal.Catalogs;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
|
@ -252,7 +253,8 @@ public class Potion extends Item {
|
|||
handler.know(this);
|
||||
updateQuickslot();
|
||||
}
|
||||
|
||||
|
||||
Catalogs.setSeen(getClass());
|
||||
Badges.validateAllPotionsIdentified();
|
||||
}
|
||||
}
|
||||
|
@ -261,7 +263,7 @@ public class Potion extends Item {
|
|||
public Item identify() {
|
||||
|
||||
setKnown();
|
||||
return this;
|
||||
return super.identify();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -142,6 +142,8 @@ public class Ring extends KindofMisc {
|
|||
handler.know( this );
|
||||
}
|
||||
|
||||
//Player has to fully identify a ring first
|
||||
//Catalogs.setSeen(getClass());
|
||||
Badges.validateAllRingsIdentified();
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.ItemStatusHandler;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.UnstableSpellbook;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.journal.Catalogs;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.HeroSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
|
@ -163,12 +164,15 @@ public abstract class Scroll extends Item {
|
|||
}
|
||||
|
||||
public void setKnown() {
|
||||
if (!isKnown() && !ownedByBook) {
|
||||
handler.know( this );
|
||||
updateQuickslot();
|
||||
if (!ownedByBook) {
|
||||
if (!isKnown()) {
|
||||
handler.know(this);
|
||||
updateQuickslot();
|
||||
}
|
||||
|
||||
Catalogs.setSeen(getClass());
|
||||
Badges.validateAllScrollsIdentified();
|
||||
}
|
||||
|
||||
Badges.validateAllScrollsIdentified();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -104,7 +104,7 @@ abstract public class Weapon extends KindOfWeapon {
|
|||
|
||||
if (!levelKnown) {
|
||||
if (--hitsToKnow <= 0) {
|
||||
levelKnown = true;
|
||||
identify();
|
||||
GLog.i( Messages.get(Weapon.class, "identify") );
|
||||
Badges.validateItemLevelAquired( this );
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
package com.shatteredpixel.shatteredpixeldungeon.journal;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.armor.ClothArmor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.armor.HuntressArmor;
|
||||
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.missiles.Boomerang;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
public class Catalogs {
|
||||
|
||||
public static final Class<?>[] weapons = new Class<?>[]{
|
||||
WornShortsword.class,
|
||||
Knuckles.class,
|
||||
Dagger.class,
|
||||
MagesStaff.class,
|
||||
Boomerang.class,
|
||||
Shortsword.class,
|
||||
HandAxe.class,
|
||||
Spear.class,
|
||||
Quarterstaff.class,
|
||||
Dirk.class,
|
||||
Sword.class,
|
||||
Mace.class,
|
||||
Scimitar.class,
|
||||
RoundShield.class,
|
||||
Sai.class,
|
||||
Whip.class,
|
||||
Longsword.class,
|
||||
BattleAxe.class,
|
||||
Flail.class,
|
||||
RunicBlade.class,
|
||||
AssassinsBlade.class,
|
||||
Greatsword.class,
|
||||
WarHammer.class,
|
||||
Glaive.class,
|
||||
Greataxe.class,
|
||||
Greatshield.class
|
||||
};
|
||||
private static final LinkedHashMap<Class<? extends Item>, Boolean> weapons = new LinkedHashMap<>();
|
||||
static {
|
||||
weapons.put( WornShortsword.class, false);
|
||||
weapons.put( Knuckles.class, false);
|
||||
weapons.put( Dagger.class, false);
|
||||
weapons.put( MagesStaff.class, false);
|
||||
weapons.put( Boomerang.class, false);
|
||||
weapons.put( Shortsword.class, false);
|
||||
weapons.put( HandAxe.class, false);
|
||||
weapons.put( Spear.class, false);
|
||||
weapons.put( Quarterstaff.class, false);
|
||||
weapons.put( Dirk.class, false);
|
||||
weapons.put( Sword.class, false);
|
||||
weapons.put( Mace.class, false);
|
||||
weapons.put( Scimitar.class, false);
|
||||
weapons.put( RoundShield.class, false);
|
||||
weapons.put( Sai.class, false);
|
||||
weapons.put( Whip.class, false);
|
||||
weapons.put( Longsword.class, false);
|
||||
weapons.put( BattleAxe.class, false);
|
||||
weapons.put( Flail.class, false);
|
||||
weapons.put( RunicBlade.class, false);
|
||||
weapons.put( AssassinsBlade.class, false);
|
||||
weapons.put( Greatsword.class, false);
|
||||
weapons.put( WarHammer.class, false);
|
||||
weapons.put( Glaive.class, false);
|
||||
weapons.put( Greataxe.class, false);
|
||||
weapons.put( Greatshield.class, false);
|
||||
}
|
||||
|
||||
public static final Class<?>[] armor = new Class<?>[]{
|
||||
ClothArmor.class,
|
||||
LeatherArmor.class,
|
||||
MailArmor.class,
|
||||
ScaleArmor.class,
|
||||
PlateArmor.class,
|
||||
WarriorArmor.class,
|
||||
MageArmor.class,
|
||||
RogueArmor.class,
|
||||
HuntressArmor.class,
|
||||
};
|
||||
public static Collection<Class<? extends Item>> weapons(){
|
||||
return weapons.keySet();
|
||||
}
|
||||
|
||||
public static final Class<?>[] wands = new Class<?>[]{
|
||||
WandOfMagicMissile.class,
|
||||
WandOfLightning.class,
|
||||
WandOfDisintegration.class,
|
||||
WandOfFireblast.class,
|
||||
WandOfVenom.class,
|
||||
WandOfBlastWave.class,
|
||||
//WandOfLivingEarth.class,
|
||||
WandOfFrost.class,
|
||||
WandOfPrismaticLight.class,
|
||||
//WandOfWarding.class,
|
||||
WandOfTransfusion.class,
|
||||
WandOfCorruption.class,
|
||||
WandOfRegrowth.class
|
||||
};
|
||||
private static final LinkedHashMap<Class<? extends Item>, Boolean> armors = new LinkedHashMap<>();
|
||||
static {
|
||||
armors.put( ClothArmor.class, false);
|
||||
armors.put( LeatherArmor.class, false);
|
||||
armors.put( MailArmor.class, false);
|
||||
armors.put( ScaleArmor.class, false);
|
||||
armors.put( PlateArmor.class, false);
|
||||
armors.put( WarriorArmor.class, false);
|
||||
armors.put( MageArmor.class, false);
|
||||
armors.put( RogueArmor.class, false);
|
||||
armors.put( HuntressArmor.class, false);
|
||||
}
|
||||
|
||||
public static final Class<?>[] rings = new Class<?>[]{
|
||||
RingOfAccuracy.class,
|
||||
RingOfEvasion.class,
|
||||
RingOfElements.class,
|
||||
RingOfForce.class,
|
||||
RingOfFuror.class,
|
||||
RingOfHaste.class,
|
||||
//RingOfMagic.class,
|
||||
RingOfMight.class,
|
||||
RingOfSharpshooting.class,
|
||||
RingOfTenacity.class,
|
||||
RingOfWealth.class
|
||||
};
|
||||
public static Collection<Class<? extends Item>> armors(){
|
||||
return armors.keySet();
|
||||
}
|
||||
|
||||
public static final Class<?>[] artifacts = new Class<?>[]{
|
||||
//AlchemistsToolkit.class,
|
||||
CapeOfThorns.class,
|
||||
ChaliceOfBlood.class,
|
||||
CloakOfShadows.class,
|
||||
DriedRose.class,
|
||||
EtherealChains.class,
|
||||
HornOfPlenty.class,
|
||||
LloydsBeacon.class,
|
||||
MasterThievesArmband.class,
|
||||
SandalsOfNature.class,
|
||||
TalismanOfForesight.class,
|
||||
TimekeepersHourglass.class,
|
||||
UnstableSpellbook.class
|
||||
};
|
||||
private static final LinkedHashMap<Class<? extends Item>, Boolean> wands = new LinkedHashMap<>();
|
||||
static {
|
||||
wands.put( WandOfMagicMissile.class, false);
|
||||
wands.put( WandOfLightning.class, false);
|
||||
wands.put( WandOfDisintegration.class, false);
|
||||
wands.put( WandOfFireblast.class, false);
|
||||
wands.put( WandOfVenom.class, false);
|
||||
wands.put( WandOfBlastWave.class, false);
|
||||
//wands.put( WandOfLivingEarth.class, false);
|
||||
wands.put( WandOfFrost.class, false);
|
||||
wands.put( WandOfPrismaticLight.class, false);
|
||||
//wands.put( WandOfWarding.class, false);
|
||||
wands.put( WandOfTransfusion.class, false);
|
||||
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
|
||||
};
|
||||
}
|
||||
|
|
|
@ -275,10 +275,10 @@ public class ShopRoom extends SpecialRoom {
|
|||
break;
|
||||
case 1:
|
||||
rare = Generator.random(Generator.Category.RING);
|
||||
rare.level( 1 );
|
||||
rare.level( 0 );
|
||||
break;
|
||||
case 2:
|
||||
rare = Generator.random( Generator.Category.ARTIFACT ).identify();
|
||||
rare = Generator.random( Generator.Category.ARTIFACT );
|
||||
break;
|
||||
default:
|
||||
rare = new Stylus();
|
||||
|
|
|
@ -47,8 +47,8 @@ import com.watabou.noosa.Image;
|
|||
import com.watabou.noosa.ui.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
|
||||
//FIXME a lot of cleanup and improvements to do here
|
||||
|
@ -256,7 +256,15 @@ public class WndJournal extends WndTabbed {
|
|||
private RedButton[] itemButtons;
|
||||
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;
|
||||
|
||||
|
@ -329,37 +337,52 @@ public class WndJournal extends WndTabbed {
|
|||
content.clear();
|
||||
list.scrollTo( 0, 0 );
|
||||
|
||||
ArrayList<Class<?>> itemClasses;
|
||||
HashMap<Class<?>, Boolean> known = new HashMap<>();
|
||||
if (currentItemIdx == 0) {
|
||||
itemClasses = new ArrayList<>(Arrays.asList(Catalogs.weapons));
|
||||
for (Class<?> cls : itemClasses) known.put(cls, true);
|
||||
} else if (currentItemIdx == 1){
|
||||
itemClasses = new ArrayList<>(Arrays.asList(Catalogs.armor));
|
||||
for (Class<?> cls : itemClasses) known.put(cls, true);
|
||||
} else if (currentItemIdx == 2){
|
||||
itemClasses = new ArrayList<>(Arrays.asList(Catalogs.wands));
|
||||
for (Class<?> cls : itemClasses) known.put(cls, true);
|
||||
} else if (currentItemIdx == 3){
|
||||
itemClasses = new ArrayList<>(Arrays.asList(Catalogs.rings));
|
||||
for (Class<?> cls : itemClasses) known.put(cls, Ring.getKnown().contains(cls));
|
||||
} else if (currentItemIdx == 4){
|
||||
itemClasses = new ArrayList<>(Arrays.asList(Catalogs.artifacts));
|
||||
for (Class<?> cls : itemClasses) known.put(cls, true);
|
||||
} else if (currentItemIdx == 5){
|
||||
itemClasses = new ArrayList<>(Arrays.asList(Catalogs.potions));
|
||||
for (Class<?> cls : itemClasses) known.put(cls, Potion.getKnown().contains(cls));
|
||||
} else if (currentItemIdx == 6) {
|
||||
itemClasses = new ArrayList<>(Arrays.asList(Catalogs.scrolls));
|
||||
for (Class<?> cls : itemClasses) known.put(cls, Scroll.getKnown().contains(cls));
|
||||
ArrayList<Class<? extends Item>> itemClasses;
|
||||
final HashMap<Class<? extends Item>, Boolean> known = new HashMap<>();
|
||||
if (currentItemIdx == WEAPON_IDX) {
|
||||
itemClasses = new ArrayList<>(Catalogs.weapons());
|
||||
for (Class<? extends Item> cls : itemClasses) known.put(cls, true);
|
||||
} else if (currentItemIdx == ARMOR_IDX){
|
||||
itemClasses = new ArrayList<>(Catalogs.armors());
|
||||
for (Class<? extends Item> cls : itemClasses) known.put(cls, true);
|
||||
} else if (currentItemIdx == WAND_IDX){
|
||||
itemClasses = new ArrayList<>(Catalogs.wands());
|
||||
for (Class<? extends Item> cls : itemClasses) known.put(cls, true);
|
||||
} else if (currentItemIdx == RING_IDX){
|
||||
itemClasses = new ArrayList<>(Catalogs.rings());
|
||||
for (Class<? extends Item> cls : itemClasses) known.put(cls, Ring.getKnown().contains(cls));
|
||||
} else if (currentItemIdx == ARTIF_IDX){
|
||||
itemClasses = new ArrayList<>(Catalogs.artifacts());
|
||||
for (Class<? extends Item> cls : itemClasses) known.put(cls, true);
|
||||
} else if (currentItemIdx == POTION_IDX){
|
||||
itemClasses = new ArrayList<>(Catalogs.potions());
|
||||
for (Class<? extends Item> cls : itemClasses) known.put(cls, Potion.getKnown().contains(cls));
|
||||
} else if (currentItemIdx == SCROLL_IDX) {
|
||||
itemClasses = new ArrayList<>(Catalogs.scrolls());
|
||||
for (Class<? extends Item> cls : itemClasses) known.put(cls, Scroll.getKnown().contains(cls));
|
||||
} else {
|
||||
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;
|
||||
for (Class<?> itemClass : itemClasses) {
|
||||
for (Class<? extends Item> itemClass : itemClasses) {
|
||||
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 );
|
||||
content.add( item );
|
||||
items.add( item );
|
||||
|
@ -377,13 +400,19 @@ public class WndJournal extends WndTabbed {
|
|||
private static class CatalogItem extends ListItem {
|
||||
|
||||
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()));
|
||||
|
||||
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) );
|
||||
label.hardlight( 0xCCCCCC );
|
||||
}
|
||||
|
@ -391,7 +420,7 @@ public class WndJournal extends WndTabbed {
|
|||
}
|
||||
|
||||
public boolean onClick( float x, float y ) {
|
||||
if (inside( x, y )) {
|
||||
if (inside( x, y ) && seen) {
|
||||
GameScene.show(new WndTitledMessage( new Image(icon),
|
||||
Messages.titleCase(item.trueName()), item.desc() ));
|
||||
return true;
|
||||
|
|
|
@ -102,6 +102,7 @@ public class WndSadGhost extends Window {
|
|||
|
||||
hide();
|
||||
|
||||
reward.identify();
|
||||
if (reward.doPickUp( Dungeon.hero )) {
|
||||
GLog.i( Messages.get(Dungeon.hero, "you_now_have", reward.name()) );
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue
Block a user