Skip to content

Commit

Permalink
more validation
Browse files Browse the repository at this point in the history
  • Loading branch information
notTamion committed Nov 10, 2024
1 parent 8d01885 commit bcd4759
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
7 changes: 4 additions & 3 deletions frontend/src/ts/test/funbox/funbox-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ const list: FunboxMetadata[] = [
{
name: "mirror",
info: "Everything is mirrored!",
properties: ["changesTextOrientation"],
properties: ["mirror"],
hasCSS: true,
},
{
name: "upside_down",
info: "Everything is upside down!",
properties: ["changesTextOrientation"],
properties: ["changesTextOrientation", "conflictsWithMirror"],
hasCSS: true,
},
{
Expand Down Expand Up @@ -94,6 +94,7 @@ const list: FunboxMetadata[] = [
{
name: "space_balls",
info: "In a galaxy far far away.",
properties: ["changesBackground"],
hasCSS: true,
},
{
Expand Down Expand Up @@ -268,7 +269,7 @@ const list: FunboxMetadata[] = [
{
name: "crt",
info: "Go back to the 1980s",
properties: ["noLigatures"],
properties: ["noLigatures", "changesBackground"],
},
{
name: "backwards",
Expand Down
12 changes: 12 additions & 0 deletions frontend/src/ts/test/funbox/funbox-validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,16 @@ export function areFunboxesCompatible(
funboxesToCheck.filter((f) =>
f.properties?.find((fp) => fp === "changesTextOrientation")
).length <= 1;
const oneChangesBackground =
funboxesToCheck.filter((f) =>
f.properties?.find((fp) => fp === "changesBackground")
).length <= 1;
const noConflictsWithMirror =
funboxesToCheck.filter((f) =>
f.properties?.find((fp) => fp === "conflictsWithMirror")
).length === 0 ||
funboxesToCheck.filter((f) => f.properties?.find((fp) => fp === "mirror"))
.length === 0;
const allowedConfig = {} as FunboxForcedConfig;
let noConfigConflicts = true;
for (const f of funboxesToCheck) {
Expand Down Expand Up @@ -357,6 +367,8 @@ export function areFunboxesCompatible(
oneMovesCharacters &&
oneRotatesText &&
oneChangesTextOrientation &&
oneChangesBackground &&
noConflictsWithMirror &&
noConfigConflicts
);
}
5 changes: 4 additions & 1 deletion frontend/src/ts/utils/json-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,10 @@ type FunboxProperty =
| "movesText"
| "movesCharacters"
| "rotatesText"
| "changesTextOrientation";
| "changesTextOrientation"
| "mirror"
| "conflictsWithMirror"
| "changesBackground";

export type FunboxForcedConfig = Record<string, ConfigValue[]>;

Expand Down

0 comments on commit bcd4759

Please sign in to comment.