Fixed bug in achievement popup listing wrong xp left values.

This commit is contained in:
Nick Winter 2014-11-10 08:31:26 -08:00
parent f78ff257ab
commit ab448532f5
2 changed files with 8 additions and 8 deletions

View file

@ -14,7 +14,7 @@
.progress
- var currentTitle = $.i18n.t('achievements.current_xp_prefix') + currentXP + ' XP' + $.i18n.t('achievements.current_xp_postfix');
- var newTitle = $.i18n.t('achievements.new_xp_prefix') + newXP + ' XP' + $.i18n.t('achievements.new_xp_postfix');
- var leftTitle = $.i18n.t('achievements.left_xp_prefix') + newXP + ' XP' + $.i18n.t('achievements.left_xp_infix') + (level+1) + $.i18n.t('achievements.left_xp_postfix');
- var leftTitle = $.i18n.t('achievements.left_xp_prefix') + leftXP + ' XP' + $.i18n.t('achievements.left_xp_infix') + (level+1) + $.i18n.t('achievements.left_xp_postfix');
.progress-bar.xp-bar-old(style="width:#{oldXPWidth}%" data-toggle="tooltip" data-placement="top" title="#{currentTitle}")
.progress-bar.xp-bar-new(style="width:#{newXPWidth}%" data-toggle="tooltip" title="#{newTitle}")
.progress-bar.xp-bar-left(style="width:#{leftXPWidth}%" data-toggle="tooltip" title="#{leftTitle}")

View file

@ -20,9 +20,9 @@ module.exports = class AchievementPopup extends CocoView
calculateData: ->
currentLevel = me.level()
nextLevel = currentLevel + 1
currentLevelExp = User.expForLevel(currentLevel)
currentLevelXP = User.expForLevel(currentLevel)
nextLevelXP = User.expForLevel(nextLevel)
totalExpNeeded = nextLevelXP - currentLevelExp
totalXPNeeded = nextLevelXP - currentLevelXP
expFunction = @achievement.getExpFunction()
currentXP = me.get 'points', true
if @achievement.isRepeatable()
@ -30,14 +30,14 @@ module.exports = class AchievementPopup extends CocoView
else
achievedXP = @achievement.get 'worth', true
previousXP = currentXP - achievedXP
leveledUp = currentXP - achievedXP < currentLevelExp
leveledUp = currentXP - achievedXP < currentLevelXP
#console.debug 'Leveled up' if leveledUp
alreadyAchievedPercentage = 100 * (previousXP - currentLevelExp) / totalExpNeeded
alreadyAchievedPercentage = 100 * (previousXP - currentLevelXP) / totalXPNeeded
alreadyAchievedPercentage = 0 if alreadyAchievedPercentage < 0 # In case of level up
newlyAchievedPercentage = if leveledUp then 100 * (currentXP - currentLevelExp) / totalExpNeeded else 100 * achievedXP / totalExpNeeded
newlyAchievedPercentage = if leveledUp then 100 * (currentXP - currentLevelXP) / totalXPNeeded else 100 * achievedXP / totalXPNeeded
#console.debug "Current level is #{currentLevel} (#{currentLevelExp} xp), next level is #{nextLevel} (#{nextLevelXP} xp)."
#console.debug "Need a total of #{nextLevelXP - currentLevelExp}, already had #{previousXP} and just now earned #{achievedXP} totalling on #{currentXP}"
#console.debug "Current level is #{currentLevel} (#{currentLevelXP} xp), next level is #{nextLevel} (#{nextLevelXP} xp)."
#console.debug "Need a total of #{nextLevelXP - currentLevelXP}, already had #{previousXP} and just now earned #{achievedXP} totalling on #{currentXP}"
data =
title: @achievement.i18nName()