Skip to content

Commit 5db41b9

Browse files
committed
fix: Fix wrong logic in update nickname and add nickname in level up notification
1 parent 50d44eb commit 5db41b9

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/main/kotlin/com/github/ilovegamecoding/intellijcodexp/manager/CodeXPNotificationManager.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ object CodeXPNotificationManager {
1717
notify("${codeXPChallenge.name} completed!", "Reward: ${codeXPChallenge.rewardXP} XP")
1818
}
1919

20-
fun notifyLevelUp(level: Int, xpToNextLevel: Long) {
21-
notify("Level up!", "Congratulations! You are now level $level. You need $xpToNextLevel XP to reach the next level.")
20+
fun notifyLevelUp(nickname: String, level: Int, xpToNextLevel: Long) {
21+
notify(
22+
"Level up!",
23+
"Congratulations $nickname! You are now level $level. You need $xpToNextLevel XP to reach the next level."
24+
)
2225
}
2326
}

src/main/kotlin/com/github/ilovegamecoding/intellijcodexp/toolWindow/CodeXPToolWindowFactory.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ class CodeXPToolWindowFactory : ToolWindowFactory {
161161
* @param codeXPDashboard CodeXP dashboard.
162162
*/
163163
private fun updateNickname(codeXPService: CodeXPService, codeXPDashboard: CodeXPDashboard) {
164-
codeXPDashboard.tfNickname.text = codeXPService.state.nickname
164+
codeXPService.state.nickname = codeXPDashboard.tfNickname.text
165165
}
166166

167167
/**
@@ -180,7 +180,7 @@ class CodeXPToolWindowFactory : ToolWindowFactory {
180180

181181
val beforeLevel = codeXPDashboard.lblCurrentLevel.text.toInt()
182182
if (beforeLevel != currentLevel && beforeLevel != 0) {
183-
CodeXPNotificationManager.notifyLevelUp(currentLevel, xpToNextLevel)
183+
CodeXPNotificationManager.notifyLevelUp(codeXPService.state.nickname, currentLevel, xpToNextLevel)
184184
}
185185

186186
codeXPDashboard.lblCurrentLevel.text = StringUtil.numberToStringWithCommas(currentLevel.toLong())

0 commit comments

Comments
 (0)