diff --git a/AndorsTrail/AndroidManifest.xml b/AndorsTrail/AndroidManifest.xml index 50e2e56b0..c7b996b8c 100644 --- a/AndorsTrail/AndroidManifest.xml +++ b/AndorsTrail/AndroidManifest.xml @@ -3,8 +3,8 @@ - - + + + + @xml/guynmart_main_1 @xml/guynmart_main_2 @xml/guynmart_main_3 - @xml/guynmart_main_3 @xml/guynmart_passage @xml/guynmart_tower_0 @xml/guynmart_tower_1 diff --git a/AndorsTrail/res/xml/blackwater_mountain7.tmx b/AndorsTrail/res/xml/blackwater_mountain7.tmx index acfa76bc7..519a06a29 100644 --- a/AndorsTrail/res/xml/blackwater_mountain7.tmx +++ b/AndorsTrail/res/xml/blackwater_mountain7.tmx @@ -1,5 +1,5 @@ - + @@ -135,9 +135,6 @@ - - - eJztlkESwiAMRTssXLjyAL2CwRtYV+57Bg7rscQZmcH0Jw0UrAsXbzpNSX+B5FPvhiEInCP30yev+AyYQCyA/ISPzx4HzBXkSWNn4T01ujPQlcYHEEfrZdFF66SNb6WL1kkaf2k4X5S3ly7F2DEyvq+Jid2nWA65pe7olpDyvST0k4Y2fyte6fsSP6jRtda1Zb+t3Cp0cx8isP8WXcmfNHIf8gWemoP8aY3AdPn+W3RLNbkPofr4Rl3x/NE43626xLxiAuuOeqB1H0l12ltXqtPeutYcvj8WNL+vyfnTD+6vpWetdo6u5dXW7lr+Hrq/Pt/avpN0W/yTaEi+09snnlpanUE= diff --git a/AndorsTrail/res/xml/wild20a.tmx b/AndorsTrail/res/xml/wild20a.tmx index 1b817a17c..ca3e3256d 100644 --- a/AndorsTrail/res/xml/wild20a.tmx +++ b/AndorsTrail/res/xml/wild20a.tmx @@ -1,5 +1,5 @@ - + @@ -183,9 +183,6 @@ - - - eJxbz8TAsIWTgaEdSK+nEhsAYaMNwg== diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/AndorsTrailApplication.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/AndorsTrailApplication.java index 6489b6b5f..26b81a953 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/AndorsTrailApplication.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/AndorsTrailApplication.java @@ -25,11 +25,11 @@ public final class AndorsTrailApplication extends Application { public static final boolean DEVELOPMENT_FORCE_CONTINUEGAME = false; public static final boolean DEVELOPMENT_DEBUGBUTTONS = false; public static final boolean DEVELOPMENT_FASTSPEED = false; - public static final boolean DEVELOPMENT_VALIDATEDATA = false; - public static final boolean DEVELOPMENT_DEBUGMESSAGES = false; + public static final boolean DEVELOPMENT_VALIDATEDATA = true; + public static final boolean DEVELOPMENT_DEBUGMESSAGES = true; public static final boolean DEVELOPMENT_INCOMPATIBLE_SAVEGAMES = DEVELOPMENT_DEBUGRESOURCES || DEVELOPMENT_DEBUGBUTTONS || DEVELOPMENT_FASTSPEED; - public static final int CURRENT_VERSION = DEVELOPMENT_INCOMPATIBLE_SAVEGAMES ? 999 : 46; - public static final String CURRENT_VERSION_DISPLAY = "0.7.5dev"; + public static final int CURRENT_VERSION = DEVELOPMENT_INCOMPATIBLE_SAVEGAMES ? 999 : 47; + public static final String CURRENT_VERSION_DISPLAY = "0.7.6dev"; public static final boolean IS_RELEASE_VERSION = !CURRENT_VERSION_DISPLAY.matches(".*[a-d].*"); private final AndorsTrailPreferences preferences = new AndorsTrailPreferences(); diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/LoadSaveActivity.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/LoadSaveActivity.java index af2587ec2..89ef0591a 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/LoadSaveActivity.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/LoadSaveActivity.java @@ -3,9 +3,13 @@ package com.gpl.rpg.AndorsTrail.activity; import java.util.Collections; import java.util.List; +import android.Manifest; +import android.annotation.TargetApi; import android.app.Activity; import android.app.Dialog; import android.content.Intent; +import android.content.pm.PackageManager; +import android.os.Build; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; @@ -13,6 +17,7 @@ import android.view.ViewGroup; import android.view.ViewGroup.LayoutParams; import android.widget.Button; import android.widget.TextView; +import android.widget.Toast; import com.gpl.rpg.AndorsTrail.AndorsTrailApplication; import com.gpl.rpg.AndorsTrail.AndorsTrailPreferences; @@ -67,6 +72,8 @@ public final class LoadSaveActivity extends Activity implements OnClickListener addSavegameSlotButtons(slotList, params, Savegames.getUsedSavegameSlots()); + checkAndRequestPermissions(); + if (!isLoading) { createNewSlot.setTag(SLOT_NUMBER_CREATE_NEW_SLOT); createNewSlot.setOnClickListener(this); @@ -76,6 +83,30 @@ public final class LoadSaveActivity extends Activity implements OnClickListener } } + private static final int READ_EXTERNAL_STORAGE_REQUEST=1; + private static final int WRITE_EXTERNAL_STORAGE_REQUEST=2; + + @TargetApi(23) + private void checkAndRequestPermissions() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (getApplicationContext().checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { + this.requestPermissions(new String[] {Manifest.permission.READ_EXTERNAL_STORAGE}, READ_EXTERNAL_STORAGE_REQUEST); + } + if (getApplicationContext().checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { + this.requestPermissions(new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE}, WRITE_EXTERNAL_STORAGE_REQUEST); + } + } + } + + @Override + public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { + if (grantResults.length > 0 && grantResults[0] != PackageManager.PERMISSION_GRANTED) { + Toast.makeText(this, R.string.storage_permissions_mandatory, Toast.LENGTH_LONG).show(); + ((AndorsTrailApplication)getApplication()).discardWorld(); + finish(); + } + } + private void addSavegameSlotButtons(ViewGroup parent, LayoutParams params, List usedSavegameSlots) { for (int slot : usedSavegameSlots) { final FileHeader header = Savegames.quickload(this, slot); diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/MainActivity.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/MainActivity.java index 0fed16ded..38b812119 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/MainActivity.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/MainActivity.java @@ -308,7 +308,7 @@ public final class MainActivity @Override - public void onPlayerMoved(Coord newPosition, Coord previousPosition) { } + public void onPlayerMoved(PredefinedMap map, Coord newPosition, Coord previousPosition) { } @Override public void onPlayerEnteredNewMap(PredefinedMap map, Coord p) { } diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/HeroinfoActivity_Inventory.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/HeroinfoActivity_Inventory.java index 6a95ee8fa..ad71ea402 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/HeroinfoActivity_Inventory.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/HeroinfoActivity_Inventory.java @@ -79,6 +79,9 @@ public final class HeroinfoActivity_Inventory extends Fragment implements Custom public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View v = inflater.inflate(R.layout.heroinfo_inventory, container, false); + AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this.getActivity()); + if (!app.isInitialized()) return v; + inventoryList = (ListView) v.findViewById(R.id.inventorylist_root); ImageView heroicon = (ImageView) v.findViewById(R.id.heroinfo_inventory_heroicon); heroinfo_stats_gold = (TextView) v.findViewById(R.id.heroinfo_stats_gold); diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/HeroinfoActivity_Quests.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/HeroinfoActivity_Quests.java index d51d19f72..ece9d03f7 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/HeroinfoActivity_Quests.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/HeroinfoActivity_Quests.java @@ -51,7 +51,10 @@ public final class HeroinfoActivity_Quests extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.questlog, container, false); - + + AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this.getActivity()); + if (!app.isInitialized()) return v; + Context ctx = getActivity(); diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/HeroinfoActivity_Skills.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/HeroinfoActivity_Skills.java index 22bcf6918..6d3a3275e 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/HeroinfoActivity_Skills.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/HeroinfoActivity_Skills.java @@ -48,7 +48,10 @@ public final class HeroinfoActivity_Skills extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.heroinfo_skill_list, container, false); - + + AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this.getActivity()); + if (!app.isInitialized()) return v; + final Activity ctx = getActivity(); new SpinnerEmulator(v,R.id.skillList_category_filters_button, R.array.skill_category_filters, R.string.heroinfo_skill_categories) { diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/HeroinfoActivity_Stats.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/HeroinfoActivity_Stats.java index 088b28e6c..3068e181f 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/HeroinfoActivity_Stats.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/fragment/HeroinfoActivity_Stats.java @@ -67,10 +67,14 @@ public final class HeroinfoActivity_Stats extends Fragment { View v = inflater.inflate(R.layout.heroinfo_stats, container, false); view = v; + AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this.getActivity()); + if (!app.isInitialized()) return v; + TextView tv = (TextView) v.findViewById(R.id.heroinfo_title); - tv.setText(player.getName()); - tv.setCompoundDrawablesWithIntrinsicBounds(HeroCollection.getHeroLargeSprite(player.iconID), 0, 0, 0); - + if (tv != null) { + tv.setText(player.getName()); + tv.setCompoundDrawablesWithIntrinsicBounds(HeroCollection.getHeroLargeSprite(player.iconID), 0, 0, 0); + } heroinfo_container = (ViewGroup) v.findViewById(R.id.heroinfo_container); heroinfo_reequip_cost = (TextView) v.findViewById(R.id.heroinfo_reequip_cost); heroinfo_useitem_cost = (TextView) v.findViewById(R.id.heroinfo_useitem_cost); diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/CombatController.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/CombatController.java index b0cd7978d..f38ac9ffc 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/CombatController.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/CombatController.java @@ -176,12 +176,13 @@ public final class CombatController implements VisualEffectCompletedCallback { playerKilledMonster(target); } + controllers.skillController.applySkillEffectsFromPlayerAttack(attack, target); startAttackEffect(attack, attackPosition, this, CALLBACK_PLAYERATTACK); } else { combatActionListeners.onPlayerAttackMissed(target, attack); + controllers.skillController.applySkillEffectsFromPlayerAttack(attack, target); startMissedEffect(attack, attackPosition, this, CALLBACK_PLAYERATTACK); } - controllers.skillController.applySkillEffectsFromPlayerAttack(attack, target); } @@ -404,12 +405,13 @@ public final class CombatController implements VisualEffectCompletedCallback { if (attack.isHit) { combatActionListeners.onMonsterAttackSuccess(currentActiveMonster, attack); + controllers.skillController.applySkillEffectsFromMonsterAttack(attack, currentActiveMonster); startAttackEffect(attack, world.model.player.position, this, CALLBACK_MONSTERATTACK); } else { combatActionListeners.onMonsterAttackMissed(currentActiveMonster, attack); + controllers.skillController.applySkillEffectsFromMonsterAttack(attack, currentActiveMonster); startMissedEffect(attack, world.model.player.position, this, CALLBACK_MONSTERATTACK); } - controllers.skillController.applySkillEffectsFromMonsterAttack(attack, currentActiveMonster); } private static final int CALLBACK_MONSTERATTACK = 0; diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/ConversationController.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/ConversationController.java index 9d57477df..5834be335 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/ConversationController.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/ConversationController.java @@ -295,6 +295,9 @@ public final class ConversationController { case spentGold: result = stats.getSpentGold() >= requirement.value; break; + case random: + result = Constants.rollResult(requirement.chance); + break; case consumedBonemeals: result = stats.getNumberOfUsedBonemealPotions() >= requirement.value; break; diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MovementController.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MovementController.java index 6695ff0ad..a7d1e67c6 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MovementController.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MovementController.java @@ -246,7 +246,7 @@ public final class MovementController implements TimedMessageTask.Callback { @Override public void onVisualEffectCompleted(int callbackValue) { - playerMovementListeners.onPlayerMoved(newPosition, player.lastPosition); + playerMovementListeners.onPlayerMoved(currentMap, newPosition, player.lastPosition); controllers.mapController.handleMapEventsAfterMovement(currentMap, newPosition, player.lastPosition); if (!world.model.uiSelections.isInCombat) { diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/SkillController.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/SkillController.java index a4a264123..68667b556 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/SkillController.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/SkillController.java @@ -284,10 +284,10 @@ public final class SkillController { return SkillID.weaponProficiency1hsword; else if (itemCategoryID.equals("2hsword")) return SkillID.weaponProficiency2hsword; - else if (itemCategoryID.equals("axe") || itemCategoryID.equals("axe2h")) + else if (itemCategoryID.equals("axe") || itemCategoryID.equals("axe2h") || itemCategoryID.equals("scythe")) return SkillID.weaponProficiencyAxe; else if (itemCategoryID.equals("club") || itemCategoryID.equals("staff") || itemCategoryID.equals("mace") - || itemCategoryID.equals("scepter") || itemCategoryID.equals("hammer") || itemCategoryID.equals("hammer2h")) + || itemCategoryID.equals("scepter") || itemCategoryID.equals("hammer") || itemCategoryID.equals("hammer2h") || itemCategoryID.equals("whip")) return SkillID.weaponProficiencyBlunt; } else if (category.isShield()) { return SkillID.armorProficiencyShield; diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/listeners/PlayerMovementListener.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/listeners/PlayerMovementListener.java index ffa475d5d..3f6a53d73 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/listeners/PlayerMovementListener.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/listeners/PlayerMovementListener.java @@ -4,6 +4,6 @@ import com.gpl.rpg.AndorsTrail.model.map.PredefinedMap; import com.gpl.rpg.AndorsTrail.util.Coord; public interface PlayerMovementListener { - void onPlayerMoved(Coord newPosition, Coord previousPosition); + void onPlayerMoved(PredefinedMap map, Coord newPosition, Coord previousPosition); void onPlayerEnteredNewMap(PredefinedMap map, Coord p); } diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/listeners/PlayerMovementListeners.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/listeners/PlayerMovementListeners.java index c0a373ba2..739ae13fb 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/listeners/PlayerMovementListeners.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/listeners/PlayerMovementListeners.java @@ -6,8 +6,8 @@ import com.gpl.rpg.AndorsTrail.util.ListOfListeners; public final class PlayerMovementListeners extends ListOfListeners implements PlayerMovementListener { - private final Function2 onPlayerMoved = new Function2() { - @Override public void call(PlayerMovementListener listener, Coord newPosition, Coord previousPosition) { listener.onPlayerMoved(newPosition, previousPosition); } + private final Function3 onPlayerMoved = new Function3() { + @Override public void call(PlayerMovementListener listener, PredefinedMap map, Coord newPosition, Coord previousPosition) { listener.onPlayerMoved(map, newPosition, previousPosition); } }; private final Function2 onPlayerEnteredNewMap = new Function2() { @@ -15,8 +15,8 @@ public final class PlayerMovementListeners extends ListOfListeners= 0; - case hasActorCondition: - return requireID != null; - case inventoryKeep: - case inventoryRemove: - case usedItem: - return requireID != null && value >= 0; - case killedMonster: - return requireID != null && value >= 0; - case questLatestProgress: - case questProgress: - return requireID != null && value >= 0; - case skillLevel: - return requireID != null && value >= 0; - case spentGold: - return value >= 0; - case timerElapsed: - return requireID != null && value >= 0; - case wear: - return requireID != null; - default: - return false; + case consumedBonemeals: + return value >= 0; + case hasActorCondition: + return requireID != null; + case inventoryKeep: + case inventoryRemove: + case usedItem: + return requireID != null && value >= 0; + case killedMonster: + return requireID != null && value >= 0; + case questLatestProgress: + case questProgress: + return requireID != null && value >= 0; + case skillLevel: + return requireID != null && value >= 0; + case spentGold: + return value >= 0; + case random: + return chance != null; + case timerElapsed: + return requireID != null && value >= 0; + case wear: + return requireID != null; + default: + return false; } } } diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/parsers/ConversationListParser.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/parsers/ConversationListParser.java index aef8b1c0f..215c984b2 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/parsers/ConversationListParser.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/parsers/ConversationListParser.java @@ -22,11 +22,14 @@ public final class ConversationListParser extends JsonCollectionParserFor requirementParser = new JsonArrayParserFor(Requirement.class) { @Override protected Requirement parseObject(JSONObject o) throws JSONException { + Requirement.RequirementType type = Requirement.RequirementType.valueOf(o.getString(JsonFieldNames.ReplyRequires.requireType)); + String requireID = o.getString(JsonFieldNames.ReplyRequires.requireID); return new Requirement( - Requirement.RequirementType.valueOf(o.getString(JsonFieldNames.ReplyRequires.requireType)) - ,o.getString(JsonFieldNames.ReplyRequires.requireID) + type + ,type == Requirement.RequirementType.random ? null : requireID ,o.optInt(JsonFieldNames.ReplyRequires.value, 0) ,o.optBoolean(JsonFieldNames.ReplyRequires.negate, false) + ,type == Requirement.RequirementType.random ? ResourceParserUtils.parseChance(requireID) : null ); } }; diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/MainView.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/MainView.java index b79255b11..d1f2684b4 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/MainView.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/MainView.java @@ -665,7 +665,8 @@ public final class MainView extends SurfaceView @Override - public void onPlayerMoved(Coord newPosition, Coord previousPosition) { + public void onPlayerMoved(PredefinedMap map, Coord newPosition, Coord previousPosition) { + if (map != currentMap) return; recalculateMapTopLeft(newPosition, preferences.enableUiAnimations); redrawAll(RedrawAllDebugReason.PlayerMoved); }