olistic / warriorjs

🏰 An exciting game of programming and Artificial Intelligence
https://warriorjs.com
MIT License
9.41k stars 488 forks source link

Check after each effect if the unit is still alive before performing actions #250

Open glneto opened 5 years ago

glneto commented 5 years ago

I used some to check if after any effect the unit.isAlive() would return false. In case the unit is not alive after any effect, it will skip the next iterations and return true to diedAfterEffects.

Then, I added another check (!diedAfterEffects) before starting to perform the unit actions.

Let me know if you think this can be improved in any way.

codecov[bot] commented 5 years ago

Codecov Report

Merging #250 into master will increase coverage by 0.02%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #250      +/-   ##
==========================================
+ Coverage   92.39%   92.41%   +0.02%     
==========================================
  Files          92       92              
  Lines        1091     1094       +3     
  Branches      165      165              
==========================================
+ Hits         1008     1011       +3     
  Misses         68       68              
  Partials       15       15
Impacted Files Coverage Δ
packages/warriorjs-core/src/Unit.js 100% <100%> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update ec531b4...0bfc2a4. Read the comment docs.

codecov[bot] commented 5 years ago

Codecov Report

Merging #250 into master will increase coverage by 0.02%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #250      +/-   ##
==========================================
+ Coverage   92.39%   92.41%   +0.02%     
==========================================
  Files          92       92              
  Lines        1091     1094       +3     
  Branches      165      165              
==========================================
+ Hits         1008     1011       +3     
  Misses         68       68              
  Partials       15       15
Impacted Files Coverage Δ
packages/warriorjs-core/src/Unit.js 100% <100%> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update ec531b4...0bfc2a4. Read the comment docs.

codecov[bot] commented 5 years ago

Codecov Report

Merging #250 into master will increase coverage by 0.02%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #250      +/-   ##
==========================================
+ Coverage   92.39%   92.41%   +0.02%     
==========================================
  Files          92       92              
  Lines        1091     1094       +3     
  Branches      165      165              
==========================================
+ Hits         1008     1011       +3     
  Misses         68       68              
  Partials       15       15
Impacted Files Coverage Δ
packages/warriorjs-core/src/Unit.js 100% <100%> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update ec531b4...0bfc2a4. Read the comment docs.