[virtualcommons-svn] commit/foraging: alllee: adding logic to display updated total income, includ
Status: Beta
Brought to you by:
alllee
From: Bitbucket <com...@bi...> - 2011-09-21 19:13:15
|
1 new changeset in foraging: http://bitbucket.org/virtualcommons/foraging/changeset/77cecbdf3f88/ changeset: 77cecbdf3f88 user: alllee date: 2011-09-21 21:13:03 summary: adding logic to display updated total income, including quiz answer rewards and trust game earnings. fixing ant clean target to remove ant cache and maven cache so that the proper csidex jar will be downloaded affected #: 4 files (-1 bytes) --- a/build.xml Fri Sep 16 15:32:44 2011 -0700 +++ b/build.xml Wed Sep 21 12:13:03 2011 -0700 @@ -190,6 +190,9 @@ </target><!-- Clean up build by deleting build directories --><target name="clean"> + <echo message="Removing ${user.home}/.ant/cache" /> + <delete dir='${user.home}/.ant/cache' /> + <delete dir='${user.home}/.m2/repository/edu/asu/commons' /><delete dir="${build.dir}"/><delete dir="${test.build.dir}"/><delete dir="${lib.dir}"/> --- a/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java Fri Sep 16 15:32:44 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java Wed Sep 21 12:13:03 2011 -0700 @@ -333,10 +333,6 @@ return getProperty(questionNumber + "-explanation"); } - public double getQuizCorrectAnswerReward() { - return getDoubleProperty("quiz-correct-answer-reward", 0.50d); - } - /** * Possible values, freeze, fine? * @@ -626,4 +622,9 @@ return getProperty("trust-game-instructions"); } + public double getQuizCorrectAnswerReward() { + String key = "quiz-correct-answer-reward"; + return getDoubleProperty(key, getParentConfiguration().getDoubleProperty(key)); + } + } --- a/src/main/java/edu/asu/commons/foraging/conf/ServerConfiguration.java Fri Sep 16 15:32:44 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/conf/ServerConfiguration.java Wed Sep 21 12:13:03 2011 -0700 @@ -66,6 +66,10 @@ public double getShowUpPayment() { return assistant.getDoubleProperty("show-up-payment", 5.0d); } + + public double getQuizCorrectAnswerReward() { + return assistant.getDoubleProperty("quiz-correct-answer-reward", 0.50d); + } public String getWelcomeInstructions() { return assistant.getStringProperty("welcome-instructions", "Please wait quietly and do not open or close any programs on this computer."); @@ -79,6 +83,8 @@ return assistant.getProperty("field-of-vision-instructions", "Your view of the resource will be limited in this round. The area visible to you will be shaded."); } + + } --- a/src/main/java/edu/asu/commons/foraging/facilitator/FacilitatorWindow.java Fri Sep 16 15:32:44 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/facilitator/FacilitatorWindow.java Wed Sep 21 12:13:03 2011 -0700 @@ -24,6 +24,7 @@ import javax.swing.ScrollPaneConstants; import edu.asu.commons.foraging.conf.RoundConfiguration; +import edu.asu.commons.foraging.conf.ServerConfiguration; import edu.asu.commons.foraging.event.FacilitatorEndRoundEvent; import edu.asu.commons.foraging.event.FacilitatorSanctionUpdateEvent; import edu.asu.commons.foraging.model.ClientData; @@ -326,8 +327,6 @@ TreeSet<Identifier> orderedSet = new TreeSet<Identifier>(clientDataMap.keySet()); for (Identifier clientId : orderedSet) { ClientData data = clientDataMap.get(clientId); - // FIXME: hack... inject the configuration into the client data so that getIncome() will return something appropriate. - // should just refactor getIncome or remove it from ClientData entirely. builder.append(String.format( "<tr><td>%s</td>" + "<td align='center'>%d</td>" + @@ -336,7 +335,7 @@ clientId.toString(), data.getCurrentTokens(), getIncome(data.getCurrentTokens()), - data.getTotalIncome() + facilitator.getServerConfiguration().getShowUpPayment())); + getTotalIncome(data))); } builder.append("</tbody></table><hr>"); if (event.isLastRound()) { @@ -349,12 +348,16 @@ stopRoundMenuItem.setEnabled(false); } + private double getTotalIncome(ClientData data) { + ServerConfiguration serverConfiguration = facilitator.getServerConfiguration(); + double quizEarnings = data.getCorrectQuizAnswers() * serverConfiguration.getQuizCorrectAnswerReward(); + double trustGameEarnings = data.getTrustGameEarnings(); + double totalIncome = data.getTotalIncome() + serverConfiguration.getShowUpPayment() + quizEarnings + trustGameEarnings; + return totalIncome; + } + private double getIncome(float numTokens) { RoundConfiguration configuration = facilitator.getCurrentRoundConfiguration(); - if (configuration == null) { - // FIXME: last minute hack. - return 0.02f * numTokens; - } if (configuration.isPracticeRound()) { return 0.0f; } @@ -396,8 +399,6 @@ TreeSet<Identifier> orderedSet = new TreeSet<Identifier>(clientDataMap.keySet()); for (Identifier clientId : orderedSet) { ClientData data = clientDataMap.get(clientId); - // FIXME: hack... inject the configuration into the client data so that getIncome() will return something appropriate. - // should just refactor getIncome or remove it from ClientData entirely. buffer.append(String.format( "<tr><td>%s</td>" + "<td align='center'>%d</td>" + Repository URL: https://bitbucket.org/virtualcommons/foraging/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. |