Add a few more cards
This commit is contained in:
parent
dc49eb961f
commit
6c3194c256
46
src/cards.ts
46
src/cards.ts
@ -1,6 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
DominionCard,
|
DominionCard,
|
||||||
TYPE_ACTION,
|
TYPE_ACTION,
|
||||||
|
TYPE_CURSE,
|
||||||
TYPE_DURATION,
|
TYPE_DURATION,
|
||||||
TYPE_NIGHT,
|
TYPE_NIGHT,
|
||||||
TYPE_TREASURE,
|
TYPE_TREASURE,
|
||||||
@ -112,13 +113,13 @@ export const cards: DominionCard[] = [
|
|||||||
orientation: "card",
|
orientation: "card",
|
||||||
title: "Secret Society",
|
title: "Secret Society",
|
||||||
description:
|
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],
|
types: [TYPE_ACTION],
|
||||||
image: "",
|
image: "",
|
||||||
artist: "",
|
artist: "",
|
||||||
author: "Dylan",
|
author: "Dylan",
|
||||||
version: "0.1",
|
version: "0.1",
|
||||||
cost: "$?",
|
cost: "$4*",
|
||||||
preview: "",
|
preview: "",
|
||||||
expansionIcon,
|
expansionIcon,
|
||||||
},
|
},
|
||||||
@ -232,4 +233,45 @@ export const cards: DominionCard[] = [
|
|||||||
preview: "",
|
preview: "",
|
||||||
expansionIcon,
|
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,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
@ -134,11 +134,14 @@ const hrPiece = pieceDef({
|
|||||||
type: "hr",
|
type: "hr",
|
||||||
measure(context, _piece) {
|
measure(context, _piece) {
|
||||||
const metrics = context.measureText(" ");
|
const metrics = context.measureText(" ");
|
||||||
|
const h =
|
||||||
|
(metrics.fontBoundingBoxAscent + metrics.fontBoundingBoxDescent) /
|
||||||
|
3;
|
||||||
return {
|
return {
|
||||||
type: "content",
|
type: "content",
|
||||||
width: 750,
|
width: 750,
|
||||||
ascent: metrics.fontBoundingBoxAscent / 3,
|
ascent: h / 2,
|
||||||
descent: metrics.fontBoundingBoxDescent / 3,
|
descent: h / 2,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
render(context, _piece, x, y, measure) {
|
render(context, _piece, x, y, measure) {
|
||||||
@ -177,6 +180,9 @@ const symbolPiece = pieceDef({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
render(context, piece, x, y, measure) {
|
render(context, piece, x, y, measure) {
|
||||||
|
if (piece.isBig) {
|
||||||
|
console.log("big", piece, measure);
|
||||||
|
}
|
||||||
context.save();
|
context.save();
|
||||||
// context.fillStyle = "yellow";
|
// context.fillStyle = "yellow";
|
||||||
const height = measure.ascent + measure.descent;
|
const height = measure.ascent + measure.descent;
|
||||||
@ -189,6 +195,7 @@ const symbolPiece = pieceDef({
|
|||||||
height
|
height
|
||||||
);
|
);
|
||||||
|
|
||||||
|
context.save();
|
||||||
const prefixFontInfo = parseFont(context.font);
|
const prefixFontInfo = parseFont(context.font);
|
||||||
prefixFontInfo.weight = "bold";
|
prefixFontInfo.weight = "bold";
|
||||||
prefixFontInfo.size =
|
prefixFontInfo.size =
|
||||||
@ -196,6 +203,7 @@ const symbolPiece = pieceDef({
|
|||||||
const prefixFont = stringifyFont(prefixFontInfo);
|
const prefixFont = stringifyFont(prefixFontInfo);
|
||||||
context.font = prefixFont;
|
context.font = prefixFont;
|
||||||
context.fillText(piece.prefix ?? "", x, y);
|
context.fillText(piece.prefix ?? "", x, y);
|
||||||
|
context.restore();
|
||||||
|
|
||||||
const fontInfo = parseFont(context.font);
|
const fontInfo = parseFont(context.font);
|
||||||
fontInfo.family = ["DominionSpecial"];
|
fontInfo.family = ["DominionSpecial"];
|
||||||
@ -265,7 +273,7 @@ export const measureDominionText = async (
|
|||||||
measure: await measurePiece(context, piece),
|
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) {
|
for (const pieceInfo of data) {
|
||||||
const line = lines[lines.length - 1]!;
|
const line = lines[lines.length - 1]!;
|
||||||
if (pieceInfo.measure.type === "break") {
|
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 {
|
return {
|
||||||
lines: lines.map((line) => {
|
lines,
|
||||||
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;
|
|
||||||
}),
|
|
||||||
width: Math.max(...lines.map((line) => line.width)),
|
width: Math.max(...lines.map((line) => line.width)),
|
||||||
height: lines
|
height: lines
|
||||||
.map((line) => line.ascent + line.descent)
|
.map((line) => line.ascent + line.descent)
|
||||||
|
@ -310,8 +310,13 @@ const drawStandardCard = async (
|
|||||||
size = 60;
|
size = 60;
|
||||||
context.font = `${size}pt DominionText`;
|
context.font = `${size}pt DominionText`;
|
||||||
while (
|
while (
|
||||||
(await measureDominionText(context, parse(card.description), 1000))
|
(
|
||||||
.height > 600
|
await measureDominionText(
|
||||||
|
context,
|
||||||
|
parse(card.description, { isDescription: true }),
|
||||||
|
1000
|
||||||
|
)
|
||||||
|
).height > 650
|
||||||
) {
|
) {
|
||||||
size -= 1;
|
size -= 1;
|
||||||
context.font = `${size}pt DominionText`;
|
context.font = `${size}pt DominionText`;
|
||||||
|
10
src/types.ts
10
src/types.ts
@ -13,6 +13,7 @@ export type DominionBasicCardType = {
|
|||||||
| "Action"
|
| "Action"
|
||||||
| "Treasure"
|
| "Treasure"
|
||||||
| "Victory"
|
| "Victory"
|
||||||
|
| "Curse"
|
||||||
| "Reaction"
|
| "Reaction"
|
||||||
| "Duration"
|
| "Duration"
|
||||||
| "Reserve"
|
| "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 = {
|
export const TYPE_REACTION: DominionBasicCardType = {
|
||||||
typeType: "basic",
|
typeType: "basic",
|
||||||
name: "Reaction",
|
name: "Reaction",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user