This commit is contained in:
Alex 2024-05-08 10:42:45 +08:00
parent 39783b1e02
commit 0eb7b5cb5b
10 changed files with 161 additions and 47 deletions

View file

@ -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",

View file

@ -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": {

View file

@ -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 = <T>(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;

View file

@ -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",

View file

@ -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,
};

View file

@ -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",

View file

@ -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],
];

View file

@ -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":

View file

@ -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() {

View file

@ -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");