v0.6.1: more refactoring and improvements to journal and catalogs

This commit is contained in:
Evan Debenham 2017-07-12 03:49:26 -04:00
parent be396f4e2d
commit e486e9896d
11 changed files with 457 additions and 456 deletions

View File

@ -33,7 +33,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.bags.PotionBandolier;
import com.shatteredpixel.shatteredpixeldungeon.items.bags.ScrollHolder;
import com.shatteredpixel.shatteredpixeldungeon.items.bags.SeedPouch;
import com.shatteredpixel.shatteredpixeldungeon.items.bags.WandHolster;
import com.shatteredpixel.shatteredpixeldungeon.journal.Catalogs;
import com.shatteredpixel.shatteredpixeldungeon.journal.Catalog;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
@ -48,7 +48,6 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
public class Badges {
@ -466,9 +465,9 @@ public class Badges {
public static void validateItemsIdentified() {
for (LinkedHashMap<Class<? extends Item>, Boolean> catalog : Catalogs.allCatalogs){
if (Catalogs.allSeen(catalog.keySet())){
Badge b = Catalogs.catalogBadges.get(catalog);
for (Catalog cat : Catalog.values()){
if (Catalog.allSeen(cat.items())){
Badge b = Catalog.catalogBadges.get(cat);
if (!global.contains(b)){
displayBadge(b);
}

View File

@ -34,7 +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.journal.Catalog;
import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.CellSelector;
@ -339,7 +339,7 @@ public class Item implements Bundlable {
cursedKnown = true;
if (Dungeon.hero.isAlive()) {
Catalogs.setSeen(getClass());
Catalog.setSeen(getClass());
}
return this;

View File

@ -33,7 +33,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.journal.Catalog;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
@ -254,7 +254,7 @@ public class Potion extends Item {
}
if (Dungeon.hero.isAlive()) {
Catalogs.setSeen(getClass());
Catalog.setSeen(getClass());
}
}
}

View File

@ -30,7 +30,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.ItemStatusHandler;
import com.shatteredpixel.shatteredpixeldungeon.items.KindofMisc;
import com.shatteredpixel.shatteredpixeldungeon.journal.Catalogs;
import com.shatteredpixel.shatteredpixeldungeon.journal.Catalog;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
@ -144,7 +144,7 @@ public class Ring extends KindofMisc {
}
if (Dungeon.hero.isAlive()) {
Catalogs.setSeen(getClass());
Catalog.setSeen(getClass());
}
}

View File

@ -27,7 +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.journal.Catalog;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.sprites.HeroSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
@ -171,7 +171,7 @@ public abstract class Scroll extends Item {
}
if (Dungeon.hero.isAlive()) {
Catalogs.setSeen(getClass());
Catalog.setSeen(getClass());
}
}
}

View File

@ -0,0 +1,345 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2017 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.journal;
import com.shatteredpixel.shatteredpixeldungeon.Badges;
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;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.MageArmor;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.MailArmor;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.PlateArmor;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.RogueArmor;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.ScaleArmor;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.WarriorArmor;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.AlchemistsToolkit;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.CapeOfThorns;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.ChaliceOfBlood;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.CloakOfShadows;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.DriedRose;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.EtherealChains;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.HornOfPlenty;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.LloydsBeacon;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.MasterThievesArmband;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.SandalsOfNature;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TalismanOfForesight;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TimekeepersHourglass;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.UnstableSpellbook;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfExperience;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfFrost;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfHealing;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfInvisibility;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfLevitation;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfLiquidFlame;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfMight;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfMindVision;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfParalyticGas;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfPurity;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfStrength;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfToxicGas;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfAccuracy;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfElements;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfEvasion;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfForce;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfFuror;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfHaste;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfMight;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfSharpshooting;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfTenacity;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfWealth;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfIdentify;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfLullaby;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfMagicMapping;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfMagicalInfusion;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfMirrorImage;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfPsionicBlast;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRage;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRecharging;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRemoveCurse;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportation;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTerror;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfUpgrade;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfBlastWave;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfCorruption;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfDisintegration;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfFireblast;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfFrost;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfLightning;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfMagicMissile;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfPrismaticLight;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfRegrowth;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfTransfusion;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfVenom;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.AssassinsBlade;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.BattleAxe;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Dagger;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Dirk;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Flail;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Glaive;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Greataxe;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Greatshield;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Greatsword;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.HandAxe;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Knuckles;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Longsword;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Mace;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MagesStaff;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Quarterstaff;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.RoundShield;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.RunicBlade;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Sai;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Scimitar;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Shortsword;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Spear;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Sword;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.WarHammer;
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 com.watabou.utils.Bundle;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List;
public enum Catalog {
WEAPONS,
ARMOR,
WANDS,
RINGS,
ARTIFACTS,
POTIONS,
SCROLLS;
private LinkedHashMap<Class<? extends Item>, Boolean> seen = new LinkedHashMap<>();
public Collection<Class<? extends Item>> items(){
return seen.keySet();
}
static {
WEAPONS.seen.put( WornShortsword.class, false);
WEAPONS.seen.put( Knuckles.class, false);
WEAPONS.seen.put( Dagger.class, false);
WEAPONS.seen.put( MagesStaff.class, false);
WEAPONS.seen.put( Boomerang.class, false);
WEAPONS.seen.put( Shortsword.class, false);
WEAPONS.seen.put( HandAxe.class, false);
WEAPONS.seen.put( Spear.class, false);
WEAPONS.seen.put( Quarterstaff.class, false);
WEAPONS.seen.put( Dirk.class, false);
WEAPONS.seen.put( Sword.class, false);
WEAPONS.seen.put( Mace.class, false);
WEAPONS.seen.put( Scimitar.class, false);
WEAPONS.seen.put( RoundShield.class, false);
WEAPONS.seen.put( Sai.class, false);
WEAPONS.seen.put( Whip.class, false);
WEAPONS.seen.put( Longsword.class, false);
WEAPONS.seen.put( BattleAxe.class, false);
WEAPONS.seen.put( Flail.class, false);
WEAPONS.seen.put( RunicBlade.class, false);
WEAPONS.seen.put( AssassinsBlade.class, false);
WEAPONS.seen.put( Greatsword.class, false);
WEAPONS.seen.put( WarHammer.class, false);
WEAPONS.seen.put( Glaive.class, false);
WEAPONS.seen.put( Greataxe.class, false);
WEAPONS.seen.put( Greatshield.class, false);
ARMOR.seen.put( ClothArmor.class, false);
ARMOR.seen.put( LeatherArmor.class, false);
ARMOR.seen.put( MailArmor.class, false);
ARMOR.seen.put( ScaleArmor.class, false);
ARMOR.seen.put( PlateArmor.class, false);
ARMOR.seen.put( WarriorArmor.class, false);
ARMOR.seen.put( MageArmor.class, false);
ARMOR.seen.put( RogueArmor.class, false);
ARMOR.seen.put( HuntressArmor.class, false);
WANDS.seen.put( WandOfMagicMissile.class, false);
WANDS.seen.put( WandOfLightning.class, false);
WANDS.seen.put( WandOfDisintegration.class, false);
WANDS.seen.put( WandOfFireblast.class, false);
WANDS.seen.put( WandOfVenom.class, false);
WANDS.seen.put( WandOfBlastWave.class, false);
//WANDS.seen.put( WandOfLivingEarth.class, false);
WANDS.seen.put( WandOfFrost.class, false);
WANDS.seen.put( WandOfPrismaticLight.class, false);
//WANDS.seen.put( WandOfWarding.class, false);
WANDS.seen.put( WandOfTransfusion.class, false);
WANDS.seen.put( WandOfCorruption.class, false);
WANDS.seen.put( WandOfRegrowth.class, false);
RINGS.seen.put( RingOfAccuracy.class, false);
RINGS.seen.put( RingOfElements.class, false);
RINGS.seen.put( RingOfEvasion.class, false);
RINGS.seen.put( RingOfForce.class, false);
RINGS.seen.put( RingOfFuror.class, false);
RINGS.seen.put( RingOfHaste.class, false);
//RINGS.seen.put( RingOfMagic.class, false);
RINGS.seen.put( RingOfMight.class, false);
RINGS.seen.put( RingOfSharpshooting.class, false);
RINGS.seen.put( RingOfTenacity.class, false);
RINGS.seen.put( RingOfWealth.class, false);
ARTIFACTS.seen.put( AlchemistsToolkit.class, false);
ARTIFACTS.seen.put( CapeOfThorns.class, false);
ARTIFACTS.seen.put( ChaliceOfBlood.class, false);
ARTIFACTS.seen.put( CloakOfShadows.class, false);
ARTIFACTS.seen.put( DriedRose.class, false);
ARTIFACTS.seen.put( EtherealChains.class, false);
ARTIFACTS.seen.put( HornOfPlenty.class, false);
ARTIFACTS.seen.put( LloydsBeacon.class, false);
ARTIFACTS.seen.put( MasterThievesArmband.class, false);
ARTIFACTS.seen.put( SandalsOfNature.class, false);
ARTIFACTS.seen.put( TalismanOfForesight.class, false);
ARTIFACTS.seen.put( TimekeepersHourglass.class, false);
ARTIFACTS.seen.put(UnstableSpellbook.class, false);
POTIONS.seen.put( PotionOfHealing.class, false);
POTIONS.seen.put( PotionOfStrength.class, false);
POTIONS.seen.put( PotionOfLiquidFlame.class, false);
POTIONS.seen.put( PotionOfFrost.class, false);
POTIONS.seen.put( PotionOfToxicGas.class, false);
POTIONS.seen.put( PotionOfParalyticGas.class, false);
POTIONS.seen.put( PotionOfPurity.class, false);
POTIONS.seen.put( PotionOfLevitation.class, false);
POTIONS.seen.put( PotionOfMindVision.class, false);
POTIONS.seen.put( PotionOfInvisibility.class, false);
POTIONS.seen.put( PotionOfExperience.class, false);
POTIONS.seen.put( PotionOfMight.class, false);
SCROLLS.seen.put( ScrollOfIdentify.class, false);
SCROLLS.seen.put( ScrollOfUpgrade.class, false);
SCROLLS.seen.put( ScrollOfRemoveCurse.class, false);
SCROLLS.seen.put( ScrollOfMagicMapping.class, false);
SCROLLS.seen.put( ScrollOfTeleportation.class, false);
SCROLLS.seen.put( ScrollOfRecharging.class, false);
SCROLLS.seen.put( ScrollOfMirrorImage.class, false);
SCROLLS.seen.put( ScrollOfTerror.class, false);
SCROLLS.seen.put( ScrollOfLullaby.class, false);
SCROLLS.seen.put( ScrollOfRage.class, false);
SCROLLS.seen.put( ScrollOfPsionicBlast.class, false);
SCROLLS.seen.put( ScrollOfMagicalInfusion.class, false);
}
public static LinkedHashMap<Catalog, Badges.Badge> catalogBadges = new LinkedHashMap<>();
static {
catalogBadges.put(WEAPONS, Badges.Badge.ALL_WEAPONS_IDENTIFIED);
catalogBadges.put(ARMOR, Badges.Badge.ALL_ARMOR_IDENTIFIED);
catalogBadges.put(WANDS, Badges.Badge.ALL_WANDS_IDENTIFIED);
catalogBadges.put(RINGS, Badges.Badge.ALL_RINGS_IDENTIFIED);
catalogBadges.put(ARTIFACTS, Badges.Badge.ALL_ARTIFACTS_IDENTIFIED);
catalogBadges.put(POTIONS, Badges.Badge.ALL_POTIONS_IDENTIFIED);
catalogBadges.put(SCROLLS, Badges.Badge.ALL_SCROLLS_IDENTIFIED);
}
public static boolean allSeen( Collection<Class<?extends Item>> items){
for (Class<?extends Item> item : items){
if (!isSeen(item)){
return false;
}
}
return true;
}
public static boolean isSeen(Class<? extends Item> itemClass){
for (Catalog cat : values()) {
if (cat.seen.containsKey(itemClass)) {
return cat.seen.get(itemClass);
}
}
return false;
}
public static void setSeen(Class<? extends Item> itemClass){
for (Catalog cat : values()) {
if (cat.seen.containsKey(itemClass)) {
cat.seen.put(itemClass, true);
Journal.saveNeeded = true;
}
}
Badges.validateItemsIdentified();
}
private static final String CATALOGS = "catalogs";
public static void store( Bundle bundle ){
Badges.loadGlobal();
ArrayList<String> seen = new ArrayList<>();
//if we have identified all items of a set, we use the badge to keep track instead.
if (!Badges.isUnlocked(Badges.Badge.ALL_ITEMS_IDENTIFIED)) {
for (Catalog cat : values()) {
if (!Badges.isUnlocked(catalogBadges.get(cat))) {
for (Class<? extends Item> item : cat.items()) {
if (cat.seen.get(item)) seen.add(item.getSimpleName());
}
}
}
}
bundle.put( CATALOGS, seen.toArray(new String[0]) );
}
public static void restore( Bundle bundle ){
Badges.loadGlobal();
//logic for if we have all badges
if (Badges.isUnlocked(Badges.Badge.ALL_ITEMS_IDENTIFIED)){
for ( Catalog cat : values()){
for (Class<? extends Item> item : cat.items()){
cat.seen.put(item, true);
}
}
return;
}
//catalog-specific badge logic
for (Catalog cat : values()){
if (Badges.isUnlocked(catalogBadges.get(cat))){
for (Class<? extends Item> item : cat.items()){
cat.seen.put(item, true);
}
}
}
//general save/load
List<String> seen = Arrays.asList(bundle.getStringArray(CATALOGS));
for ( Catalog cat : values()){
for (Class<? extends Item> item : cat.items()){
if (seen.contains( item.getSimpleName() )) {
cat.seen.put(item, true );
}
}
}
}
}

View File

@ -1,424 +0,0 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2017 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.journal;
import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
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;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.MageArmor;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.MailArmor;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.PlateArmor;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.RogueArmor;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.ScaleArmor;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.WarriorArmor;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.AlchemistsToolkit;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.CapeOfThorns;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.ChaliceOfBlood;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.CloakOfShadows;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.DriedRose;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.EtherealChains;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.HornOfPlenty;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.LloydsBeacon;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.MasterThievesArmband;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.SandalsOfNature;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TalismanOfForesight;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TimekeepersHourglass;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.UnstableSpellbook;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfExperience;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfFrost;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfHealing;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfInvisibility;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfLevitation;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfLiquidFlame;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfMight;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfMindVision;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfParalyticGas;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfPurity;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfStrength;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfToxicGas;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfAccuracy;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfElements;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfEvasion;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfForce;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfFuror;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfHaste;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfMight;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfSharpshooting;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfTenacity;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfWealth;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfIdentify;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfLullaby;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfMagicMapping;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfMagicalInfusion;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfMirrorImage;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfPsionicBlast;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRage;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRecharging;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRemoveCurse;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportation;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTerror;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfUpgrade;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfBlastWave;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfCorruption;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfDisintegration;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfFireblast;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfFrost;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfLightning;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfMagicMissile;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfPrismaticLight;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfRegrowth;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfTransfusion;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfVenom;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.AssassinsBlade;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.BattleAxe;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Dagger;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Dirk;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Flail;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Glaive;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Greataxe;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Greatshield;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Greatsword;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.HandAxe;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Knuckles;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Longsword;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Mace;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MagesStaff;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Quarterstaff;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.RoundShield;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.RunicBlade;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Sai;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Scimitar;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Shortsword;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Spear;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Sword;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.WarHammer;
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 com.watabou.noosa.Game;
import com.watabou.utils.Bundle;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List;
public class Catalogs {
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 Collection<Class<? extends Item>> weapons(){
return weapons.keySet();
}
private static final LinkedHashMap<Class<? extends Item>, Boolean> armor = new LinkedHashMap<>();
static {
armor.put( ClothArmor.class, false);
armor.put( LeatherArmor.class, false);
armor.put( MailArmor.class, false);
armor.put( ScaleArmor.class, false);
armor.put( PlateArmor.class, false);
armor.put( WarriorArmor.class, false);
armor.put( MageArmor.class, false);
armor.put( RogueArmor.class, false);
armor.put( HuntressArmor.class, false);
}
public static Collection<Class<? extends Item>> armor(){
return armor.keySet();
}
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(armor);
allCatalogs.add(wands);
allCatalogs.add(rings);
allCatalogs.add(artifacts);
allCatalogs.add(potions);
allCatalogs.add(scrolls);
}
public static LinkedHashMap<LinkedHashMap<Class<? extends Item>, Boolean>, Badges.Badge> catalogBadges = new LinkedHashMap<>();
static {
catalogBadges.put(weapons, Badges.Badge.ALL_WEAPONS_IDENTIFIED);
catalogBadges.put(armor, Badges.Badge.ALL_ARMOR_IDENTIFIED);
catalogBadges.put(wands, Badges.Badge.ALL_WANDS_IDENTIFIED);
catalogBadges.put(rings, Badges.Badge.ALL_RINGS_IDENTIFIED);
catalogBadges.put(artifacts, Badges.Badge.ALL_ARTIFACTS_IDENTIFIED);
catalogBadges.put(potions, Badges.Badge.ALL_POTIONS_IDENTIFIED);
catalogBadges.put(scrolls, Badges.Badge.ALL_SCROLLS_IDENTIFIED);
}
public static boolean allSeen( Collection<Class<?extends Item>> items){
for (Class<?extends Item> item : items){
if (!isSeen(item)){
return false;
}
}
return true;
}
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);
saveNeeded = true;
}
}
Badges.validateItemsIdentified();
}
private static boolean saveNeeded = false;
public static void save(){
if (!saveNeeded){
return;
}
Badges.loadGlobal();
Bundle bundle = new Bundle();
ArrayList<String> seen = new ArrayList<>();
//if we have identified all items of a set, we use the badge to keep track instead.
if (!Badges.global.contains(Badges.Badge.ALL_ITEMS_IDENTIFIED)) {
for (LinkedHashMap<Class<? extends Item>, Boolean> cat : allCatalogs) {
if (!Badges.global.contains(catalogBadges.get(cat))) {
for (Class<? extends Item> item : cat.keySet()) {
if (cat.get(item)) seen.add(item.getSimpleName());
}
}
}
}
bundle.put( "catalogs", seen.toArray(new String[0]));
try {
OutputStream output = Game.instance.openFileOutput( "journal.dat", Game.MODE_PRIVATE );
Bundle.write( bundle, output );
output.close();
saveNeeded = false;
} catch (IOException e) {
ShatteredPixelDungeon.reportException(e);
}
}
private static boolean loaded = false;
public static void load( ){
if (loaded){
return;
}
Badges.loadGlobal();
//logic for if we have all badges
if (Badges.global.contains(Badges.Badge.ALL_ITEMS_IDENTIFIED)){
for ( LinkedHashMap<Class<? extends Item>, Boolean> cat : allCatalogs){
for (Class<? extends Item> item : cat.keySet()){
cat.put(item, true);
}
}
loaded = true;
return;
}
//catalog-specific badge logic
for (LinkedHashMap<Class<? extends Item>, Boolean> cat : allCatalogs){
if (Badges.global.contains(catalogBadges.get(cat))){
for (Class<? extends Item> item : cat.keySet()){
cat.put(item, true);
}
}
}
//general save/load
try {
InputStream input = Game.instance.openFileInput("journal.dat");
Bundle bundle = Bundle.read(input);
input.close();
List<String> seen = Arrays.asList(bundle.getStringArray("catalogs"));
for ( LinkedHashMap<Class<? extends Item>, Boolean> cat : allCatalogs){
for (Class<? extends Item> item : cat.keySet()){
if (seen.contains( item.getSimpleName() )) {
cat.put(item, true );
}
}
}
loaded = true;
} catch (IOException e){
}
}
}

