Tighten formatting to the smogon.com house style

Annotation colons are tight (ternaries keep their spaces), plain
double-quoted strings become single-quoted, and .editorconfig comes
over verbatim. Rule cmd values are untouched; the sheet rules reran
once because their tool sources are declared deps, byte-identically.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Christopher Monsanto
2026-08-17 18:55:11 -04:00
parent 3e87df43da
commit ebbb5e6f2e
34 changed files with 501 additions and 500 deletions

View File

@@ -4,30 +4,30 @@ import {compresspng, pad, trimimg} from '../tools/build/helpers.ts';
// Uniform size minisprites
export function gen6Padded() : Artifact[] {
return forEachRule("src/minisprites/pokemon/gen6/*.png", {
display: "pad g6 minisprite %f",
cmds: [pad({w: 40, h: 30}), compresspng({config: "MINISPRITE"})],
}, "%b");
export function gen6Padded(): Artifact[] {
return forEachRule('src/minisprites/pokemon/gen6/*.png', {
display: 'pad g6 minisprite %f',
cmds: [pad({w: 40, h: 30}), compresspng({config: 'MINISPRITE'})],
}, '%b');
}
export function itemPadded() : Artifact[] {
return forEachRule("src/minisprites/items/*.png", {
display: "pad item minisprite %f",
cmds: [pad({w: 24, h: 24}), compresspng({config: "MINISPRITE"})],
}, "%b");
export function itemPadded(): Artifact[] {
return forEachRule('src/minisprites/items/*.png', {
display: 'pad item minisprite %f',
cmds: [pad({w: 24, h: 24}), compresspng({config: 'MINISPRITE'})],
}, '%b');
}
export function gen6Trimmed() : Artifact[] {
return forEachRule("src/minisprites/pokemon/gen6/*.png", {
display: "trim g6 minisprite %f",
cmds: [trimimg(), compresspng({config: "MINISPRITE"})],
}, "%b");
export function gen6Trimmed(): Artifact[] {
return forEachRule('src/minisprites/pokemon/gen6/*.png', {
display: 'trim g6 minisprite %f',
cmds: [trimimg(), compresspng({config: 'MINISPRITE'})],
}, '%b');
}
export function itemTrimmed() : Artifact[] {
return forEachRule("src/minisprites/items/*.png", {
display: "trim item minisprite %f",
cmds: [trimimg(), compresspng({config: "MINISPRITE"})],
}, "%b");
export function itemTrimmed(): Artifact[] {
return forEachRule('src/minisprites/items/*.png', {
display: 'trim item minisprite %f',
cmds: [trimimg(), compresspng({config: 'MINISPRITE'})],
}, '%b');
}

View File

@@ -3,39 +3,39 @@ import {type Artifact, forEachRule} from '../tools/build/artifact.ts';
// Gen 9
export function gen9Modelslike() : Artifact[] {
return forEachRule("src/gen9species/*.png", {
display: "96x96 %f",
export function gen9Modelslike(): Artifact[] {
return forEachRule('src/gen9species/*.png', {
display: '96x96 %f',
// TODO, add customizable compression for gif
// ... or investigate using webp instead of both png/gif here
cmds: [
"magick convert %f -trim +repage -resize 90x90 %o",
"gifsicle -O3 -b %o",
'magick convert %f -trim +repage -resize 90x90 %o',
'gifsicle -O3 -b %o',
],
}, "%B.gif");
}, '%B.gif');
}
// Gen 10
export function gen10Modelslike() : Artifact[] {
return forEachRule("src/champions/*.png", {
display: "96x96 %f",
export function gen10Modelslike(): Artifact[] {
return forEachRule('src/champions/*.png', {
display: '96x96 %f',
// TODO, add customizable compression for gif
// ... or investigate using webp instead of both png/gif here
cmds: [
"magick convert %f -trim +repage -resize 90x90 %o",
"gifsicle -O3 -b %o",
'magick convert %f -trim +repage -resize 90x90 %o',
'gifsicle -O3 -b %o',
],
}, "%B.gif");
}, '%B.gif');
}
// Gen 5 CAPs...
export function gen5Gifs() : Artifact[] {
return forEachRule("src/sprites/gen5/*.png", [
export function gen5Gifs(): Artifact[] {
return forEachRule('src/sprites/gen5/*.png', [
// TODO, add customizable compression for gif
// ... or investigate using webp instead of both png/gif here
"magick convert %f %o",
"gifsicle -O3 -b %o",
], "%B.gif");
'magick convert %f %o',
'gifsicle -O3 -b %o',
], '%B.gif');
}

View File

@@ -10,14 +10,14 @@ export type Sprite = Artifact | SrcFile;
// The unhashed -> hashed name mapping published beside a stamped set.
export class Manifest {
readonly ctx : DeployCtx;
readonly ctx: DeployCtx;
private entries = new Map<string, string>();
constructor(ctx : DeployCtx) {
constructor(ctx: DeployCtx) {
this.ctx = ctx;
}
set(key : string, value : string) : void {
set(key: string, value: string): void {
// ActionQueue only dedups final dsts; hashed dsts differ even when
// unhashed names collide, so check the key explicitly.
if (this.entries.has(key)) {
@@ -26,8 +26,8 @@ export class Manifest {
this.entries.set(key, value);
}
write(dst : string) : void {
const sorted : Record<string, string> = {};
write(dst: string): void {
const sorted: Record<string, string> = {};
for (const k of [...this.entries.keys()].sort()) {
sorted[k] = this.entries.get(k)!;
}
@@ -36,11 +36,11 @@ export class Manifest {
}
export interface Dest {
dir : string;
ext? : string;
dir: string;
ext?: string;
}
function extOf(f : Sprite, ext? : string) : string {
function extOf(f: Sprite, ext?: string): string {
const result = ext ?? f.ext;
if (result === null) {
throw new Error(`Sprite ${f.name} has no extension`);
@@ -48,37 +48,37 @@ function extOf(f : Sprite, ext? : string) : string {
return result;
}
export function toSmogonAlias(name : string) : string {
export function toSmogonAlias(name: string): string {
return name.toLowerCase().
replace(/[ _]+/, "-").
replace(/[ _]+/, '-').
replace(/[^a-z0-9-]+/g, '');
}
export function toPSID(name : string) : string {
export function toPSID(name: string): string {
return name.toLowerCase().replace(/[^a-z0-9]+/g, '');
}
// Copy with a content-hash-stamped name and record the unhashed -> hashed
// mapping in `manifest`.
export function stampcopy(manifest : Manifest, f : Sprite, {dir, ext}: Dest, name : string) : void {
export function stampcopy(manifest: Manifest, f: Sprite, {dir, ext}: Dest, name: string): void {
const h = manifest.ctx.hash(f);
manifest.set(`${name}.${extOf(f, ext)}`, `${name}-${h}.${extOf(f, ext)}`);
manifest.ctx.copy(f, `${dir}/${name}-${h}.${extOf(f, ext)}`);
}
export function spritecopy(manifest : Manifest, f : Sprite, dest : Dest,
allowUnknown = false) : void {
export function spritecopy(manifest: Manifest, f: Sprite, dest: Dest,
allowUnknown = false): void {
const sn = spritedata.parseFilename(f.name);
let name : string;
let name: string;
// Skip asymmetrical for now
if (sn.extra.has("a") || sn.extra.has("b") || sn.extra.has("s")) {
if (sn.extra.has('a') || sn.extra.has('b') || sn.extra.has('s')) {
return;
}
if (sn.extension) {
if (allowUnknown && sn.name === "Unknown") {
name = "unknown";
if (allowUnknown && sn.name === 'Unknown') {
name = 'unknown';
} else {
// Skip this, we don't use Unknown/Substitute
return;
@@ -93,18 +93,18 @@ export function spritecopy(manifest : Manifest, f : Sprite, dest : Dest,
name += `-${toSmogonAlias(sd.forme)}`;
}
}
if (sn.extra.has("f")) {
name += "-f";
if (sn.extra.has('f')) {
name += '-f';
}
if (sn.extra.has("g")) {
name += "-gmax";
if (sn.extra.has('g')) {
name += '-gmax';
}
stampcopy(manifest, f, dest, name);
}
// TODO: merge with above
export function itemspritecopy(manifest : Manifest, f : Sprite, dest : Dest) : void {
export function itemspritecopy(manifest: Manifest, f: Sprite, dest: Dest): void {
const sn = spritedata.parseFilename(f.name);
if (sn.extension) {
throw new Error(`Not an item sprite: ${f.name}`);
@@ -118,7 +118,7 @@ export function itemspritecopy(manifest : Manifest, f : Sprite, dest : Dest) : v
}
}
export function newspritecopy(ctx : DeployCtx, f : Sprite, dest : Dest) : void {
export function newspritecopy(ctx: DeployCtx, f: Sprite, dest: Dest): void {
const sn = spritedata.parseFilename(f.name);
if (sn.extension) {
return;
@@ -126,11 +126,11 @@ export function newspritecopy(ctx : DeployCtx, f : Sprite, dest : Dest) : void {
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('f')) {
name += 'f';
}
if (sn.extra.has("g")) {
name += "gmax";
if (sn.extra.has('g')) {
name += 'gmax';
}
ctx.copy(f, `${dest.dir}/${name}.${extOf(f, dest.ext)}`);
}

View File

@@ -5,10 +5,10 @@ import {PNG_DETERMINISTIC, base, compresspng, spriteglob} from '../tools/build/h
// Smogdex social images: models, backfilled with gen9 species not yet in
// models (first source wins).
function socialInputs() : string[] {
const social = spriteglob(["src/models/*"], {b: false, s: false});
function socialInputs(): string[] {
const social = spriteglob(['src/models/*'], {b: false, s: false});
const socialSeen = new Set(social.map(base));
for (const file of spriteglob(["src/gen9species/*"], {b: false, s: false})) {
for (const file of spriteglob(['src/gen9species/*'], {b: false, s: false})) {
if (!socialSeen.has(base(file))) {
social.push(file);
socialSeen.add(base(file));
@@ -17,22 +17,22 @@ function socialInputs() : string[] {
return social;
}
export function fbSprites() : Artifact[] {
export function fbSprites(): Artifact[] {
return forEachRule(socialInputs(), {
display: "fbsprite %f",
display: 'fbsprite %f',
cmds: [
`magick convert "%f[0]" ${PNG_DETERMINISTIC} -trim -resize 150x150 -background white -gravity center -extent 198x198 -bordercolor black -border 1 %o`,
compresspng({config: "MODELS"}),
compresspng({config: 'MODELS'}),
],
}, "%B.png");
}, '%B.png');
}
export function twitterSprites() : Artifact[] {
export function twitterSprites(): Artifact[] {
return forEachRule(socialInputs(), {
display: "twittersprite %f",
display: 'twittersprite %f',
cmds: [
`magick convert "%f[0]" ${PNG_DETERMINISTIC} -trim -resize 115x115 -background white -gravity center -extent 120x120 %o`,
compresspng({config: "MODELS"}),
compresspng({config: 'MODELS'}),
],
}, "%B.png");
}, '%B.png');
}