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

Enhance "look" ability #162

Merged
merged 3 commits into from
May 26, 2018
Merged

Enhance "look" ability #162

merged 3 commits into from
May 26, 2018

Conversation

pigalot
Copy link
Contributor

@pigalot pigalot commented May 26, 2018

Fixes #160

@codecov-io
Copy link

codecov-io commented May 26, 2018

Codecov Report

Merging #162 into master will increase coverage by 0.03%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #162      +/-   ##
==========================================
+ Coverage   92.32%   92.35%   +0.03%     
==========================================
  Files          83       83              
  Lines        1055     1060       +5     
  Branches      173      177       +4     
==========================================
+ Hits          974      979       +5     
  Misses         66       66              
  Partials       15       15
Impacted Files Coverage Δ
packages/warriorjs-abilities/src/look.js 100% <100%> (ø) ⬆️

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 17d040f...bf958b7. Read the comment docs.

@olistic
Copy link
Owner

olistic commented May 26, 2018

@pigalot I added a .gitattributes and .editorconfig in the master branch that should fix the issues in Windows in a broader way, so you should be able to drop your changes to gitattributes in this branch after a rebase against master.

Copy link
Owner

@olistic olistic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @pigalot, nice work! Just a couple of comments, please review.

.map(offset => unit.getSensedSpaceAt(direction, offset))
.some(space => {
sensedSpaces.push(space);
return space && space.isWall && space.isWall();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can safely assume any space returned by unit.getSensedSpaceAt() will have the isWall method so this check should be simplified.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be true but the fakes given by the existing unit tests are not of type Space so do not have .isWall method.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, you should add isWall() to the mocks though now that a simple string does not suffice.

const space1 = { isWall: () => false };
const space2 = { isWall: () => false };
...
unit.getSensedSpaceAt
  .mockReturnValueOnce(space1)
  .mockReturnValueOnce(space2)
...

const sensedSpaces = [];
offsets
.map(offset => unit.getSensedSpaceAt(direction, offset))
.some(space => {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you thought about using spaces.slice() instead of .some() and an auxiliary array? I think it's cleaner than .some().

firstWallIndex can be calculated with spaces.findIndex(). If a wall is found, then slice the spaces array up to that wall. If not, return all spaces. What do you think?

@olistic olistic merged commit fb51f5b into olistic:master May 26, 2018
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