From bbce25930d9910c715245f5d87a108ab1dac3426 Mon Sep 17 00:00:00 2001 From: nathan Date: Wed, 14 Jan 2026 02:08:06 -0700 Subject: Mad libs thingy working --- src/mad-libs.c | 208 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 208 insertions(+) create mode 100644 src/mad-libs.c (limited to 'src/mad-libs.c') diff --git a/src/mad-libs.c b/src/mad-libs.c new file mode 100644 index 0000000..3e6882c --- /dev/null +++ b/src/mad-libs.c @@ -0,0 +1,208 @@ +#include "mad-libs.h" + +// Yes, these are mostly made up and/or wrong. + +const char madLibsNouns[NOUN_COUNT][MAD_LIBS_MAX] = { + "infundibulum", + "bike", + "church", + "pinball", + "shark", + "finger", + "trolley", + "loo", + "khazi", + "science", + "philosophy", + "math", + "wingus", + "fartulum", + "gorilla", + "glue", + "turdus", + "acid", + "weed", + "fungus", + "algorithm", + "schrodinger", + "irregularist", + "bioliquidifeazion", + "arson", + "art", + "triangle", + "fuck", + "mold", + "wyoming", + "duck", + "goose", + "fish", + "wheel", + "gack", + "poop", + "vin-dit", + "duffle" +}; + +const char madLibsVerbs[VERB_COUNT][MAD_LIBS_MAX] = { + "conpockulate", + "vomit", + "ejackulate", + "dualmakulate", + "fart", + "run", + "hide", + "hiss", + "piss", + "walk", + "backwards", // Yes, backwards shall be a verb! + "forwards", // Again hehehe + "jump", + "fall", + "fly", + "sidewalk", + "slift", + "sniff", + "piff", + "conmanoulrlate", + "quack", + "yell", + "spin", + "spit", + "fuck" +}; + +const char madLibsAdverbs[ADVERB_COUNT][MAD_LIBS_MAX] = { + "speedi", + "pacedfullili", + "admorsfullili", + "analsisli", + "dupaleli", + "quickli", + "slowli", + "snailenleli", + "painfulli", + "very", + "torroe", + "eispfulli", + "gentli", + "badli", + "goodli", + "bearli", + "skilllessli" +}; + +const char madLibsAdjectives[ADJECTIVE_COUNT][MAD_LIBS_MAX] = { + "skibidi", + "neolimbpengintical", + "surreal", + "reverse", + "chrono-synclastic", + "purple", + "pink", + "nurple", + "macro", + "cracko", + "dualo", + "smelli", + "maximus", + "moronic", + "mundane", + "grandeural", + "neon", + "irregular", + "stuppa", + "fuck", + "blissfull", + "kind", + "bald", + "mini", + "idealistic", + "materialistic", + "nincompoop", + "granfalloon" +}; + +Seed getRandomMapLibsWord(char* outputString, char type, Seed seed) +{ + // Random type. + if (type == 'r') + { + char types[] = {'n', 'v', 'a', 'j'}; + type = types[FT_RANDOM16(seed) % sizeof(types)]; + } + + FT_RANDOM16(seed); + + switch (type) + { + case 'n': + strncpy(outputString, madLibsNouns[seed % NOUN_COUNT], MAD_LIBS_MAX); + break; + case 'v': + strncpy(outputString, madLibsVerbs[seed % VERB_COUNT], MAD_LIBS_MAX); + break; + case 'a': + strncpy(outputString, madLibsAdverbs[seed % ADVERB_COUNT], MAD_LIBS_MAX); + break; + case 'j': + strncpy(outputString, madLibsAdjectives[seed % ADJECTIVE_COUNT], + MAD_LIBS_MAX); + break; + case '@': + outputString[0] = '@'; + outputString[1] = '\0'; + break; + default: + outputString[0] = '\0'; + break; + } + + return seed; +} + +Seed mapLibs(char* outputString, const char* formatString, size_t maxSize, + Seed seed) +{ + int outputStringIndex = 0; + bool skipNext = false; + memset(outputString, 0, maxSize); + + for (int index = 0; index < maxSize; ++index) + { + if (formatString[index] == '\0') + { + break; + } + + if (!skipNext && formatString[index] == '@' && index < maxSize - 1) + { + skipNext = true; + char type = formatString[index + 1]; + char randomWord[MAD_LIBS_MAX]; + seed = getRandomMapLibsWord(randomWord, type, seed); + + for (int index2 = 0; index2 < MAD_LIBS_MAX; ++index2) + { + if (randomWord[index2] == '\0') + { + break; + } + + outputString[outputStringIndex] = randomWord[index2]; + ++outputStringIndex; + } + } + else + { + if (!skipNext) + { + outputString[outputStringIndex] = formatString[index]; + ++outputStringIndex; + } + + skipNext = false; + } + } + + return seed; +} -- cgit v1.2.3