Skip to content
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

Merged
merged 4 commits into from Aug 1, 2018
Merged

Conversation

AndrewJakubowicz
Copy link
Contributor

  • Health is raised if below recommendedHealth
  • Added maximumHealth to schemas.

@@ -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')
Copy link
Contributor Author

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.

Copy link
Contributor

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'

@@ -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?
Copy link
Contributor Author

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.

Copy link
Contributor

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.

@coveralls
Copy link

coveralls commented Jul 31, 2018

Coverage Status

Coverage remained the same at 63.616% when pulling 0e246c1 on clamp-health-restriction into 5794c0d on master.

Copy link
Contributor

@nwinter nwinter left a 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.

@@ -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')
Copy link
Contributor

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'

@@ -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?
Copy link
Contributor

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
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@AndrewJakubowicz AndrewJakubowicz merged commit 89d14f2 into master Aug 1, 2018
@AndrewJakubowicz AndrewJakubowicz deleted the clamp-health-restriction branch October 9, 2018 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants