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

Gameplay improvements #72

Merged
merged 1 commit into from Jun 10, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
46 changes: 36 additions & 10 deletions board.js
Expand Up @@ -83,19 +83,32 @@ let gameBoard = {
// Creation of outlying islands
this.boardArray[(row-1)/3][2].terrain = 'land';
this.boardArray[2][(col-1)/3].terrain = 'land';
this.boardArray[5][5].terrain = 'land';
this.boardArray[4][6].terrain = 'land';
this.boardArray[6][4].terrain = 'land';
this.boardArray[5][6].terrain = 'sea';
this.boardArray[6][5].terrain = 'sea';


this.boardArray[row-3][2*((col-1)/3)].terrain = 'land';
this.boardArray[2*((row-1)/3)][col-3].terrain = 'land';
this.boardArray[row-6][col-6].terrain = 'land';
this.boardArray[row-7][col-5].terrain = 'land';
this.boardArray[row-5][col-7].terrain = 'land';
this.boardArray[row-6][col-7].terrain = 'sea';
this.boardArray[row-7][col-6].terrain = 'sea';

this.boardArray[2][2*((col-1)/3)].terrain = 'land';
this.boardArray[(row-1)/3][col-3].terrain = 'land';
this.boardArray[row-6][5].terrain = 'land';
this.boardArray[row-7][4].terrain = 'land';
this.boardArray[row-7][5].terrain = 'sea';
this.boardArray[row-5][6].terrain = 'land';
this.boardArray[row-6][6].terrain = 'sea';

this.boardArray[2*((row-1)/3)][2].terrain = 'land';
this.boardArray[row-3][(col-1)/3].terrain = 'land';
this.boardArray[5][col-6].terrain = 'land';
this.boardArray[4][col-7].terrain = 'land';
this.boardArray[6][col-5].terrain = 'land';
this.boardArray[6][col-6].terrain = 'sea';
this.boardArray[5][col-7].terrain = 'sea';

// Creation of central volcanic shaped island for trading post
this.overlayTiles(boardCenter-1, boardCenter+1, boardCenter-1, boardCenter+1, 'land');
Expand All @@ -104,6 +117,16 @@ let gameBoard = {
this.boardArray[boardCenter+1][boardCenter+1].terrain = 'sea';
this.boardArray[boardCenter+1][boardCenter-1].terrain = 'sea';

// Inner circle of islands
this.boardArray[boardCenter][boardCenter+4].terrain = 'land';
this.boardArray[boardCenter][boardCenter-4].terrain = 'land';
this.boardArray[boardCenter+4][boardCenter].terrain = 'land';
this.boardArray[boardCenter-4][boardCenter].terrain = 'land';
this.boardArray[boardCenter-3][boardCenter-3].terrain = 'land';
this.boardArray[boardCenter+3][boardCenter+3].terrain = 'land';
this.boardArray[boardCenter-3][boardCenter+3].terrain = 'land';
this.boardArray[boardCenter+3][boardCenter-3].terrain = 'land';

// Creation of bay shaped islands
this.overlayTiles(boardCenter-1, boardCenter+1, 2*((row-1)/3)+4, 2*((row-1)/3)+4, 'land');
//this.overlayTiles(boardCenter-1, boardCenter+1, 2*((row-1)/3)+3, 2*((row-1)/3)+4, 'land');
Expand Down Expand Up @@ -171,19 +194,19 @@ let gameBoard = {
this.boardArray[boardCenter+1][0].pieces = {populatedSquare: true, category: 'Transport', type: 'catamaran', direction: '90', used: 'unused', damageStatus: 5, team: 'Blue Team', goods: 'none', stock: 0, production: 0, homeRow: boardCenter+1, homeCol: 0};

// Creation of pirate ships and pirate harbours
this.boardArray[4][6] = {xpos: 4, ypos: 6, terrain: 'sea', subTerrain: 'pirateHarbour', activeStatus: 'inactive', pieces: {populatedSquare: true, category: 'Transport', type: 'warship', direction: '135', used: 'unused', damageStatus: 5, team: 'Pirate', goods: 'none', stock: 0, ref: 0}};
this.boardArray[5][5] = {xpos: 5, ypos: 5, terrain: 'sea', subTerrain: 'pirateHarbour', activeStatus: 'inactive', pieces: {populatedSquare: true, category: 'Transport', type: 'warship', direction: '135', used: 'unused', damageStatus: 5, team: 'Pirate', goods: 'none', stock: 0, ref: 0}};
//this.boardArray[4][6].terrain = 'sea';
//this.boardArray[4][6].pieces = {populatedSquare: true, category: 'Transport', type: 'cargo ship', direction: '135', used: 'unused', damageStatus: 5, team: 'Pirate', goods: 'none', stock: 0};

this.boardArray[row-7][4] = {xpos: row-7, ypos: 4, terrain: 'sea', subTerrain: 'pirateHarbour', activeStatus: 'inactive', pieces: {populatedSquare: true, category: 'Transport', type: 'warship', direction: '45', used: 'unused', damageStatus: 5, team: 'Pirate', goods: 'none', stock: 0, ref: 1}};
this.boardArray[row-6][5] = {xpos: row-6, ypos: 5, terrain: 'sea', subTerrain: 'pirateHarbour', activeStatus: 'inactive', pieces: {populatedSquare: true, category: 'Transport', type: 'warship', direction: '45', used: 'unused', damageStatus: 5, team: 'Pirate', goods: 'none', stock: 0, ref: 1}};
//this.boardArray[row-7][4].terrain = 'sea';
//this.boardArray[row-7][4].pieces = {populatedSquare: true, category: 'Transport', type: 'cargo ship', direction: '45', used: 'unused', damageStatus: 5, team: 'Pirate', goods: 'none', stock: 0};

this.boardArray[row-5][col-7] = {xpos: row-5, ypos: col-7, terrain: 'sea', subTerrain: 'pirateHarbour', activeStatus: 'inactive', pieces: {populatedSquare: true, category: 'Transport', type: 'warship', direction: '-45', used: 'unused', damageStatus: 5, team: 'Pirate', goods: 'none', stock: 0, ref: 2}};
this.boardArray[row-6][col-6] = {xpos: row-5, ypos: col-7, terrain: 'sea', subTerrain: 'pirateHarbour', activeStatus: 'inactive', pieces: {populatedSquare: true, category: 'Transport', type: 'warship', direction: '-45', used: 'unused', damageStatus: 5, team: 'Pirate', goods: 'none', stock: 0, ref: 2}};
//this.boardArray[row-5][col-7].terrain = 'sea';
//this.boardArray[row-5][col-7].pieces = {populatedSquare: true, category: 'Transport', type: 'cargo ship', direction: '-45', used: 'unused', damageStatus: 5, team: 'Pirate', goods: 'none', stock: 0};

this.boardArray[6][col-5] = {xpos: 6, ypos: col-5, terrain: 'sea', subTerrain: 'pirateHarbour', activeStatus: 'inactive', pieces: {populatedSquare: true, category: 'Transport', type: 'warship', direction: '-135', used: 'unused', damageStatus: 5, team: 'Pirate', goods: 'none', stock: 0, ref: 3}};
this.boardArray[5][col-6] = {xpos: 6, ypos: col-5, terrain: 'sea', subTerrain: 'pirateHarbour', activeStatus: 'inactive', pieces: {populatedSquare: true, category: 'Transport', type: 'warship', direction: '-135', used: 'unused', damageStatus: 5, team: 'Pirate', goods: 'none', stock: 0, ref: 3}};
//this.boardArray[6][col-5].terrain = 'sea';
//this.boardArray[6][col-5].pieces = {populatedSquare: true, category: 'Transport', type: 'cargo ship', direction: '-135', used: 'unused', damageStatus: 5, team: 'Pirate', goods: 'none', stock: 0};

Expand Down Expand Up @@ -953,7 +976,7 @@ let gameBoard = {
return actionTile;
},

// Method to create plantation tile
// Method to create flax tile
// --------------------------------
createFlaxTile: function(actionTile, localTeam) {

Expand All @@ -972,6 +995,7 @@ let gameBoard = {

petal.setAttribute('stroke-linecap', 'round');
petal.setAttribute('transform', 'scale(0.9, 0.9), translate(1.38, 1.38), rotate(' + rotatePetal + ', ' + centerX + ', ' + centerY + ')');
petal.style.strokeWidth = '1.1px';
return petal
}

Expand All @@ -989,6 +1013,7 @@ let gameBoard = {
flaxBranch.setAttribute('stroke','rgb(138, 87, 50)');
flaxBranch.setAttribute('fill', 'none');
flaxBranch.setAttribute('stroke-linecap', 'round');
flaxBranch.style.strokeWidth = '1px';

// stalk
let flaxStalk = document.createElementNS('http://www.w3.org/2000/svg', 'path');
Expand All @@ -997,6 +1022,7 @@ let gameBoard = {
flaxStalk.setAttribute('stroke','rgb(138, 87, 50)');
flaxStalk.setAttribute('fill', 'none');
flaxStalk.setAttribute('stroke-linecap', 'round');
flaxStalk.style.strokeWidth = '1px';

// Building the tile
actionTile.appendChild(petal1);
Expand Down Expand Up @@ -1143,7 +1169,7 @@ let gameBoard = {
return(goodsIcon);
},

// Method to create iron goods icon
// Method to create cloth goods icon
// ----------------------------------------
createClothIcon: function(goodsIcon) {
// Front end of joist
Expand Down
11 changes: 8 additions & 3 deletions contracts.js
Expand Up @@ -50,10 +50,15 @@ let tradeContracts = {
while (this.contractsArray[settlementNumber].contracts[resourceType].struck != 'unopen')

// Picks a random initial amount for delivery plus a recurring weekly amount
let initialAmount = Math.floor(Math.random() * (resourceManagement.resourcePieces[resourceNumber].maxProduction * 4)) + 5;
let initialAmount = 0;
if (gameManagement.gameDate <= 8) {
initialAmount = Math.floor(Math.random() * (resourceManagement.resourcePieces[resourceNumber].maxProduction * 2)) + 3;
} else if (gameManagement.gameDate > 8 && gameManagement.gameDate <= 16) {
initialAmount = Math.floor(Math.random() * (resourceManagement.resourcePieces[resourceNumber].maxProduction * 4)) + 5;
} else {
initialAmount = Math.floor(Math.random() * (resourceManagement.resourcePieces[resourceNumber].maxProduction * 4)) + 10;
}
let renewalAmount = 1;
//let renewalAmount = Math.floor(Math.random() * (resourceManagement.resourcePieces[resourceNumber].maxProduction)) + 1;


// Put into array as open contract and updates totals
this.contractsArray[settlementNumber].totalOpen += 1;
Expand Down
18 changes: 9 additions & 9 deletions dashboard.js
Expand Up @@ -10,15 +10,15 @@ let stockDashboard = {
// Array to hold list of all piece types
// -------------------------------------
// Pieces must be added in the order: Settlements, Transport, Resources
pieceTypes: [ {type: 'fort', category: 'Settlements', maxNo: 1, goods: 'none', maxProduction: 0, maxMove: 0, maxHold: 20, deckNumber: 0},
{type: 'catamaran', category: 'Transport', maxNo: 1, goods: 'none', maxProduction: 0, maxMove: 5, maxHold: 5, deckNumber: 0},
{type: 'warship', category: 'Transport', maxNo: 1, goods: 'none', maxProduction: 0, maxMove: 4, maxHold: 10, deckNumber: 0},
{type: 'cargo ship', category: 'Transport', maxNo: 1, goods: 'none', maxProduction: 0, maxMove: 3, maxHold: 20, deckNumber: 0},
{type: 'forest', category: 'Resources', maxNo: 1, goods: 'wood', maxProduction: 2, maxMove: 0, maxHold: 20, deckNumber: 4},
{type: 'ironworks', category: 'Resources', maxNo: 1, goods: 'iron', maxProduction: 2, maxMove: 0, maxHold: 20, deckNumber: 4},
{type: 'quarry', category: 'Resources', maxNo: 1, goods: 'stone', maxProduction: 2, maxMove: 0, maxHold: 20, deckNumber: 4},
{type: 'plantation', category: 'Resources', maxNo: 1, goods: 'coffee', maxProduction: 2, maxMove: 0, maxHold: 20, deckNumber: 4},
{type: 'flax', category: 'Resources', maxNo: 1, goods: 'cloth', maxProduction: 2, maxMove: 0, maxHold: 20, deckNumber: 4},
pieceTypes: [ {type: 'fort', category: 'Settlements', maxNo: 1, goods: 'none', maxProduction: 0, maxMove: 0, maxHold: 20, battlePerc: 0, deckNumber: 0},
{type: 'catamaran', category: 'Transport', maxNo: 1, goods: 'none', maxProduction: 0, maxMove: 5, maxHold: 5, battlePerc: 0.1, deckNumber: 0},
{type: 'warship', category: 'Transport', maxNo: 1, goods: 'none', maxProduction: 0, maxMove: 4, maxHold: 10, battlePerc: 0.5, deckNumber: 0},
{type: 'cargo ship', category: 'Transport', maxNo: 1, goods: 'none', maxProduction: 0, maxMove: 3, maxHold: 20, battlePerc: 0.25, deckNumber: 0},
{type: 'forest', category: 'Resources', maxNo: 1, goods: 'wood', maxProduction: 2, maxMove: 0, maxHold: 20, battlePerc: 0, deckNumber: 4},
{type: 'ironworks', category: 'Resources', maxNo: 1, goods: 'iron', maxProduction: 2, maxMove: 0, maxHold: 20, battlePerc: 0, deckNumber: 4},
{type: 'quarry', category: 'Resources', maxNo: 1, goods: 'stone', maxProduction: 2, maxMove: 0, maxHold: 20, battlePerc: 0, deckNumber: 4},
{type: 'plantation', category: 'Resources', maxNo: 1, goods: 'coffee', maxProduction: 2, maxMove: 0, maxHold: 20, battlePerc: 0, deckNumber: 4},
{type: 'flax', category: 'Resources', maxNo: 1, goods: 'cloth', maxProduction: 2, maxMove: 0, maxHold: 20, battlePerc: 0, deckNumber: 4},
],


Expand Down
5 changes: 3 additions & 2 deletions movement.js
Expand Up @@ -611,8 +611,9 @@ let pieceMovement = {
} else {
if(workFlow == 1) {console.log('Conflict transition ended - decide winner and update board array: ' + (Date.now() - launchTime)); }
//console.log(pirates.conflictArray);
// Calculates winner of sea battle - 50% chance of each ship winning battle
if (Math.random()>0.5) {
// Calculates winner of sea battle - battlePerc% gives chance of team ship type winning battle
let arrayPosition = stockDashboard.pieceTypes.findIndex(fI => fI.type == gameBoard.boardArray[pirates.conflictArray.ship.row][pirates.conflictArray.ship.col].pieces.type);
if (Math.random()>stockDashboard.pieceTypes[arrayPosition].battlePerc) {
// Pirate ship wins battle and team ship is damaged
if (gameBoard.boardArray[pirates.conflictArray.ship.row][pirates.conflictArray.ship.col].pieces.type == 'cargo ship') {
gameBoard.boardArray[pirates.conflictArray.ship.row][pirates.conflictArray.ship.col].pieces.damageStatus = 0;
Expand Down
8 changes: 4 additions & 4 deletions pirates.js
Expand Up @@ -3,10 +3,10 @@
let pirates = {

pirateShips: [
{manifest: {ref: 0, homeRow: 4, homeCol: 6, returnRow: 11, returnCol: 11}, start: {row: '', col: ''}, end: {row: '', col: ''}},
{manifest: {ref: 1, homeRow: 24, homeCol: 4, returnRow: 19, returnCol: 11}, start: {row: '', col: ''}, end: {row: '', col: ''}},
{manifest: {ref: 2, homeRow: 26, homeCol: 24, returnRow: 19, returnCol: 19}, start: {row: '', col: ''}, end: {row: '', col: ''}},
{manifest: {ref: 3, homeRow: 6, homeCol: 26, returnRow: 11, returnCol: 19}, start: {row: '', col: ''}, end: {row: '', col: ''}},
{manifest: {ref: 0, homeRow: 5, homeCol: 5, returnRow: 11, returnCol: 11}, start: {row: '', col: ''}, end: {row: '', col: ''}},
{manifest: {ref: 1, homeRow: 25, homeCol: 5, returnRow: 19, returnCol: 11}, start: {row: '', col: ''}, end: {row: '', col: ''}},
{manifest: {ref: 2, homeRow: 25, homeCol: 25, returnRow: 19, returnCol: 19}, start: {row: '', col: ''}, end: {row: '', col: ''}},
{manifest: {ref: 3, homeRow: 5, homeCol: 25, returnRow: 11, returnCol: 19}, start: {row: '', col: ''}, end: {row: '', col: ''}},
],

pirateCount: -1,
Expand Down