Riddling Gnome

Forest event encounter (100% weight when triggered). Short gnome with leaves in hair offers riddle challenge. Accept/decline choice. Submit text answer with fuzzy matching (levenshtein distance ≤2 for words longer than 2 letters, exact match required for short words). Correct rewards (random): 40% chance 1 gem, 30% chance 2 gems, 20% chance +1 forest turn, 10% chance specialty point (if have specialty) or experience (level×10). Wrong penalties (random): 50% lose gold (random level×1-10 gold, capped at current gold), 33% lose 1 forest turn (if have turns) OR 1 charm (if 0 turns), 17% lose 1 charm. Database-driven riddles (admin can add/edit via Riddle Editor). Answer filtering removes common words and suffixes. Where a mischievous gnome proves that intellectual property theft is alive and well in the magical community by asking you riddles lifted from folklore and the internet, then demanding gems as payment for your correct answers even though he didn't write them.

Encounter Trigger

Location:

  • Forest event hook
  • Event weight: 100 (always triggers when selected from event pool)
  • Random forest encounter (no player control over appearance)

Encounter Text:

"A short little gnome with leaves in his hair squats beside a small tree. He smirks, giggling behind one of his fatty hands. For a moment, it looks like he might scramble off into the trees, but after a moment smirks and looks at you.

"I'll give you a boon," he says, "if you can think and answer my riddle!"

He loses himself momentarily in a fit of giggling, then contains his excitement for a moment and continues.

"But if ere long your guess is wrong, then my boon it will be!"

Do you accept his challenge?"

Initial Choice:

  • Yes: Accept riddle challenge (proceed to riddle)
  • No: Decline challenge (gnome leaves, no reward/penalty)

Declining the Challenge

If You Choose "No":

"Afraid to look the fool, you decline his challenge. He was a little bit creepy anyway.

The strange gnome giggles hysterically as he disappears into the forest."

Effects:

  • No reward
  • No penalty
  • Encounter ends
  • Safe exit (risk-averse option)

