Skip to content

Commit

Permalink
fix kwargs
Browse files Browse the repository at this point in the history
  • Loading branch information
scheibo committed Jan 27, 2024
1 parent 9fc5fe8 commit a3d6a06
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
5 changes: 3 additions & 2 deletions anon/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,16 @@ function anonymize(
const buf = `|${a.join('|')}`;
const kws: string[] = [];
for (const k in kwArgs) {
let v = kwArgs[k as keyof typeof kwArgs] as string;
let v = kwArgs[k as keyof typeof kwArgs] as any;

if (k === 'of') {
v = anonymizePokemon(v as PokemonIdent, pokemonMap);
} else if (k === 'spread') {
// TODO: why do we anonymize this - [spread] is currently just hit slots, not idents?
v = v.split(',').map((s: string | PokemonIdent) =>
IDENT.test(s) ? anonymizePokemon(s as PokemonIdent, pokemonMap) : s).join(',');
}
kws.push(`[${k}] ${v}`);
kws.push(v === true ? `[${k}]` : `[${k}] ${v}`);
}
return kws.length ? `${buf}|${kws.join('|')}` : buf;
};
Expand Down
8 changes: 4 additions & 4 deletions anon/src/testdata/anon.json
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@
"|-unboost|p2a: Rayquaza|spd|1",
"|faint|p1a: Darmanitan",
"|",
"|-weather|DeltaStream|[upkeep] true",
"|-weather|DeltaStream|[upkeep]",
"|upkeep",
"|",
"|switch|p1a: Zygarde|Zygarde|100/100",
Expand All @@ -443,7 +443,7 @@
"|",
"|-activate|p1a: Zygarde|ability: Power Construct|",
"|detailschange|p1a: Zygarde|Zygarde-Complete",
"|-heal|p1a: Zygarde|62/100|[silent] true",
"|-heal|p1a: Zygarde|62/100|[silent]",
"|upkeep",
"|turn|3",
"|",
Expand Down Expand Up @@ -483,7 +483,7 @@
"|-damage|p1a: Dugtrio|21/100",
"|-hitcount|p1a: Dugtrio|2",
"|-damage|p2a: Greninja|71/100|[from] item: Life Orb",
"|move|p1a: Dugtrio|Sucker Punch||[still] true",
"|move|p1a: Dugtrio|Sucker Punch||[still]",
"|-fail|p1a: Dugtrio",
"|",
"|upkeep",
Expand Down Expand Up @@ -566,7 +566,7 @@
"|",
"|move|p1a: Shaymin|Hidden Power|p2a: Ditto",
"|-damage|p2a: Ditto|79/100",
"|move|p2a: Ditto|Play Rough|p1a: Shaymin|[miss] true",
"|move|p2a: Ditto|Play Rough|p1a: Shaymin|[miss]",
"|-miss|p2a: Ditto|p1a: Shaymin",
"|",
"|upkeep",
Expand Down
8 changes: 4 additions & 4 deletions anon/src/testdata/salt.json
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@
"|-unboost|p2a: 64bd07b346|spd|1",
"|faint|p1a: 544459d148",
"|",
"|-weather|DeltaStream|[upkeep] true",
"|-weather|DeltaStream|[upkeep]",
"|upkeep",
"|",
"|switch|p1a: ad9358a773|Zygarde|100/100",
Expand All @@ -443,7 +443,7 @@
"|",
"|-activate|p1a: ad9358a773|ability: Power Construct|",
"|detailschange|p1a: ad9358a773|Zygarde-Complete",
"|-heal|p1a: ad9358a773|62/100|[silent] true",
"|-heal|p1a: ad9358a773|62/100|[silent]",
"|upkeep",
"|turn|3",
"|",
Expand Down Expand Up @@ -483,7 +483,7 @@
"|-damage|p1a: 8db0521bcb|21/100",
"|-hitcount|p1a: 8db0521bcb|2",
"|-damage|p2a: d677adb2c9|71/100|[from] item: Life Orb",
"|move|p1a: 8db0521bcb|Sucker Punch||[still] true",
"|move|p1a: 8db0521bcb|Sucker Punch||[still]",
"|-fail|p1a: 8db0521bcb",
"|",
"|upkeep",
Expand Down Expand Up @@ -566,7 +566,7 @@
"|",
"|move|p1a: 540aaed869|Hidden Power|p2a: ce04869101",
"|-damage|p2a: ce04869101|79/100",
"|move|p2a: ce04869101|Play Rough|p1a: 540aaed869|[miss] true",
"|move|p2a: ce04869101|Play Rough|p1a: 540aaed869|[miss]",
"|-miss|p2a: ce04869101|p1a: 540aaed869",
"|",
"|upkeep",
Expand Down

0 comments on commit a3d6a06

Please sign in to comment.