New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Min Health Restriction #4803
Conversation
app/lib/world/world.coffee
Outdated
@@ -260,6 +260,11 @@ module.exports = class World | |||
system.start @thangs | |||
catch err | |||
console.error "Error starting system!", system, err | |||
# Silently clamp health after systems run. | |||
hero = _.find(@thangs, (thang) -> thang.id == 'Hero Placeholder') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this is the best way to locate the hero.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works. You can also shorten a bit:
hero = _.find @thangs, id: 'Hero Placeholder'
app/lib/world/world.coffee
Outdated
@@ -260,6 +260,14 @@ module.exports = class World | |||
system.start @thangs | |||
catch err | |||
console.error "Error starting system!", system, err | |||
# Silently clamp health after systems run. | |||
hero = _.find(@thangs, (thang) -> thang.id == 'Hero Placeholder') | |||
if hero? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be refactored out?
It's not long enough and doesn't need to be called anywhere else currently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would just put it into its own world
method here called clampHeroHealth
or something like that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I didn't capture in Asana, but we need to only apply this in course mode.
app/lib/world/world.coffee
Outdated
@@ -260,6 +260,11 @@ module.exports = class World | |||
system.start @thangs | |||
catch err | |||
console.error "Error starting system!", system, err | |||
# Silently clamp health after systems run. | |||
hero = _.find(@thangs, (thang) -> thang.id == 'Hero Placeholder') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works. You can also shorten a bit:
hero = _.find @thangs, id: 'Hero Placeholder'
app/lib/world/world.coffee
Outdated
@@ -260,6 +260,14 @@ module.exports = class World | |||
system.start @thangs | |||
catch err | |||
console.error "Error starting system!", system, err | |||
# Silently clamp health after systems run. | |||
hero = _.find(@thangs, (thang) -> thang.id == 'Hero Placeholder') | |||
if hero? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would just put it into its own world
method here called clampHeroHealth
or something like that.
hero.maxHealth = Math.max(hero.maxHealth, level.recommendedHealth) | ||
if level.maximumHealth? | ||
hero.maxHealth = Math.min(hero.maxHealth, level.maximumHealth) | ||
hero.health = hero.maxHealth |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized we only want to do this if we are in classroom mode, so when level.type is 'course'
. In home mode, they still need to actually have that much health.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review and clarification.
recommendedHealth
maximumHealth
to schemas.