|
|
|
@ -6,6 +6,7 @@ function drawGameBoard(){
|
|
|
|
drawPlayerNames();
|
|
|
|
drawPlayerNames();
|
|
|
|
calculateDeckPositions();
|
|
|
|
calculateDeckPositions();
|
|
|
|
calculateHandPositions();
|
|
|
|
calculateHandPositions();
|
|
|
|
|
|
|
|
calculateBoardPositions();
|
|
|
|
|
|
|
|
|
|
|
|
drawEntities();
|
|
|
|
drawEntities();
|
|
|
|
|
|
|
|
|
|
|
|
@ -100,6 +101,50 @@ function calculateHandPositions(){
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Move from draw into somewhere else
|
|
|
|
|
|
|
|
function calculateBoardPositions(){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (const [key, value] of Object.entries(gameData.board)) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// key is entity Id here
|
|
|
|
|
|
|
|
let cardsOnBoard = 0;
|
|
|
|
|
|
|
|
let position = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch(gameData.player[key]){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Set position for player hand (all the time at current)
|
|
|
|
|
|
|
|
case gameData.playerId:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cardsOnBoard = gameData.cardCount.board[gameData.playerId];
|
|
|
|
|
|
|
|
position = gameData.listPosition[key];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gameData.position[key] = [
|
|
|
|
|
|
|
|
canvas.width/2 - (cardWidth * (cardsOnBoard - (position+1)) - (cardMargin * (position+1)))
|
|
|
|
|
|
|
|
,canvas.height-((cardHeight*2) * handScale)-30
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gameData.size[key] = [cardWidth * handScale, cardHeight * handScale];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Opponent
|
|
|
|
|
|
|
|
case gameData.opponentId:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cardsOnBoard = gameData.cardCount.board[gameData.opponentId];
|
|
|
|
|
|
|
|
position = gameData.listPosition[key];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gameData.position[key] = [
|
|
|
|
|
|
|
|
canvas.width/2 - (cardWidth * (cardsOnBoard - (position+1)) - (cardMargin * (position+1)))
|
|
|
|
|
|
|
|
,((cardHeight*2) * handScale)+30
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
gameData.size[key] = [cardWidth * handScale, cardHeight * handScale];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// TODO: Move this function elsewhere, not really a draw function
|
|
|
|
// TODO: Move this function elsewhere, not really a draw function
|
|
|
|
function calculateCardSpacing(positionInt, size, standardSize){
|
|
|
|
function calculateCardSpacing(positionInt, size, standardSize){
|
|
|
|
@ -129,6 +174,11 @@ function drawEntities(){
|
|
|
|
drawCardInHand(key);
|
|
|
|
drawCardInHand(key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If card on board
|
|
|
|
|
|
|
|
if(key in gameData.board){
|
|
|
|
|
|
|
|
drawCardOnBoard(key);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(key in gameData.inInteractionMenu){
|
|
|
|
if(key in gameData.inInteractionMenu){
|
|
|
|
// Add the menu with 'play', 'activate effect', 'inspect', etc.
|
|
|
|
// Add the menu with 'play', 'activate effect', 'inspect', etc.
|
|
|
|
drawInteractionMenu(key);
|
|
|
|
drawInteractionMenu(key);
|
|
|
|
@ -168,10 +218,27 @@ function drawDeck(entity){
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function drawCardInHand(entity){
|
|
|
|
function drawCardInHand(entity){
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: Tapped, Attacking, Targettable, Activatable borders
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: Change card colour based on its colours
|
|
|
|
// TODO: Change card colour based on its colours
|
|
|
|
// TODO: Not for hand, but cards on board need flight, etc.
|
|
|
|
|
|
|
|
|
|
|
|
// Draw the card shape
|
|
|
|
|
|
|
|
let shape = new Shape({
|
|
|
|
|
|
|
|
x: gameData.position[entity][0],
|
|
|
|
|
|
|
|
y: gameData.position[entity][1],
|
|
|
|
|
|
|
|
width: gameData.size[entity][0],
|
|
|
|
|
|
|
|
height: gameData.size[entity][1],
|
|
|
|
|
|
|
|
fillStyle: '#EEE',
|
|
|
|
|
|
|
|
strokeStyle: '#AAA',
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
shape.draw();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
drawCardDetails(entity);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function drawCardOnBoard(entity){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: Tapped, Attacking, Targettable, Activatable borders
|
|
|
|
|
|
|
|
// TODO: Passives, flight, etc. effects
|
|
|
|
|
|
|
|
|
|
|
|
// Draw the card shape
|
|
|
|
// Draw the card shape
|
|
|
|
let shape = new Shape({
|
|
|
|
let shape = new Shape({
|
|
|
|
@ -261,29 +328,36 @@ function drawCardText(entity){
|
|
|
|
// so TODO gotta make it scaled % wise with the 80/16 I wrote above
|
|
|
|
// so TODO gotta make it scaled % wise with the 80/16 I wrote above
|
|
|
|
|
|
|
|
|
|
|
|
// NAME
|
|
|
|
// NAME
|
|
|
|
|
|
|
|
if(gameData.cardData[entity] !== undefined && gameData.cardData[entity]['name'] !== undefined){
|
|
|
|
printText(gameData.cardData[entity]['name']
|
|
|
|
printText(gameData.cardData[entity]['name']
|
|
|
|
, positionX + 5 + 10 // + 5 (spacing for cost) + 10 for more spacing
|
|
|
|
, positionX + 5 + 10 // + 5 (spacing for cost) + 10 for more spacing
|
|
|
|
, positionY + 10 + 5 // + 10pt + 5 as it's the spacing I actually want
|
|
|
|
, positionY + 10 + 5 // + 10pt + 5 as it's the spacing I actually want
|
|
|
|
, 'left', 'alphabetic', 'normal', 'normal', fontSize, 'Arial', fillStyle, strokeStyle, strokeSize, false
|
|
|
|
, 'left', 'alphabetic', 'normal', 'normal', fontSize, 'Arial', fillStyle, strokeStyle, strokeSize, false
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// COST
|
|
|
|
// COST
|
|
|
|
|
|
|
|
if(gameData.cardData[entity] !== undefined && gameData.cardData[entity]['cost'] !== undefined){
|
|
|
|
printText(gameData.cardData[entity]['cost']
|
|
|
|
printText(gameData.cardData[entity]['cost']
|
|
|
|
, positionX + 5
|
|
|
|
, positionX + 5
|
|
|
|
, positionY + 10 + 5 // + 10pt + 5 as it's the spacing I actually want
|
|
|
|
, positionY + 10 + 5 // + 10pt + 5 as it's the spacing I actually want
|
|
|
|
, 'left', 'alphabetic', 'normal', 'normal', fontSize, 'Arial', fillStyle, strokeStyle, strokeSize, false
|
|
|
|
, 'left', 'alphabetic', 'normal', 'normal', fontSize, 'Arial', fillStyle, strokeStyle, strokeSize, false
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TYPE
|
|
|
|
// TYPE
|
|
|
|
|
|
|
|
if(gameData.cardData[entity] !== undefined && gameData.cardData[entity]['type'] !== undefined){
|
|
|
|
printText(
|
|
|
|
printText(
|
|
|
|
CLASS[gameData.cardData[entity]['type']]
|
|
|
|
CLASS[gameData.cardData[entity]['type']]
|
|
|
|
, positionX + 5
|
|
|
|
, positionX + 5
|
|
|
|
, positionY + width // To be slightly over bottom of image (which uses width to position)
|
|
|
|
, positionY + width // To be slightly over bottom of image (which uses width to position)
|
|
|
|
, 'left', 'alphabetic', 'normal', 'normal', fontSize, 'Arial', fillStyle, strokeStyle, strokeSize, false
|
|
|
|
, 'left', 'alphabetic', 'normal', 'normal', fontSize, 'Arial', fillStyle, strokeStyle, strokeSize, false
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// CLASS(ES)
|
|
|
|
// CLASS(ES)
|
|
|
|
|
|
|
|
if(gameData.cardData[entity] !== undefined && gameData.cardData[entity]['class'] !== undefined){
|
|
|
|
let classes = '';
|
|
|
|
let classes = '';
|
|
|
|
// Loop the classes, and add each of them to the card
|
|
|
|
// Loop the classes, and add each of them to the card
|
|
|
|
for(let i = 0; i < gameData.cardData[entity]['class'].length; i++){
|
|
|
|
for(let i = 0; i < gameData.cardData[entity]['class'].length; i++){
|
|
|
|
@ -299,8 +373,10 @@ function drawCardText(entity){
|
|
|
|
, positionY + width // To be slightly over bottom of image (which uses width to position)
|
|
|
|
, positionY + width // To be slightly over bottom of image (which uses width to position)
|
|
|
|
, 'left', 'alphabetic', 'normal', 'normal', fontSize, 'Arial', fillStyle, strokeStyle, strokeSize, false
|
|
|
|
, 'left', 'alphabetic', 'normal', 'normal', fontSize, 'Arial', fillStyle, strokeStyle, strokeSize, false
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// EFFECT(S)
|
|
|
|
// EFFECT(S)
|
|
|
|
|
|
|
|
if(gameData.cardData[entity] !== undefined && gameData.cardData[entity]['effect'] !== undefined){
|
|
|
|
// TODO: Split the text onto lines based on character count (but not splitting words) so they fit into the
|
|
|
|
// TODO: Split the text onto lines based on character count (but not splitting words) so they fit into the
|
|
|
|
// bounds of the card element
|
|
|
|
// bounds of the card element
|
|
|
|
let effects = '';
|
|
|
|
let effects = '';
|
|
|
|
@ -317,13 +393,16 @@ function drawCardText(entity){
|
|
|
|
, positionY + width + 10 // To be beneath image, and type + classes
|
|
|
|
, positionY + width + 10 // To be beneath image, and type + classes
|
|
|
|
, 'left', 'alphabetic', 'normal', 'normal', fontSize, 'Arial', fillStyle, strokeStyle, strokeSize, false
|
|
|
|
, 'left', 'alphabetic', 'normal', 'normal', fontSize, 'Arial', fillStyle, strokeStyle, strokeSize, false
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ATTACK
|
|
|
|
// ATTACK
|
|
|
|
|
|
|
|
if(gameData.cardData[entity] !== undefined && gameData.cardData[entity]['attack'] !== undefined){
|
|
|
|
printText(gameData.cardData[entity]['attack']
|
|
|
|
printText(gameData.cardData[entity]['attack']
|
|
|
|
, positionX + width/2 - ctx.measureText(gameData.cardData[entity]['attack']).width/2 // Should be centred
|
|
|
|
, positionX + width/2 - ctx.measureText(gameData.cardData[entity]['attack']).width/2 // Should be centred
|
|
|
|
, positionY + 10 + (height - 10) // + 10pt + 5 as it's the spacing I actually want
|
|
|
|
, positionY + 10 + (height - 10) // + 10pt + 5 as it's the spacing I actually want
|
|
|
|
, 'left', 'alphabetic', 'normal', 'normal', fontSize, 'Arial', fillStyle, strokeStyle, strokeSize, false
|
|
|
|
, 'left', 'alphabetic', 'normal', 'normal', fontSize, 'Arial', fillStyle, strokeStyle, strokeSize, false
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Reset font for other draws
|
|
|
|
// Reset font for other draws
|
|
|
|
// TODO: Probably just use a save/restore for the font draws in here
|
|
|
|
// TODO: Probably just use a save/restore for the font draws in here
|
|
|
|
@ -477,3 +556,11 @@ function drawInteractionMenu(entity){
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: Put the stack into the UI
|
|
|
|
|
|
|
|
function drawStackResolve(){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Draw stack, all cards in the stack in order (use the cardId for display)
|
|
|
|
|
|
|
|
// make inspectable, and display which part of the effect will be triggered in it's
|
|
|
|
|
|
|
|
// stack position
|
|
|
|
|
|
|
|
|
|
|
|
|