From 7ba3a6c81cecf02ae58ff5b6346e28fd92309fdd Mon Sep 17 00:00:00 2001 From: Edu Garcia Date: Mon, 13 Oct 2014 23:31:02 +1100 Subject: [PATCH] #43: Added BUNDLE_KEY_ prefix to all (or almost all) the bundle keys --- PD-classes/src/com/watabou/utils/Bundle.java | 8 +- core/src/com/watabou/pixeldungeon/Bones.java | 12 +-- .../src/com/watabou/pixeldungeon/Dungeon.java | 88 +++++++++---------- .../src/com/watabou/pixeldungeon/Journal.java | 12 +-- .../com/watabou/pixeldungeon/Rankings.java | 38 ++++---- .../com/watabou/pixeldungeon/Statistics.java | 60 ++++++------- .../com/watabou/pixeldungeon/actors/Char.java | 26 +++--- .../pixeldungeon/actors/blobs/Blob.java | 12 +-- .../pixeldungeon/actors/buffs/Bleeding.java | 7 +- .../pixeldungeon/actors/buffs/Hunger.java | 7 +- .../pixeldungeon/actors/hero/Belongings.java | 24 ++--- .../pixeldungeon/actors/hero/Hero.java | 36 ++++---- .../pixeldungeon/actors/hero/HeroClass.java | 10 +-- .../actors/hero/HeroSubClass.java | 10 +-- .../pixeldungeon/actors/mobs/King.java | 6 +- .../watabou/pixeldungeon/actors/mobs/Mob.java | 14 +-- .../pixeldungeon/actors/mobs/Swarm.java | 6 +- .../pixeldungeon/actors/mobs/Wraith.java | 6 +- .../actors/mobs/npcs/Blacksmith.java | 42 ++++----- .../pixeldungeon/actors/mobs/npcs/Ghost.java | 66 +++++++------- .../pixeldungeon/actors/mobs/npcs/Imp.java | 44 +++++----- .../actors/mobs/npcs/MirrorImage.java | 18 ++-- .../actors/mobs/npcs/Wandmaker.java | 48 +++++----- .../watabou/pixeldungeon/items/DewVial.java | 6 +- .../com/watabou/pixeldungeon/items/Gold.java | 6 +- .../com/watabou/pixeldungeon/items/Heap.java | 18 ++-- .../com/watabou/pixeldungeon/items/Item.java | 36 ++++---- .../pixeldungeon/items/LloydsBeacon.java | 12 +-- .../pixeldungeon/items/armor/Armor.java | 6 +- .../pixeldungeon/items/armor/ClassArmor.java | 12 +-- .../items/armor/glyphs/Viscosity.java | 7 +- .../watabou/pixeldungeon/items/keys/Key.java | 6 +- .../pixeldungeon/items/quest/Pickaxe.java | 8 +- .../pixeldungeon/items/wands/Wand.java | 18 ++-- .../pixeldungeon/levels/CavesBossLevel.java | 18 ++-- .../pixeldungeon/levels/CityBossLevel.java | 18 ++-- .../pixeldungeon/levels/HallsBossLevel.java | 18 ++-- .../watabou/pixeldungeon/levels/Level.java | 54 ++++++------ .../pixeldungeon/levels/PrisonBossLevel.java | 24 ++--- .../com/watabou/pixeldungeon/levels/Room.java | 32 ++++--- .../pixeldungeon/plants/Earthroot.java | 12 +-- .../watabou/pixeldungeon/plants/Plant.java | 8 +- .../watabou/pixeldungeon/plants/Sungrass.java | 6 +- 43 files changed, 464 insertions(+), 461 deletions(-) diff --git a/PD-classes/src/com/watabou/utils/Bundle.java b/PD-classes/src/com/watabou/utils/Bundle.java index e266acca..eca12512 100644 --- a/PD-classes/src/com/watabou/utils/Bundle.java +++ b/PD-classes/src/com/watabou/utils/Bundle.java @@ -37,7 +37,7 @@ public class Bundle { - private static final String CLASS_NAME = "__className"; + private static final String BUNDLE_KEY_CLASS_NAME = "__className"; private static HashMap aliases = new HashMap(); @@ -81,7 +81,7 @@ public Bundle getBundle( String key ) { private Bundlable get() { try { - String clName = getString( CLASS_NAME ); + String clName = getString(BUNDLE_KEY_CLASS_NAME); if (aliases.containsKey( clName )) { clName = aliases.get( clName ); } @@ -206,7 +206,7 @@ public void put( String key, Bundlable object ) { if (object != null) { try { Bundle bundle = new Bundle(); - bundle.put( CLASS_NAME, object.getClass().getName() ); + bundle.put(BUNDLE_KEY_CLASS_NAME, object.getClass().getName()); object.storeInBundle( bundle ); data.put( key, bundle.data ); } catch (JSONException e) { @@ -254,7 +254,7 @@ public void put( String key, Collection collection ) { JSONArray array = new JSONArray(); for (Bundlable object : collection) { Bundle bundle = new Bundle(); - bundle.put( CLASS_NAME, object.getClass().getName() ); + bundle.put(BUNDLE_KEY_CLASS_NAME, object.getClass().getName() ); object.storeInBundle( bundle ); array.put( bundle.data ); } diff --git a/core/src/com/watabou/pixeldungeon/Bones.java b/core/src/com/watabou/pixeldungeon/Bones.java index e741b528..3467643d 100644 --- a/core/src/com/watabou/pixeldungeon/Bones.java +++ b/core/src/com/watabou/pixeldungeon/Bones.java @@ -32,8 +32,8 @@ public class Bones { private static final String BONES_FILE = "bones.dat"; - private static final String LEVEL = "level"; - private static final String ITEM = "item"; + private static final String BUNDLE_KEY_LEVEL = "level"; + private static final String BUNDLE_KEY_ITEM = "item"; private static int depth = -1; private static Item item; @@ -66,8 +66,8 @@ public static void leave() { depth = Dungeon.depth; Bundle bundle = new Bundle(); - bundle.put( LEVEL, depth ); - bundle.put( ITEM, item ); + bundle.put(BUNDLE_KEY_LEVEL, depth ); + bundle.put(BUNDLE_KEY_ITEM, item ); try { OutputStream output = Game.instance.openFileOutput( BONES_FILE ); @@ -86,8 +86,8 @@ public static Item get() { Bundle bundle = Bundle.read( input ); input.close(); - depth = bundle.getInt( LEVEL ); - item = (Item)bundle.get( ITEM ); + depth = bundle.getInt(BUNDLE_KEY_LEVEL); + item = (Item)bundle.get(BUNDLE_KEY_ITEM); return get(); diff --git a/core/src/com/watabou/pixeldungeon/Dungeon.java b/core/src/com/watabou/pixeldungeon/Dungeon.java index ffa72951..d4c16227 100644 --- a/core/src/com/watabou/pixeldungeon/Dungeon.java +++ b/core/src/com/watabou/pixeldungeon/Dungeon.java @@ -322,20 +322,20 @@ public static boolean asNeeded() { private static final String RN_GAME_FILE = "ranger.dat"; private static final String RN_DEPTH_FILE = "ranger%d.dat"; - private static final String VERSION = "version"; - private static final String HERO = "hero"; - private static final String GOLD = "gold"; - private static final String DEPTH = "depth"; - private static final String QUICKSLOT = "quickslot"; - private static final String LEVEL = "level"; - private static final String POS = "potionsOfStrength"; - private static final String SOU = "scrollsOfEnhancement"; - private static final String AS = "arcaneStyli"; - private static final String DV = "dewVial"; - private static final String WT = "transmutation"; - private static final String CHAPTERS = "chapters"; - private static final String QUESTS = "quests"; - private static final String BADGES = "badges"; + private static final String BUNDLE_KEY_VERSION = "version"; + private static final String BUNDLE_KEY_HERO = "hero"; + private static final String BUNDLE_KEY_GOLD = "gold"; + private static final String BUNDLE_KEY_DEPTH = "depth"; + private static final String BUNDLE_KEY_QUICKSLOT = "quickslot"; + private static final String BUNDLE_KEY_LEVEL = "level"; + private static final String BUNDLE_KEY_POS = "potionsOfStrength"; + private static final String BUNDLE_KEY_SOU = "scrollsOfEnhancement"; + private static final String BUNDLE_KEY_AS = "arcaneStyli"; + private static final String BUNDLE_KEY_DV = "dewVial"; + private static final String BUNDLE_KEY_WT = "transmutation"; + private static final String BUNDLE_KEY_CHAPTERS = "chapters"; + private static final String BUNDLE_KEY_QUESTS = "quests"; + private static final String BUNDLE_KEY_BADGES = "badges"; public static String gameFile( HeroClass cl ) { switch (cl) { @@ -367,30 +367,30 @@ public static void saveGame( String fileName ) throws IOException { try { Bundle bundle = new Bundle(); - bundle.put( VERSION, Game.version ); - bundle.put( HERO, hero ); - bundle.put( GOLD, gold ); - bundle.put( DEPTH, depth ); + bundle.put(BUNDLE_KEY_VERSION, Game.version ); + bundle.put(BUNDLE_KEY_HERO, hero ); + bundle.put(BUNDLE_KEY_GOLD, gold ); + bundle.put(BUNDLE_KEY_DEPTH, depth ); - bundle.put( POS, potionOfStrength ); - bundle.put( SOU, scrollsOfUpgrade ); - bundle.put( AS, arcaneStyli ); - bundle.put( DV, dewVial ); - bundle.put( WT, transmutation ); + bundle.put(BUNDLE_KEY_POS, potionOfStrength ); + bundle.put(BUNDLE_KEY_SOU, scrollsOfUpgrade ); + bundle.put(BUNDLE_KEY_AS, arcaneStyli ); + bundle.put(BUNDLE_KEY_DV, dewVial ); + bundle.put(BUNDLE_KEY_WT, transmutation ); int count = 0; int ids[] = new int[chapters.size()]; for (Integer id : chapters) { ids[count++] = id; } - bundle.put( CHAPTERS, ids ); + bundle.put(BUNDLE_KEY_CHAPTERS, ids ); Bundle quests = new Bundle(); Ghost .Quest.storeInBundle( quests ); Wandmaker .Quest.storeInBundle( quests ); Blacksmith .Quest.storeInBundle( quests ); Imp .Quest.storeInBundle( quests ); - bundle.put( QUESTS, quests ); + bundle.put(BUNDLE_KEY_QUESTS, quests ); Room.storeRoomsInBundle( bundle ); @@ -398,7 +398,7 @@ public static void saveGame( String fileName ) throws IOException { Journal.storeInBundle( bundle ); if (quickslot instanceof Class) { - bundle.put( QUICKSLOT, ((Class)quickslot).getName() ); + bundle.put(BUNDLE_KEY_QUICKSLOT, ((Class)quickslot).getName() ); } Scroll.save( bundle ); @@ -408,7 +408,7 @@ public static void saveGame( String fileName ) throws IOException { Bundle badges = new Bundle(); Badges.saveLocal( badges ); - bundle.put( BADGES, badges ); + bundle.put(BUNDLE_KEY_BADGES, badges ); OutputStream output = Game.instance.openFileOutput( fileName ); Bundle.write( bundle, output ); @@ -422,7 +422,7 @@ public static void saveGame( String fileName ) throws IOException { public static void saveLevel() throws IOException { Bundle bundle = new Bundle(); - bundle.put( LEVEL, level ); + bundle.put(BUNDLE_KEY_LEVEL, level ); OutputStream output = Game.instance.openFileOutput( Utils.format( depthFile( hero.heroClass ), depth ) ); @@ -475,22 +475,22 @@ public static void loadGame( String fileName, boolean fullLoad ) throws IOExcept Wand.restore( bundle ); Ring.restore( bundle ); - potionOfStrength = bundle.getInt( POS ); - scrollsOfUpgrade = bundle.getInt( SOU ); - arcaneStyli = bundle.getInt( AS ); - dewVial = bundle.getBoolean( DV ); - transmutation = bundle.getInt( WT ); + potionOfStrength = bundle.getInt(BUNDLE_KEY_POS); + scrollsOfUpgrade = bundle.getInt(BUNDLE_KEY_SOU); + arcaneStyli = bundle.getInt(BUNDLE_KEY_AS); + dewVial = bundle.getBoolean(BUNDLE_KEY_DV); + transmutation = bundle.getInt(BUNDLE_KEY_WT); if (fullLoad) { chapters = new HashSet(); - int ids[] = bundle.getIntArray( CHAPTERS ); + int ids[] = bundle.getIntArray(BUNDLE_KEY_CHAPTERS); if (ids != null) { for (int id : ids) { chapters.add( id ); } } - Bundle quests = bundle.getBundle( QUESTS ); + Bundle quests = bundle.getBundle(BUNDLE_KEY_QUESTS); if (!quests.isNull()) { Ghost.Quest.restoreFromBundle( quests ); Wandmaker.Quest.restoreFromBundle( quests ); @@ -506,14 +506,14 @@ public static void loadGame( String fileName, boolean fullLoad ) throws IOExcept Room.restoreRoomsFromBundle( bundle ); } - Bundle badges = bundle.getBundle( BADGES ); + Bundle badges = bundle.getBundle(BUNDLE_KEY_BADGES); if (!badges.isNull()) { Badges.loadLocal( badges ); } else { Badges.reset(); } - String qsClass = bundle.getString( QUICKSLOT ); + String qsClass = bundle.getString(BUNDLE_KEY_QUICKSLOT); if (qsClass != null) { try { quickslot = Class.forName( qsClass ); @@ -524,13 +524,13 @@ public static void loadGame( String fileName, boolean fullLoad ) throws IOExcept } @SuppressWarnings("unused") - String version = bundle.getString( VERSION ); + String version = bundle.getString(BUNDLE_KEY_VERSION); hero = null; - hero = (Hero)bundle.get( HERO ); + hero = (Hero)bundle.get(BUNDLE_KEY_HERO); - gold = bundle.getInt( GOLD ); - depth = bundle.getInt( DEPTH ); + gold = bundle.getInt(BUNDLE_KEY_GOLD); + depth = bundle.getInt(BUNDLE_KEY_DEPTH); Statistics.restoreFromBundle( bundle ); Journal.restoreFromBundle( bundle ); @@ -545,7 +545,7 @@ public static Level loadLevel( HeroClass cl ) throws IOException { Bundle bundle = Bundle.read( input ); input.close(); - return (Level)bundle.get( "level" ); + return (Level)bundle.get(BUNDLE_KEY_LEVEL); } public static void deleteGame( HeroClass cl, boolean deleteLevels ) { @@ -572,11 +572,11 @@ public static Bundle gameBundle( String fileName ) throws IOException { } public static void preview( GamesInProgress.Info info, Bundle bundle ) { - info.depth = bundle.getInt( DEPTH ); + info.depth = bundle.getInt(BUNDLE_KEY_DEPTH); if (info.depth == -1) { info.depth = bundle.getInt( "maxDepth" ); // <-- It has to be refactored! } - Hero.preview( info, bundle.getBundle( HERO ) ); + Hero.preview( info, bundle.getBundle(BUNDLE_KEY_HERO) ); } public static void fail( String desc ) { diff --git a/core/src/com/watabou/pixeldungeon/Journal.java b/core/src/com/watabou/pixeldungeon/Journal.java index 3edf2b41..3a04625a 100644 --- a/core/src/com/watabou/pixeldungeon/Journal.java +++ b/core/src/com/watabou/pixeldungeon/Journal.java @@ -46,8 +46,8 @@ private Feature( String desc ) { public static class Record implements Comparable, Bundlable { - private static final String FEATURE = "feature"; - private static final String DEPTH = "depth"; + private static final String BUNDLE_KEY_FEATURE = "feature"; + private static final String BUNDLE_KEY_DEPTH = "depth"; public Feature feature; public int depth; @@ -67,14 +67,14 @@ public int compareTo( Record another ) { @Override public void restoreFromBundle( Bundle bundle ) { - feature = Feature.valueOf( bundle.getString( FEATURE ) ); - depth = bundle.getInt( DEPTH ); + feature = Feature.valueOf( bundle.getString(BUNDLE_KEY_FEATURE) ); + depth = bundle.getInt(BUNDLE_KEY_DEPTH); } @Override public void storeInBundle( Bundle bundle ) { - bundle.put( FEATURE, feature.toString() ); - bundle.put( DEPTH, depth ); + bundle.put(BUNDLE_KEY_FEATURE, feature.toString()); + bundle.put(BUNDLE_KEY_DEPTH, depth); } } diff --git a/core/src/com/watabou/pixeldungeon/Rankings.java b/core/src/com/watabou/pixeldungeon/Rankings.java index 9e8fc980..f0f382a6 100644 --- a/core/src/com/watabou/pixeldungeon/Rankings.java +++ b/core/src/com/watabou/pixeldungeon/Rankings.java @@ -143,11 +143,11 @@ public void load() { public static class Record implements Bundlable { - private static final String REASON = "reason"; - private static final String WIN = "win"; - private static final String SCORE = "score"; - private static final String TIER = "tier"; - private static final String GAME = "gameFile"; + private static final String BUNDLE_KEY_REASON = "reason"; + private static final String BUNDLE_KEY_WIN = "win"; + private static final String BUNDLE_KEY_SCORE = "score"; + private static final String BUNDLE_KEY_TIER = "tier"; + private static final String BUNDLE_KEY_GAME = "gameFile"; public String info; public boolean win; @@ -162,27 +162,27 @@ public static class Record implements Bundlable { @Override public void restoreFromBundle( Bundle bundle ) { - info = bundle.getString( REASON ); - win = bundle.getBoolean( WIN ); - score = bundle.getInt( SCORE ); + info = bundle.getString(BUNDLE_KEY_REASON); + win = bundle.getBoolean(BUNDLE_KEY_WIN); + score = bundle.getInt(BUNDLE_KEY_SCORE); heroClass = HeroClass.restoreInBundle( bundle ); - armorTier = bundle.getInt( TIER ); + armorTier = bundle.getInt(BUNDLE_KEY_TIER); - gameFile = bundle.getString( GAME ); + gameFile = bundle.getString(BUNDLE_KEY_GAME); } @Override public void storeInBundle( Bundle bundle ) { - - bundle.put( REASON, info ); - bundle.put( WIN, win ); - bundle.put( SCORE, score ); - - heroClass.storeInBundle( bundle ); - bundle.put( TIER, armorTier ); - - bundle.put( GAME, gameFile ); + + bundle.put(BUNDLE_KEY_REASON, info); + bundle.put(BUNDLE_KEY_WIN, win); + bundle.put(BUNDLE_KEY_SCORE, score); + + heroClass.storeInBundle(bundle); + bundle.put(BUNDLE_KEY_TIER, armorTier); + + bundle.put(BUNDLE_KEY_GAME, gameFile); } } diff --git a/core/src/com/watabou/pixeldungeon/Statistics.java b/core/src/com/watabou/pixeldungeon/Statistics.java index 2b745317..691703de 100644 --- a/core/src/com/watabou/pixeldungeon/Statistics.java +++ b/core/src/com/watabou/pixeldungeon/Statistics.java @@ -56,41 +56,41 @@ public static void reset() { } - private static final String GOLD = "score"; - private static final String DEEPEST = "maxDepth"; - private static final String SLAIN = "enemiesSlain"; - private static final String FOOD = "foodEaten"; - private static final String ALCHEMY = "potionsCooked"; - private static final String PIRANHAS = "priranhas"; - private static final String NIGHT = "nightHunt"; - private static final String ANKHS = "ankhsUsed"; - private static final String DURATION = "duration"; - private static final String AMULET = "amuletObtained"; + private static final String BUNDLE_KEY_GOLD = "score"; + private static final String BUNDLE_KEY_DEEPEST = "maxDepth"; + private static final String BUNDLE_KEY_SLAIN = "enemiesSlain"; + private static final String BUNDLE_KEY_FOOD = "foodEaten"; + private static final String BUNDLE_KEY_ALCHEMY = "potionsCooked"; + private static final String BUNDLE_KEY_PIRANHAS = "priranhas"; + private static final String BUNDLE_KEY_NIGHT = "nightHunt"; + private static final String BUNDLE_KEY_ANKHS = "ankhsUsed"; + private static final String BUNDLE_KEY_DURATION = "duration"; + private static final String BUNDLE_KEY_AMULET = "amuletObtained"; public static void storeInBundle( Bundle bundle ) { - bundle.put( GOLD, goldCollected ); - bundle.put( DEEPEST, deepestFloor ); - bundle.put( SLAIN, enemiesSlain ); - bundle.put( FOOD, foodEaten ); - bundle.put( ALCHEMY, potionsCooked ); - bundle.put( PIRANHAS, piranhasKilled ); - bundle.put( NIGHT, nightHunt ); - bundle.put( ANKHS, ankhsUsed ); - bundle.put( DURATION, duration ); - bundle.put( AMULET, amuletObtained ); + bundle.put(BUNDLE_KEY_GOLD, goldCollected); + bundle.put(BUNDLE_KEY_DEEPEST, deepestFloor); + bundle.put(BUNDLE_KEY_SLAIN, enemiesSlain); + bundle.put(BUNDLE_KEY_FOOD, foodEaten); + bundle.put(BUNDLE_KEY_ALCHEMY, potionsCooked); + bundle.put(BUNDLE_KEY_PIRANHAS, piranhasKilled); + bundle.put(BUNDLE_KEY_NIGHT, nightHunt); + bundle.put(BUNDLE_KEY_ANKHS, ankhsUsed); + bundle.put(BUNDLE_KEY_DURATION, duration); + bundle.put(BUNDLE_KEY_AMULET, amuletObtained); } public static void restoreFromBundle( Bundle bundle ) { - goldCollected = bundle.getInt( GOLD ); - deepestFloor = bundle.getInt( DEEPEST ); - enemiesSlain = bundle.getInt( SLAIN ); - foodEaten = bundle.getInt( FOOD ); - potionsCooked = bundle.getInt( ALCHEMY ); - piranhasKilled = bundle.getInt( PIRANHAS ); - nightHunt = bundle.getInt( NIGHT ); - ankhsUsed = bundle.getInt( ANKHS ); - duration = bundle.getFloat( DURATION ); - amuletObtained = bundle.getBoolean( AMULET ); + goldCollected = bundle.getInt(BUNDLE_KEY_GOLD); + deepestFloor = bundle.getInt(BUNDLE_KEY_DEEPEST); + enemiesSlain = bundle.getInt(BUNDLE_KEY_SLAIN); + foodEaten = bundle.getInt(BUNDLE_KEY_FOOD); + potionsCooked = bundle.getInt(BUNDLE_KEY_ALCHEMY); + piranhasKilled = bundle.getInt(BUNDLE_KEY_PIRANHAS); + nightHunt = bundle.getInt(BUNDLE_KEY_NIGHT); + ankhsUsed = bundle.getInt(BUNDLE_KEY_ANKHS); + duration = bundle.getFloat(BUNDLE_KEY_DURATION); + amuletObtained = bundle.getBoolean(BUNDLE_KEY_AMULET); } } diff --git a/core/src/com/watabou/pixeldungeon/actors/Char.java b/core/src/com/watabou/pixeldungeon/actors/Char.java index 626055a2..64c08c2a 100644 --- a/core/src/com/watabou/pixeldungeon/actors/Char.java +++ b/core/src/com/watabou/pixeldungeon/actors/Char.java @@ -98,20 +98,20 @@ protected boolean act() { return false; } - private static final String POS = "pos"; - private static final String TAG_HP = "HP"; - private static final String TAG_HT = "HT"; - private static final String BUFFS = "buffs"; + private static final String BUNDLE_KEY_POS = "pos"; + private static final String BUNDLE_KEY_TAG_HP = "HP"; + private static final String BUNDLE_KEY_TAG_HT = "HT"; + private static final String BUNDLE_KEY_BUFFS = "buffs"; @Override public void storeInBundle( Bundle bundle ) { super.storeInBundle( bundle ); - - bundle.put( POS, pos ); - bundle.put( TAG_HP, HP ); - bundle.put( TAG_HT, HT ); - bundle.put( BUFFS, buffs ); + + bundle.put(BUNDLE_KEY_POS, pos); + bundle.put(BUNDLE_KEY_TAG_HP, HP); + bundle.put(BUNDLE_KEY_TAG_HT, HT); + bundle.put(BUNDLE_KEY_BUFFS, buffs); } @Override @@ -119,11 +119,11 @@ public void restoreFromBundle( Bundle bundle ) { super.restoreFromBundle( bundle ); - pos = bundle.getInt( POS ); - HP = bundle.getInt( TAG_HP ); - HT = bundle.getInt( TAG_HT ); + pos = bundle.getInt(BUNDLE_KEY_POS); + HP = bundle.getInt(BUNDLE_KEY_TAG_HP); + HT = bundle.getInt(BUNDLE_KEY_TAG_HT); - for (Bundlable b : bundle.getCollection( BUFFS )) { + for (Bundlable b : bundle.getCollection(BUNDLE_KEY_BUFFS)) { if (b != null) { ((Buff)b).attachTo( this ); } diff --git a/core/src/com/watabou/pixeldungeon/actors/blobs/Blob.java b/core/src/com/watabou/pixeldungeon/actors/blobs/Blob.java index 8bbda7e4..a36a3737 100644 --- a/core/src/com/watabou/pixeldungeon/actors/blobs/Blob.java +++ b/core/src/com/watabou/pixeldungeon/actors/blobs/Blob.java @@ -49,8 +49,8 @@ protected Blob() { volume = 0; } - private static final String CUR = "cur"; - private static final String START = "start"; + private static final String BUNDLE_KEY_CUR = "cur"; + private static final String BUNDLE_KEY_START = "start"; @Override public void storeInBundle( Bundle bundle ) { @@ -71,8 +71,8 @@ public void storeInBundle( Bundle bundle ) { } } - bundle.put( START, start ); - bundle.put( CUR, trim( start, end + 1 ) ); + bundle.put(BUNDLE_KEY_START, start); + bundle.put(BUNDLE_KEY_CUR, trim( start, end + 1 )); } } @@ -89,9 +89,9 @@ public void restoreFromBundle( Bundle bundle ) { super.restoreFromBundle( bundle ); - int[] data = bundle.getIntArray( CUR ); + int[] data = bundle.getIntArray(BUNDLE_KEY_CUR); if (data != null) { - int start = bundle.getInt( START ); + int start = bundle.getInt(BUNDLE_KEY_START); for (int i=0; i < data.length; i++) { cur[i + start] = data[i]; volume += data[i]; diff --git a/core/src/com/watabou/pixeldungeon/actors/buffs/Bleeding.java b/core/src/com/watabou/pixeldungeon/actors/buffs/Bleeding.java index 43cd686c..f39ff15c 100644 --- a/core/src/com/watabou/pixeldungeon/actors/buffs/Bleeding.java +++ b/core/src/com/watabou/pixeldungeon/actors/buffs/Bleeding.java @@ -22,7 +22,6 @@ import com.watabou.pixeldungeon.effects.Splash; import com.watabou.pixeldungeon.ui.BuffIndicator; import com.watabou.pixeldungeon.utils.GLog; -import com.watabou.pixeldungeon.utils.Utils; import com.watabou.utils.Bundle; import com.watabou.utils.PointF; import com.watabou.utils.Random; @@ -33,19 +32,19 @@ public class Bleeding extends Buff { protected int level; - private static final String LEVEL = "level"; + private static final String BUNDLE_KEY_LEVEL = "level"; @Override public void storeInBundle( Bundle bundle ) { super.storeInBundle( bundle ); - bundle.put( LEVEL, level ); + bundle.put(BUNDLE_KEY_LEVEL, level); } @Override public void restoreFromBundle( Bundle bundle ) { super.restoreFromBundle( bundle ); - level = bundle.getInt( LEVEL ); + level = bundle.getInt(BUNDLE_KEY_LEVEL); } public void set( int level ) { diff --git a/core/src/com/watabou/pixeldungeon/actors/buffs/Hunger.java b/core/src/com/watabou/pixeldungeon/actors/buffs/Hunger.java index 571ea3c7..068326d0 100644 --- a/core/src/com/watabou/pixeldungeon/actors/buffs/Hunger.java +++ b/core/src/com/watabou/pixeldungeon/actors/buffs/Hunger.java @@ -25,7 +25,6 @@ import com.watabou.pixeldungeon.items.rings.RingOfSatiety; import com.watabou.pixeldungeon.ui.BuffIndicator; import com.watabou.pixeldungeon.utils.GLog; -import com.watabou.pixeldungeon.utils.Utils; import com.watabou.utils.Bundle; import com.watabou.utils.Random; @@ -44,18 +43,18 @@ public class Hunger extends Buff implements Hero.Doom { private float level; - private static final String LEVEL = "level"; + private static final String BUNDLE_KEY_LEVEL = "level"; @Override public void storeInBundle( Bundle bundle ) { super.storeInBundle( bundle ); - bundle.put( LEVEL, level ); + bundle.put(BUNDLE_KEY_LEVEL, level); } @Override public void restoreFromBundle( Bundle bundle ) { super.restoreFromBundle( bundle ); - level = bundle.getFloat( LEVEL ); + level = bundle.getFloat(BUNDLE_KEY_LEVEL); } @Override diff --git a/core/src/com/watabou/pixeldungeon/actors/hero/Belongings.java b/core/src/com/watabou/pixeldungeon/actors/hero/Belongings.java index 88a594b3..945c98a8 100644 --- a/core/src/com/watabou/pixeldungeon/actors/hero/Belongings.java +++ b/core/src/com/watabou/pixeldungeon/actors/hero/Belongings.java @@ -56,19 +56,19 @@ public Belongings( Hero owner ) { backpack.owner = owner; } - private static final String WEAPON = "weapon"; - private static final String ARMOR = "armor"; - private static final String RING1 = "ring1"; - private static final String RING2 = "ring2"; + private static final String BUNDLE_KEY_WEAPON = "weapon"; + public static final String BUNDLE_KEY_ARMOR = "armor"; + private static final String BUNDLE_KEY_RING1 = "ring1"; + private static final String BUNDLE_KEY_RING2 = "ring2"; public void storeInBundle( Bundle bundle ) { backpack.storeInBundle( bundle ); - bundle.put( WEAPON, weapon ); - bundle.put( ARMOR, armor ); - bundle.put( RING1, ring1 ); - bundle.put( RING2, ring2 ); + bundle.put(BUNDLE_KEY_WEAPON, weapon ); + bundle.put(BUNDLE_KEY_ARMOR, armor ); + bundle.put(BUNDLE_KEY_RING1, ring1 ); + bundle.put(BUNDLE_KEY_RING2, ring2 ); } public void restoreFromBundle( Bundle bundle ) { @@ -76,19 +76,19 @@ public void restoreFromBundle( Bundle bundle ) { backpack.clear(); backpack.restoreFromBundle( bundle ); - weapon = (KindOfWeapon)bundle.get( WEAPON ); + weapon = (KindOfWeapon)bundle.get(BUNDLE_KEY_WEAPON); if (weapon != null) { weapon.activate( owner ); } - armor = (Armor)bundle.get( ARMOR ); + armor = (Armor)bundle.get(BUNDLE_KEY_ARMOR); - ring1 = (Ring)bundle.get( RING1 ); + ring1 = (Ring)bundle.get(BUNDLE_KEY_RING1); if (ring1 != null) { ring1.activate( owner ); } - ring2 = (Ring)bundle.get( RING2 ); + ring2 = (Ring)bundle.get(BUNDLE_KEY_RING2); if (ring2 != null) { ring2.activate( owner ); } diff --git a/core/src/com/watabou/pixeldungeon/actors/hero/Hero.java b/core/src/com/watabou/pixeldungeon/actors/hero/Hero.java index 1eb40293..5a71d220 100644 --- a/core/src/com/watabou/pixeldungeon/actors/hero/Hero.java +++ b/core/src/com/watabou/pixeldungeon/actors/hero/Hero.java @@ -187,12 +187,12 @@ public int STR() { return weakened ? STR - 2 : STR; } - private static final String ATTACK = "attackSkill"; - private static final String DEFENSE = "defenseSkill"; - private static final String STRENGTH = "STR"; - private static final String LEVEL = "lvl"; - private static final String EXPERIENCE = "exp"; - + private static final String BUNDLE_KEY_ATTACK = "attackSkill"; + private static final String BUNDLE_KEY_DEFENSE = "defenseSkill"; + private static final String BUNDLE_KEY_STRENGTH = "STR"; + private static final String BUNDLE_KEY_LEVEL = "lvl"; + private static final String BUNDLE_KEY_EXPERIENCE = "exp"; + @Override public void storeInBundle( Bundle bundle ) { super.storeInBundle( bundle ); @@ -200,13 +200,13 @@ public void storeInBundle( Bundle bundle ) { heroClass.storeInBundle( bundle ); subClass.storeInBundle( bundle ); - bundle.put( ATTACK, attackSkill ); - bundle.put( DEFENSE, defenseSkill ); + bundle.put(BUNDLE_KEY_ATTACK, attackSkill ); + bundle.put(BUNDLE_KEY_DEFENSE, defenseSkill ); - bundle.put( STRENGTH, STR ); + bundle.put(BUNDLE_KEY_STRENGTH, STR ); - bundle.put( LEVEL, lvl ); - bundle.put( EXPERIENCE, exp ); + bundle.put(BUNDLE_KEY_LEVEL, lvl ); + bundle.put(BUNDLE_KEY_EXPERIENCE, exp ); belongings.storeInBundle( bundle ); } @@ -218,23 +218,23 @@ public void restoreFromBundle( Bundle bundle ) { heroClass = HeroClass.restoreInBundle( bundle ); subClass = HeroSubClass.restoreInBundle( bundle ); - attackSkill = bundle.getInt( ATTACK ); - defenseSkill = bundle.getInt( DEFENSE ); + attackSkill = bundle.getInt(BUNDLE_KEY_ATTACK); + defenseSkill = bundle.getInt(BUNDLE_KEY_DEFENSE); - STR = bundle.getInt( STRENGTH ); + STR = bundle.getInt(BUNDLE_KEY_STRENGTH); updateAwareness(); - lvl = bundle.getInt( LEVEL ); - exp = bundle.getInt( EXPERIENCE ); + lvl = bundle.getInt(BUNDLE_KEY_LEVEL); + exp = bundle.getInt(BUNDLE_KEY_EXPERIENCE); belongings.restoreFromBundle( bundle ); } public static void preview( GamesInProgress.Info info, Bundle bundle ) { // Refactoring needed! - Armor armor = (Armor)bundle.get( "armor" ); + Armor armor = (Armor)bundle.get(Belongings.BUNDLE_KEY_ARMOR); info.armor = armor == null ? 0 : armor.tier; - info.level = bundle.getInt( LEVEL ); + info.level = bundle.getInt(BUNDLE_KEY_LEVEL); } public String className() { diff --git a/core/src/com/watabou/pixeldungeon/actors/hero/HeroClass.java b/core/src/com/watabou/pixeldungeon/actors/hero/HeroClass.java index 7733dd01..4b6a6c16 100644 --- a/core/src/com/watabou/pixeldungeon/actors/hero/HeroClass.java +++ b/core/src/com/watabou/pixeldungeon/actors/hero/HeroClass.java @@ -208,14 +208,14 @@ public String[] perks() { return null; } - private static final String CLASS = "class"; - - public void storeInBundle( Bundle bundle ) { - bundle.put( CLASS, toString() ); + private static final String BUNDLE_KEY_CLASS = "class"; + + public void storeInBundle(Bundle bundle) { + bundle.put(BUNDLE_KEY_CLASS, toString()); } public static HeroClass restoreInBundle( Bundle bundle ) { - String value = bundle.getString( CLASS ); + String value = bundle.getString(BUNDLE_KEY_CLASS); return value.length() > 0 ? valueOf( value ) : ROGUE; } } diff --git a/core/src/com/watabou/pixeldungeon/actors/hero/HeroSubClass.java b/core/src/com/watabou/pixeldungeon/actors/hero/HeroSubClass.java index de594fc4..8a3c0376 100644 --- a/core/src/com/watabou/pixeldungeon/actors/hero/HeroSubClass.java +++ b/core/src/com/watabou/pixeldungeon/actors/hero/HeroSubClass.java @@ -70,14 +70,14 @@ public String desc() { return desc; } - private static final String SUBCLASS = "subClass"; - - public void storeInBundle( Bundle bundle ) { - bundle.put( SUBCLASS, toString() ); + private static final String BUNDLE_KEY_SUBCLASS = "subClass"; + + public void storeInBundle(Bundle bundle) { + bundle.put(BUNDLE_KEY_SUBCLASS, toString()); } public static HeroSubClass restoreInBundle( Bundle bundle ) { - String value = bundle.getString( SUBCLASS ); + String value = bundle.getString(BUNDLE_KEY_SUBCLASS); try { return valueOf( value ); } catch (Exception e) { diff --git a/core/src/com/watabou/pixeldungeon/actors/mobs/King.java b/core/src/com/watabou/pixeldungeon/actors/mobs/King.java index dc534c7d..110e2418 100644 --- a/core/src/com/watabou/pixeldungeon/actors/mobs/King.java +++ b/core/src/com/watabou/pixeldungeon/actors/mobs/King.java @@ -62,18 +62,18 @@ public class King extends Mob { private boolean nextPedestal = true; - private static final String PEDESTAL = "pedestal"; + private static final String BUNDLE_KEY_PEDESTAL = "pedestal"; @Override public void storeInBundle( Bundle bundle ) { super.storeInBundle( bundle ); - bundle.put( PEDESTAL, nextPedestal ); + bundle.put(BUNDLE_KEY_PEDESTAL, nextPedestal); } @Override public void restoreFromBundle( Bundle bundle ) { super.restoreFromBundle( bundle ); - nextPedestal = bundle.getBoolean( PEDESTAL ); + nextPedestal = bundle.getBoolean(BUNDLE_KEY_PEDESTAL); } @Override diff --git a/core/src/com/watabou/pixeldungeon/actors/mobs/Mob.java b/core/src/com/watabou/pixeldungeon/actors/mobs/Mob.java index e90867e1..f7f4325e 100644 --- a/core/src/com/watabou/pixeldungeon/actors/mobs/Mob.java +++ b/core/src/com/watabou/pixeldungeon/actors/mobs/Mob.java @@ -82,17 +82,17 @@ public enum State { } }; - private static final String STATE = "state"; - private static final String TARGET = "target"; + private static final String BUNDLE_KEY_STATE = "state"; + private static final String BUNDLE_KEY_TARGET = "target"; @Override public void storeInBundle( Bundle bundle ) { super.storeInBundle( bundle ); - - bundle.put( STATE, state.toString() ); + + bundle.put(BUNDLE_KEY_STATE, state.toString()); if (state != State.SLEEPING) { - bundle.put( TARGET, target ); + bundle.put(BUNDLE_KEY_TARGET, target); } } @@ -101,9 +101,9 @@ public void restoreFromBundle( Bundle bundle ) { super.restoreFromBundle( bundle ); - state = State.valueOf( bundle.getString( STATE ) ); + state = State.valueOf( bundle.getString(BUNDLE_KEY_STATE) ); if (state != State.SLEEPING) { - target = bundle.getInt( TARGET ); + target = bundle.getInt(BUNDLE_KEY_TARGET); } } diff --git a/core/src/com/watabou/pixeldungeon/actors/mobs/Swarm.java b/core/src/com/watabou/pixeldungeon/actors/mobs/Swarm.java index 9e3dcb54..fbb027d9 100644 --- a/core/src/com/watabou/pixeldungeon/actors/mobs/Swarm.java +++ b/core/src/com/watabou/pixeldungeon/actors/mobs/Swarm.java @@ -53,18 +53,18 @@ public class Swarm extends Mob { int generation = 0; - private static final String GENERATION = "generation"; + private static final String BUNDLE_KEY_GENERATION = "generation"; @Override public void storeInBundle( Bundle bundle ) { super.storeInBundle( bundle ); - bundle.put( GENERATION, generation ); + bundle.put(BUNDLE_KEY_GENERATION, generation); } @Override public void restoreFromBundle( Bundle bundle ) { super.restoreFromBundle( bundle ); - generation = bundle.getInt( GENERATION ); + generation = bundle.getInt(BUNDLE_KEY_GENERATION); } @Override diff --git a/core/src/com/watabou/pixeldungeon/actors/mobs/Wraith.java b/core/src/com/watabou/pixeldungeon/actors/mobs/Wraith.java index 2a05e26d..6791b6e4 100644 --- a/core/src/com/watabou/pixeldungeon/actors/mobs/Wraith.java +++ b/core/src/com/watabou/pixeldungeon/actors/mobs/Wraith.java @@ -48,18 +48,18 @@ public class Wraith extends Mob { flying = true; } - private static final String LEVEL = "level"; + private static final String BUNDLE_KEY_LEVEL = "level"; @Override public void storeInBundle( Bundle bundle ) { super.storeInBundle( bundle ); - bundle.put( LEVEL, level ); + bundle.put(BUNDLE_KEY_LEVEL, level); } @Override public void restoreFromBundle( Bundle bundle ) { super.restoreFromBundle( bundle ); - level = bundle.getInt( LEVEL ); + level = bundle.getInt(BUNDLE_KEY_LEVEL); adjustStats( level ); } diff --git a/core/src/com/watabou/pixeldungeon/actors/mobs/npcs/Blacksmith.java b/core/src/com/watabou/pixeldungeon/actors/mobs/npcs/Blacksmith.java index ab00bf8c..fdd1e3ec 100644 --- a/core/src/com/watabou/pixeldungeon/actors/mobs/npcs/Blacksmith.java +++ b/core/src/com/watabou/pixeldungeon/actors/mobs/npcs/Blacksmith.java @@ -267,39 +267,39 @@ public static void reset() { reforged = false; } - private static final String NODE = "blacksmith"; + private static final String BUNDLE_KEY_NODE = "blacksmith"; - private static final String SPAWNED = "spawned"; - private static final String ALTERNATIVE = "alternative"; - private static final String GIVEN = "given"; - private static final String COMPLETED = "completed"; - private static final String REFORGED = "reforged"; + private static final String BUNDLE_KEY_SPAWNED = "spawned"; + private static final String BUNDLE_KEY_ALTERNATIVE = "alternative"; + private static final String BUNDLE_KEY_GIVEN = "given"; + private static final String BUNDLE_KEY_COMPLETED = "completed"; + private static final String BUNDLE_KEY_REFORGED = "reforged"; public static void storeInBundle( Bundle bundle ) { Bundle node = new Bundle(); - - node.put( SPAWNED, spawned ); - + + node.put(BUNDLE_KEY_SPAWNED, spawned); + if (spawned) { - node.put( ALTERNATIVE, alternative ); - node.put( GIVEN, given ); - node.put( COMPLETED, completed ); - node.put( REFORGED, reforged ); + node.put(BUNDLE_KEY_ALTERNATIVE, alternative); + node.put(BUNDLE_KEY_GIVEN, given); + node.put(BUNDLE_KEY_COMPLETED, completed); + node.put(BUNDLE_KEY_REFORGED, reforged); } - - bundle.put( NODE, node ); + + bundle.put(BUNDLE_KEY_NODE, node); } public static void restoreFromBundle( Bundle bundle ) { - Bundle node = bundle.getBundle( NODE ); + Bundle node = bundle.getBundle(BUNDLE_KEY_NODE); - if (!node.isNull() && (spawned = node.getBoolean( SPAWNED ))) { - alternative = node.getBoolean( ALTERNATIVE ); - given = node.getBoolean( GIVEN ); - completed = node.getBoolean( COMPLETED ); - reforged = node.getBoolean( REFORGED ); + if (!node.isNull() && (spawned = node.getBoolean(BUNDLE_KEY_SPAWNED))) { + alternative = node.getBoolean(BUNDLE_KEY_ALTERNATIVE); + given = node.getBoolean(BUNDLE_KEY_GIVEN); + completed = node.getBoolean(BUNDLE_KEY_COMPLETED); + reforged = node.getBoolean(BUNDLE_KEY_REFORGED); } else { reset(); } diff --git a/core/src/com/watabou/pixeldungeon/actors/mobs/npcs/Ghost.java b/core/src/com/watabou/pixeldungeon/actors/mobs/npcs/Ghost.java index 7af8f3a0..7ce1aacc 100644 --- a/core/src/com/watabou/pixeldungeon/actors/mobs/npcs/Ghost.java +++ b/core/src/com/watabou/pixeldungeon/actors/mobs/npcs/Ghost.java @@ -200,58 +200,58 @@ public static void reset() { armor = null; } - private static final String NODE = "sadGhost"; + private static final String BUNDLE_KEY_NODE = "sadGhost"; - private static final String SPAWNED = "spawned"; - private static final String ALTERNATIVE = "alternative"; - private static final String LEFT2KILL = "left2kill"; - private static final String GIVEN = "given"; - private static final String PROCESSED = "processed"; - private static final String DEPTH = "depth"; - private static final String WEAPON = "weapon"; - private static final String ARMOR = "armor"; + private static final String BUNDLE_KEY_SPAWNED = "spawned"; + private static final String BUNDLE_KEY_ALTERNATIVE = "alternative"; + private static final String BUNDLE_KEY_LEFT2KILL = "left2kill"; + private static final String BUNDLE_KEY_GIVEN = "given"; + private static final String BUNDLE_KEY_PROCESSED = "processed"; + private static final String BUNDLE_KEY_DEPTH = "depth"; + private static final String BUNDLE_KEY_WEAPON = "weapon"; + private static final String BUNDLE_KEY_ARMOR = "armor"; public static void storeInBundle( Bundle bundle ) { Bundle node = new Bundle(); - - node.put( SPAWNED, spawned ); - + + node.put(BUNDLE_KEY_SPAWNED, spawned); + if (spawned) { - - node.put( ALTERNATIVE, alternative ); + + node.put(BUNDLE_KEY_ALTERNATIVE, alternative); if (!alternative) { - node.put( LEFT2KILL, left2kill ); + node.put(BUNDLE_KEY_LEFT2KILL, left2kill); } - - node.put( GIVEN, given ); - node.put( DEPTH, depth ); - node.put( PROCESSED, processed ); - - node.put( WEAPON, weapon ); - node.put( ARMOR, armor ); + + node.put(BUNDLE_KEY_GIVEN, given); + node.put(BUNDLE_KEY_DEPTH, depth); + node.put(BUNDLE_KEY_PROCESSED, processed); + + node.put(BUNDLE_KEY_WEAPON, weapon); + node.put(BUNDLE_KEY_ARMOR, armor); } - - bundle.put( NODE, node ); + + bundle.put(BUNDLE_KEY_NODE, node); } public static void restoreFromBundle( Bundle bundle ) { - Bundle node = bundle.getBundle( NODE ); + Bundle node = bundle.getBundle(BUNDLE_KEY_NODE); - if (!node.isNull() && (spawned = node.getBoolean( SPAWNED ))) { + if (!node.isNull() && (spawned = node.getBoolean(BUNDLE_KEY_SPAWNED))) { - alternative = node.getBoolean( ALTERNATIVE ); + alternative = node.getBoolean(BUNDLE_KEY_ALTERNATIVE); if (!alternative) { - left2kill = node.getInt( LEFT2KILL ); + left2kill = node.getInt(BUNDLE_KEY_LEFT2KILL); } - given = node.getBoolean( GIVEN ); - depth = node.getInt( DEPTH ); - processed = node.getBoolean( PROCESSED ); + given = node.getBoolean(BUNDLE_KEY_GIVEN); + depth = node.getInt(BUNDLE_KEY_DEPTH); + processed = node.getBoolean(BUNDLE_KEY_PROCESSED); - weapon = (Weapon)node.get( WEAPON ); - armor = (Armor)node.get( ARMOR ); + weapon = (Weapon)node.get(BUNDLE_KEY_WEAPON); + armor = (Armor)node.get(BUNDLE_KEY_ARMOR); } else { reset(); } diff --git a/core/src/com/watabou/pixeldungeon/actors/mobs/npcs/Imp.java b/core/src/com/watabou/pixeldungeon/actors/mobs/npcs/Imp.java index c256246b..69aaadf6 100644 --- a/core/src/com/watabou/pixeldungeon/actors/mobs/npcs/Imp.java +++ b/core/src/com/watabou/pixeldungeon/actors/mobs/npcs/Imp.java @@ -171,41 +171,41 @@ public static void reset() { reward = null; } - private static final String NODE = "demon"; + private static final String BUNDLE_KEY_NODE = "demon"; - private static final String ALTERNATIVE = "alternative"; - private static final String SPAWNED = "spawned"; - private static final String GIVEN = "given"; - private static final String COMPLETED = "completed"; - private static final String REWARD = "reward"; + private static final String BUNDLE_KEY_ALTERNATIVE = "alternative"; + private static final String BUNDLE_KEY_SPAWNED = "spawned"; + private static final String BUNDLE_KEY_GIVEN = "given"; + private static final String BUNDLE_KEY_COMPLETED = "completed"; + private static final String BUNDLE_KEY_REWARD = "reward"; public static void storeInBundle( Bundle bundle ) { Bundle node = new Bundle(); - - node.put( SPAWNED, spawned ); - + + node.put(BUNDLE_KEY_SPAWNED, spawned); + if (spawned) { - node.put( ALTERNATIVE, alternative ); - - node.put( GIVEN, given ); - node.put( COMPLETED, completed ); - node.put( REWARD, reward ); + node.put(BUNDLE_KEY_ALTERNATIVE, alternative); + + node.put(BUNDLE_KEY_GIVEN, given); + node.put(BUNDLE_KEY_COMPLETED, completed); + node.put(BUNDLE_KEY_REWARD, reward); } - - bundle.put( NODE, node ); + + bundle.put(BUNDLE_KEY_NODE, node); } public static void restoreFromBundle( Bundle bundle ) { - Bundle node = bundle.getBundle( NODE ); + Bundle node = bundle.getBundle(BUNDLE_KEY_NODE); - if (!node.isNull() && (spawned = node.getBoolean( SPAWNED ))) { - alternative = node.getBoolean( ALTERNATIVE ); + if (!node.isNull() && (spawned = node.getBoolean(BUNDLE_KEY_SPAWNED))) { + alternative = node.getBoolean(BUNDLE_KEY_ALTERNATIVE); - given = node.getBoolean( GIVEN ); - completed = node.getBoolean( COMPLETED ); - reward = (Ring)node.get( REWARD ); + given = node.getBoolean(BUNDLE_KEY_GIVEN); + completed = node.getBoolean(BUNDLE_KEY_COMPLETED); + reward = (Ring)node.get(BUNDLE_KEY_REWARD); } } diff --git a/core/src/com/watabou/pixeldungeon/actors/mobs/npcs/MirrorImage.java b/core/src/com/watabou/pixeldungeon/actors/mobs/npcs/MirrorImage.java index 813e036a..bb4d209e 100644 --- a/core/src/com/watabou/pixeldungeon/actors/mobs/npcs/MirrorImage.java +++ b/core/src/com/watabou/pixeldungeon/actors/mobs/npcs/MirrorImage.java @@ -45,24 +45,24 @@ public class MirrorImage extends Mob.NPC { private int attack; private int damage; - private static final String TIER = "tier"; - private static final String ATTACK = "attack"; - private static final String DAMAGE = "damage"; + private static final String BUNDLE_KEY_TIER = "tier"; + private static final String BUNDLE_KEY_ATTACK = "attack"; + private static final String BUNDLE_KEY_DAMAGE = "damage"; @Override public void storeInBundle( Bundle bundle ) { super.storeInBundle( bundle ); - bundle.put( TIER, tier ); - bundle.put( ATTACK, attack ); - bundle.put( DAMAGE, damage ); + bundle.put(BUNDLE_KEY_TIER, tier); + bundle.put(BUNDLE_KEY_ATTACK, attack); + bundle.put(BUNDLE_KEY_DAMAGE, damage); } @Override public void restoreFromBundle( Bundle bundle ) { super.restoreFromBundle( bundle ); - tier = bundle.getInt( TIER ); - attack = bundle.getInt( ATTACK ); - damage = bundle.getInt( DAMAGE ); + tier = bundle.getInt(BUNDLE_KEY_TIER); + attack = bundle.getInt(BUNDLE_KEY_ATTACK); + damage = bundle.getInt(BUNDLE_KEY_DAMAGE); } public void duplicate( Hero hero ) { diff --git a/core/src/com/watabou/pixeldungeon/actors/mobs/npcs/Wandmaker.java b/core/src/com/watabou/pixeldungeon/actors/mobs/npcs/Wandmaker.java index 9a68d055..a547001f 100644 --- a/core/src/com/watabou/pixeldungeon/actors/mobs/npcs/Wandmaker.java +++ b/core/src/com/watabou/pixeldungeon/actors/mobs/npcs/Wandmaker.java @@ -170,45 +170,45 @@ public static void reset() { wand2 = null; } - private static final String NODE = "wandmaker"; + private static final String BUNDLE_KEY_NODE = "wandmaker"; - private static final String SPAWNED = "spawned"; - private static final String ALTERNATIVE = "alternative"; - private static final String GIVEN = "given"; - private static final String WAND1 = "wand1"; - private static final String WAND2 = "wand2"; + private static final String BUNDLE_KEY_SPAWNED = "spawned"; + private static final String BUNDLE_KEY_ALTERNATIVE = "alternative"; + private static final String BUNDLE_KEY_GIVEN = "given"; + private static final String BUNDLE_KEY_WAND1 = "wand1"; + private static final String BUNDLE_KEY_WAND2 = "wand2"; public static void storeInBundle( Bundle bundle ) { Bundle node = new Bundle(); - - node.put( SPAWNED, spawned ); - + + node.put(BUNDLE_KEY_SPAWNED, spawned); + if (spawned) { - - node.put( ALTERNATIVE, alternative ); - - node.put(GIVEN, given ); - - node.put( WAND1, wand1 ); - node.put( WAND2, wand2 ); + + node.put(BUNDLE_KEY_ALTERNATIVE, alternative); + + node.put(BUNDLE_KEY_GIVEN, given); + + node.put(BUNDLE_KEY_WAND1, wand1); + node.put(BUNDLE_KEY_WAND2, wand2); } - - bundle.put( NODE, node ); + + bundle.put(BUNDLE_KEY_NODE, node); } public static void restoreFromBundle( Bundle bundle ) { - Bundle node = bundle.getBundle( NODE ); + Bundle node = bundle.getBundle(BUNDLE_KEY_NODE); - if (!node.isNull() && (spawned = node.getBoolean( SPAWNED ))) { + if (!node.isNull() && (spawned = node.getBoolean(BUNDLE_KEY_SPAWNED))) { - alternative = node.getBoolean( ALTERNATIVE ); + alternative = node.getBoolean(BUNDLE_KEY_ALTERNATIVE); - given = node.getBoolean( GIVEN ); + given = node.getBoolean(BUNDLE_KEY_GIVEN); - wand1 = (Wand)node.get( WAND1 ); - wand2 = (Wand)node.get( WAND2 ); + wand1 = (Wand)node.get(BUNDLE_KEY_WAND1); + wand2 = (Wand)node.get(BUNDLE_KEY_WAND2); } else { reset(); } diff --git a/core/src/com/watabou/pixeldungeon/items/DewVial.java b/core/src/com/watabou/pixeldungeon/items/DewVial.java index 57763345..aaa01cc7 100644 --- a/core/src/com/watabou/pixeldungeon/items/DewVial.java +++ b/core/src/com/watabou/pixeldungeon/items/DewVial.java @@ -58,18 +58,18 @@ public class DewVial extends Item { private int volume = 0; - private static final String VOLUME = "volume"; + private static final String BUNDLE_KEY_VOLUME = "volume"; @Override public void storeInBundle( Bundle bundle ) { super.storeInBundle( bundle ); - bundle.put( VOLUME, volume ); + bundle.put(BUNDLE_KEY_VOLUME, volume); } @Override public void restoreFromBundle( Bundle bundle ) { super.restoreFromBundle( bundle ); - volume = bundle.getInt( VOLUME ); + volume = bundle.getInt(BUNDLE_KEY_VOLUME); } @Override diff --git a/core/src/com/watabou/pixeldungeon/items/Gold.java b/core/src/com/watabou/pixeldungeon/items/Gold.java index 26ea0f86..0e605402 100644 --- a/core/src/com/watabou/pixeldungeon/items/Gold.java +++ b/core/src/com/watabou/pixeldungeon/items/Gold.java @@ -102,17 +102,17 @@ public Item random() { return this; } - private static final String VALUE = "value"; + private static final String BUNDLE_KEY_VALUE = "value"; @Override public void storeInBundle( Bundle bundle ) { super.storeInBundle( bundle ); - bundle.put( VALUE, quantity ); + bundle.put(BUNDLE_KEY_VALUE, quantity); } @Override public void restoreFromBundle( Bundle bundle ) { super.restoreFromBundle(bundle); - quantity = bundle.getInt( VALUE ); + quantity = bundle.getInt(BUNDLE_KEY_VALUE); } } diff --git a/core/src/com/watabou/pixeldungeon/items/Heap.java b/core/src/com/watabou/pixeldungeon/items/Heap.java index b18b73fa..7302296f 100644 --- a/core/src/com/watabou/pixeldungeon/items/Heap.java +++ b/core/src/com/watabou/pixeldungeon/items/Heap.java @@ -315,23 +315,23 @@ public void destroy() { items = null; } - private static final String POS = "pos"; - private static final String TYPE = "type"; - private static final String ITEMS = "items"; + private static final String BUNDLE_KEY_POS = "pos"; + private static final String BUNDLE_KEY_TYPE = "type"; + private static final String BUNDLE_KEY_ITEMS = "items"; @SuppressWarnings("unchecked") @Override public void restoreFromBundle( Bundle bundle ) { - pos = bundle.getInt( POS ); - type = Type.valueOf( bundle.getString( TYPE ) ); - items = new LinkedList( bundle.getCollection( ITEMS ) ); + pos = bundle.getInt(BUNDLE_KEY_POS); + type = Type.valueOf( bundle.getString(BUNDLE_KEY_TYPE) ); + items = new LinkedList( bundle.getCollection(BUNDLE_KEY_ITEMS) ); } @Override public void storeInBundle( Bundle bundle ) { - bundle.put( POS, pos ); - bundle.put( TYPE, type.toString() ); - bundle.put( ITEMS, items ); + bundle.put(BUNDLE_KEY_POS, pos); + bundle.put(BUNDLE_KEY_TYPE, type.toString()); + bundle.put(BUNDLE_KEY_ITEMS, items); } } diff --git a/core/src/com/watabou/pixeldungeon/items/Item.java b/core/src/com/watabou/pixeldungeon/items/Item.java index 4c1bc7aa..77358743 100644 --- a/core/src/com/watabou/pixeldungeon/items/Item.java +++ b/core/src/com/watabou/pixeldungeon/items/Item.java @@ -378,41 +378,41 @@ public void updateQuickslot() { } } - private static final String QUANTITY = "quantity"; - private static final String LEVEL = "level"; - private static final String LEVEL_KNOWN = "levelKnown"; - private static final String CURSED = "cursed"; - private static final String CURSED_KNOWN = "cursedKnown"; - private static final String QUICKSLOT = "quickslot"; + private static final String BUNDLE_KEY_QUANTITY = "quantity"; + private static final String BUNDLE_KEY_LEVEL = "level"; + private static final String BUNDLE_KEY_LEVEL_KNOWN = "levelKnown"; + private static final String BUNDLE_KEY_CURSED = "cursed"; + private static final String BUNDLE_KEY_CURSED_KNOWN = "cursedKnown"; + private static final String BUNDLE_KEY_QUICKSLOT = "quickslot"; @Override public void storeInBundle( Bundle bundle ) { - bundle.put( QUANTITY, quantity ); - bundle.put( LEVEL, level ); - bundle.put( LEVEL_KNOWN, levelKnown ); - bundle.put( CURSED, cursed ); - bundle.put( CURSED_KNOWN, cursedKnown ); + bundle.put(BUNDLE_KEY_QUANTITY, quantity); + bundle.put(BUNDLE_KEY_LEVEL, level); + bundle.put(BUNDLE_KEY_LEVEL_KNOWN, levelKnown); + bundle.put(BUNDLE_KEY_CURSED, cursed); + bundle.put(BUNDLE_KEY_CURSED_KNOWN, cursedKnown); if (this == Dungeon.quickslot) { - bundle.put( QUICKSLOT, true ); + bundle.put(BUNDLE_KEY_QUICKSLOT, true); } } @Override public void restoreFromBundle( Bundle bundle ) { - quantity = bundle.getInt( QUANTITY ); - levelKnown = bundle.getBoolean( LEVEL_KNOWN ); - cursedKnown = bundle.getBoolean( CURSED_KNOWN ); + quantity = bundle.getInt(BUNDLE_KEY_QUANTITY); + levelKnown = bundle.getBoolean(BUNDLE_KEY_LEVEL_KNOWN); + cursedKnown = bundle.getBoolean(BUNDLE_KEY_CURSED_KNOWN); - int level = bundle.getInt( LEVEL ); + int level = bundle.getInt(BUNDLE_KEY_LEVEL); if (level > 0) { upgrade( level ); } else if (level < 0) { degrade( -level ); } - cursed = bundle.getBoolean( CURSED ); + cursed = bundle.getBoolean(BUNDLE_KEY_CURSED); - if (bundle.getBoolean( QUICKSLOT )) { + if (bundle.getBoolean(BUNDLE_KEY_QUICKSLOT)) { Dungeon.quickslot = this; } } diff --git a/core/src/com/watabou/pixeldungeon/items/LloydsBeacon.java b/core/src/com/watabou/pixeldungeon/items/LloydsBeacon.java index 5be19394..5bc2f2b2 100644 --- a/core/src/com/watabou/pixeldungeon/items/LloydsBeacon.java +++ b/core/src/com/watabou/pixeldungeon/items/LloydsBeacon.java @@ -66,23 +66,23 @@ public class LloydsBeacon extends Item { unique = true; } - private static final String DEPTH = "depth"; - private static final String POS = "pos"; + private static final String BUNDLE_KEY_DEPTH = "depth"; + private static final String BUNDLE_KEY_POS = "pos"; @Override public void storeInBundle( Bundle bundle ) { super.storeInBundle( bundle ); - bundle.put( DEPTH, returnDepth ); + bundle.put(BUNDLE_KEY_DEPTH, returnDepth); if (returnDepth != -1) { - bundle.put( POS, returnPos ); + bundle.put(BUNDLE_KEY_POS, returnPos); } } @Override public void restoreFromBundle( Bundle bundle ) { super.restoreFromBundle(bundle); - returnDepth = bundle.getInt( DEPTH ); - returnPos = bundle.getInt( POS ); + returnDepth = bundle.getInt(BUNDLE_KEY_DEPTH); + returnPos = bundle.getInt(BUNDLE_KEY_POS); } @Override diff --git a/core/src/com/watabou/pixeldungeon/items/armor/Armor.java b/core/src/com/watabou/pixeldungeon/items/armor/Armor.java index 2bebad28..68c05e8f 100644 --- a/core/src/com/watabou/pixeldungeon/items/armor/Armor.java +++ b/core/src/com/watabou/pixeldungeon/items/armor/Armor.java @@ -63,18 +63,18 @@ public Armor( int tier ) { DR = typicalDR(); } - private static final String GLYPH = "glyph"; + private static final String BUNDLE_KEY_GLYPH = "glyph"; @Override public void storeInBundle( Bundle bundle ) { super.storeInBundle( bundle ); - bundle.put( GLYPH, glyph ); + bundle.put(BUNDLE_KEY_GLYPH, glyph); } @Override public void restoreFromBundle( Bundle bundle ) { super.restoreFromBundle( bundle ); - glyph = (Glyph)bundle.get( GLYPH ); + glyph = (Glyph)bundle.get(BUNDLE_KEY_GLYPH); } @Override diff --git a/core/src/com/watabou/pixeldungeon/items/armor/ClassArmor.java b/core/src/com/watabou/pixeldungeon/items/armor/ClassArmor.java index 0baebc82..6b37a0a1 100644 --- a/core/src/com/watabou/pixeldungeon/items/armor/ClassArmor.java +++ b/core/src/com/watabou/pixeldungeon/items/armor/ClassArmor.java @@ -65,21 +65,21 @@ public static ClassArmor upgrade ( Hero owner, Armor armor ) { return classArmor; } - private static final String ARMOR_STR = "STR"; - private static final String ARMOR_DR = "DR"; + private static final String BUNDLE_KEY_ARMOR_STR = "STR"; + private static final String BUNDLE_KEY_ARMOR_DR = "DR"; @Override public void storeInBundle( Bundle bundle ) { super.storeInBundle( bundle ); - bundle.put( ARMOR_STR, STR ); - bundle.put( ARMOR_DR, DR ); + bundle.put(BUNDLE_KEY_ARMOR_STR, STR); + bundle.put(BUNDLE_KEY_ARMOR_DR, DR); } @Override public void restoreFromBundle( Bundle bundle ) { super.restoreFromBundle( bundle ); - STR = bundle.getInt( ARMOR_STR ); - DR = bundle.getInt( ARMOR_DR ); + STR = bundle.getInt(BUNDLE_KEY_ARMOR_STR); + DR = bundle.getInt(BUNDLE_KEY_ARMOR_DR); } @Override diff --git a/core/src/com/watabou/pixeldungeon/items/armor/glyphs/Viscosity.java b/core/src/com/watabou/pixeldungeon/items/armor/glyphs/Viscosity.java index 6f4b5cb3..f41492a7 100644 --- a/core/src/com/watabou/pixeldungeon/items/armor/glyphs/Viscosity.java +++ b/core/src/com/watabou/pixeldungeon/items/armor/glyphs/Viscosity.java @@ -29,7 +29,6 @@ import com.watabou.pixeldungeon.sprites.ItemSprite.Glowing; import com.watabou.pixeldungeon.ui.BuffIndicator; import com.watabou.pixeldungeon.utils.GLog; -import com.watabou.pixeldungeon.utils.Utils; import com.watabou.utils.Bundle; import com.watabou.utils.Random; @@ -84,19 +83,19 @@ public static class DeferedDamage extends Buff { protected int damage = 0; - private static final String DAMAGE = "damage"; + private static final String BUNDLE_KEY_DAMAGE = "damage"; @Override public void storeInBundle( Bundle bundle ) { super.storeInBundle( bundle ); - bundle.put( DAMAGE, damage ); + bundle.put(BUNDLE_KEY_DAMAGE, damage); } @Override public void restoreFromBundle( Bundle bundle ) { super.restoreFromBundle( bundle ); - damage = bundle.getInt( DAMAGE ); + damage = bundle.getInt(BUNDLE_KEY_DAMAGE); } @Override diff --git a/core/src/com/watabou/pixeldungeon/items/keys/Key.java b/core/src/com/watabou/pixeldungeon/items/keys/Key.java index c1fba7c0..bc25fb93 100644 --- a/core/src/com/watabou/pixeldungeon/items/keys/Key.java +++ b/core/src/com/watabou/pixeldungeon/items/keys/Key.java @@ -43,18 +43,18 @@ public Item detach( Bag container ) { return key; } - private static final String DEPTH = "depth"; + private static final String BUNDLE_KEY_DEPTH = "depth"; @Override public void storeInBundle( Bundle bundle ) { super.storeInBundle( bundle ); - bundle.put( DEPTH, depth ); + bundle.put(BUNDLE_KEY_DEPTH, depth); } @Override public void restoreFromBundle( Bundle bundle ) { super.restoreFromBundle( bundle ); - depth = bundle.getInt( DEPTH ); + depth = bundle.getInt(BUNDLE_KEY_DEPTH); } @Override diff --git a/core/src/com/watabou/pixeldungeon/items/quest/Pickaxe.java b/core/src/com/watabou/pixeldungeon/items/quest/Pickaxe.java index 83574af6..28f7d6f5 100644 --- a/core/src/com/watabou/pixeldungeon/items/quest/Pickaxe.java +++ b/core/src/com/watabou/pixeldungeon/items/quest/Pickaxe.java @@ -150,20 +150,20 @@ public void proc( Char attacker, Char defender, int damage ) { } } - private static final String BLOODSTAINED = "bloodStained"; + private static final String BUNDLE_KEY_BLOODSTAINED = "bloodStained"; @Override public void storeInBundle( Bundle bundle ) { super.storeInBundle( bundle ); - - bundle.put( BLOODSTAINED, bloodStained ); + + bundle.put(BUNDLE_KEY_BLOODSTAINED, bloodStained); } @Override public void restoreFromBundle( Bundle bundle ) { super.restoreFromBundle( bundle ); - bloodStained = bundle.getBoolean( BLOODSTAINED ); + bloodStained = bundle.getBoolean(BUNDLE_KEY_BLOODSTAINED); } @Override diff --git a/core/src/com/watabou/pixeldungeon/items/wands/Wand.java b/core/src/com/watabou/pixeldungeon/items/wands/Wand.java index 4dbb2917..2528196e 100644 --- a/core/src/com/watabou/pixeldungeon/items/wands/Wand.java +++ b/core/src/com/watabou/pixeldungeon/items/wands/Wand.java @@ -367,24 +367,24 @@ public int price() { return price; } - private static final String MAX_CHARGES = "maxCharges"; - private static final String CUR_CHARGES = "curCharges"; - private static final String CUR_CHARGE_KNOWN = "curChargeKnown"; + private static final String BUNDLE_KEY_MAX_CHARGES = "maxCharges"; + private static final String BUNDLE_KEY_CUR_CHARGES = "curCharges"; + private static final String BUNDLE_KEY_CUR_CHARGE_KNOWN = "curChargeKnown"; @Override public void storeInBundle( Bundle bundle ) { super.storeInBundle( bundle ); - bundle.put( MAX_CHARGES, maxCharges ); - bundle.put( CUR_CHARGES, curCharges ); - bundle.put( CUR_CHARGE_KNOWN, curChargeKnown ); + bundle.put(BUNDLE_KEY_MAX_CHARGES, maxCharges); + bundle.put(BUNDLE_KEY_CUR_CHARGES, curCharges); + bundle.put(BUNDLE_KEY_CUR_CHARGE_KNOWN, curChargeKnown); } @Override public void restoreFromBundle( Bundle bundle ) { super.restoreFromBundle( bundle ); - maxCharges = bundle.getInt( MAX_CHARGES ); - curCharges = bundle.getInt( CUR_CHARGES ); - curChargeKnown = bundle.getBoolean( CUR_CHARGE_KNOWN ); + maxCharges = bundle.getInt(BUNDLE_KEY_MAX_CHARGES); + curCharges = bundle.getInt(BUNDLE_KEY_CUR_CHARGES); + curChargeKnown = bundle.getBoolean(BUNDLE_KEY_CUR_CHARGE_KNOWN); } protected static CellSelector.Listener zapper = new CellSelector.Listener() { diff --git a/core/src/com/watabou/pixeldungeon/levels/CavesBossLevel.java b/core/src/com/watabou/pixeldungeon/levels/CavesBossLevel.java index 0d6ef21e..4565ace0 100644 --- a/core/src/com/watabou/pixeldungeon/levels/CavesBossLevel.java +++ b/core/src/com/watabou/pixeldungeon/levels/CavesBossLevel.java @@ -65,24 +65,24 @@ public String waterTex() { return Assets.WATER_CAVES; } - private static final String DOOR = "door"; - private static final String ENTERED = "entered"; - private static final String DROPPED = "droppped"; + private static final String BUNDLE_KEY_DOOR = "door"; + private static final String BUNDLE_KEY_ENTERED = "entered"; + private static final String BUNDLE_KEY_DROPPED = "droppped"; @Override public void storeInBundle( Bundle bundle ) { super.storeInBundle( bundle ); - bundle.put( DOOR, arenaDoor ); - bundle.put( ENTERED, enteredArena ); - bundle.put( DROPPED, keyDropped ); + bundle.put(BUNDLE_KEY_DOOR, arenaDoor); + bundle.put(BUNDLE_KEY_ENTERED, enteredArena); + bundle.put(BUNDLE_KEY_DROPPED, keyDropped); } @Override public void restoreFromBundle( Bundle bundle ) { super.restoreFromBundle( bundle ); - arenaDoor = bundle.getInt( DOOR ); - enteredArena = bundle.getBoolean( ENTERED ); - keyDropped = bundle.getBoolean( DROPPED ); + arenaDoor = bundle.getInt(BUNDLE_KEY_DOOR); + enteredArena = bundle.getBoolean(BUNDLE_KEY_ENTERED); + keyDropped = bundle.getBoolean(BUNDLE_KEY_DROPPED); } @Override diff --git a/core/src/com/watabou/pixeldungeon/levels/CityBossLevel.java b/core/src/com/watabou/pixeldungeon/levels/CityBossLevel.java index 8278cfc6..74843228 100644 --- a/core/src/com/watabou/pixeldungeon/levels/CityBossLevel.java +++ b/core/src/com/watabou/pixeldungeon/levels/CityBossLevel.java @@ -62,24 +62,24 @@ public String waterTex() { return Assets.WATER_CITY; } - private static final String DOOR = "door"; - private static final String ENTERED = "entered"; - private static final String DROPPED = "droppped"; + private static final String BUNDLE_KEY_DOOR = "door"; + private static final String BUNDLE_KEY_ENTERED = "entered"; + private static final String BUNDLE_KEY_DROPPED = "droppped"; @Override public void storeInBundle( Bundle bundle ) { super.storeInBundle( bundle ); - bundle.put( DOOR, arenaDoor ); - bundle.put( ENTERED, enteredArena ); - bundle.put( DROPPED, keyDropped ); + bundle.put(BUNDLE_KEY_DOOR, arenaDoor); + bundle.put(BUNDLE_KEY_ENTERED, enteredArena); + bundle.put(BUNDLE_KEY_DROPPED, keyDropped); } @Override public void restoreFromBundle( Bundle bundle ) { super.restoreFromBundle( bundle ); - arenaDoor = bundle.getInt( DOOR ); - enteredArena = bundle.getBoolean( ENTERED ); - keyDropped = bundle.getBoolean( DROPPED ); + arenaDoor = bundle.getInt(BUNDLE_KEY_DOOR); + enteredArena = bundle.getBoolean(BUNDLE_KEY_ENTERED); + keyDropped = bundle.getBoolean(BUNDLE_KEY_DROPPED); } @Override diff --git a/core/src/com/watabou/pixeldungeon/levels/HallsBossLevel.java b/core/src/com/watabou/pixeldungeon/levels/HallsBossLevel.java index 1c22aea5..d01988e4 100644 --- a/core/src/com/watabou/pixeldungeon/levels/HallsBossLevel.java +++ b/core/src/com/watabou/pixeldungeon/levels/HallsBossLevel.java @@ -62,24 +62,24 @@ public String waterTex() { return Assets.WATER_HALLS; } - private static final String STAIRS = "stairs"; - private static final String ENTERED = "entered"; - private static final String DROPPED = "droppped"; + private static final String BUNDLE_KEY_STAIRS = "stairs"; + private static final String BUNDLE_KEY_ENTERED = "entered"; + private static final String BUNDLE_KEY_DROPPED = "droppped"; @Override public void storeInBundle( Bundle bundle ) { super.storeInBundle( bundle ); - bundle.put( STAIRS, stairs ); - bundle.put( ENTERED, enteredArena ); - bundle.put( DROPPED, keyDropped ); + bundle.put(BUNDLE_KEY_STAIRS, stairs); + bundle.put(BUNDLE_KEY_ENTERED, enteredArena); + bundle.put(BUNDLE_KEY_DROPPED, keyDropped); } @Override public void restoreFromBundle( Bundle bundle ) { super.restoreFromBundle( bundle ); - stairs = bundle.getInt( STAIRS ); - enteredArena = bundle.getBoolean( ENTERED ); - keyDropped = bundle.getBoolean( DROPPED ); + stairs = bundle.getInt(BUNDLE_KEY_STAIRS); + enteredArena = bundle.getBoolean(BUNDLE_KEY_ENTERED); + keyDropped = bundle.getBoolean(BUNDLE_KEY_DROPPED); } @Override diff --git a/core/src/com/watabou/pixeldungeon/levels/Level.java b/core/src/com/watabou/pixeldungeon/levels/Level.java index 89cf4eb5..277905c4 100644 --- a/core/src/com/watabou/pixeldungeon/levels/Level.java +++ b/core/src/com/watabou/pixeldungeon/levels/Level.java @@ -127,15 +127,15 @@ public static enum Feeling { protected static boolean pitRoomNeeded = false; protected static boolean weakFloorCreated = false; - private static final String MAP = "map"; - private static final String VISITED = "visited"; - private static final String MAPPED = "mapped"; - private static final String ENTRANCE = "entrance"; - private static final String EXIT = "exit"; - private static final String HEAPS = "heaps"; - private static final String PLANTS = "plants"; - private static final String MOBS = "mobs"; - private static final String BLOBS = "blobs"; + private static final String BUNDLE_KEY_MAP = "map"; + private static final String BUNDLE_KEY_VISITED = "visited"; + private static final String BUNDLE_KEY_MAPPED = "mapped"; + private static final String BUNDLE_KEY_ENTRANCE = "entrance"; + private static final String BUNDLE_KEY_EXIT = "exit"; + private static final String BUNDLE_KEY_HEAPS = "heaps"; + private static final String BUNDLE_KEY_PLANTS = "plants"; + private static final String BUNDLE_KEY_MOBS = "mobs"; + private static final String BUNDLE_KEY_BLOBS = "blobs"; public void create() { @@ -220,18 +220,18 @@ public void restoreFromBundle( Bundle bundle ) { blobs = new HashMap, Blob>(); plants = new SparseArray(); - map = bundle.getIntArray( MAP ); - visited = bundle.getBooleanArray( VISITED ); - mapped = bundle.getBooleanArray( MAPPED ); + map = bundle.getIntArray(BUNDLE_KEY_MAP); + visited = bundle.getBooleanArray(BUNDLE_KEY_VISITED); + mapped = bundle.getBooleanArray(BUNDLE_KEY_MAPPED); - entrance = bundle.getInt( ENTRANCE ); - exit = bundle.getInt( EXIT ); + entrance = bundle.getInt(BUNDLE_KEY_ENTRANCE); + exit = bundle.getInt(BUNDLE_KEY_EXIT); weakFloorCreated = false; adjustMapSize(); - Collection collection = bundle.getCollection( HEAPS ); + Collection collection = bundle.getCollection(BUNDLE_KEY_HEAPS); for (Bundlable h : collection) { Heap heap = (Heap)h; if (resizingNeeded) { @@ -240,7 +240,7 @@ public void restoreFromBundle( Bundle bundle ) { heaps.put( heap.pos, heap ); } - collection = bundle.getCollection( PLANTS ); + collection = bundle.getCollection(BUNDLE_KEY_PLANTS); for (Bundlable p : collection) { Plant plant = (Plant)p; if (resizingNeeded) { @@ -249,7 +249,7 @@ public void restoreFromBundle( Bundle bundle ) { plants.put( plant.pos, plant ); } - collection = bundle.getCollection( MOBS ); + collection = bundle.getCollection(BUNDLE_KEY_MOBS); for (Bundlable m : collection) { Mob mob = (Mob)m; if (mob != null) { @@ -260,7 +260,7 @@ public void restoreFromBundle( Bundle bundle ) { } } - collection = bundle.getCollection( BLOBS ); + collection = bundle.getCollection(BUNDLE_KEY_BLOBS); for (Bundlable b : collection) { Blob blob = (Blob)b; blobs.put( blob.getClass(), blob ); @@ -272,15 +272,15 @@ public void restoreFromBundle( Bundle bundle ) { @Override public void storeInBundle( Bundle bundle ) { - bundle.put( MAP, map ); - bundle.put( VISITED, visited ); - bundle.put( MAPPED, mapped ); - bundle.put( ENTRANCE, entrance ); - bundle.put( EXIT, exit ); - bundle.put( HEAPS, heaps.valuesAsList() ); - bundle.put( PLANTS, plants.valuesAsList() ); - bundle.put( MOBS, mobs ); - bundle.put( BLOBS, blobs.values() ); + bundle.put(BUNDLE_KEY_MAP, map); + bundle.put(BUNDLE_KEY_VISITED, visited); + bundle.put(BUNDLE_KEY_MAPPED, mapped); + bundle.put(BUNDLE_KEY_ENTRANCE, entrance); + bundle.put(BUNDLE_KEY_EXIT, exit); + bundle.put(BUNDLE_KEY_HEAPS, heaps.valuesAsList()); + bundle.put(BUNDLE_KEY_PLANTS, plants.valuesAsList()); + bundle.put(BUNDLE_KEY_MOBS, mobs); + bundle.put(BUNDLE_KEY_BLOBS, blobs.values()); } public int tunnelTile() { diff --git a/core/src/com/watabou/pixeldungeon/levels/PrisonBossLevel.java b/core/src/com/watabou/pixeldungeon/levels/PrisonBossLevel.java index 8d27cf5c..887e8fc7 100644 --- a/core/src/com/watabou/pixeldungeon/levels/PrisonBossLevel.java +++ b/core/src/com/watabou/pixeldungeon/levels/PrisonBossLevel.java @@ -62,27 +62,27 @@ public String waterTex() { return Assets.WATER_PRISON; } - private static final String ARENA = "arena"; - private static final String DOOR = "door"; - private static final String ENTERED = "entered"; - private static final String DROPPED = "droppped"; + private static final String BUNDLE_KEY_ARENA = "arena"; + private static final String BUNDLE_KEY_DOOR = "door"; + private static final String BUNDLE_KEY_ENTERED = "entered"; + private static final String BUNDLE_KEY_DROPPED = "droppped"; @Override public void storeInBundle( Bundle bundle ) { super.storeInBundle( bundle ); - bundle.put( ARENA, roomExit ); - bundle.put( DOOR, arenaDoor ); - bundle.put( ENTERED, enteredArena ); - bundle.put( DROPPED, keyDropped ); + bundle.put(BUNDLE_KEY_ARENA, roomExit); + bundle.put(BUNDLE_KEY_DOOR, arenaDoor); + bundle.put(BUNDLE_KEY_ENTERED, enteredArena); + bundle.put(BUNDLE_KEY_DROPPED, keyDropped); } @Override public void restoreFromBundle( Bundle bundle ) { super.restoreFromBundle( bundle ); - roomExit = (Room)bundle.get( ARENA ); - arenaDoor = bundle.getInt( DOOR ); - enteredArena = bundle.getBoolean( ENTERED ); - keyDropped = bundle.getBoolean( DROPPED ); + roomExit = (Room)bundle.get(BUNDLE_KEY_ARENA); + arenaDoor = bundle.getInt(BUNDLE_KEY_DOOR); + enteredArena = bundle.getBoolean(BUNDLE_KEY_ENTERED); + keyDropped = bundle.getBoolean(BUNDLE_KEY_DROPPED); } @Override diff --git a/core/src/com/watabou/pixeldungeon/levels/Room.java b/core/src/com/watabou/pixeldungeon/levels/Room.java index b4ff9f46..3ce69750 100644 --- a/core/src/com/watabou/pixeldungeon/levels/Room.java +++ b/core/src/com/watabou/pixeldungeon/levels/Room.java @@ -34,9 +34,15 @@ import com.watabou.utils.Rect; public class Room extends Rect implements Graph.Node, Bundlable { - - public HashSet neigbours = new HashSet(); - public HashMap connected = new HashMap(); + + private static final String BUNDLE_KEY_LEFT = "left"; + private static final String BUNDLE_KEY_TOP = "top"; + private static final String BUNDLE_KEY_RIGHT = "right"; + private static final String BUNDLE_KEY_BOTTOM = "bottom"; + private static final String BUNDLE_KEY_TYPE = "type"; + + public final HashSet neigbours = new HashSet(); + public final HashMap connected = new HashMap(); public int distance; public int price = 1; @@ -166,20 +172,20 @@ public Collection edges() { @Override public void storeInBundle( Bundle bundle ) { - bundle.put( "left", left ); - bundle.put( "top", top ); - bundle.put( "right", right ); - bundle.put( "bottom", bottom ); - bundle.put( "type", type.toString() ); + bundle.put(BUNDLE_KEY_LEFT, left ); + bundle.put(BUNDLE_KEY_TOP, top ); + bundle.put(BUNDLE_KEY_RIGHT, right ); + bundle.put(BUNDLE_KEY_BOTTOM, bottom ); + bundle.put(BUNDLE_KEY_TYPE, type.toString() ); } @Override public void restoreFromBundle( Bundle bundle ) { - left = bundle.getInt( "left" ); - top = bundle.getInt( "top" ); - right = bundle.getInt( "right" ); - bottom = bundle.getInt( "bottom" ); - type = Type.valueOf( bundle.getString( "type" ) ); + left = bundle.getInt(BUNDLE_KEY_LEFT); + top = bundle.getInt(BUNDLE_KEY_TOP); + right = bundle.getInt(BUNDLE_KEY_RIGHT); + bottom = bundle.getInt(BUNDLE_KEY_BOTTOM); + type = Type.valueOf( bundle.getString(BUNDLE_KEY_TYPE) ); } public static void shuffleTypes() { diff --git a/core/src/com/watabou/pixeldungeon/plants/Earthroot.java b/core/src/com/watabou/pixeldungeon/plants/Earthroot.java index 400614eb..2ddf1658 100644 --- a/core/src/com/watabou/pixeldungeon/plants/Earthroot.java +++ b/core/src/com/watabou/pixeldungeon/plants/Earthroot.java @@ -123,21 +123,21 @@ public String toString() { return "Herbal armor"; } - private static final String POS = "pos"; - private static final String LEVEL = "level"; + private static final String BUNDLE_KEY_POS = "pos"; + private static final String BUNDLE_KEY_LEVEL = "level"; @Override public void storeInBundle( Bundle bundle ) { super.storeInBundle( bundle ); - bundle.put( POS, pos ); - bundle.put( LEVEL, level ); + bundle.put(BUNDLE_KEY_POS, pos); + bundle.put(BUNDLE_KEY_LEVEL, level); } @Override public void restoreFromBundle( Bundle bundle ) { super.restoreFromBundle( bundle ); - pos = bundle.getInt( POS ); - level = bundle.getInt( LEVEL ); + pos = bundle.getInt(BUNDLE_KEY_POS); + level = bundle.getInt(BUNDLE_KEY_LEVEL); } } } diff --git a/core/src/com/watabou/pixeldungeon/plants/Plant.java b/core/src/com/watabou/pixeldungeon/plants/Plant.java index 5772c88d..29cbd649 100644 --- a/core/src/com/watabou/pixeldungeon/plants/Plant.java +++ b/core/src/com/watabou/pixeldungeon/plants/Plant.java @@ -77,16 +77,16 @@ public void wither() { } } - private static final String POS = "pos"; + private static final String BUNDLE_KEY_POS = "pos"; @Override public void restoreFromBundle( Bundle bundle ) { - pos = bundle.getInt( POS ); + pos = bundle.getInt(BUNDLE_KEY_POS); } @Override - public void storeInBundle( Bundle bundle ) { - bundle.put( POS, pos ); + public void storeInBundle(Bundle bundle) { + bundle.put(BUNDLE_KEY_POS, pos); } public String desc() { diff --git a/core/src/com/watabou/pixeldungeon/plants/Sungrass.java b/core/src/com/watabou/pixeldungeon/plants/Sungrass.java index c1a1e82a..f331e27c 100644 --- a/core/src/com/watabou/pixeldungeon/plants/Sungrass.java +++ b/core/src/com/watabou/pixeldungeon/plants/Sungrass.java @@ -106,18 +106,18 @@ public String toString() { return "Herbal healing"; } - private static final String POS = "pos"; + private static final String BUNDLE_KEY_POS = "pos"; @Override public void storeInBundle( Bundle bundle ) { super.storeInBundle( bundle ); - bundle.put( POS, pos ); + bundle.put(BUNDLE_KEY_POS, pos); } @Override public void restoreFromBundle( Bundle bundle ) { super.restoreFromBundle( bundle ); - pos = bundle.getInt( POS ); + pos = bundle.getInt(BUNDLE_KEY_POS); } } }