diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ConversationActivity.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ConversationActivity.java index ac65fd2ae..0ba938439 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ConversationActivity.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ConversationActivity.java @@ -220,9 +220,8 @@ public final class ConversationActivity extends Activity implements OnKeyListene assert(npc != null); assert(npc.getDropList() != null); Intent intent = new Intent(this, ShopActivity.class); - intent.setData(Uri.parse("content://com.gpl.rpg.AndorsTrail/shop")); Dialogs.addMonsterIdentifiers(intent, npc); - startActivityForResult(intent, MainActivity.INTENTREQUEST_SHOP); + startActivity(intent); ConversationActivity.this.finish(); return; } else if (phraseID.equalsIgnoreCase(ConversationCollection.PHRASE_ATTACK)) { @@ -239,10 +238,10 @@ public final class ConversationActivity extends Activity implements OnKeyListene if (AndorsTrailApplication.DEVELOPMENT_DEBUGMESSAGES) { if (phrase == null) phrase = new Phrase("(phrase \"" + phraseID + "\" not implemented yet)", null, null); } - - Loot loot = null; + + ConversationController.PhraseRewards phraseRewards = null; if (applyPhraseRewards) { - loot = view.conversationController.applyPhraseRewards(player, phrase); + phraseRewards = view.conversationController.applyPhraseRewards(player, phrase); } if (phrase.message == null) { @@ -256,23 +255,24 @@ public final class ConversationActivity extends Activity implements OnKeyListene String message = ConversationController.getDisplayMessage(phrase, player); - if (applyPhraseRewards && loot != null) { + if (applyPhraseRewards && phraseRewards != null) { + Loot loot = phraseRewards.loot; if (loot.hasItemsOrExp()) { message += "\n"; if (loot.exp > 0) { - message += "\n" + getResources().getString(R.string.conversation_rewardexp, loot.exp); + message += "\n" + getString(R.string.conversation_rewardexp, loot.exp); } if (loot.gold > 0) { - message += "\n" + getResources().getString(R.string.conversation_rewardgold, loot.gold); + message += "\n" + getString(R.string.conversation_rewardgold, loot.gold); } else if (loot.gold < 0) { - message += "\n" + getResources().getString(R.string.conversation_lostgold, -loot.gold); + message += "\n" + getString(R.string.conversation_lostgold, -loot.gold); } if (!loot.items.isEmpty()) { final int len = loot.items.countItems(); if (len == 1) { - message += "\n" + getResources().getString(R.string.conversation_rewarditem); + message += "\n" + getString(R.string.conversation_rewarditem); } else { - message += "\n" + getResources().getString(R.string.conversation_rewarditems, len); + message += "\n" + getString(R.string.conversation_rewarditems, len); } } } @@ -359,16 +359,6 @@ public final class ConversationActivity extends Activity implements OnKeyListene listAdapter.notifyDataSetChanged(); statementList.requestLayout(); } - - @Override - protected void onActivityResult(int requestCode, int resultCode, Intent data) { - super.onActivityResult(requestCode, resultCode, data); - switch (requestCode) { - case MainActivity.INTENTREQUEST_SHOP: - ConversationActivity.this.finish(); - break; - } - } @Override public void onSaveInstanceState(Bundle outState) { diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/MainActivity.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/MainActivity.java index 0c184e760..50b40c92d 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/MainActivity.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/MainActivity.java @@ -53,7 +53,6 @@ public final class MainActivity extends Activity implements PlayerMovementListen public static final int INTENTREQUEST_MONSTERENCOUNTER = 2; public static final int INTENTREQUEST_ITEMINFO = 3; public static final int INTENTREQUEST_CONVERSATION = 4; - public static final int INTENTREQUEST_SHOP = 5; public static final int INTENTREQUEST_LEVELUP = 6; public static final int INTENTREQUEST_PREFERENCES = 7; public static final int INTENTREQUEST_SAVEGAME = 8; diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/ConversationController.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/ConversationController.java index aae284f9f..516e4f1be 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/ConversationController.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/ConversationController.java @@ -8,6 +8,7 @@ import com.gpl.rpg.AndorsTrail.conversation.Phrase.Reward; import com.gpl.rpg.AndorsTrail.model.ability.ActorCondition; import com.gpl.rpg.AndorsTrail.model.ability.ActorConditionEffect; import com.gpl.rpg.AndorsTrail.model.ability.ActorConditionType; +import com.gpl.rpg.AndorsTrail.model.ability.SkillInfo; import com.gpl.rpg.AndorsTrail.model.actor.Player; import com.gpl.rpg.AndorsTrail.model.item.ItemTypeCollection; import com.gpl.rpg.AndorsTrail.model.item.Loot; @@ -15,6 +16,8 @@ import com.gpl.rpg.AndorsTrail.model.quest.QuestLogEntry; import com.gpl.rpg.AndorsTrail.model.quest.QuestProgress; import com.gpl.rpg.AndorsTrail.util.ConstRange; +import java.util.ArrayList; + public final class ConversationController { private final ViewContext view; @@ -26,11 +29,18 @@ public final class ConversationController { } private static final ConstRange always = new ConstRange(1, 1); - - public Loot applyPhraseRewards(final Player player, final Phrase phrase) { + + public static final class PhraseRewards { + public final Loot loot = new Loot(); + public final ArrayList actorConditions = new ArrayList(); + public final ArrayList skillIncrease = new ArrayList(); + public final ArrayList questProgress = new ArrayList(); + } + + public PhraseRewards applyPhraseRewards(final Player player, final Phrase phrase) { if (phrase.rewards == null || phrase.rewards.length == 0) return null; - final Loot loot = new Loot(); + final PhraseRewards result = new PhraseRewards(); for (Reward reward : phrase.rewards) { switch (reward.rewardType) { case Reward.REWARD_TYPE_ACTOR_CONDITION: @@ -42,13 +52,18 @@ public final class ConversationController { ActorConditionType conditionType = world.actorConditionsTypes.getActorConditionType(reward.rewardID); ActorConditionEffect e = new ActorConditionEffect(conditionType, magnitude, duration, always); view.actorStatsController.applyActorCondition(player, e); + result.actorConditions.add(e); break; case Reward.REWARD_TYPE_SKILL_INCREASE: int skillID = Integer.parseInt(reward.rewardID); - view.skillController.levelUpSkillByQuest(player, world.skills.getSkill(skillID)); + SkillInfo skill = world.skills.getSkill(skillID); + boolean addedSkill = view.skillController.levelUpSkillByQuest(player, skill); + if (addedSkill) { + result.skillIncrease.add(skill); + } break; case Reward.REWARD_TYPE_DROPLIST: - world.dropLists.getDropList(reward.rewardID).createRandomLoot(loot, player); + world.dropLists.getDropList(reward.rewardID).createRandomLoot(result.loot, player); break; case Reward.REWARD_TYPE_QUEST_PROGRESS: QuestProgress progress = new QuestProgress(reward.rewardID, reward.value); @@ -56,7 +71,8 @@ public final class ConversationController { if (added) { // Only apply exp reward if the quest stage was reached just now (and not re-reached) QuestLogEntry stage = world.quests.getQuestLogEntry(progress); if (stage != null) { - loot.exp += stage.rewardExperience; + result.loot.exp += stage.rewardExperience; + result.questProgress.add(progress); } } break; @@ -66,9 +82,9 @@ public final class ConversationController { } } - player.inventory.add(loot); - view.actorStatsController.addExperience(loot.exp); - return loot; + player.inventory.add(result.loot); + view.actorStatsController.addExperience(result.loot.exp); + return result; } public static void applyReplyEffect(final Player player, final Reply reply) { diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/SkillController.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/SkillController.java index c40859086..0860dfef1 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/SkillController.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/SkillController.java @@ -103,9 +103,10 @@ public final class SkillController { player.availableSkillIncreases -= 1; addSkillLevel(skill.id); } - public void levelUpSkillByQuest(Player player, SkillInfo skill) { - if (!canLevelupSkillWithQuest(player, skill)) return; + public boolean levelUpSkillByQuest(Player player, SkillInfo skill) { + if (!canLevelupSkillWithQuest(player, skill)) return false; addSkillLevel(skill.id); + return true; } public void addSkillLevel(int skillID) {