Port over column filter to static cube generator

This commit is contained in:
Hamcha 2019-11-21 18:00:30 +01:00
parent f5c94268be
commit 9953f6c289
Signed by: hamcha
GPG key ID: 44AD3571EB09A39E

View file

@ -32,6 +32,16 @@ const colorNames = {
URG: "Temur" URG: "Temur"
}; };
const columns: Record<string, (c: CardItem) => boolean> = {
W: c => colorid(c.colorIdentity) == "W",
U: c => colorid(c.colorIdentity) == "U",
B: c => colorid(c.colorIdentity) == "B",
R: c => colorid(c.colorIdentity) == "R",
G: c => colorid(c.colorIdentity) == "G",
MC: c => c.colorIdentity.length > 0,
CL: c => colorid(c.colorIdentity) == "CL"
};
function wubrg(a: string, b: string) { function wubrg(a: string, b: string) {
const order = ["W", "U", "B", "R", "G"]; const order = ["W", "U", "B", "R", "G"];
const indexA = order.indexOf(a); const indexA = order.indexOf(a);
@ -87,6 +97,7 @@ async function run() {
const template = await ejs.renderFile("templates/cube.ejs", { const template = await ejs.renderFile("templates/cube.ejs", {
user: uid, user: uid,
cards: valid, cards: valid,
columns,
utils: { wubrg, colorNames, colorid } utils: { wubrg, colorNames, colorid }
}); });
let cubeFile = `${uid}-cube.html`; let cubeFile = `${uid}-cube.html`;