Oracle | AI Dungeon

Oracle

Define your character, and play your way. This scenario has a scripted oracle to determine success or failure of an action. You can still do "Do" actions without a random roll. I use a simple match in the Do action box. Start with one of (try, attempt, strive, seek, endeavor, hope) followed by "to" e.g. "try to " followed by what you are trying to do. I like to use: "try to jump." "hope to make the gap by jumping.” The code for the Oracle is below. ```js const modifier = (text) => { // Define oracle function const oracle = (text) => { // Attempt to match on key words. var match = text.match(/(> You (try|attempt|strive|seek|endeavor|hope))/); // If match is not null or undefined and has at least one match. if (match && match[1]) { // Roll between 0-5 switch (Math.floor(Math.random() * 6)) { case 0: return text + "But you fail in an unfortunate way."; case 1: return text + "But you fail."; case 2: return text + "But you fail but in a positive way."; case 3: return text + "You succeed in an unfortunate way."; case 4: return text + "You succeed."; case 5: return text + "You don't just succeed."; default: return text; } } else { // If no match return unmodified text. return text } } return { text: oracle(text) } } // Don't modify this part modifier(text) ```

Cover art for Oracle, an oracle scenario on AI Dungeon