Skip to content

Commit

Permalink
new monster on death + fix monster attack bar bug
Browse files Browse the repository at this point in the history
  • Loading branch information
SKeeneCode committed May 27, 2020
1 parent b6cdac8 commit 787e5bb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/main/kotlin/com/game/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ class App : Application() {
}
// monster death
monsterStore.subscribe { monster ->
if (monster.life <= 0) monsterStore.dispatch(MonsterActions.NewMonster)
if (monster.life <= 0) {
playerStore.dispatch(XPActions.IncrementBy(monster.xp))
monsterStore.dispatch(MonsterActions.NewMonster)
}
}

GlobalScope.launch {
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/com/game/reducers/AttackReducer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import com.game.actions.AttackActions

fun attackReducer(canAttack: Boolean, action: Any) = when (action) {
is AttackActions.CanAttack -> action.canAttack
else -> false
else -> canAttack
}
6 changes: 3 additions & 3 deletions src/main/kotlin/com/game/ui/center/BattleDisplay.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class BattleDisplay : ResponsiveGridPanel(rows = 12, cols = 12, align = Align.CE
setAttribute("aria-valuenow", player.attackBar.toString())
setAttribute("aria-valuemin", "0")
setAttribute("aria-valuemax", player.attackBarMax.toString())
content = "Attack: ${player.attackBar} / ${player.attackBarMax}"
content = "Attack: ${player.attackBar.toInt()} / ${player.attackBarMax}"
width = CssSize((player.attackBar * 100) / player.attackBarMax, UNIT.perc)
}
}
Expand All @@ -47,12 +47,12 @@ class BattleDisplay : ResponsiveGridPanel(rows = 12, cols = 12, align = Align.CE
private fun monsterAttackBar() =
Div(classes = setOf("progress", "m-1")) {
div(classes = setOf("progress-bar-no-animation", "progress-bar-striped", "bg-info", "barText")) {
bind(playerStore) { monster ->
bind(monsterStore) { monster ->
role = "progressbar"
setAttribute("aria-valuenow", monster.attackBar.toString())
setAttribute("aria-valuemin", "0")
setAttribute("aria-valuemax", monster.attackBarMax.toString())
content = "Attack: ${monster.attackBar} / ${monster.attackBarMax}"
content = "Attack: ${monster.attackBar.toInt()} / ${monster.attackBarMax}"
width = CssSize((monster.attackBar * 100) / monster.attackBarMax, UNIT.perc)
}
}
Expand Down

0 comments on commit 787e5bb

Please sign in to comment.