v0.6.1: refactored keys, now stored in notes
This commit is contained in:
@@ -602,6 +602,8 @@ public class Dungeon {
|
|||||||
Badges.reset();
|
Badges.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Notes.restoreFromBundle( bundle );
|
||||||
|
|
||||||
hero = null;
|
hero = null;
|
||||||
hero = (Hero)bundle.get( HERO );
|
hero = (Hero)bundle.get( HERO );
|
||||||
|
|
||||||
@@ -609,10 +611,9 @@ public class Dungeon {
|
|||||||
depth = bundle.getInt( DEPTH );
|
depth = bundle.getInt( DEPTH );
|
||||||
|
|
||||||
Statistics.restoreFromBundle( bundle );
|
Statistics.restoreFromBundle( bundle );
|
||||||
Notes.restoreFromBundle( bundle );
|
|
||||||
Generator.restoreFromBundle( bundle );
|
Generator.restoreFromBundle( bundle );
|
||||||
|
|
||||||
droppedItems = new SparseArray<ArrayList<Item>>();
|
droppedItems = new SparseArray<>();
|
||||||
for (int i=2; i <= Statistics.deepestFloor + 1; i++) {
|
for (int i=2; i <= Statistics.deepestFloor + 1; i++) {
|
||||||
ArrayList<Item> dropped = new ArrayList<Item>();
|
ArrayList<Item> dropped = new ArrayList<Item>();
|
||||||
if (bundle.contains(Messages.format( DROPPED, i )))
|
if (bundle.contains(Messages.format( DROPPED, i )))
|
||||||
|
|||||||
+25
-22
@@ -27,10 +27,13 @@ import com.shatteredpixel.shatteredpixeldungeon.items.KindOfWeapon;
|
|||||||
import com.shatteredpixel.shatteredpixeldungeon.items.KindofMisc;
|
import com.shatteredpixel.shatteredpixeldungeon.items.KindofMisc;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
|
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.bags.Bag;
|
import com.shatteredpixel.shatteredpixeldungeon.items.bags.Bag;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.items.keys.GoldenKey;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey;
|
import com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.keys.Key;
|
import com.shatteredpixel.shatteredpixeldungeon.items.keys.Key;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.items.keys.SkeletonKey;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRemoveCurse;
|
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRemoveCurse;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand;
|
import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.journal.Notes;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||||
import com.watabou.utils.Bundle;
|
import com.watabou.utils.Bundle;
|
||||||
import com.watabou.utils.Random;
|
import com.watabou.utils.Random;
|
||||||
@@ -49,9 +52,6 @@ public class Belongings implements Iterable<Item> {
|
|||||||
public Armor armor = null;
|
public Armor armor = null;
|
||||||
public KindofMisc misc1 = null;
|
public KindofMisc misc1 = null;
|
||||||
public KindofMisc misc2 = null;
|
public KindofMisc misc2 = null;
|
||||||
|
|
||||||
public int[] ironKeys = new int[26];
|
|
||||||
public int[] specialKeys = new int[26]; //golden or boss keys
|
|
||||||
|
|
||||||
public Belongings( Hero owner ) {
|
public Belongings( Hero owner ) {
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
@@ -68,9 +68,6 @@ public class Belongings implements Iterable<Item> {
|
|||||||
private static final String MISC1 = "misc1";
|
private static final String MISC1 = "misc1";
|
||||||
private static final String MISC2 = "misc2";
|
private static final String MISC2 = "misc2";
|
||||||
|
|
||||||
private static final String IRON_KEYS = "ironKeys";
|
|
||||||
private static final String SPECIAL_KEYS = "specialKeys";
|
|
||||||
|
|
||||||
public void storeInBundle( Bundle bundle ) {
|
public void storeInBundle( Bundle bundle ) {
|
||||||
|
|
||||||
backpack.storeInBundle( bundle );
|
backpack.storeInBundle( bundle );
|
||||||
@@ -79,29 +76,35 @@ public class Belongings implements Iterable<Item> {
|
|||||||
bundle.put( ARMOR, armor );
|
bundle.put( ARMOR, armor );
|
||||||
bundle.put( MISC1, misc1);
|
bundle.put( MISC1, misc1);
|
||||||
bundle.put( MISC2, misc2);
|
bundle.put( MISC2, misc2);
|
||||||
|
|
||||||
bundle.put( IRON_KEYS, ironKeys);
|
|
||||||
bundle.put( SPECIAL_KEYS, specialKeys);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void restoreFromBundle( Bundle bundle ) {
|
public void restoreFromBundle( Bundle bundle ) {
|
||||||
|
|
||||||
if (bundle.contains(IRON_KEYS)) ironKeys = bundle.getIntArray( IRON_KEYS );
|
//moving keys to Notes, for pre-0.6.1 saves
|
||||||
if (bundle.contains(SPECIAL_KEYS)) specialKeys = bundle.getIntArray( SPECIAL_KEYS );
|
if (bundle.contains("ironKeys")) {
|
||||||
|
int[] ironKeys = bundle.getIntArray( "ironKeys" );
|
||||||
|
for (int i = 0; i < ironKeys.length; i++){
|
||||||
|
if (ironKeys[i] > 0){
|
||||||
|
Notes.add((Key) new IronKey(i).quantity(ironKeys[i]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bundle.contains("specialKeys")) {
|
||||||
|
int[] specialKeys = bundle.getIntArray( "specialKeys" );
|
||||||
|
for (int i = 0; i < specialKeys.length; i++){
|
||||||
|
if (specialKeys[i] > 0){
|
||||||
|
if (i % 5 == 0){
|
||||||
|
Notes.add((Key) new GoldenKey(i).quantity(specialKeys[i]));
|
||||||
|
} else {
|
||||||
|
Notes.add((Key) new SkeletonKey(i).quantity(specialKeys[i]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
backpack.clear();
|
backpack.clear();
|
||||||
backpack.restoreFromBundle( bundle );
|
backpack.restoreFromBundle( bundle );
|
||||||
|
|
||||||
//removing keys, from pre-0.4.1 saves
|
|
||||||
for (Item item : backpack.items.toArray(new Item[0])){
|
|
||||||
if (item instanceof Key){
|
|
||||||
item.detachAll(backpack);
|
|
||||||
if (item instanceof IronKey)
|
|
||||||
ironKeys[((Key) item).depth] += item.quantity();
|
|
||||||
else
|
|
||||||
specialKeys[((Key) item).depth] += item.quantity();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
weapon = (KindOfWeapon) bundle.get(WEAPON);
|
weapon = (KindOfWeapon) bundle.get(WEAPON);
|
||||||
if (weapon != null) {
|
if (weapon != null) {
|
||||||
|
|||||||
@@ -68,7 +68,10 @@ import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.EtherealChains;
|
|||||||
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.HornOfPlenty;
|
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.HornOfPlenty;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TalismanOfForesight;
|
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TalismanOfForesight;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TimekeepersHourglass;
|
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TimekeepersHourglass;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.items.keys.GoldenKey;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.keys.Key;
|
import com.shatteredpixel.shatteredpixeldungeon.items.keys.Key;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.items.keys.SkeletonKey;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion;
|
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfMight;
|
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfMight;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfStrength;
|
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfStrength;
|
||||||
@@ -86,6 +89,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfUpgrade;
|
|||||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
|
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Flail;
|
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Flail;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.MissileWeapon;
|
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.MissileWeapon;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.journal.Notes;
|
||||||
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.levels.features.AlchemyPot;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.features.AlchemyPot;
|
||||||
@@ -717,7 +721,7 @@ public class Hero extends Char {
|
|||||||
if (heap != null && (heap.type != Type.HEAP && heap.type != Type.FOR_SALE)) {
|
if (heap != null && (heap.type != Type.HEAP && heap.type != Type.FOR_SALE)) {
|
||||||
|
|
||||||
if ((heap.type == Type.LOCKED_CHEST || heap.type == Type.CRYSTAL_CHEST)
|
if ((heap.type == Type.LOCKED_CHEST || heap.type == Type.CRYSTAL_CHEST)
|
||||||
&& belongings.specialKeys[Dungeon.depth] < 1) {
|
&& Notes.keyCount(new GoldenKey(Dungeon.depth)) < 1) {
|
||||||
|
|
||||||
GLog.w( Messages.get(this, "locked_chest") );
|
GLog.w( Messages.get(this, "locked_chest") );
|
||||||
ready();
|
ready();
|
||||||
@@ -764,12 +768,12 @@ public class Hero extends Char {
|
|||||||
int door = Dungeon.level.map[doorCell];
|
int door = Dungeon.level.map[doorCell];
|
||||||
|
|
||||||
if (door == Terrain.LOCKED_DOOR
|
if (door == Terrain.LOCKED_DOOR
|
||||||
&& belongings.ironKeys[Dungeon.depth] > 0) {
|
&& Notes.keyCount(new IronKey(Dungeon.depth)) > 0) {
|
||||||
|
|
||||||
hasKey = true;
|
hasKey = true;
|
||||||
|
|
||||||
} else if (door == Terrain.LOCKED_EXIT
|
} else if (door == Terrain.LOCKED_EXIT
|
||||||
&& belongings.specialKeys[Dungeon.depth] > 0) {
|
&& Notes.keyCount(new GoldenKey(Dungeon.depth)) > 0) {
|
||||||
|
|
||||||
hasKey = true;
|
hasKey = true;
|
||||||
|
|
||||||
@@ -1459,10 +1463,10 @@ public class Hero extends Char {
|
|||||||
int door = Dungeon.level.map[doorCell];
|
int door = Dungeon.level.map[doorCell];
|
||||||
|
|
||||||
if (door == Terrain.LOCKED_DOOR){
|
if (door == Terrain.LOCKED_DOOR){
|
||||||
belongings.ironKeys[Dungeon.depth]--;
|
Notes.remove(new IronKey(Dungeon.depth));
|
||||||
Level.set( doorCell, Terrain.DOOR );
|
Level.set( doorCell, Terrain.DOOR );
|
||||||
} else {
|
} else {
|
||||||
belongings.specialKeys[Dungeon.depth]--;
|
Notes.remove(new SkeletonKey(Dungeon.depth));
|
||||||
Level.set( doorCell, Terrain.UNLOCKED_EXIT );
|
Level.set( doorCell, Terrain.UNLOCKED_EXIT );
|
||||||
}
|
}
|
||||||
StatusPane.needsKeyUpdate = true;
|
StatusPane.needsKeyUpdate = true;
|
||||||
@@ -1476,7 +1480,7 @@ public class Hero extends Char {
|
|||||||
if (heap.type == Type.SKELETON || heap.type == Type.REMAINS) {
|
if (heap.type == Type.SKELETON || heap.type == Type.REMAINS) {
|
||||||
Sample.INSTANCE.play( Assets.SND_BONES );
|
Sample.INSTANCE.play( Assets.SND_BONES );
|
||||||
} else if (heap.type == Type.LOCKED_CHEST || heap.type == Type.CRYSTAL_CHEST){
|
} else if (heap.type == Type.LOCKED_CHEST || heap.type == Type.CRYSTAL_CHEST){
|
||||||
belongings.specialKeys[Dungeon.depth]--;
|
Notes.remove(new GoldenKey(Dungeon.depth));
|
||||||
}
|
}
|
||||||
StatusPane.needsKeyUpdate = true;
|
StatusPane.needsKeyUpdate = true;
|
||||||
heap.open( this );
|
heap.open( this );
|
||||||
|
|||||||
@@ -21,8 +21,6 @@
|
|||||||
|
|
||||||
package com.shatteredpixel.shatteredpixeldungeon.items.keys;
|
package com.shatteredpixel.shatteredpixeldungeon.items.keys;
|
||||||
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||||
|
|
||||||
public class GoldenKey extends Key {
|
public class GoldenKey extends Key {
|
||||||
@@ -31,12 +29,6 @@ public class GoldenKey extends Key {
|
|||||||
image = ItemSpriteSheet.GOLDEN_KEY;
|
image = ItemSpriteSheet.GOLDEN_KEY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean doPickUp(Hero hero) {
|
|
||||||
Dungeon.hero.belongings.specialKeys[depth] += quantity();
|
|
||||||
return super.doPickUp(hero);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GoldenKey() {
|
public GoldenKey() {
|
||||||
this( 0 );
|
this( 0 );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,8 +21,6 @@
|
|||||||
|
|
||||||
package com.shatteredpixel.shatteredpixeldungeon.items.keys;
|
package com.shatteredpixel.shatteredpixeldungeon.items.keys;
|
||||||
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||||
|
|
||||||
public class IronKey extends Key {
|
public class IronKey extends Key {
|
||||||
@@ -31,12 +29,6 @@ public class IronKey extends Key {
|
|||||||
image = ItemSpriteSheet.IRON_KEY;
|
image = ItemSpriteSheet.IRON_KEY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean doPickUp(Hero hero) {
|
|
||||||
Dungeon.hero.belongings.ironKeys[depth] += quantity();
|
|
||||||
return super.doPickUp(hero);
|
|
||||||
}
|
|
||||||
|
|
||||||
public IronKey() {
|
public IronKey() {
|
||||||
this( 0 );
|
this( 0 );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ package com.shatteredpixel.shatteredpixeldungeon.items.keys;
|
|||||||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.journal.Notes;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.ui.StatusPane;
|
import com.shatteredpixel.shatteredpixeldungeon.ui.StatusPane;
|
||||||
import com.watabou.noosa.audio.Sample;
|
import com.watabou.noosa.audio.Sample;
|
||||||
@@ -48,6 +49,7 @@ public abstract class Key extends Item {
|
|||||||
@Override
|
@Override
|
||||||
public boolean doPickUp(Hero hero) {
|
public boolean doPickUp(Hero hero) {
|
||||||
GameScene.pickUpJournal(this);
|
GameScene.pickUpJournal(this);
|
||||||
|
Notes.add(this);
|
||||||
Sample.INSTANCE.play( Assets.SND_ITEM );
|
Sample.INSTANCE.play( Assets.SND_ITEM );
|
||||||
hero.spendAndNext( TIME_TO_PICK_UP );
|
hero.spendAndNext( TIME_TO_PICK_UP );
|
||||||
StatusPane.needsKeyUpdate = true;
|
StatusPane.needsKeyUpdate = true;
|
||||||
|
|||||||
-15
@@ -21,16 +21,12 @@
|
|||||||
|
|
||||||
package com.shatteredpixel.shatteredpixeldungeon.items.keys;
|
package com.shatteredpixel.shatteredpixeldungeon.items.keys;
|
||||||
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||||
|
|
||||||
public class SkeletonKey extends Key {
|
public class SkeletonKey extends Key {
|
||||||
|
|
||||||
{
|
{
|
||||||
image = ItemSpriteSheet.SKELETON_KEY;
|
image = ItemSpriteSheet.SKELETON_KEY;
|
||||||
stackable = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SkeletonKey() {
|
public SkeletonKey() {
|
||||||
@@ -42,15 +38,4 @@ public class SkeletonKey extends Key {
|
|||||||
this.depth = depth;
|
this.depth = depth;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean doPickUp(Hero hero) {
|
|
||||||
Dungeon.hero.belongings.specialKeys[depth]++;
|
|
||||||
return super.doPickUp(hero);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isSimilar( Item item ) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,14 +22,47 @@
|
|||||||
package com.shatteredpixel.shatteredpixeldungeon.journal;
|
package com.shatteredpixel.shatteredpixeldungeon.journal;
|
||||||
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.items.keys.Key;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||||
import com.watabou.utils.Bundlable;
|
import com.watabou.utils.Bundlable;
|
||||||
import com.watabou.utils.Bundle;
|
import com.watabou.utils.Bundle;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
public class Notes {
|
public class Notes {
|
||||||
|
|
||||||
|
public static abstract class Record implements Comparable<Record>, Bundlable {
|
||||||
|
|
||||||
|
protected int depth;
|
||||||
|
|
||||||
|
public int depth(){
|
||||||
|
return depth;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract String desc();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public abstract boolean equals(Object obj);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo( Record another ) {
|
||||||
|
return another.depth() - depth();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final String DEPTH = "depth";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void restoreFromBundle( Bundle bundle ) {
|
||||||
|
depth = bundle.getInt( DEPTH );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void storeInBundle( Bundle bundle ) {
|
||||||
|
bundle.put( DEPTH, depth );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public enum Landmark {
|
public enum Landmark {
|
||||||
WELL_OF_HEALTH,
|
WELL_OF_HEALTH,
|
||||||
WELL_OF_AWARENESS,
|
WELL_OF_AWARENESS,
|
||||||
@@ -42,94 +75,178 @@ public class Notes {
|
|||||||
WANDMAKER,
|
WANDMAKER,
|
||||||
TROLL,
|
TROLL,
|
||||||
IMP;
|
IMP;
|
||||||
|
|
||||||
public String desc() {
|
public String desc() {
|
||||||
return Messages.get(this, name());
|
return Messages.get(this, name());
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
public static class Record implements Comparable<Record>, Bundlable {
|
public static class LandmarkRecord extends Record {
|
||||||
|
|
||||||
//compatibility with pre-0.6.1 saves
|
protected Landmark landmark;
|
||||||
private static final String FEATURE = "feature";
|
|
||||||
|
|
||||||
private static final String LANDMARK = "landmark";
|
public LandmarkRecord() {}
|
||||||
|
|
||||||
private static final String DEPTH = "depth";
|
public LandmarkRecord(Landmark landmark, int depth ) {
|
||||||
|
|
||||||
public Landmark landmark;
|
|
||||||
|
|
||||||
public int depth;
|
|
||||||
|
|
||||||
public Record() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public Record(Landmark landmark, int depth ) {
|
|
||||||
this.landmark = landmark;
|
this.landmark = landmark;
|
||||||
this.depth = depth;
|
this.depth = depth;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo( Record another ) {
|
public String desc() {
|
||||||
return another.depth - depth;
|
return landmark.desc();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void restoreFromBundle( Bundle bundle ) {
|
public boolean equals(Object obj) {
|
||||||
if (bundle.contains(FEATURE)) {
|
return (obj instanceof LandmarkRecord)
|
||||||
landmark = Landmark.valueOf(bundle.getString(FEATURE));
|
&& landmark == ((LandmarkRecord) obj).landmark
|
||||||
} else {
|
&& depth() == ((LandmarkRecord) obj).depth();
|
||||||
landmark = Landmark.valueOf(bundle.getString(LANDMARK));
|
|
||||||
}
|
|
||||||
depth = bundle.getInt( DEPTH );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final String LANDMARK = "landmark";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void storeInBundle( Bundle bundle ) {
|
public void restoreFromBundle(Bundle bundle) {
|
||||||
|
super.restoreFromBundle(bundle);
|
||||||
|
landmark = Landmark.valueOf(bundle.getString(LANDMARK));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void storeInBundle(Bundle bundle) {
|
||||||
|
super.storeInBundle(bundle);
|
||||||
bundle.put( LANDMARK, landmark.toString() );
|
bundle.put( LANDMARK, landmark.toString() );
|
||||||
bundle.put( DEPTH, depth );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ArrayList<Record> records;
|
public static class KeyRecord extends Record {
|
||||||
|
|
||||||
|
protected Key key;
|
||||||
|
|
||||||
|
public KeyRecord() {}
|
||||||
|
|
||||||
|
public KeyRecord( Key key ){
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int depth() {
|
||||||
|
return key.depth;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String desc() {
|
||||||
|
return key.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Class<? extends Key> type(){
|
||||||
|
return key.getClass();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int quantity(){
|
||||||
|
return key.quantity();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void quantity(int num){
|
||||||
|
key.quantity(num);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
return (obj instanceof KeyRecord)
|
||||||
|
&& key.isSimilar(((KeyRecord) obj).key);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final String KEY = "key";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void restoreFromBundle(Bundle bundle) {
|
||||||
|
super.restoreFromBundle(bundle);
|
||||||
|
key = (Key) bundle.get(KEY);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void storeInBundle(Bundle bundle) {
|
||||||
|
super.storeInBundle(bundle);
|
||||||
|
bundle.put( KEY, key );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ArrayList<Record> records;
|
||||||
|
|
||||||
public static void reset() {
|
public static void reset() {
|
||||||
records = new ArrayList<>();
|
records = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String JOURNAL = "journal";
|
private static final String RECORDS = "records";
|
||||||
|
|
||||||
public static void storeInBundle( Bundle bundle ) {
|
public static void storeInBundle( Bundle bundle ) {
|
||||||
bundle.put( JOURNAL, records );
|
bundle.put( RECORDS, records );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void restoreFromBundle( Bundle bundle ) {
|
public static void restoreFromBundle( Bundle bundle ) {
|
||||||
records = new ArrayList<>();
|
records = new ArrayList<>();
|
||||||
for (Bundlable rec : bundle.getCollection( JOURNAL ) ) {
|
for (Bundlable rec : bundle.getCollection( RECORDS ) ) {
|
||||||
records.add( (Record) rec );
|
records.add( (Record) rec );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void add( Landmark landmark ) {
|
public static void add( Landmark landmark ) {
|
||||||
int size = records.size();
|
LandmarkRecord l = new LandmarkRecord( landmark, Dungeon.depth );
|
||||||
for (int i=0; i < size; i++) {
|
if (!records.contains(l)) {
|
||||||
Record rec = records.get( i );
|
records.add(new LandmarkRecord(landmark, Dungeon.depth));
|
||||||
if (rec.landmark == landmark && rec.depth == Dungeon.depth) {
|
Collections.sort(records);
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
records.add( new Record(landmark, Dungeon.depth ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void remove( Landmark landmark ) {
|
public static void remove( Landmark landmark ) {
|
||||||
int size = records.size();
|
records.remove( new LandmarkRecord(landmark, Dungeon.depth) );
|
||||||
for (int i=0; i < size; i++) {
|
}
|
||||||
Record rec = records.get( i );
|
|
||||||
if (rec.landmark == landmark && rec.depth == Dungeon.depth) {
|
public static void add( Key key ){
|
||||||
records.remove( i );
|
KeyRecord k = new KeyRecord(key);
|
||||||
return;
|
if (!records.contains(k)){
|
||||||
|
records.add(k);
|
||||||
|
Collections.sort(records);
|
||||||
|
} else {
|
||||||
|
k = (KeyRecord) records.get(records.indexOf(k));
|
||||||
|
k.quantity(k.quantity() + key.quantity());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void remove( Key key ){
|
||||||
|
KeyRecord k = new KeyRecord( key );
|
||||||
|
if (records.contains(k)){
|
||||||
|
k = (KeyRecord) records.get(records.indexOf(k));
|
||||||
|
k.quantity(k.quantity() - key.quantity());
|
||||||
|
if (k.quantity() <= 0){
|
||||||
|
records.remove(k);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int keyCount( Key key ){
|
||||||
|
KeyRecord k = new KeyRecord( key );
|
||||||
|
if (records.contains(k)){
|
||||||
|
k = (KeyRecord) records.get(records.indexOf(k));
|
||||||
|
return k.quantity();
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ArrayList<Record> getRecords(){
|
||||||
|
return getRecords(Record.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T extends Record> ArrayList<T> getRecords( Class<T> recordType ){
|
||||||
|
ArrayList<T> filtered = new ArrayList<>();
|
||||||
|
for (Record rec : records){
|
||||||
|
if (recordType.isInstance(rec)){
|
||||||
|
filtered.add((T)rec);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return filtered;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-2
@@ -25,6 +25,10 @@ import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
|||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Belongings;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Belongings;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.LloydsBeacon;
|
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.LloydsBeacon;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.items.keys.GoldenKey;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.items.keys.Key;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.journal.Notes;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.InterlevelScene;
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.InterlevelScene;
|
||||||
import com.watabou.noosa.Game;
|
import com.watabou.noosa.Game;
|
||||||
|
|
||||||
@@ -39,8 +43,8 @@ public class DistortionTrap extends Trap{
|
|||||||
public void activate() {
|
public void activate() {
|
||||||
InterlevelScene.returnDepth = Dungeon.depth;
|
InterlevelScene.returnDepth = Dungeon.depth;
|
||||||
Belongings belongings = Dungeon.hero.belongings;
|
Belongings belongings = Dungeon.hero.belongings;
|
||||||
belongings.ironKeys[Dungeon.depth] = 0;
|
Notes.remove((Key) new IronKey(Dungeon.depth).quantity(99));
|
||||||
belongings.specialKeys[Dungeon.depth] = 0;
|
Notes.remove((Key) new GoldenKey(Dungeon.depth).quantity(99));
|
||||||
for (Item i : belongings){
|
for (Item i : belongings){
|
||||||
if (i instanceof LloydsBeacon && ((LloydsBeacon) i).returnDepth == Dungeon.depth)
|
if (i instanceof LloydsBeacon && ((LloydsBeacon) i).returnDepth == Dungeon.depth)
|
||||||
((LloydsBeacon) i).returnDepth = -1;
|
((LloydsBeacon) i).returnDepth = -1;
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ public class Messages {
|
|||||||
private static String[] prop_files = new String[]{
|
private static String[] prop_files = new String[]{
|
||||||
"com.shatteredpixel.shatteredpixeldungeon.messages.actors.actors",
|
"com.shatteredpixel.shatteredpixeldungeon.messages.actors.actors",
|
||||||
"com.shatteredpixel.shatteredpixeldungeon.messages.items.items",
|
"com.shatteredpixel.shatteredpixeldungeon.messages.items.items",
|
||||||
|
"com.shatteredpixel.shatteredpixeldungeon.messages.journal.journal",
|
||||||
"com.shatteredpixel.shatteredpixeldungeon.messages.levels.levels",
|
"com.shatteredpixel.shatteredpixeldungeon.messages.levels.levels",
|
||||||
"com.shatteredpixel.shatteredpixeldungeon.messages.plants.plants",
|
"com.shatteredpixel.shatteredpixeldungeon.messages.plants.plants",
|
||||||
"com.shatteredpixel.shatteredpixeldungeon.messages.scenes.scenes",
|
"com.shatteredpixel.shatteredpixeldungeon.messages.scenes.scenes",
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
|||||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
|
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.journal.Notes;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.HeroSprite;
|
import com.shatteredpixel.shatteredpixeldungeon.sprites.HeroSprite;
|
||||||
@@ -272,30 +274,23 @@ public class StatusPane extends Component {
|
|||||||
|
|
||||||
public void updateKeyDisplay() {
|
public void updateKeyDisplay() {
|
||||||
needsKeyUpdate = false;
|
needsKeyUpdate = false;
|
||||||
|
|
||||||
boolean foundKeys = false;
|
|
||||||
boolean blackKey = false;
|
boolean blackKey = false;
|
||||||
boolean specialKey = false;
|
boolean specialKey = false;
|
||||||
int ironKeys = 0;
|
int ironKeys = 0;
|
||||||
for (int i = 1; i <= Math.min(Dungeon.depth, 25); i++) {
|
for (Notes.KeyRecord rec : Notes.getRecords(Notes.KeyRecord.class)){
|
||||||
if (Dungeon.hero.belongings.ironKeys[i] > 0 || Dungeon.hero.belongings.specialKeys[i] > 0) {
|
if (rec.depth() < Dungeon.depth){
|
||||||
foundKeys = true;
|
blackKey = true;
|
||||||
|
} else if (rec.depth() == Dungeon.depth){
|
||||||
if (i < Dungeon.depth){
|
if (rec.type().equals(IronKey.class)) {
|
||||||
blackKey = true;
|
ironKeys += rec.quantity();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (Dungeon.hero.belongings.specialKeys[i] > 0){
|
specialKey = true;
|
||||||
specialKey = true;
|
|
||||||
}
|
|
||||||
ironKeys = Dungeon.hero.belongings.ironKeys[i];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!foundKeys){
|
if (blackKey || specialKey || ironKeys > 0){
|
||||||
icon.frame(31, 0, 11, 7);
|
|
||||||
} else {
|
|
||||||
int left = 46, top = 0, width = 0, height = 7;
|
int left = 46, top = 0, width = 0, height = 7;
|
||||||
if (blackKey){
|
if (blackKey){
|
||||||
left = 43;
|
left = 43;
|
||||||
@@ -308,6 +303,8 @@ public class StatusPane extends Component {
|
|||||||
width += ironKeys*3;
|
width += ironKeys*3;
|
||||||
width = Math.min( width, 9);
|
width = Math.min( width, 9);
|
||||||
icon.frame(left, top, width, height);
|
icon.frame(left, top, width, height);
|
||||||
|
} else {
|
||||||
|
icon.frame(31, 0, 11, 7);
|
||||||
}
|
}
|
||||||
layout();
|
layout();
|
||||||
|
|
||||||
|
|||||||
+10
-38
@@ -24,9 +24,6 @@ package com.shatteredpixel.shatteredpixeldungeon.windows;
|
|||||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.keys.GoldenKey;
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey;
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.keys.SkeletonKey;
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion;
|
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.rings.Ring;
|
import com.shatteredpixel.shatteredpixeldungeon.items.rings.Ring;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll;
|
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll;
|
||||||
@@ -199,47 +196,22 @@ public class WndJournal extends WndTabbed {
|
|||||||
private void updateList(){
|
private void updateList(){
|
||||||
Component content = list.content();
|
Component content = list.content();
|
||||||
|
|
||||||
Collections.sort( Notes.records );
|
|
||||||
|
|
||||||
float pos = 0;
|
float pos = 0;
|
||||||
|
|
||||||
//Keys
|
//Keys
|
||||||
for (int i = Dungeon.hero.belongings.ironKeys.length-1; i > 0; i--){
|
for(Notes.Record rec : Notes.getRecords(Notes.KeyRecord.class)){
|
||||||
if (Dungeon.hero.belongings.specialKeys[i] > 0){
|
ListItem item = new ListItem( Icons.get(Icons.DEPTH),
|
||||||
String text;
|
Messages.titleCase(rec.desc()), rec.depth() );
|
||||||
if (i % 5 == 0)
|
item.setRect( 0, pos, width(), ITEM_HEIGHT );
|
||||||
text = Messages.capitalize(Messages.get(SkeletonKey.class, "name"));
|
content.add( item );
|
||||||
else
|
|
||||||
text = Messages.capitalize(Messages.get(GoldenKey.class, "name"));
|
|
||||||
|
|
||||||
if (Dungeon.hero.belongings.specialKeys[i] > 1){
|
|
||||||
text += " x" + Dungeon.hero.belongings.specialKeys[i];
|
|
||||||
}
|
|
||||||
ListItem item = new ListItem( Icons.get(Icons.DEPTH), Messages.titleCase(text), i );
|
|
||||||
item.setRect( 0, pos, width(), ITEM_HEIGHT );
|
|
||||||
content.add( item );
|
|
||||||
|
|
||||||
pos += item.height();
|
|
||||||
}
|
|
||||||
if (Dungeon.hero.belongings.ironKeys[i] > 0){
|
|
||||||
String text = Messages.titleCase(Messages.get(IronKey.class, "name"));
|
|
||||||
|
|
||||||
if (Dungeon.hero.belongings.ironKeys[i] > 1){
|
|
||||||
text += " x" + Dungeon.hero.belongings.ironKeys[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
ListItem item = new ListItem( Icons.get(Icons.DEPTH), text, i );
|
|
||||||
item.setRect( 0, pos, width(), ITEM_HEIGHT );
|
|
||||||
content.add( item );
|
|
||||||
|
|
||||||
pos += item.height();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
pos += item.height();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Notes entries
|
//Landmarks
|
||||||
for (Notes.Record rec : Notes.records) {
|
for (Notes.Record rec : Notes.getRecords(Notes.LandmarkRecord.class)) {
|
||||||
ListItem item = new ListItem( Icons.get(Icons.DEPTH), rec.landmark.desc(), rec.depth );
|
ListItem item = new ListItem( Icons.get(Icons.DEPTH),
|
||||||
|
Messages.titleCase(rec.desc()), rec.depth() );
|
||||||
item.setRect( 0, pos, width(), ITEM_HEIGHT );
|
item.setRect( 0, pos, width(), ITEM_HEIGHT );
|
||||||
content.add( item );
|
content.add( item );
|
||||||
|
|
||||||
|
|||||||
+10
-10
@@ -1,10 +1,10 @@
|
|||||||
notes$landmark.well_of_health=Well of Health
|
journal.notes$landmark.well_of_health=well of health
|
||||||
notes$landmark.well_of_awareness=Well of Awareness
|
journal.notes$landmark.well_of_awareness=well of awareness
|
||||||
notes$landmark.well_of_transmutation=Well of Transmutation
|
journal.notes$landmark.well_of_transmutation=well of transmutation
|
||||||
notes$landmark.alchemy=Alchemy pot
|
journal.notes$landmark.alchemy=alchemy pot
|
||||||
notes$landmark.garden=Garden
|
journal.notes$landmark.garden=garden
|
||||||
notes$landmark.statue=Animated statue
|
journal.notes$landmark.statue=animated statue
|
||||||
notes$landmark.ghost=Sad ghost
|
journal.notes$landmark.ghost=sad ghost
|
||||||
notes$landmark.wandmaker=Old wandmaker
|
journal.notes$landmark.wandmaker=old wandmaker
|
||||||
notes$landmark.troll=Troll blacksmith
|
journal.notes$landmark.troll=troll blacksmith
|
||||||
notes$landmark.imp=Ambitious imp
|
journal.notes$landmark.imp=ambitious imp
|
||||||
Reference in New Issue
Block a user