Skip to content

Commit c7751d9

Browse files
authored
fix: allow only one funbox changing capitalisation (@fehmer) (monkeytypegame#5959)
Fixes funboxes like `capitals` and `instant messaging` not working at the same time.
1 parent 4f541da commit c7751d9

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

backend/src/utils/validation.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ export function areFunboxesCompatible(funboxesString: string): boolean {
136136
const oneCharReplacerMax =
137137
funboxesToCheck.filter((f) => f.frontendFunctions?.includes("getWordHtml"))
138138
.length <= 1;
139+
const oneChangesCapitalisationMax =
140+
funboxesToCheck.filter((f) =>
141+
f.properties?.find((fp) => fp === "changesCapitalisation")
142+
).length <= 1;
139143
const allowedConfig = {} as Record<string, string[] | boolean[]>;
140144
let noConfigConflicts = true;
141145
for (const f of funboxesToCheck) {
@@ -174,6 +178,7 @@ export function areFunboxesCompatible(funboxesString: string): boolean {
174178
onePunctuateWordMax &&
175179
oneCharCheckerMax &&
176180
oneCharReplacerMax &&
181+
oneChangesCapitalisationMax &&
177182
noConfigConflicts &&
178183
oneWordOrderMax
179184
);

frontend/src/ts/test/funbox/funbox-validation.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,10 @@ export function areFunboxesCompatible(
296296
funboxesToCheck.filter((f) => f.functions?.isCharCorrect).length <= 1;
297297
const oneCharReplacerMax =
298298
funboxesToCheck.filter((f) => f.functions?.getWordHtml).length <= 1;
299+
const oneChangesCapitalisationMax =
300+
funboxesToCheck.filter((f) =>
301+
f.properties?.find((fp) => fp === "changesCapitalisation")
302+
).length <= 1;
299303
const allowedConfig = {} as FunboxForcedConfig;
300304
let noConfigConflicts = true;
301305
for (const f of funboxesToCheck) {
@@ -335,6 +339,7 @@ export function areFunboxesCompatible(
335339
onePunctuateWordMax &&
336340
oneCharCheckerMax &&
337341
oneCharReplacerMax &&
342+
oneChangesCapitalisationMax &&
338343
noConfigConflicts
339344
);
340345
}

0 commit comments

Comments
 (0)