-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Corrected the movements, the coordinate object and its tests. Added more functionality to the element object added the codes to the unitsLoader
- Loading branch information
Nuno Silva
committed
Mar 9, 2014
1 parent
5509df2
commit 92b22f6
Showing
12 changed files
with
175 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
(function allMovement(module) { | ||
|
||
module.isValid = function(src,dst,position) { | ||
if( dst.x <= src.x + 1 && dst.x >= src.x - 1 ) { | ||
if( dst.y <= src.y + 1 && dst.y >= src.y - 1 ) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
if( dst.x <= src.x + 1 && dst.x >= src.x - 1 ) { | ||
if( dst.y <= src.y + 1 && dst.y >= src.y - 1 ) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
}; | ||
|
||
})(exports); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,17 @@ | ||
(function frontMovement(module) { | ||
|
||
module.isValid = function(src,dst,position) { | ||
switch(position) { | ||
case "N": | ||
if( dst.x == src.x - 1 && src.y == dst.y ) { | ||
return true; | ||
} | ||
case "S": | ||
if( dst.x == src.x + 1 && src.y == dst.y ) { | ||
return true; | ||
} | ||
case "W": | ||
if( dst.y == src.y - 1 && src.x == dst.x ) { | ||
return true; | ||
} | ||
case "E": | ||
if( dst.y == src.y + 1 && src.x == dst.x ) { | ||
return true; | ||
} | ||
default: | ||
throw new Error("Invalid position.") | ||
} | ||
return false; | ||
|
||
}; | ||
var frontValues = { | ||
N : { x : 0, y: -1 }, | ||
S : { x : 0, y: 1 }, | ||
W : { x : -1, y: 0 }, | ||
E : { x : 1, y: 0 } | ||
}; | ||
|
||
module.isValid = function(src,dst,position) { | ||
var value = frontValues[position]; | ||
if( value != null ) { | ||
return dst.x == src.x + value.x && dst.y == src.y + value.y; | ||
} | ||
throw new Error("Invalid position.") | ||
}; | ||
})(exports); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
(function normalMovement(module) { | ||
|
||
module.isValid = function(src,dst,position) { | ||
if( dst.x <= src.x + 1 && dst.x >= src.x - 1 && src.y == dst.y ) { | ||
return true; | ||
} | ||
if( dst.x <= src.x + 1 && dst.x >= src.x - 1 && src.y == dst.y ) { | ||
return true; | ||
} | ||
|
||
if( dst.y <= src.y + 1 && dst.y >= src.y - 1 && src.x == dst.x ) { | ||
return true; | ||
} | ||
if( dst.y <= src.y + 1 && dst.y >= src.y - 1 && src.x == dst.x ) { | ||
return true; | ||
} | ||
|
||
return false; | ||
return false; | ||
}; | ||
|
||
})(exports); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
(function allMovement(module) { | ||
|
||
module.isValid = function(numberOfPlayers,dst) { | ||
if( numberOfPlayers == 2 ) { | ||
if( dst.x != 8 && dst.x != 7 ) { | ||
return false; | ||
} | ||
if( numberOfPlayers == 2 ) { | ||
if( dst.y != 8 && dst.y != 7 ) { | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
return true; | ||
} | ||
|
||
//4 Players | ||
if( ( dst.x == 12 || dst.x == 11 ) && ( dst.y > 2 && dst.y < 11 ) ) { | ||
return true; | ||
} | ||
//4 Players | ||
if( ( dst.y == 12 || dst.y == 11 ) && ( dst.x > 2 && dst.x < 11 ) ) { | ||
return true; | ||
} | ||
|
||
return false; | ||
return false; | ||
}; | ||
|
||
})(exports); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.