Add debt and potion

This commit is contained in:
Dylan Pizzo
2025-01-06 21:06:13 -08:00
parent a5979647fc
commit 7f4268f960
3 changed files with 135 additions and 22 deletions

View File

@@ -51,6 +51,14 @@ const imageList = [
key: "coin",
src: "/static/assets/Coin.png",
},
{
key: "debt",
src: "/static/assets/Debt.png",
},
{
key: "potion",
src: "/static/assets/Potion.png",
},
];
export const loadImages = async () => {
@@ -124,6 +132,7 @@ const drawStandardCard = async (
): Promise<void> => {
const w = context.canvas.width;
const h = context.canvas.height;
let size;
context.save();
// Draw the image
const image = await loadImage(card.image);
@@ -151,8 +160,15 @@ const drawStandardCard = async (
context.drawImage(colorImage(getImage("card-brown"), "#ff9911"), 0, 0);
context.drawImage(getImage("card-description-focus"), 44, 1094);
// Draw the name
context.font = "78pt DominionTitle";
await renderDominionText(context, parse(card.title), w / 2, 220, 1100);
size = 78;
context.font = `${size}pt DominionTitle`;
while (
(await measureDominionText(context, parse(card.title))).width > 1050
) {
size -= 1;
context.font = `${size}pt DominionTitle`;
}
await renderDominionText(context, parse(card.title), w / 2, 220);
// Draw the description
context.font = "60pt DominionText";
await renderDominionText(
@@ -163,7 +179,7 @@ const drawStandardCard = async (
1000
);
// Draw the types
let size = 65;
size = 65;
context.font = `${size}pt DominionTitle`;
while (
(
@@ -185,18 +201,18 @@ const drawStandardCard = async (
);
// Draw the cost
context.font = "90pt DominionText";
await renderDominionText(context, parse(card.cost), 210, 1940, 200);
const costMeasure = await measureDominionText(context, parse(card.cost));
await renderDominionText(
context,
parse(card.cost),
130 + costMeasure.width / 2,
1940
);
// Draw the preview
if (card.preview) {
context.font = "90pt DominionText";
await renderDominionText(context, parse(card.preview), 200, 210, 200);
await renderDominionText(
context,
parse(card.preview),
w - 200,
210,
200
);
await renderDominionText(context, parse(card.preview), 200, 210);
await renderDominionText(context, parse(card.preview), w - 200, 210);
}
// Draw the icon
// Draw the author credit
@@ -210,8 +226,7 @@ const drawStandardCard = async (
context,
parse(card.author),
w - 150 - authorMeasure.width / 2,
2035,
w / 2 - 150
2035
);
// Draw the artist credit
const artistMeasure = await measureDominionText(
@@ -222,8 +237,7 @@ const drawStandardCard = async (
context,
parse(card.artist),
155 + artistMeasure.width / 2,
2035,
w / 2 - 150
2035
);
// Restore the context
context.restore();