From 4da82d0f2b7bccedfcbc45ff3d74ee6bd000edb9 Mon Sep 17 00:00:00 2001 From: Justiniscoding Date: Tue, 6 Jan 2026 10:42:02 -0500 Subject: [PATCH] feat: create new sPoNgEcAsE and modify raNDOmcASe to be random (@Justiniscoding) (#7295) ### Description The old rAnDoMcAsE mode was not actually random and more accurately reflected [sponge case](https://en.wikipedia.org/wiki/Alternating_caps). I modified the old rAnDoMcAsE mode and turned it into raNDOmcASe, where it calls `Math.random()` for every letter and bases the capitalization of of it. The old code from rAnDoMcAsE was moved to a separate sPoNgEcAsE funbox mode. ### Changes - `rAnDoMcAsE` becomes `raNDOmcASe` and has a 50% chance to capitalize every letter. - `sPoNgEcAsE` is added as a funbox mode and contains the old functionality of `rAnDoMcAsE` - "i KINda LikE HoW inEFFICIeNt QwErtY Is." challenge is updated to use the updated `raNDOmcASe` mode as well as a new title that is in proper random case. ### Checks - [x] Adding/modifying Typescript code? - [ ] I have used `qs`, `qsa` or `qsr` instead of JQuery selectors. - [ ] Adding quotes? - [ ] Make sure to include translations for the quotes in the description (or another comment) so we can verify their content. - [ ] Adding a language? - Make sure to follow the [languages documentation](https://github.com/monkeytypegame/monkeytype/blob/master/docs/LANGUAGES.md) - [ ] Add language to `packages/schemas/src/languages.ts` - [ ] Add language to exactly one group in `frontend/src/ts/constants/languages.ts` - [ ] Add language json file to `frontend/static/languages` - [ ] Adding a theme? - Make sure to follow the [themes documentation](https://github.com/monkeytypegame/monkeytype/blob/master/docs/THEMES.md) - [ ] Add theme to `packages/schemas/src/themes.ts` - [ ] Add theme to `frontend/src/ts/constants/themes.ts` - [ ] Add theme css file to `frontend/static/themes` - [ ] Add some screenshots of the theme, especially with different test settings (colorful, flip colors) to your pull request - [ ] Adding a layout? - [ ] Make sure to follow the [layouts documentation](https://github.com/monkeytypegame/monkeytype/blob/master/docs/LAYOUTS.md) - [ ] Add layout to `packages/schemas/src/layouts.ts` - [ ] Add layout json file to `frontend/static/layouts` - [ ] Adding a font? - Make sure to follow the [themes documentation](https://github.com/monkeytypegame/monkeytype/blob/master/docs/FONTS.md) - [ ] Add font file to `frontend/static/webfonts` - [ ] Add font to `packages/schemas/src/fonts.ts` - [ ] Add font to `frontend/src/ts/constants/fonts.ts` - [ ] Check if any open issues are related to this PR; if so, be sure to tag them below. - [x] Make sure the PR title follows the Conventional Commits standard. (https://www.conventionalcommits.org for more info) - [x] Make sure to include your GitHub username prefixed with @ inside parentheses at the end of the PR title. --------- Co-authored-by: Miodec --- .../src/ts/test/funbox/funbox-functions.ts | 32 +++++++++++++------ frontend/static/challenges/_list.json | 8 ++--- packages/funbox/src/list.ts | 10 +++++- packages/schemas/src/configs.ts | 1 + 4 files changed, 37 insertions(+), 14 deletions(-) diff --git a/frontend/src/ts/test/funbox/funbox-functions.ts b/frontend/src/ts/test/funbox/funbox-functions.ts index 4810b36fb..200720604 100644 --- a/frontend/src/ts/test/funbox/funbox-functions.ts +++ b/frontend/src/ts/test/funbox/funbox-functions.ts @@ -318,18 +318,32 @@ const list: Partial> = { }, rAnDoMcAsE: { alterText(word: string): string { - let randomcaseword = word[0] as string; - for (let i = 1; i < word.length; i++) { - if ( - randomcaseword[i - 1] === - (randomcaseword[i - 1] as string).toUpperCase() - ) { - randomcaseword += (word[i] as string).toLowerCase(); + let randomCaseWord = ""; + + for (let letter of word) { + if (Math.random() < 0.5) { + randomCaseWord += letter.toUpperCase(); } else { - randomcaseword += (word[i] as string).toUpperCase(); + randomCaseWord += letter.toLowerCase(); } } - return randomcaseword; + + return randomCaseWord; + }, + }, + sPoNgEcAsE: { + alterText(word: string): string { + let spongeCaseWord = ""; + + for (let i = 0; i < word.length; i++) { + if (i % 2 === 0) { + spongeCaseWord += word[i]?.toLowerCase(); + } else { + spongeCaseWord += word[i]?.toUpperCase(); + } + } + + return spongeCaseWord; }, }, rot13: { diff --git a/frontend/static/challenges/_list.json b/frontend/static/challenges/_list.json index 73564f303..69d487158 100644 --- a/frontend/static/challenges/_list.json +++ b/frontend/static/challenges/_list.json @@ -613,11 +613,11 @@ } }, { - "name": "iKiNdAlIkEhOwInEfFiCiEnTqWeRtYiS", - "display": "I kInDa LiKe HoW iNeFfIcIeNt QwErTy Is", + "name": "iKINdaLikEHoWinEFFICIeNtQwErtYIs.", + "display": "i KINda LikE HoW inEFFICIeNt QwErtY Is.", "autoRole": true, "type": "funbox", - "parameters": [["rAnDoMcAsE"], "time", 3600], + "parameters": [["sPoNgEcAsE"], "time", 3600], "requirements": { "wpm": { "min": 100 @@ -626,7 +626,7 @@ "min": 60 }, "funbox": { - "exact": ["rAnDoMcAsE"] + "exact": ["sPoNgEcAsE"] } } }, diff --git a/packages/funbox/src/list.ts b/packages/funbox/src/list.ts index bae05e7f6..f43ab93e8 100644 --- a/packages/funbox/src/list.ts +++ b/packages/funbox/src/list.ts @@ -114,13 +114,21 @@ const list: Record = { name: "arrows", }, rAnDoMcAsE: { - description: "I kInDa LiKe HoW iNeFfIcIeNt QwErTy Is.", + description: "raNdomIze ThE CApitaLizatIon Of EveRY LeTtEr.", canGetPb: false, difficultyLevel: 2, properties: ["changesCapitalisation"], frontendFunctions: ["alterText"], name: "rAnDoMcAsE", }, + sPoNgEcAsE: { + description: "I kInDa LiKe HoW iNeFfIcIeNt QwErTy Is.", + canGetPb: false, + difficultyLevel: 2, + properties: ["changesCapitalisation"], + frontendFunctions: ["alterText"], + name: "sPoNgEcAsE", + }, capitals: { description: "Capitalize Every Word.", canGetPb: false, diff --git a/packages/schemas/src/configs.ts b/packages/schemas/src/configs.ts index 21e374ebb..d6e8e1d51 100644 --- a/packages/schemas/src/configs.ts +++ b/packages/schemas/src/configs.ts @@ -280,6 +280,7 @@ export const FunboxNameSchema = z.enum([ "choo_choo", "arrows", "rAnDoMcAsE", + "sPoNgEcAsE", "capitals", "layout_mirror", "layoutfluid",