Add a few more cards

This commit is contained in:
Dylan Pizzo 2025-01-08 21:47:44 -08:00
parent dc49eb961f
commit 6c3194c256
4 changed files with 85 additions and 19 deletions

View File

@ -1,6 +1,7 @@
import {
DominionCard,
TYPE_ACTION,
TYPE_CURSE,
TYPE_DURATION,
TYPE_NIGHT,
TYPE_TREASURE,
@ -112,13 +113,13 @@ export const cards: DominionCard[] = [
orientation: "card",
title: "Secret Society",
description:
"+1 Action\n\nIf you have at least 3 copies of Secret Society in play, trash all of them to gain any number of cards costing at least $2, whose total combined cost is at most $50.\n\n-\n\nOn your turn, this costs $3 plus $2 per Secret Society you've gained this game.",
"+1 Action\n\nIf you have at least 3 copies of Secret Society in play, trash all of them to gain any number of cards costing at least $2, whose total combined cost is at most $50.\n\n-\n\nThis card cannot be gained other than by buying it. During a player's buy phase, this costs $3 plus $2 per Secret Society they've gained this game.",
types: [TYPE_ACTION],
image: "",
artist: "",
author: "Dylan",
version: "0.1",
cost: "$?",
cost: "$4*",
preview: "",
expansionIcon,
},
@ -232,4 +233,45 @@ export const cards: DominionCard[] = [
preview: "",
expansionIcon,
},
{
orientation: "card",
title: "Crop Field",
description: "$1\n\n-\n\n1%",
types: [TYPE_TREASURE, TYPE_VICTORY],
image: "",
artist: "",
author,
version: "0.1",
cost: "$3",
preview: "",
expansionIcon,
},
{
orientation: "card",
title: "Duet",
description:
"Play one of the set aside cards, leaving it there\n\n-\n\nSetup: set aside two unused non-Duration Action cards of the same cost. This costs $1 more than the cost of the set aside cards.",
types: [TYPE_ACTION],
image: "",
artist: "",
author,
version: "0.1",
cost: "$?",
preview: "",
expansionIcon,
},
{
orientation: "card",
title: "Scraps",
description:
"If it's your Action phase, trash up to 4 cards from your hand.\n\nIf it's your Buy phase, +$1 per 10 cards in the trash (round down).",
types: [TYPE_ACTION, TYPE_TREASURE],
image: "",
artist: "",
author,
version: "0.1",
cost: "$4",
preview: "",
expansionIcon,
},
];

View File

@ -134,11 +134,14 @@ const hrPiece = pieceDef({
type: "hr",
measure(context, _piece) {
const metrics = context.measureText(" ");
const h =
(metrics.fontBoundingBoxAscent + metrics.fontBoundingBoxDescent) /
3;
return {
type: "content",
width: 750,
ascent: metrics.fontBoundingBoxAscent / 3,
descent: metrics.fontBoundingBoxDescent / 3,
ascent: h / 2,
descent: h / 2,
};
},
render(context, _piece, x, y, measure) {
@ -177,6 +180,9 @@ const symbolPiece = pieceDef({
};
},
render(context, piece, x, y, measure) {
if (piece.isBig) {
console.log("big", piece, measure);
}
context.save();
// context.fillStyle = "yellow";
const height = measure.ascent + measure.descent;
@ -189,6 +195,7 @@ const symbolPiece = pieceDef({
height
);
context.save();
const prefixFontInfo = parseFont(context.font);
prefixFontInfo.weight = "bold";
prefixFontInfo.size =
@ -196,6 +203,7 @@ const symbolPiece = pieceDef({
const prefixFont = stringifyFont(prefixFontInfo);
context.font = prefixFont;
context.fillText(piece.prefix ?? "", x, y);
context.restore();
const fontInfo = parseFont(context.font);
fontInfo.family = ["DominionSpecial"];
@ -265,7 +273,7 @@ export const measureDominionText = async (
measure: await measurePiece(context, piece),
}))
);
const lines: Line[] = [{ pieces: [], width: 0, ascent: 0, descent: 0 }];
let lines: Line[] = [{ pieces: [], width: 0, ascent: 0, descent: 0 }];
for (const pieceInfo of data) {
const line = lines[lines.length - 1]!;
if (pieceInfo.measure.type === "break") {
@ -296,19 +304,20 @@ export const measureDominionText = async (
}
}
}
lines = lines.map((line) => {
while (
line.pieces[line.pieces.length - 1] &&
line.pieces[line.pieces.length - 1]!.measure.type === "space"
) {
line.pieces = line.pieces.slice(0, -1);
}
line.width = line.pieces
.map((piece) => piece.measure.width)
.reduce((a, b) => a + b, 0);
return line;
});
return {
lines: lines.map((line) => {
while (
line.pieces[line.pieces.length - 1] &&
line.pieces[line.pieces.length - 1]!.measure.type === "space"
) {
line.pieces = line.pieces.slice(0, -1);
}
line.width = line.pieces
.map((piece) => piece.measure.width)
.reduce((a, b) => a + b, 0);
return line;
}),
lines,
width: Math.max(...lines.map((line) => line.width)),
height: lines
.map((line) => line.ascent + line.descent)

View File

@ -310,8 +310,13 @@ const drawStandardCard = async (
size = 60;
context.font = `${size}pt DominionText`;
while (
(await measureDominionText(context, parse(card.description), 1000))
.height > 600
(
await measureDominionText(
context,
parse(card.description, { isDescription: true }),
1000
)
).height > 650
) {
size -= 1;
context.font = `${size}pt DominionText`;

View File

@ -13,6 +13,7 @@ export type DominionBasicCardType = {
| "Action"
| "Treasure"
| "Victory"
| "Curse"
| "Reaction"
| "Duration"
| "Reserve"
@ -108,6 +109,15 @@ export const TYPE_VICTORY: DominionBasicCardType = {
},
};
export const TYPE_CURSE: DominionBasicCardType = {
typeType: "basic",
name: "Curse",
color: {
value: "#d285ff",
priority: 4,
},
};
export const TYPE_REACTION: DominionBasicCardType = {
typeType: "basic",
name: "Reaction",