From 447a1ccb6a07a4b2d4470ca3fa09160393c05090 Mon Sep 17 00:00:00 2001 From: Christopher Monsanto Date: Tue, 28 Mar 2023 22:52:59 -0400 Subject: [PATCH] basic smogdex webp sprite deploy --- smogon.deploy.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/smogon.deploy.js b/smogon.deploy.js index f7143223..ce47ecaf 100644 --- a/smogon.deploy.js +++ b/smogon.deploy.js @@ -5,6 +5,10 @@ function toSmogonAlias(name) { replace(/[^a-z0-9-]+/g, ''); } +function toPSID(name) { + return name.toLowerCase().replace(/[^a-z0-9]+/g, ''); +} + function spritecopy(f, {dir, ext}) { const sn = spritedata.parseFilename(f.name); let name; @@ -44,6 +48,24 @@ function itemspritecopy(f, {dir, ext}) { } } +function newspritecopy(f, {dir, ext}) { + const sn = spritedata.parseFilename(f.name); + if (sn.extension) { + return + } + const sd = spritedata.get(sn.id); + for (const n of sd.type === 'item' ? sd.names : [sd.base + sd.forme]) { + let name = toPSID(n); + if (sn.extra.has("f")) { + name += "f"; + } + if (sn.extra.has("g")) { + name += "gmax"; + } + copy(f, {dir, ext, name}); + } +} + for (const f of list("src/models")) { spritecopy(f, {dir: "xy"}); } @@ -60,6 +82,10 @@ for (const f of list("build/item-minisprites-trimmed")) { itemspritecopy(f, {dir: "xyitems"}); } +for (const f of list("build/smogon/minisprites")) { + newspritecopy(f, {dir: "minisprites"}); +} + for (const f of list("build/item-minisprites-padded")) { itemspritecopy(f, {dir: "forumsprites"}); }