diff --git a/manifest.json b/manifest.json index 133d42c..6abfb96 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian-solo-rpg-toolkit", "name": "Solo RPG Toolkit", - "version": "0.1.0", + "version": "0.1.1", "minAppVersion": "0.12.15", "description": "Solo RPG toolkit for Obsidian.md", "author": "Alex Kurowski", diff --git a/package.json b/package.json index f6f649a..548e8a9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "alexkurowski/solo-toolkit", - "version": "0.1.0", + "version": "0.1.1", "description": "Solo RPG toolkit for Obsidian (https://obsidian.md)", "main": "./dist/api.js", "scripts": { diff --git a/src/utils/dice.ts b/src/utils/dice.ts index 10d1aa6..69b6d11 100644 --- a/src/utils/dice.ts +++ b/src/utils/dice.ts @@ -11,7 +11,9 @@ export const random = (min: number, max: number, not = -1): number => { export const roll = (max: number, not = -1): number => random(1, max, not); export const randomFrom = (values: T[], not: T | null = null): T => { - if (not === null || values.length <= 1) { + if (!values.length) { + return values[0]; + } else if (not === null) { return values[random(0, values.length - 1)]; } else { let result: T = not; diff --git a/src/utils/dictionary/descriptors.ts b/src/utils/dictionary/descriptors.ts index ff06db6..7572874 100644 --- a/src/utils/dictionary/descriptors.ts +++ b/src/utils/dictionary/descriptors.ts @@ -50,6 +50,7 @@ export default [ "contrary", "courageous", "courteous", + "crazy", "creepy", "cunning", "curious", @@ -204,6 +205,7 @@ export default [ "tired", "touchy", "tough", + "toxic", "trustworthy", "unassuming", "understanding", diff --git a/src/utils/dictionary/index.ts b/src/utils/dictionary/index.ts index 6824601..b35816c 100644 --- a/src/utils/dictionary/index.ts +++ b/src/utils/dictionary/index.ts @@ -7,6 +7,7 @@ import names2 from "./names2"; import names3 from "./names3"; import occupations from "./occupations"; import descriptors from "./descriptors"; +import skills from "./skills"; import hairs from "./hairs"; import settlement from "./settlement"; @@ -20,5 +21,7 @@ export const dictionary = { names3, occupations, descriptors, + skills, + hairs, settlement, }; diff --git a/src/utils/dictionary/settlement.ts b/src/utils/dictionary/settlement.ts index 892759f..d3dd480 100644 --- a/src/utils/dictionary/settlement.ts +++ b/src/utils/dictionary/settlement.ts @@ -22,6 +22,7 @@ export default [ "dagger", "dark", "darrow", + "dee", "deep", "dor", "dragon", @@ -32,9 +33,15 @@ export default [ "edge", "eld", "ever", + "eye", + "farm", + "fear", "fey", + "fish", + "flower", "frey", "frost", + "fur", "gill", "gold", "grand", @@ -44,9 +51,13 @@ export default [ "grim", "hammer", "haw", + "hell", + "hib", + "hield", "high", "hol", "ice", + "iris", "iron", "jewel", "kel", @@ -54,10 +65,12 @@ export default [ "king", "lan", "leaf", + "lily", "long", "lost", "low", "lun", + "luna", "mal", "marsh", "mon", @@ -72,18 +85,24 @@ export default [ "old", "pan", "pel", + "peon", + "petal", "pine", "rain", "raven", "red", "rock", "rom", + "rosales", + "rose", + "rosehip", "roth", "ruby", "rune", "salt", "san", - "shield", + "sand", + "shadow", "silver", "south", "star", @@ -94,14 +113,19 @@ export default [ "sun", "sweet", "sword", + "sworn", "tar", "ten", "thorn", + "tiger", "tin", "torr", "tran", + "tulip", "val", "vine", + "violet", + "weed", "west", "white", "wild", @@ -114,8 +138,12 @@ export default [ "wolfen", "yar", "zel", + "zet", ], [ + " island", + " isle", + " isles", "barrow", "bay", "bend", @@ -126,6 +154,7 @@ export default [ "bury", "cairn", "cliff", + "cove", "crag", "cress", "crest", @@ -135,6 +164,7 @@ export default [ "end", "fall", "far", + "farm", "fell", "field", "ford", @@ -159,10 +189,13 @@ export default [ "point", "pool", "port", + "reef", "rest", "ridge", "river", + "rock", "shire", + "shore", "smith", "song", "spring", @@ -171,6 +204,8 @@ export default [ "stow", "town", "tree", + "vale", + "ville", "wall", "watch", "well", diff --git a/src/utils/dictionary/skills.ts b/src/utils/dictionary/skills.ts new file mode 100644 index 0000000..90ae988 --- /dev/null +++ b/src/utils/dictionary/skills.ts @@ -0,0 +1,70 @@ +export default [ + ["agility", 0], + ["alertness", 0], + ["artillery", 0], + ["athletic", 0], + ["culture", 0], + ["deceive", 0], + ["driving", 0], + ["endurance", 0], + ["fighting", 0], + ["intimidation", 0], + ["investigation", 0], + ["medical", 0], + ["networking", 0], + ["oratory", 0], + ["perception", 0], + ["piloting", 0], + ["repair", 0], + ["riding", 0], + ["sleight of hand", 0], + ["stamina", 0], + ["survival", 0], + ["willpower", 0], + + ["academics", 1], + ["archaeology", 1], + ["art", 1], + ["brawling", 1], + ["brokerage", 1], + ["burglary", 1], + ["charming", 1], + ["close combat", 1], + ["communication", 1], + ["connections", 1], + ["empathy", 1], + ["engineering", 1], + ["esoterics", 1], + ["following orders", 1], + ["gambling", 1], + ["investigating", 1], + ["leadership", 1], + ["mimicry", 1], + ["navigation", 1], + ["philosophy", 1], + ["ranged combat", 1], + ["science", 1], + ["social", 1], + ["stealth", 1], + ["trading", 1], + ["unarmed combat", 1], + + ["aircrafts", 2], + ["animals", 2], + ["assets", 2], + ["bureaucracy", 2], + ["computers", 2], + ["crafts", 2], + ["demolitions", 2], + ["guns", 2], + ["languages", 2], + ["lore", 2], + ["medicine", 2], + ["mysteries", 2], + ["resources", 2], + ["systems", 2], + ["tactics", 2], + ["tech", 2], + ["vehicles", 2], + ["weapons", 2], +]; diff --git a/src/utils/word.ts b/src/utils/word.ts index 239b877..d1c0fc1 100644 --- a/src/utils/word.ts +++ b/src/utils/word.ts @@ -94,17 +94,25 @@ const getAspects = () => { const word2 = randomFrom(dictionary.descriptors, word1); return capitalize(`${word1} and ${word2}`); +}; - // const basic = randomFrom(dictionary.descriptors.basic); - // const hairColor = randomFrom(dictionary.descriptors.hairColor); - // const hairLength = randomFrom(dictionary.descriptors.hairLength); +const getSkills = () => { + const good = randomFrom(dictionary.skills); + const bad = randomFrom(dictionary.skills, good); - // const hair = - // hairLength === "no" - // ? `${hairLength} hair` - // : `${hairLength} ${hairColor} hair`; + const [goodSkill, goodType] = good; + const [badSkill, badType] = bad; - // return capitalize(`${basic} looking, with ${hair}`); + let goodStr = `good ${goodSkill}`; + if (goodType === 0) goodStr = `good ${goodSkill} skills`; + if (goodType === 1) goodStr = `good at ${goodSkill}`; + if (goodType === 2) goodStr = `good with ${goodSkill}`; + let badStr = `bad ${badSkill}`; + if (badType === 0) badStr = `bad ${badSkill} skills`; + if (badType === 1) badStr = `bad at ${badSkill}`; + if (badType === 2) badStr = `bad with ${badSkill}`; + + return capitalize(`${goodStr} but ${badStr}`); }; const getTown = () => @@ -122,6 +130,8 @@ export const generateWord = (type: string): string => { return getSomeName(); case "Aspects": return getAspects(); + case "Skills": + return getSkills(); case "Job": return getJob(); case "Town": diff --git a/src/view/index.ts b/src/view/index.ts index 45b49c9..bbe0aed 100644 --- a/src/view/index.ts +++ b/src/view/index.ts @@ -11,6 +11,8 @@ import { SoloToolkitSettings } from "../settings"; export const VIEW_TYPE = "MAIN_VIEW"; +const resetTimeout = 800; + const tabLabels = { dice: "Dice", deck: "Deck", @@ -101,54 +103,43 @@ export class SoloToolkitView extends ItemView { .setTooltip(tabLabels.dice), }; - const setCta = (btn: keyof typeof btns) => { + const setCta = (tab: keyof typeof btns) => { for (const btn of Object.values(btns)) { - btn.extraSettingsEl.classList.remove("highlight"); + if (btn === btns[tab]) { + btn.extraSettingsEl.classList.add("highlight"); + } else { + btn.extraSettingsEl.classList.remove("highlight"); + } } - btns[btn].extraSettingsEl.classList.add("highlight"); }; setCta(this.tab); - let resetCount = 0; - const maybeReset = (btn: keyof typeof btns) => { - if (this.tab === btn) { - if (resetCount === 0) { - setTimeout(() => { - resetCount = 0; - }, 3000); - } - resetCount++; - if (resetCount >= 3) { - this[btn].reset(); - resetCount = 0; + let lastBtnClickAt = 0; + const maybeReset = (tab: keyof typeof btns) => { + if (this.tab === tab) { + const now = Date.now(); + if (lastBtnClickAt && now - lastBtnClickAt <= resetTimeout) { + this[tab].reset(); + lastBtnClickAt = 0; + } else { + lastBtnClickAt = now; } } else { - resetCount = 0; + lastBtnClickAt = 0; } }; - btns.word.onClick(() => { - maybeReset("word"); - this.tab = "word"; - setCta("word"); + const btnOnClick = (tab: keyof typeof btns) => () => { + maybeReset(tab); + this.tab = tab; + setCta(tab); this.createTab(); updateResetBtnTooltip(); - }); - btns.deck.onClick(() => { - maybeReset("deck"); - this.tab = "deck"; - setCta("deck"); - this.createTab(); - updateResetBtnTooltip(); - }); - btns.dice.onClick(() => { - maybeReset("dice"); - this.tab = "dice"; - setCta("dice"); - this.createTab(); - updateResetBtnTooltip(); - }); + }; + btns.word.onClick(btnOnClick("word")); + btns.deck.onClick(btnOnClick("deck")); + btns.dice.onClick(btnOnClick("dice")); } createTab() { diff --git a/src/view/word.ts b/src/view/word.ts index 348e515..04f5db3 100644 --- a/src/view/word.ts +++ b/src/view/word.ts @@ -26,6 +26,7 @@ export class WordView { this.createWordBtn("Action"); this.createWordBtn("Name"); this.createWordBtn("Aspects"); + this.createWordBtn("Skills"); this.createWordBtn("Job"); this.createWordBtn("Town");