Skip to content

Commit

Permalink
Fix adjacency logic: diagonally adjacent cell should count too
Browse files Browse the repository at this point in the history
  • Loading branch information
silviot committed Aug 16, 2023
1 parent b96f20d commit ddec2bc
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.
7 changes: 3 additions & 4 deletions dlgr/griduniverse/static/scripts/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,10 +384,9 @@ var playerSet = (function () {
let player = this._players[id];
if (player.hasOwnProperty('position')) {
let position = player.position;
if (position[0] === egoPostiion[0] && Math.abs(position[1] - egoPostiion[1]) === 1) {
adjacentPlayers.push(player);
}
if (position[1] === egoPostiion[1] && Math.abs(position[0] - egoPostiion[0]) === 1) {
let distanceX = Math.abs(position[0] - egoPostiion[0]);
let distanceY = Math.abs(position[1] - egoPostiion[1])
if (distanceX <= 1 && distanceY <= 1) {
adjacentPlayers.push(player);
}
}
Expand Down
7 changes: 3 additions & 4 deletions dlgr/griduniverse/static/scripts/dist/bundle.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dlgr/griduniverse/static/scripts/dist/bundle.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dlgr/griduniverse/static/scripts/dist/difi.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dlgr/griduniverse/static/scripts/dist/questionnaire.js.map

Large diffs are not rendered by default.

0 comments on commit ddec2bc

Please sign in to comment.