View File

@ -0,0 +1,81 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2017 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.journal;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.watabou.noosa.Game;
import com.watabou.utils.Bundle;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
public class Journal {
private static final String JOURNAL_FILE = "journal.dat";
private static boolean loaded = false;
public static void loadGlobal(){
if (loaded){
return;
}
Bundle bundle;
try {
InputStream input = Game.instance.openFileInput( JOURNAL_FILE );
bundle = Bundle.read(input);
input.close();
} catch (IOException e){
bundle = new Bundle();
}
Catalog.restore( bundle );
loaded = true;
}
//package-private
static boolean saveNeeded = false;
public static void saveGlobal(){
if (!saveNeeded){
return;
}
Bundle bundle = new Bundle();
Catalog.store(bundle);
try {
OutputStream output = Game.instance.openFileOutput( JOURNAL_FILE, Game.MODE_PRIVATE );
Bundle.write( bundle, output );
output.close();
saveNeeded = false;
} catch (IOException e) {
ShatteredPixelDungeon.reportException(e);
}
}
}

View File

@ -47,7 +47,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.bags.SeedPouch;
import com.shatteredpixel.shatteredpixeldungeon.items.bags.WandHolster;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportation;
import com.shatteredpixel.shatteredpixeldungeon.journal.Catalogs;
import com.shatteredpixel.shatteredpixeldungeon.journal.Journal;
import com.shatteredpixel.shatteredpixeldungeon.levels.RegularLevel;
import com.shatteredpixel.shatteredpixeldungeon.levels.features.Chasm;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap;
@ -440,7 +440,7 @@ public class GameScene extends PixelScene {
scene = null;
Badges.saveGlobal();
Catalogs.save();
Journal.saveGlobal();
super.destroy();
}
@ -450,7 +450,7 @@ public class GameScene extends PixelScene {
try {
Dungeon.saveAll();
Badges.saveGlobal();
Catalogs.save();
Journal.saveGlobal();
} catch (IOException e) {
ShatteredPixelDungeon.reportException(e);
}

View File

@ -30,7 +30,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass;
import com.shatteredpixel.shatteredpixeldungeon.effects.BannerSprites;
import com.shatteredpixel.shatteredpixeldungeon.effects.BannerSprites.Type;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.journal.Catalogs;
import com.shatteredpixel.shatteredpixeldungeon.journal.Journal;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.ui.Archs;
import com.shatteredpixel.shatteredpixeldungeon.ui.ExitButton;
@ -84,7 +84,7 @@ public class StartScene extends PixelScene {
super.create();
Badges.loadGlobal();
Catalogs.load();
Journal.loadGlobal();
uiCamera.visible = false;

View File

@ -27,7 +27,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.Ring;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll;
import com.shatteredpixel.shatteredpixeldungeon.journal.Catalogs;
import com.shatteredpixel.shatteredpixeldungeon.journal.Catalog;
import com.shatteredpixel.shatteredpixeldungeon.journal.Notes;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
@ -64,7 +64,7 @@ public class WndJournal extends WndTabbed {
private NotesTab notesTab;
private CatalogTab catalogTab;
public static int last_index = 0;
public static int last_index = 2;
public WndJournal(){
@ -362,25 +362,25 @@ public class WndJournal extends WndTabbed {
ArrayList<Class<? extends Item>> itemClasses;
final HashMap<Class<? extends Item>, Boolean> known = new HashMap<>();
if (currentItemIdx == WEAPON_IDX) {
itemClasses = new ArrayList<>(Catalogs.weapons());
itemClasses = new ArrayList<>(Catalog.WEAPONS.items());
for (Class<? extends Item> cls : itemClasses) known.put(cls, true);
} else if (currentItemIdx == ARMOR_IDX){
itemClasses = new ArrayList<>(Catalogs.armor());
itemClasses = new ArrayList<>(Catalog.ARMOR.items());
for (Class<? extends Item> cls : itemClasses) known.put(cls, true);
} else if (currentItemIdx == WAND_IDX){
itemClasses = new ArrayList<>(Catalogs.wands());
itemClasses = new ArrayList<>(Catalog.WANDS.items());
for (Class<? extends Item> cls : itemClasses) known.put(cls, true);
} else if (currentItemIdx == RING_IDX){
itemClasses = new ArrayList<>(Catalogs.rings());
itemClasses = new ArrayList<>(Catalog.RINGS.items());
for (Class<? extends Item> cls : itemClasses) known.put(cls, Ring.getKnown().contains(cls));
} else if (currentItemIdx == ARTIF_IDX){
itemClasses = new ArrayList<>(Catalogs.artifacts());
itemClasses = new ArrayList<>(Catalog.ARTIFACTS.items());
for (Class<? extends Item> cls : itemClasses) known.put(cls, true);
} else if (currentItemIdx == POTION_IDX){
itemClasses = new ArrayList<>(Catalogs.potions());
itemClasses = new ArrayList<>(Catalog.POTIONS.items());
for (Class<? extends Item> cls : itemClasses) known.put(cls, Potion.getKnown().contains(cls));
} else if (currentItemIdx == SCROLL_IDX) {
itemClasses = new ArrayList<>(Catalogs.scrolls());
itemClasses = new ArrayList<>(Catalog.SCROLLS.items());
for (Class<? extends Item> cls : itemClasses) known.put(cls, Scroll.getKnown().contains(cls));
} else {
itemClasses = new ArrayList<>();
@ -392,10 +392,10 @@ public class WndJournal extends WndTabbed {
int result = 0;
//specifically known items appear first, then seen items, then unknown items.
if (known.get(a) && Catalogs.isSeen(a)) result -= 2;
if (known.get(b) && Catalogs.isSeen(b)) result += 2;
if (Catalogs.isSeen(a)) result --;
if (Catalogs.isSeen(b)) result ++;
if (known.get(a) && Catalog.isSeen(a)) result -= 2;
if (known.get(b) && Catalog.isSeen(b)) result += 2;
if (Catalog.isSeen(a)) result --;
if (Catalog.isSeen(b)) result ++;
return result;
}
@ -404,7 +404,7 @@ public class WndJournal extends WndTabbed {
float pos = 0;
for (Class<? extends Item> itemClass : itemClasses) {
try{
CatalogItem item = new CatalogItem(itemClass.newInstance(), known.get(itemClass), Catalogs.isSeen(itemClass));
CatalogItem item = new CatalogItem(itemClass.newInstance(), known.get(itemClass), Catalog.isSeen(itemClass));
item.setRect( 0, pos, width, ITEM_HEIGHT );
content.add( item );
items.add( item );