From c4d2989640f0a2364b883a06464d8ce4805c518c Mon Sep 17 00:00:00 2001 From: Nathan Date: Thu, 24 Oct 2024 15:28:00 +0100 Subject: [PATCH] Add visual queues for passive effects --- public/board.js | 26 ++++++++++++++++++++++++++ public/shapes.js | 16 ++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/public/board.js b/public/board.js index 444d9a8..964329b 100644 --- a/public/board.js +++ b/public/board.js @@ -215,6 +215,10 @@ class Board{ fillStyle: fill, strokeStyle: border }); + // Add a dropshadow to flight cards (they're flyin) + if(flight[itemKey]){ + shape.setShadow(true); + } shape.draw(); // Draw the card face-up @@ -222,6 +226,7 @@ class Board{ this.addCardImage(itemKey); this.printCardDetails(itemKey); this.printColourRequirements(itemKey); + this.printCardPassives(itemKey); } if(!this.isFaceUp(itemKey)){ this.addCardBack(itemKey); @@ -346,6 +351,23 @@ class Board{ // TODO: CardBack/Sleeves as spritesheet like cardArt ctx.drawImage(cardBackArt, 0,0, 80,120,positionX,positionY,width,height); } + // Check each passive, if the card has it, add the 'icon' to display it. + printCardPassives(itemKey){ + + let passiveCount = 0; + + let positionX = position[itemKey][0]; + let positionY = position[itemKey][1] - 10; + + if(itemKey in flight){ + this.printCenterText('F', positionX + (10*passiveCount), positionY); + passiveCount++; + } + if(itemKey in reach){ + this.printCenterText('R', positionX + (10*passiveCount), positionY); + passiveCount++; + } + } printColourRequirements(itemKey){ // Set the size(s) let width = size[itemKey][0]*.1; @@ -1550,6 +1572,10 @@ function calculateItemSizePosition(itemKey){ if(itemPlayer == 0 && itemElement == 'board'){ positionX = canvas.width/2 - (cardWidth * (itemListLength - (i+1)) - (cardMargin * (i+1))); positionY = canvas.height - cardHeight-30-(cardHeight); + // Move up to denote 'Flight' keyword + if(flight[itemKey]){ + positionY-=10; + } width = cardWidth; height = cardHeight; } diff --git a/public/shapes.js b/public/shapes.js index 8313964..515d13e 100644 --- a/public/shapes.js +++ b/public/shapes.js @@ -17,6 +17,10 @@ class Shape extends Path2D{ this.fillStyle = params.fillStyle || "#FFFFFF"; this.strokeStyle = params.strokeStyle || false; this.lineWidth = params.lineWidth || 0; + this.shadow = params.shadow || false; + } + setShadow(shadow){ + this.shadow = shadow; } draw(){ //console.log('Draw Shape: '+this.name); @@ -26,6 +30,14 @@ class Shape extends Path2D{ if (this.fillStyle) { context.fillStyle = this.fillStyle; + + if(this.shadow){ + context.shadowColor = "#333"; + context.shadowOffsetX = 1; + context.shadowOffsetY = 3; + context.shadowBlur = 10; + } + if(this.shape == 'circle'){ // X,Y,Radius, start, end context.beginPath(); @@ -41,6 +53,10 @@ class Shape extends Path2D{ context.fillRect(this.x, this.y, this.width, this.height); } context.fillStyle = defaultFillStyle; // Reset back to default + context.shadowColor = 'transparent'; + context.shadowBlur = null; + context.shadowOffsetX = null; + context.shadowOffsetY = null; } if (this.strokeStyle && this.lineWidth || shapeDebug) { context.strokeStyle = this.strokeStyle;