diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/AndorsTrailApplication.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/AndorsTrailApplication.java index 5b7415d9a..964f872d5 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/AndorsTrailApplication.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/AndorsTrailApplication.java @@ -36,7 +36,7 @@ public final class AndorsTrailApplication extends Application { public static AndorsTrailApplication getApplicationFromActivityContext(Context context) { return getApplicationFromActivity(getActivityFromActivityContext(context)); } - public static Activity getActivityFromActivityContext(Context context) { + private static Activity getActivityFromActivityContext(Context context) { return (Activity) context; } diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/Dialogs.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/Dialogs.java index 31a778205..467e81694 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/Dialogs.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/Dialogs.java @@ -162,7 +162,7 @@ public final class Dialogs { } public static void showGroundLoot(final MainActivity mainActivity, final ViewContext view, final WorldContext world, final Loot loot, final String msg) { - showLoot(mainActivity, view, world, loot, Collections.singletonList(loot), R.string.dialog_monsterloot_title, msg); + showLoot(mainActivity, view, world, loot, Collections.singletonList(loot), R.string.dialog_groundloot_title, msg); } private static void showLoot(final MainActivity mainActivity, final ViewContext view, final WorldContext world, final Loot combinedLoot, final Iterable lootBags, final int title, final String msg) { @@ -302,8 +302,8 @@ public final class Dialogs { public static void showBulkDroppingInterface(HeroinfoActivity_Inventory currentActivity, String itemTypeID, int totalAvailableAmount) { showBulkSelectionInterface(currentActivity, itemTypeID, totalAvailableAmount, BulkSelectionInterface.BULK_INTERFACE_DROP, MainActivity.INTENTREQUEST_BULKSELECT_DROP); } - - public static void showBulkSelectionInterface(Activity currentActivity, String itemTypeID, int totalAvailableAmount, int interfaceType, int requestCode) { + + private static void showBulkSelectionInterface(Activity currentActivity, String itemTypeID, int totalAvailableAmount, int interfaceType, int requestCode) { Intent intent = new Intent(currentActivity, BulkSelectionInterface.class); intent.putExtra("itemTypeID", itemTypeID); intent.putExtra("totalAvailableAmount", totalAvailableAmount); diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ConversationActivity.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ConversationActivity.java index eae615b5d..ac65fd2ae 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ConversationActivity.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ConversationActivity.java @@ -58,8 +58,7 @@ public final class ConversationActivity extends Activity implements OnKeyListene private ArrayList conversationHistory = new ArrayList(); private StatementContainerAdapter listAdapter; private Button nextButton; - private Button leaveButton; - private ListView statementList; + private ListView statementList; private Monster npc; private RadioGroup replyGroup; private OnCheckedChangeListener radioButtonListener; @@ -84,7 +83,7 @@ public final class ConversationActivity extends Activity implements OnKeyListene this.npc = Dialogs.getMonsterFromIntent(getIntent(), world); displayActors = (npc != null); - phraseID = uri.getLastPathSegment().toString(); + phraseID = uri.getLastPathSegment(); if (savedInstanceState != null) { applyPhraseRewards = false; phraseID = savedInstanceState.getString("phraseID"); @@ -109,13 +108,13 @@ public final class ConversationActivity extends Activity implements OnKeyListene statementList.setAdapter(listAdapter); nextButton = (Button) findViewById(R.id.conversation_next); - leaveButton = (Button) findViewById(R.id.conversation_leave); + Button leaveButton = (Button) findViewById(R.id.conversation_leave); leaveButton.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - ConversationActivity.this.finish(); - } - }); + @Override + public void onClick(View v) { + ConversationActivity.this.finish(); + } + }); radioButtonListener = new OnCheckedChangeListener() { @Override @@ -354,7 +353,7 @@ public final class ConversationActivity extends Activity implements OnKeyListene } s.text = text; s.color = color; - s.isPlayerActor = actor != null ? actor == player : false; + s.isPlayerActor = actor != null && actor == player; conversationHistory.add(s); statementList.clearFocus(); listAdapter.notifyDataSetChanged(); diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/DisplayWorldMapActivity.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/DisplayWorldMapActivity.java index 704b11d1e..09ec2a620 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/DisplayWorldMapActivity.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/DisplayWorldMapActivity.java @@ -74,7 +74,10 @@ public final class DisplayWorldMapActivity extends Activity { WorldMapSegment segment = world.maps.worldMapSegments.get(worldMapSegmentName); WorldMapSegmentMap map = segment.maps.get(world.model.currentMap.name); - if (map == null) this.finish(); + if (map == null) { + this.finish(); + return; + } String url = "file://" + worldmap.getAbsolutePath() + '?' + (world.model.player.position.x + map.worldPosition.x) * WorldMapController.WORLDMAP_DISPLAY_TILESIZE diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ItemInfoActivity.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ItemInfoActivity.java index 6be9b005f..3dc6559bd 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ItemInfoActivity.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ItemInfoActivity.java @@ -18,12 +18,12 @@ import java.util.Collections; public final class ItemInfoActivity extends Activity { - public static int ITEMACTION_NONE = 1; - public static int ITEMACTION_USE = 2; - public static int ITEMACTION_EQUIP = 3; - public static int ITEMACTION_UNEQUIP = 4; - public static int ITEMACTION_BUY = 5; - public static int ITEMACTION_SELL = 6; + public static final int ITEMACTION_NONE = 1; + public static final int ITEMACTION_USE = 2; + public static final int ITEMACTION_EQUIP = 3; + public static final int ITEMACTION_UNEQUIP = 4; + public static final int ITEMACTION_BUY = 5; + public static final int ITEMACTION_SELL = 6; @Override public void onCreate(Bundle savedInstanceState) { diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/MainActivity.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/MainActivity.java index 941dc6528..0c184e760 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/MainActivity.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/MainActivity.java @@ -64,11 +64,11 @@ public final class MainActivity extends Activity implements PlayerMovementListen private ViewContext view; private WorldContext world; - - public MainView mainview; - public StatusView statusview; - public CombatView combatview; - public QuickitemView quickitemview; + + private MainView mainview; + private StatusView statusview; + private CombatView combatview; + private QuickitemView quickitemview; private DisplayActiveActorConditionIcons activeConditions; private ToolboxView toolboxview; private VirtualDpadView dpad; diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/StartScreenActivity.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/StartScreenActivity.java index 14f94e69f..d6c273f5f 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/StartScreenActivity.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/StartScreenActivity.java @@ -99,9 +99,9 @@ public final class StartScreenActivity extends Activity { } }); - TextView development_version = (TextView) findViewById(R.id.startscreen_dev_version); if (AndorsTrailApplication.DEVELOPMENT_INCOMPATIBLE_SAVEGAMES) { - development_version.setVisibility(View.VISIBLE); + TextView development_version = (TextView) findViewById(R.id.startscreen_dev_version); + development_version.setVisibility(View.VISIBLE); } final Resources res = getResources(); diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/context/ViewContext.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/context/ViewContext.java index 5233d506f..3de0ca7a4 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/context/ViewContext.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/context/ViewContext.java @@ -35,7 +35,7 @@ public final class ViewContext { public final SkillController skillController; public final AndorsTrailPreferences preferences; - public final WeakReference app; + private final WeakReference app; public ViewContext(AndorsTrailApplication app, WorldContext world) { this.app = new WeakReference(app); diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/Constants.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/Constants.java index 72dcc217c..9b299b3fe 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/Constants.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/Constants.java @@ -25,8 +25,8 @@ public final class Constants { public static final int ATTACK_ANIMATION_FPS = 10; public static final int TICK_DELAY = 500; - public static final int ROUND_DURATION = 6000; - public static final int FULLROUND_DURATION = 25000; + private static final int ROUND_DURATION = 6000; + private static final int FULLROUND_DURATION = 25000; public static final int TICKS_PER_ROUND = ROUND_DURATION / TICK_DELAY; public static final int TICKS_PER_FULLROUND = FULLROUND_DURATION / TICK_DELAY; public static final int SPLATTER_DURATION_MS = 20000; diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/ConversationController.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/ConversationController.java index 91939655a..aae284f9f 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/ConversationController.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/ConversationController.java @@ -108,7 +108,7 @@ public final class ConversationController { public static String getDisplayMessage(Phrase phrase, Player player) { return replacePlayerName(phrase.message, player); } public static String getDisplayMessage(Reply reply, Player player) { return replacePlayerName(reply.text, player); } - public static String replacePlayerName(String s, Player player) { + private static String replacePlayerName(String s, Player player) { return s.replace(Constants.PLACEHOLDER_PLAYERNAME, player.getName()); } } diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/ItemController.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/ItemController.java index 2643caf53..696ad2677 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/ItemController.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/ItemController.java @@ -146,7 +146,7 @@ public final class ItemController { SkillController.applySkillEffectsFromItemProficiencies(player); SkillController.applySkillEffectsFromFightingStyles(player); } - public static ItemType getMainWeapon(Player player) { + private static ItemType getMainWeapon(Player player) { ItemType itemType = player.inventory.wear[Inventory.WEARSLOT_WEAPON]; if (itemType != null) return itemType; itemType = player.inventory.wear[Inventory.WEARSLOT_SHIELD]; diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/SkillController.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/SkillController.java index fcf4d038b..c40859086 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/SkillController.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/SkillController.java @@ -81,7 +81,7 @@ public final class SkillController { } - public static boolean canLevelupSkillWithQuest(Player player, SkillInfo skill) { + private static boolean canLevelupSkillWithQuest(Player player, SkillInfo skill) { final int playerSkillLevel = player.getSkillLevel(skill.id); if (skill.hasMaxLevel()) { if (playerSkillLevel >= skill.maxLevel) return false; diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/WorldMapController.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/WorldMapController.java index aa5491c80..d64db9b75 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/WorldMapController.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/WorldMapController.java @@ -36,8 +36,8 @@ import com.gpl.rpg.AndorsTrail.util.Size; public final class WorldMapController { - public static int WORLDMAP_SCREENSHOT_TILESIZE = 8; - public static int WORLDMAP_DISPLAY_TILESIZE = WORLDMAP_SCREENSHOT_TILESIZE; + private static final int WORLDMAP_SCREENSHOT_TILESIZE = 8; + public static final int WORLDMAP_DISPLAY_TILESIZE = WORLDMAP_SCREENSHOT_TILESIZE; public static void updateWorldMap(final WorldContext world, final PredefinedMap map, final LayeredTileMap mapTiles, final TileCollection cachedTiles, final Resources res) { @@ -148,11 +148,11 @@ public final class WorldMapController { File noMediaFile = new File(dir, ".nomedia"); if (!noMediaFile.exists()) noMediaFile.createNewFile(); } - public static File getFileForMap(PredefinedMap map) { return getFileForMap(map.name); } - public static File getFileForMap(String mapName) { + private static File getFileForMap(PredefinedMap map) { return getFileForMap(map.name); } + private static File getFileForMap(String mapName) { return new File(getWorldmapDirectory(), mapName + ".png"); } - public static File getWorldmapDirectory() { + private static File getWorldmapDirectory() { File dir = Environment.getExternalStorageDirectory(); dir = new File(dir, Constants.FILENAME_SAVEGAME_DIRECTORY); return new File(dir, Constants.FILENAME_WORLDMAP_DIRECTORY); @@ -165,7 +165,7 @@ public final class WorldMapController { File f = WorldMapController.getFileForMap(mapName); return f.exists(); } - private static String getWorldMapSegmentAsHtml(Resources res, WorldContext world, String segmentName) throws IOException { + private static String getWorldMapSegmentAsHtml(Resources res, WorldContext world, String segmentName) { WorldMapSegment segment = world.maps.worldMapSegments.get(segmentName); Collection displayedMapNames = new HashSet(); diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/conversation/Phrase.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/conversation/Phrase.java index 3b73d205d..edeef3604 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/conversation/Phrase.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/conversation/Phrase.java @@ -3,7 +3,7 @@ package com.gpl.rpg.AndorsTrail.conversation; import com.gpl.rpg.AndorsTrail.model.quest.QuestProgress; public final class Phrase { - public static final Reply[] NO_REPLIES = new Reply[0]; + private static final Reply[] NO_REPLIES = new Reply[0]; public final String message; public final Reply[] replies; diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/GameStatistics.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/GameStatistics.java index 4dfbe1848..7ad675247 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/GameStatistics.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/GameStatistics.java @@ -12,10 +12,10 @@ import com.gpl.rpg.AndorsTrail.model.actor.MonsterType; import com.gpl.rpg.AndorsTrail.model.item.ItemType; public final class GameStatistics { - public int deaths = 0; - public final HashMap killedMonsters = new HashMap(); - public final HashMap usedItems = new HashMap(); - public int spentGold = 0; + private int deaths = 0; + private final HashMap killedMonsters = new HashMap(); + private final HashMap usedItems = new HashMap(); + private int spentGold = 0; public GameStatistics() { } public void addMonsterKill(String monsterTypeID) { diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/ability/SkillCollection.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/ability/SkillCollection.java index 3450802de..2d23efd40 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/ability/SkillCollection.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/ability/SkillCollection.java @@ -69,10 +69,10 @@ public final class SkillCollection { public static final int CONCUSSION_THRESHOLD = 50; public static final int PER_SKILLPOINT_INCREASE_CONCUSSION_CHANCE = 15; - public static final int MAX_LEVEL_BARTER = (int) Math.floor((float) Constants.MARKET_PRICEFACTOR_PERCENT / PER_SKILLPOINT_INCREASE_BARTER_PRICEFACTOR_PERCENTAGE); - public static final int MAX_LEVEL_BARKSKIN = 5; - public static final int MAX_LEVEL_SPEED = 2; - public static final int MAX_LEVEL_EVASION = Math.max( + private static final int MAX_LEVEL_BARTER = (int) Math.floor((float) Constants.MARKET_PRICEFACTOR_PERCENT / PER_SKILLPOINT_INCREASE_BARTER_PRICEFACTOR_PERCENTAGE); + private static final int MAX_LEVEL_BARKSKIN = 5; + private static final int MAX_LEVEL_SPEED = 2; + private static final int MAX_LEVEL_EVASION = Math.max( Constants.FLEE_FAIL_CHANCE_PERCENT / PER_SKILLPOINT_INCREASE_EVASION_FLEE_CHANCE_PERCENTAGE ,Constants.MONSTER_AGGRESSION_CHANCE_PERCENT / PER_SKILLPOINT_INCREASE_EVASION_MONSTER_ATTACK_CHANCE_PERCENTAGE ); diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/actor/Monster.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/actor/Monster.java index ece742a52..83dfdcc37 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/actor/Monster.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/actor/Monster.java @@ -40,7 +40,6 @@ public final class Monster extends Actor { this.name = monsterType.name; this.ap.max = monsterType.maxAP; this.health.max = monsterType.maxHP; - this.position.set(position); this.moveCost = monsterType.moveCost; this.attackCost = monsterType.attackCost; this.attackChance = monsterType.attackChance; @@ -105,7 +104,7 @@ public final class Monster extends Actor { return new Monster(src, world, fileversion, monsterType); } - public Monster(DataInputStream src, WorldContext world, int fileversion, MonsterType monsterType) throws IOException { + private Monster(DataInputStream src, WorldContext world, int fileversion, MonsterType monsterType) throws IOException { this(monsterType); boolean readCombatTraits = true; diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/actor/Player.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/actor/Player.java index b299c9c63..3bb371d8b 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/actor/Player.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/actor/Player.java @@ -190,7 +190,7 @@ public final class Player extends Actor { public boolean nextLevelAddsNewSkillpoint() { return thisLevelAddsNewSkillpoint(level + 1); } - public static boolean thisLevelAddsNewSkillpoint(int level) { + private static boolean thisLevelAddsNewSkillpoint(int level) { return ((level - Constants.FIRST_SKILL_POINT_IS_GIVEN_AT_LEVEL) % Constants.NEW_SKILL_POINT_EVERY_N_LEVELS == 0); } public boolean hasAvailableSkillpoints() { diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/ItemCategory.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/ItemCategory.java index 43dd3ff7d..824b26058 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/ItemCategory.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/ItemCategory.java @@ -10,7 +10,7 @@ public final class ItemCategory { public final String displayName; public final int inventorySlot; private final int actionType; - public final int size; + private final int size; public ItemCategory(String id, String displayName, int actionType, int inventorySlot, int size) { this.id = id; diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/ItemType.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/ItemType.java index a5714af7d..14a2c45e9 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/ItemType.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/ItemType.java @@ -91,9 +91,8 @@ public final class ItemType { } return -1; } - - public int calculateCost() { return calculateCost(category, effects_equip, effects_use); } - public static int calculateCost(ItemCategory category, ItemTraits_OnEquip effects_equip, ItemTraits_OnUse effects_use) { + + private static int calculateCost(ItemCategory category, ItemTraits_OnEquip effects_equip, ItemTraits_OnUse effects_use) { final int costEquipStats = effects_equip == null ? 0 : effects_equip.calculateCost(category.isWeapon()); final int costUse = effects_use == null ? 0 : effects_use.calculateCost(); //final int costHit = effects_hit == null ? 0 : effects_hit.calculateCost(); diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/Loot.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/Loot.java index 31f26e3df..e06e90d80 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/Loot.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/item/Loot.java @@ -25,8 +25,8 @@ public final class Loot { this.position = new Coord(); this.isVisible = isVisible; } - - public void add(Loot l) { + + private void add(Loot l) { this.exp += l.exp; this.gold += l.gold; this.items.add(l.items); diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/LayeredTileMap.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/LayeredTileMap.java index 7cec950c5..c2aa00122 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/LayeredTileMap.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/LayeredTileMap.java @@ -17,14 +17,12 @@ public final class LayeredTileMap { private static final ColorFilter colorFilterBlack40 = createGrayScaleColorFilter(0.4f); private static final ColorFilter colorFilterBlack60 = createGrayScaleColorFilter(0.6f); private static final ColorFilter colorFilterBlack80 = createGrayScaleColorFilter(0.8f); - - public final Size size; + public final MapLayer[] layers; public final Collection usedTileIDs; public final String colorFilter; public LayeredTileMap(Size size, MapLayer[] layers, Collection usedTileIDs, String colorFilter) { - this.size = size; assert(size.width > 0); assert(size.height > 0); assert(layers.length == 3); diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/MapLayer.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/MapLayer.java index a071c2a57..906ae4dc3 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/MapLayer.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/MapLayer.java @@ -4,7 +4,7 @@ import com.gpl.rpg.AndorsTrail.util.Coord; import com.gpl.rpg.AndorsTrail.util.Size; public final class MapLayer { - public final Size size; + private final Size size; public final int[][] tiles; public MapLayer(Size size) { diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/PredefinedMap.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/PredefinedMap.java index 0a884d195..fb0a5656d 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/PredefinedMap.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/PredefinedMap.java @@ -30,12 +30,12 @@ public final class PredefinedMap { public boolean visited = false; public long lastVisitTime = VISIT_RESET; public int lastVisitVersion = 0; - public final boolean isOutdoors; + private final boolean isOutdoors; - public final boolean[][] isWalkable; + private final boolean[][] isWalkable; public final ArrayList splatters = new ArrayList(); - public PredefinedMap(int xmlResourceId, String name, Size size, boolean[][] isWalkable, MapObject[] eventObjects, MonsterSpawnArea[] spawnAreas, boolean hasFOW, boolean isOutdoors) { + public PredefinedMap(int xmlResourceId, String name, Size size, boolean[][] isWalkable, MapObject[] eventObjects, MonsterSpawnArea[] spawnAreas, boolean isOutdoors) { this.xmlResourceId = xmlResourceId; this.name = name; this.size = size; diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/TMXMapFileParser.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/TMXMapFileParser.java index d9f468f5f..456784203 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/TMXMapFileParser.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/TMXMapFileParser.java @@ -211,7 +211,7 @@ public final class TMXMapFileParser { } } - private static TMXProperty readTMXProperty(XmlResourceParser xrp) throws XmlPullParserException, IOException { + private static TMXProperty readTMXProperty(XmlResourceParser xrp) { final TMXProperty property = new TMXProperty(); property.name = xrp.getAttributeValue(null, "name"); property.value = xrp.getAttributeValue(null, "value"); @@ -255,7 +255,7 @@ public final class TMXMapFileParser { public String orientation; public int tilewidth; public int tileheight; - public ArrayList objectGroups = new ArrayList(); + public final ArrayList objectGroups = new ArrayList(); } public static class TMXLayerMap { public int width; diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/TMXMapTranslator.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/TMXMapTranslator.java index 1dd0e0416..c76b193cb 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/TMXMapTranslator.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/TMXMapTranslator.java @@ -28,7 +28,7 @@ import com.gpl.rpg.AndorsTrail.util.Size; import android.content.res.Resources; public final class TMXMapTranslator { - private ArrayList maps = new ArrayList(); + private final ArrayList maps = new ArrayList(); public void read(Resources r, int xmlResourceId, String name) { maps.add(TMXMapFileParser.read(r, xmlResourceId, name)); @@ -123,16 +123,11 @@ public final class TMXMapTranslator { ArrayList types = monsterTypes.getMonsterTypesFromSpawnGroup(object.name); int maxQuantity = 1; int spawnChance = 10; - boolean isUnique = false; for (TMXProperty p : object.properties) { if (p.name.equalsIgnoreCase("quantity")) { maxQuantity = Integer.parseInt(p.value); } else if (p.name.equalsIgnoreCase("spawnchance")) { spawnChance = Integer.parseInt(p.value); - } else if (p.name.equalsIgnoreCase("respawn")) { - isUnique = !Boolean.parseBoolean(p.value); - } else if (p.name.equalsIgnoreCase("unique")) { - isUnique = Boolean.parseBoolean(p.value); } else if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) { L.log("OPTIMIZE: Map " + m.name + ", spawn " + object.name + " has unrecognized property \"" + p.name + "\"."); } @@ -146,7 +141,7 @@ public final class TMXMapTranslator { } String[] monsterTypeIDs = new String[types.size()]; - isUnique = types.get(0).isUnique; + boolean isUnique = types.get(0).isUnique; for (int i = 0; i < monsterTypeIDs.length; ++i) { monsterTypeIDs[i] = types.get(i).id; } @@ -192,7 +187,7 @@ public final class TMXMapTranslator { MonsterSpawnArea[] _spawnAreas = new MonsterSpawnArea[spawnAreas.size()]; _spawnAreas = spawnAreas.toArray(_spawnAreas); - result.add(new PredefinedMap(m.xmlResourceId, m.name, mapSize, isWalkable, _eventObjects, _spawnAreas, false, isOutdoors)); + result.add(new PredefinedMap(m.xmlResourceId, m.name, mapSize, isWalkable, _eventObjects, _spawnAreas, isOutdoors)); } return result; @@ -213,7 +208,7 @@ public final class TMXMapTranslator { } HashSet usedTileIDs = new HashSet(); for (TMXLayer layer : map.layers) { - int ixMapLayer = -2; + int ixMapLayer; String layerName = layer.name; assert(layerName != null); assert(layerName.length() > 0); diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/ResourceFileTokenizer.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/ResourceFileTokenizer.java deleted file mode 100644 index a5570b7ff..000000000 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/ResourceFileTokenizer.java +++ /dev/null @@ -1,100 +0,0 @@ -package com.gpl.rpg.AndorsTrail.resource; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import com.gpl.rpg.AndorsTrail.AndorsTrailApplication; -import com.gpl.rpg.AndorsTrail.util.L; -import com.gpl.rpg.AndorsTrail.util.Pair; - -public class ResourceFileTokenizer { - private static final Pattern rowPattern = Pattern.compile("\\{(.+?)\\};", Pattern.MULTILINE | Pattern.DOTALL); - private static final String columnSeparator = "\\|"; - private static final String fieldPattern = "([^\\|]*?|\\{\\s*\\{.*?\\}\\s*\\})" + columnSeparator; - private static String repeat(String s, int count) { - StringBuilder result = new StringBuilder(s); - for(int i = 1; i < count; ++i) result.append(s); - return result.toString(); - } - - - private final int columns; - private final Pattern pattern; - private final String[] parts; - - public ResourceFileTokenizer(int columns) { - this.columns = columns; - this.pattern = Pattern.compile('^' + repeat(fieldPattern, columns) + '$', Pattern.MULTILINE | Pattern.DOTALL); - this.parts = new String[columns]; - } - - private void tokenizeRows(String input, ArrayList dest, ResourceObjectParser parser) { - Matcher rowMatcher = rowPattern.matcher(input); - while (rowMatcher.find()) { - tokenizeRow(rowMatcher.group(1), dest, parser); - } - } - - public final Collection tokenizeRows(String input, HashMap dest, ResourceObjectParser> parser) { - HashSet ids = new HashSet(); - ArrayList> objects = new ArrayList>(); - tokenizeRows(input, objects, parser); - - for (Pair o : objects) { - final String id = o.first; - if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) { - if (id == null || id.length() <= 0) { - L.log("WARNING: Entity " + o.second.toString() + " has empty id."); - } else if (dest.containsKey(id)) { - L.log("WARNING: Entity " + id + " is duplicated."); - } - } - dest.put(id, o.second); - ids.add(id); - } - return ids; - } - - private void tokenizeRow(String input, ArrayList dest, ResourceObjectParser parser) { - Matcher groups = pattern.matcher(input); - if (!groups.find()) return; - if (groups.groupCount() < columns) return; - for(int i = 0; i < columns; ++i) { - parts[i] = groups.group(i + 1); - } - T obj = parser.parseRow(parts); - if (obj != null) dest.add(obj); - } - - - private static final Pattern outerPattern = Pattern.compile("^\\{(.*)\\}$", Pattern.MULTILINE | Pattern.DOTALL); - private static final Pattern innerPattern = Pattern.compile("\\{(.*?)\\}", Pattern.MULTILINE | Pattern.DOTALL); - - public final void tokenizeArray(String input, ArrayList dest, ResourceObjectParser parser) { - Matcher matcher = outerPattern.matcher(input); - if (!matcher.find()) return; - - matcher = innerPattern.matcher(matcher.group(1)); - while (matcher.find()) { - tokenizeRow(matcher.group(1), dest, parser); - } - } - - public static interface ResourceObjectParser { - T parseRow(String[] parts); - } - - public abstract static class ResourceParserFor extends ResourceFileTokenizer implements ResourceObjectParser> { - protected ResourceParserFor(int columns) { - super(columns); - } - - public Collection parseRows(String input, HashMap dest) { - return tokenizeRows(input, dest, this); - } - } -} diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/ResourceLoader.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/ResourceLoader.java index cf1fd6de5..d064f28f5 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/ResourceLoader.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/ResourceLoader.java @@ -193,7 +193,7 @@ public final class ResourceLoader { InputStream is = r.openRawResource(resourceID); BufferedReader br = new BufferedReader(new InputStreamReader(is)); StringBuilder sb = new StringBuilder(1000); - String line = ""; + String line; try { while((line = br.readLine()) != null) sb.append(line); br.close(); diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/tiles/TileManager.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/tiles/TileManager.java index 82f74d97c..b4e84e159 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/tiles/TileManager.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/tiles/TileManager.java @@ -54,9 +54,8 @@ public final class TileManager { public static final int iconID_splatter_brown_2b = 17; public static final int iconID_splatter_white_1a = 18; public static final int iconID_splatter_white_1b = 19; - - private float density; - public int tileSize; + + public int tileSize; public int viewTileSize; public float scale; @@ -114,7 +113,7 @@ public final class TileManager { } public void setDensity(Resources r) { - density = r.getDisplayMetrics().density; + float density = r.getDisplayMetrics().density; tileSize = (int) (32 * density); } @@ -197,7 +196,7 @@ public final class TileManager { tileCache.loadTilesFor(preloadedTileIDs, r, preloadedTiles); } - private HashMap> tileIDsPerMap = new HashMap>(); + private final HashMap> tileIDsPerMap = new HashMap>(); private void addTileIDsFor(HashSet dest, String mapName, final Resources res, final WorldContext world) { HashSet cachedTileIDs = tileIDsPerMap.get(mapName); if (cachedTileIDs == null) { diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/util/Range.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/util/Range.java index 4179bd846..053f3d473 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/util/Range.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/util/Range.java @@ -19,6 +19,9 @@ public final class Range { public boolean equals(Range r) { return max == r.max && current == r.current; } + public boolean equals(ConstRange r) { + return max == r.max && current == r.current; + } public void set(Range r) { this.max = r.max; diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/ActorConditionEffectList.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/ActorConditionEffectList.java index 36672bf23..4bd3beae6 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/ActorConditionEffectList.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/ActorConditionEffectList.java @@ -56,8 +56,8 @@ public final class ActorConditionEffectList extends LinearLayout { this.addView(tv, layoutParams); } } - - public static String describeEffect(Resources res, ActorConditionEffect effect) { + + private static String describeEffect(Resources res, ActorConditionEffect effect) { String msg = describeEffect(res, effect.conditionType, effect.magnitude, effect.duration); if (effect.chance.isMax()) return msg; diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/MainView.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/MainView.java index 501a88419..fb027ad14 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/MainView.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/MainView.java @@ -44,7 +44,7 @@ public final class MainView extends SurfaceView private final int tileSize; private float scale; - public int scaledTileSize; + private int scaledTileSize; private Size screenSizeTileCount = null; private final Coord screenOffset = new Coord(); // pixel offset where the image begins diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/SkillListAdapter.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/SkillListAdapter.java index 8b448c7ad..9d3810de3 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/SkillListAdapter.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/SkillListAdapter.java @@ -73,7 +73,7 @@ public final class SkillListAdapter extends ArrayAdapter { title.setText(skillTitle); description.setText(getSkillShortDescriptionResourceID(skillID)); - boolean enabled = true; + boolean enabled; if (player.hasAvailableSkillpoints()) { enabled = SkillController.canLevelupSkillManually(player, skill); } else {