Why Decline:

  • Low on gold (can't afford loss)
  • Low on turns (can't afford turn loss)
  • Don't know riddles (expect failure)
  • Risk-averse playstyle (avoid gambling)

The Riddle Challenge

If You Choose "Yes":

  • Gnome asks riddle from database (random selection)
  • Riddle displayed with formatting
  • Text input box for answer
  • "Guess" submit button

Riddle Text:

"Giggling with glee, he asks his riddle:

"[Riddle text from database]"

What is your guess?"

Answering:

  • Type answer in text box
  • Click "Guess" button
  • Answer processed with fuzzy matching (see below)
  • Result: correct or wrong

Answer Matching System

Filtering Process

Step 1: Remove Non-Alphanumeric

  • Both player answer and correct answer: preg_replace("/[^[:alnum:]]/", " ", $answer)
  • Removes punctuation, special chars
  • Spaces replace removed chars

Step 2: Filter Common Words (Beginning)

  • Removed from start of answer: "a", "an", "and", "the", "my", "your", "someones", "someone's", "someone", "his", "her", "s"
  • Example: "the answer" → "answer"
  • Example: "a river" → "river"

Step 3: Filter Common Suffixes (End)

  • Removed from end of answer (if word long enough): "s", "ing", "ed"
  • Example: "rivers" → "river"
  • Example: "running" → "runn"
  • Example: "walked" → "walk"

Step 4: Convert to Lowercase

  • All text lowercased
  • Case-insensitive matching

Fuzzy Matching Logic

Short Words (≤2 letters):

  • Must match exactly (after filtering)
  • No levenshtein tolerance
  • Example: "it" must be exactly "it"

Long Words (>2 letters):

  • Levenshtein distance ≤ 2 allowed
  • Up to 2 letter differences acceptable
  • Examples:
    • "river" matches "rivre" (1 letter swap)
    • "mountain" matches "mountin" (1 letter missing)
    • "shadow" matches "shadw" (1 letter missing)
    • "dragon" does NOT match "dargon" if >2 differences

Multiple Correct Answers:

  • Database stores multiple answers separated by semicolons (;)
  • Example: "river;stream;water"
  • Player answer checked against ALL possible answers
  • Match any = correct

Empty Answer Handling:

  • Empty/blank submission = always wrong
  • No accidental correct via empty string

Rewards (Correct Answer)

Success Text:

"Lizards and pollywogs!!" he blusters, "You got it!"

"Oh very well. Here's your stupid prize."

Random Reward Table (e_rand 1-10):

Roll 1-4 (40%): One Gem

  • Text: "He gives you a gem!"
  • Reward: +1 gem
  • Logged: "gained 1 gem from the riddle master"

Roll 5-7 (30%): Two Gems

  • Text: "He gives you two gems!"
  • Reward: +2 gems
  • Logged: "gained 2 gems from the riddle master"

Roll 8-9 (20%): Extra Turn

  • Text: "He does the hokey pokey, and turns himself around. After that display, you feel ready for battle! You gain a forest fight!"
  • Reward: +1 forest turn
  • No log entry
  • Hokey pokey = motivational dance apparently

Roll 10 (10%): Specialty Point OR Experience

  • Text: "He looks deep in your eyes, then whacks you hard across the side of your head. When you come to, you feel a little bit smarter."
  • If you have specialty:
    • Reward: +1 specialty point (increment_specialty)
    • Text color: green ("`3")
  • If you have NO specialty:
    • Reward: experience = level × 10
    • Text: "That was a fun lesson. You gain some experience!"
  • Educational violence (head whack = learning tool)

Expected Reward Value:

  • Gem average: (40% × 1) + (30% × 2) = 1.0 gem expected
  • Turn chance: 20% for +1 turn
  • Specialty/XP chance: 10%
  • Best possible: 2 gems (30% chance)

Penalties (Wrong Answer)

Failure Text:

"The strange gnome cackles with glee and dances around you. You feel very silly standing there with a crazy gnome prancing around like a fairy, so you quietly make your exit while he's distracted. Somehow you feel like less of a hero with his mocking laughter echoing in your ears."

Random Penalty Table (e_rand 1-6):

Roll 1-3 (50%): Lose Gold

  • Text: "It's not until much later that you also notice some of your gold is missing. You lost [amount] gold!"
  • Amount: random(1, level × 10)
  • Capped at current gold (can't go negative)
  • Examples:
    • Level 5: lose 1-50 gold
    • Level 10: lose 1-100 gold
    • Level 20: lose 1-200 gold
  • Logged: "lost [amount] gold to the riddlemaster"
  • Pickpocket gnome (mocking laughter = distraction)

Roll 4-5 (33%): Lose Turn or Charm

  • Text: "You don't think you can face another opponent right away."
  • If turns > 0:
    • Penalty: -1 forest turn
    • Text: "You lose a forest fight!"
  • If turns = 0:
    • Penalty: -1 charm (if charm > 0)
    • Text: "You lose a charm point due to despair."
  • Conditional penalty (worse if out of turns)

Roll 6 (17%): Lose Charm

  • Text: "What would [partner] think? You lose a charm point!"
  • Penalty: -1 charm (if charm > 0)
  • Partner name displayed (from get_partner())
  • Shame mechanism (partner disappointment)

Expected Penalty:

  • 50% chance: lose 1 to (level×10) gold
  • 33% chance: lose 1 turn or 1 charm
  • 17% chance: lose 1 charm
  • Total charm loss chance: 50% (if turns=0) or 17% (if turns>0)
  • Worst case: level 20 loses 200 gold

Risk/Reward Analysis

Correct Answer (Win)

  • Best: +2 gems (30%)
  • Good: +1 gem (40%)
  • Decent: +1 turn (20%)
  • Variable: specialty point or exp (10%)
  • Average: ~1 gem worth

Wrong Answer (Loss)

  • Worst: -(level×1-10) gold (50%, scales with level)
  • Bad: -1 turn or -1 charm (33%)
  • Minor: -1 charm (17%)
  • Average at level 10: ~25-50 gold loss

Expected Value (If 50% Correct Rate)

  • 50% chance: +1 gem average (~1000 gold value?)
  • 50% chance: -(level×5) gold average OR -1 turn/charm
  • Break-even if gem worth > level×10 gold
  • Low-level players: profitable (gems > gold loss)
  • High-level players: risky (gold loss scales up)

Optimal Strategy

  • Accept if: You know riddles well, low level, high gold
  • Decline if: Don't know answer, high level, low gold
  • Can't preview riddle before accepting (gamble)
  • Fuzzy matching helps (2-letter tolerance)

Riddle Database

How Riddles Are Stored:

  • Database table: "riddles"
  • Columns: id, riddle (text), answer (text), author (login)
  • Random selection: ORDER BY rand()
  • One riddle per encounter (selected when you accept challenge)

Answer Format:

  • Single answer: "river"
  • Multiple answers: "river;stream;water" (semicolon-separated)
  • All alternatives checked
  • Case-insensitive, filtered, fuzzy-matched

Default Riddles:

  • Module comes with install script (riddles_install.php)
  • Pre-loaded riddles on installation
  • Admin can add more via Riddle Editor

Riddle Editor (Admin Tool)

Access:

  • Superuser menu (SU_EDIT_RIDDLES permission)
  • OR user pref "canedit" = 1
  • Link: "Riddle Editor" in Module Configurations

Editor Features:

  • View all riddles (table format)
  • Add new riddle (riddle text + answer + author)
  • Edit existing riddle
  • Delete riddle (with confirmation)
  • Author field: auto-filled with admin login

Answer Guidelines:

  • Separate multiple answers with semicolons
  • Example: "fire;flame;flames"
  • Ignored at start: a, an, and, the, my, your, someones, someone's, someone, his, her, s
  • Ignored at end: s, ing, ed
  • Design answers accounting for filtering

Localization Note:

  • Riddles stored in database language
  • Answers expected in database language
  • No automatic translation

Strategy & Tips

For Players

When to Accept Challenge:

  • High gold reserves (can afford loss)
  • Low level (gold penalty smaller)
  • Know riddles well (high success rate)
  • Want gems (best reward = 2 gems)
  • Risk-tolerant playstyle

When to Decline:

  • Low gold (can't afford level×10 loss)
  • High level (penalty scales up)
  • Don't know riddles (low success rate)
  • Out of turns + low charm (double penalty risk)
  • Risk-averse playstyle

Answering Tips:

  • Don't overthink (simple answers often correct)
  • Spelling tolerance: 2 letters off OK (for long words)
  • Plurals work (suffix filtering removes "s")
  • Skip articles (a/an/the filtered automatically)
  • Common riddle categories: body parts, natural elements, objects, concepts

For High-Level Players

Scaling Penalty Problem:

  • Level 1: lose 1-10 gold (manageable)
  • Level 10: lose 1-100 gold (significant)
  • Level 20: lose 1-200 gold (painful)
  • Reward doesn't scale (still 1-2 gems)
  • Conclusion: Less favorable at higher levels

Break-Even Analysis:

  • If gem worth ~1000 gold: profitable until level ~20 (assuming 50% success)
  • If gem worth ~500 gold: profitable until level ~10
  • Adjust risk tolerance based on gem value on your server

Common Questions

Q: What happens if I answer wrong?
A: Random penalty (50% lose gold scaling with level, 33% lose 1 turn or charm, 17% lose 1 charm). Gnome mocks you.

Q: Can I see the riddle before accepting?
A: No. Riddle only appears after you click "Yes." Initial decision is blind.

Q: How exact does my answer need to be?
A: Fuzzy matching allows 2-letter differences for words >2 letters. Short words must match exactly. Case-insensitive.

Q: What if there are multiple correct answers?
A: Database supports semicolon-separated answers. Matching any = correct.

Q: Can I encounter the same riddle twice?
A: Yes. Random selection from database each time. No tracking of seen riddles.

Q: What's the best reward?
A: 2 gems (30% chance if correct). Or specialty point if you value that highly.

Q: What's the worst penalty?
A: Losing gold (50% penalty chance, amount = level×1-10). High-level players can lose 100-200 gold.

Q: Can I die from this encounter?
A: No. Penalties are gold/turns/charm only. No HP damage or death.

Q: Is declining considered cowardly?
A: Text says "afraid to look the fool" but no mechanical consequence. Smart risk management = not cowardice.

Q: Can I add my own riddles?
A: Only if admin gives you "canedit" pref. Default: superuser only.

Example Riddles (Typical)

Classic Riddle Formats:

  • "What has hands but cannot clap?" → clock
  • "What gets wet while drying?" → towel
  • "What has a head and tail but no body?" → coin
  • "The more you take, the more you leave behind. What am I?" → footsteps
  • "I have cities but no houses, forests but no trees, water but no fish. What am I?" → map

Answer Filtering Examples:

  • Player types: "a clock" → filtered to "clock" → correct
  • Player types: "the towel" → filtered to "towel" → correct
  • Player types: "footstep" → filtered to "footstep" → matches "footsteps" (suffix removed)
  • Player types: "mapp" (typo) → levenshtein(mapp, map) = 1 → correct

Riddling Gnome: where a short giggling forest cryptid with leaves in his hair intercepts you during forest fights to demand intellectual combat, wagering asymmetric stakes where correct answers reward you with 1-2 gems (70% combined probability) or a forest turn (20%) or a specialty point slash experience boost (10%) determined by e_rand(1,10), while incorrect answers punish you with either 50% probability of losing random(level×1, level×10) gold that scales dramatically with your level creating a penalty structure that becomes increasingly punishing as you progress making this encounter favorable for newbies but potentially devastating for high-level players who can lose 200 gold for failing to identify that "the more you take the more you leave behind" refers to footsteps, or 33% probability of losing a forest turn if you have turns available otherwise losing a charm point due to despair, or 17% probability of losing a charm point because your romantic partner would be disappointed in your riddling performance according to the gnome's psychological warfare tactics. The answer matching system employs sophisticated fuzzy logic via levenshtein distance calculations allowing up to 2 character differences for words longer than 2 letters while requiring exact matches for short words, combined with aggressive filtering that strips common articles (a, an, the, my, your, etc.) from the beginning and common suffixes (s, ing, ed) from the end, meaning you can type "the rivers" and it'll match "river" in the database, and multiple correct answers can be stored semicolon-separated so "fire;flame;flames" all work, though empty submissions are hardcoded as incorrect to prevent accidental wins via blank strings. The riddles themselves live in a database table populated during installation via riddles_install.php and managed through a Riddle Editor accessible to superusers or users with the "canedit" preference, where admins can add/edit/delete riddles with the editor helpfully noting that riddles display in their stored language with no automatic translation so multilingual servers better maintain separate riddle sets per language, and the encounter offers a decline option where you can refuse the challenge receiving neither reward nor penalty with flavor text explaining you were "afraid to look the fool" and noting the gnome "was a little bit creepy anyway" which is valid risk management not cowardice, though declining means forfeiting the 70% chance at free gems which at low levels represents excellent expected value but at high levels where wrong answers cost 100-200 gold the math becomes significantly less favorable unless you maintain a riddle database in your head or Google answers mid-encounter which the game doesn't prevent because it can't detect tab-switching making this encounter secretly a test of your web search skills as much as your riddle knowledge.