Skip to content

Commit 90aab4d

Browse files
Add new sPoNgECaSe mode and modify raNDOMcASe
1 parent d6233f3 commit 90aab4d

File tree

5 files changed

+48
-25
lines changed

5 files changed

+48
-25
lines changed

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

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -316,20 +316,34 @@ const list: Partial<Record<FunboxName, FunboxFunctions>> = {
316316
return retval;
317317
},
318318
},
319-
rAnDoMcAsE: {
319+
raNDOmcASe: {
320320
alterText(word: string): string {
321-
let randomcaseword = word[0] as string;
322-
for (let i = 1; i < word.length; i++) {
323-
if (
324-
randomcaseword[i - 1] ===
325-
(randomcaseword[i - 1] as string).toUpperCase()
326-
) {
327-
randomcaseword += (word[i] as string).toLowerCase();
321+
let randomCaseWord = "";
322+
323+
for (let letter of word) {
324+
if (Math.random() > 0.5) {
325+
randomCaseWord += letter.toUpperCase();
326+
} else {
327+
randomCaseWord += letter.toLowerCase();
328+
}
329+
}
330+
331+
return randomCaseWord;
332+
},
333+
},
334+
sPoNgEcAsE: {
335+
alterText(word: string): string {
336+
let spongeCaseWord = "";
337+
338+
for (let i = 0; i < word.length; i++) {
339+
if (i % 2 === 0) {
340+
spongeCaseWord += word[i]?.toLowerCase();
328341
} else {
329-
randomcaseword += (word[i] as string).toUpperCase();
342+
spongeCaseWord += word[i]?.toUpperCase();
330343
}
331344
}
332-
return randomcaseword;
345+
346+
return spongeCaseWord;
333347
},
334348
},
335349
rot13: {

frontend/static/challenges/_list.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -613,11 +613,11 @@
613613
}
614614
},
615615
{
616-
"name": "iKiNdAlIkEhOwInEfFiCiEnTqWeRtYiS",
617-
"display": "I kInDa LiKe HoW iNeFfIcIeNt QwErTy Is",
616+
"name": "iKINdaLikEHoWinEFFICIeNtQwErtYIs.",
617+
"display": "i KINda LikE HoW inEFFICIeNt QwErtY Is.",
618618
"autoRole": true,
619619
"type": "funbox",
620-
"parameters": [["rAnDoMcAsE"], "time", 3600],
620+
"parameters": [["raNDOmcASe"], "time", 3600],
621621
"requirements": {
622622
"wpm": {
623623
"min": 100
@@ -626,7 +626,7 @@
626626
"min": 60
627627
},
628628
"funbox": {
629-
"exact": ["rAnDoMcAsE"]
629+
"exact": ["raNDOmcASe"]
630630
}
631631
}
632632
},

frontend/static/challenges/sourcecode.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23222,16 +23222,16 @@ async function getNextWord(wordset, language, wordsBound) {
2322223222
randomWord = randomWord.replace(/ +/gm, " ");
2322323223
randomWord = randomWord.replace(/^ | $/gm, "");
2322423224

23225-
if (Config.funbox === "rAnDoMcAsE") {
23226-
let randomcaseword = "";
23227-
for (let i = 0; i < randomWord.length; i++) {
23228-
if (i % 2 != 0) {
23229-
randomcaseword += randomWord[i].toUpperCase();
23225+
if (Config.funbox === "raNDOmcASe") {
23226+
let randomCaseWord = "";
23227+
for (let letter of randomWord) {
23228+
if (Math.random() > 0.5) {
23229+
randomCaseWord += letter.toUpperCase();
2323023230
} else {
23231-
randomcaseword += randomWord[i];
23231+
randomCaseWord += letter;
2323223232
}
2323323233
}
23234-
randomWord = randomcaseword;
23234+
randomWord = randomCaseWord;
2323523235
} else if (Config.funbox === "capitals") {
2323623236
randomWord = Misc.capitalizeFirstLetter(randomWord);
2323723237
} else if (Config.funbox === "gibberish") {

packages/funbox/src/list.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,21 @@ const list: Record<FunboxName, FunboxMetadata> = {
113113
],
114114
name: "arrows",
115115
},
116-
rAnDoMcAsE: {
117-
description: "I kInDa LiKe HoW iNeFfIcIeNt QwErTy Is.",
116+
raNDOmcASe: {
117+
description: "i KINda LikE HoW inEFFICIeNt QwErtY Is.",
118118
canGetPb: false,
119119
difficultyLevel: 2,
120120
properties: ["changesCapitalisation"],
121121
frontendFunctions: ["alterText"],
122-
name: "rAnDoMcAsE",
122+
name: "raNDOmcASe",
123+
},
124+
sPoNgEcAsE: {
125+
description: "aLtErNaTe ThE cApItAlIzAtIoN oF eVeRy LeTtEr.",
126+
canGetPb: false,
127+
difficultyLevel: 2,
128+
properties: ["changesCapitalisation"],
129+
frontendFunctions: ["alterText"],
130+
name: "sPoNgEcAsE",
123131
},
124132
capitals: {
125133
description: "Capitalize Every Word.",

packages/schemas/src/configs.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,8 @@ export const FunboxNameSchema = z.enum([
278278
"tts",
279279
"choo_choo",
280280
"arrows",
281-
"rAnDoMcAsE",
281+
"raNDOmcASe",
282+
"sPoNgEcAsE",
282283
"capitals",
283284
"layout_mirror",
284285
"layoutfluid",

0 commit comments

Comments
 (0)