From b47d063c6be1fa0b8011e2ae613c28043a423718 Mon Sep 17 00:00:00 2001 From: Oskar Wiksten Date: Tue, 7 Aug 2012 14:14:44 +0200 Subject: [PATCH] Bugfix: do not give out rewards from conversation phrases when returning to the conversation activity. Rewards should only be applied when first visiting a phrase. --- .../activity/ConversationActivity.java | 45 +++++++++++-------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ConversationActivity.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ConversationActivity.java index f9d9b34..9bcb18f 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ConversationActivity.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ConversationActivity.java @@ -61,6 +61,7 @@ public final class ConversationActivity extends Activity implements OnKeyListene private RadioGroup replyGroup; private OnCheckedChangeListener radioButtonListener; private boolean displayActors = true; + private boolean applyPhraseRewards = true; private final ConversationCollection conversationCollection = new ConversationCollection(); @@ -80,6 +81,7 @@ public final class ConversationActivity extends Activity implements OnKeyListene phraseID = uri.getLastPathSegment().toString(); if (savedInstanceState != null) { + applyPhraseRewards = false; phraseID = savedInstanceState.getString("phraseID"); conversationHistory = savedInstanceState.getParcelableArrayList("conversationHistory"); if (conversationHistory == null) conversationHistory = new ArrayList(); @@ -135,6 +137,7 @@ public final class ConversationActivity extends Activity implements OnKeyListene super.onResume(); setPhrase(phraseID); + applyPhraseRewards = true; nextButton.requestFocus(); } @@ -228,7 +231,11 @@ 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 = ConversationController.applyPhraseRewards(player, phrase, world); + + Loot loot = null; + if (applyPhraseRewards) { + loot = ConversationController.applyPhraseRewards(player, phrase, world); + } if (phrase.message == null) { for (Reply r : phrase.replies) { @@ -241,23 +248,25 @@ public final class ConversationActivity extends Activity implements OnKeyListene String message = ConversationController.getDisplayMessage(phrase, player); - if (loot != null && loot.hasItemsOrExp()) { - message += "\n"; - if (loot.exp > 0) { - message += "\n" + getResources().getString(R.string.conversation_rewardexp, loot.exp); - } - if (loot.gold > 0) { - message += "\n" + getResources().getString(R.string.conversation_rewardgold, loot.gold); - } else if (loot.gold < 0) { - message += "\n" + getResources().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); - } else { - message += "\n" + getResources().getString(R.string.conversation_rewarditems, len); - } + if (applyPhraseRewards && loot != null) { + if (loot.hasItemsOrExp()) { + message += "\n"; + if (loot.exp > 0) { + message += "\n" + getResources().getString(R.string.conversation_rewardexp, loot.exp); + } + if (loot.gold > 0) { + message += "\n" + getResources().getString(R.string.conversation_rewardgold, loot.gold); + } else if (loot.gold < 0) { + message += "\n" + getResources().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); + } else { + message += "\n" + getResources().getString(R.string.conversation_rewarditems, len); + } + } } } -- 2.49.0