Skip to content

Commit

Permalink
Whirlpools - interrupting trade routes
Browse files Browse the repository at this point in the history
Previously trade routes were interrupted and cancelled when pirate ships ended on them. However this created the possibility of other players luring pirate ships onto opposition trade paths. Instead, whirlpools will now be used as the interruptors of trade paths whilst pirate ships will just chase ships and steal cargo.

contracts.js
* Method (contractObstacle) updated to check for whirlpools rather than pirate ships.
  • Loading branch information
miniature-tiger committed Jan 14, 2019
1 parent 96480c7 commit 4615e64
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
6 changes: 3 additions & 3 deletions contracts.js
Expand Up @@ -198,7 +198,7 @@ let tradeContracts = {
for (let resourceType of this.resourcePieces) {
if (island.contracts[resourceType.goods].team == game.turn) {
if(island.contracts[resourceType.goods].struck == 'active') {
if(this.contractObstacle(island.contracts[resourceType.goods].contractPath) == true) {
if(this.contractObstacle(island.contracts[resourceType.goods].contractPath) === true) {
IDtradeRoute = resourceType.goods + '_' + island.name;
let closedTradeRoute = document.getElementById(IDtradeRoute);
closedTradeRoute.remove();
Expand Down Expand Up @@ -233,8 +233,8 @@ let tradeContracts = {
// ------------------------------------------------------------------------------------------
contractObstacle: function(tradePath) {
let obstacle = false;
for (var i = 0; i < tradePath.length; i++) {
if(game.boardArray[tradePath[i].fromRow][tradePath[i].fromCol].piece.team == 'Pirate') {
for (let i = 0; i < tradePath.length; i+=1) {
if (game.boardArray[tradePath[i].fromRow][tradePath[i].fromCol].piece.type == 'whirlpool') {
obstacle = true;
//console.log(tradePath[i], 'Pirate');
} else {
Expand Down
1 change: 0 additions & 1 deletion movement.js
Expand Up @@ -177,7 +177,6 @@ let pieceMovement = {
game.boardArray[startRow+i][startCol+j].tile.activeStatus = 'inactive';
// Prevents damaged pirate ships targeting other ships
} else if (game.boardArray[startRow][startCol].piece.damageStatus === 0) {
console.log('here2')
this.findPath[startRow+i][startCol+j].activeStatus = 'inactive';
game.boardArray[startRow+i][startCol+j].tile.activeStatus = 'inactive';
}
Expand Down

0 comments on commit 4615e64

Please sign in to comment.