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

Land discovery error correction #63

Merged
merged 1 commit into from
May 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
// --------------------------
// --------------------------

window.addEventListener("error", function(e) {
console.log('error: ' + e.message + ' at linenumber: ' + e.lineno + ' of file: ' +e.filename);
});


const launchTime = Date.now();
let workFlow = 1;
let gameBoardTrack = 0;
Expand All @@ -13,6 +18,7 @@ let transitionMonitor = 1;




// ------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------
// SETTING UP GAME BOARD
Expand Down
4 changes: 2 additions & 2 deletions movement.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,9 +450,9 @@ let pieceMovement = {
// At end of each move check a 1x1 grid to see if the ship is next to land that is unpopulated
let searchDistance = 1;
for (var i = -searchDistance; i < searchDistance + 1; i++) {
if(this.movementArray.start.row+i >=0 && this.movementArray.start.row+i <row) {
if(this.movementArray.end.row+i >=0 && this.movementArray.end.row+i <row) {
for (var j = -searchDistance; j < searchDistance + 1; j++) {
if(this.movementArray.start.col+j >=0 && this.movementArray.start.col+j <col) {
if(this.movementArray.end.col+j >=0 && this.movementArray.end.col+j <col) {
// Reduces seacrh to exclude diagonals
if(i == 0 || j == 0) {
// Checks if tile is land and unpopulated
Expand Down