rpg-engine 0.13.0 → 0.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/README.md +2 -0
  2. package/dist/campaign/choices.d.ts +30 -0
  3. package/dist/campaign/choices.js +84 -0
  4. package/dist/campaign/index.d.ts +4 -1
  5. package/dist/campaign/index.js +4 -1
  6. package/dist/campaign/last-choices.d.ts +6 -0
  7. package/dist/campaign/last-choices.js +34 -0
  8. package/dist/campaign/levels.d.ts +50 -0
  9. package/dist/campaign/levels.js +189 -0
  10. package/dist/campaign/settings.d.ts +35 -13
  11. package/dist/campaign/settings.js +20 -51
  12. package/dist/commands/ask.d.ts +8 -0
  13. package/dist/commands/ask.js +2 -1
  14. package/dist/commands/change/change.js +6 -4
  15. package/dist/commands/choices.d.ts +64 -0
  16. package/dist/commands/choices.js +216 -0
  17. package/dist/commands/config.d.ts +8 -1
  18. package/dist/commands/config.js +165 -21
  19. package/dist/commands/index.js +2 -0
  20. package/dist/commands/init.d.ts +1 -0
  21. package/dist/commands/init.js +8 -4
  22. package/dist/commands/rename.js +8 -3
  23. package/dist/commands/save.d.ts +1 -1
  24. package/dist/commands/shared/experience.d.ts +9 -2
  25. package/dist/commands/shared/experience.js +42 -7
  26. package/dist/commands/shared/knowledge.d.ts +2 -0
  27. package/dist/commands/shared/knowledge.js +5 -0
  28. package/dist/commands/shared/mode.js +10 -3
  29. package/dist/commands/shared/offers.d.ts +3 -1
  30. package/dist/commands/shared/offers.js +6 -1
  31. package/dist/commands/shared/rules.js +5 -1
  32. package/dist/commands/shared/time.d.ts +6 -0
  33. package/dist/commands/shared/time.js +35 -3
  34. package/dist/commands/shared/upkeep.js +3 -3
  35. package/dist/commands/shared/world.js +7 -4
  36. package/dist/commands/status.d.ts +2 -0
  37. package/dist/commands/status.js +15 -7
  38. package/dist/commands/view/view.js +10 -7
  39. package/dist/commands/write/write.js +5 -2
  40. package/dist/dashboard/address.js +8 -1
  41. package/dist/dashboard/api.js +20 -0
  42. package/dist/dashboard/app.js +18 -6
  43. package/dist/dashboard/choices.js +343 -0
  44. package/dist/dashboard/guide/ar.md +12 -10
  45. package/dist/dashboard/guide/cs.md +12 -10
  46. package/dist/dashboard/guide/da.md +13 -11
  47. package/dist/dashboard/guide/de.md +12 -10
  48. package/dist/dashboard/guide/el.md +14 -12
  49. package/dist/dashboard/guide/en.md +11 -9
  50. package/dist/dashboard/guide/es.md +12 -10
  51. package/dist/dashboard/guide/fi.md +12 -10
  52. package/dist/dashboard/guide/fr.md +12 -10
  53. package/dist/dashboard/guide/he.md +12 -10
  54. package/dist/dashboard/guide/hi.md +12 -10
  55. package/dist/dashboard/guide/hu.md +12 -10
  56. package/dist/dashboard/guide/is.md +13 -11
  57. package/dist/dashboard/guide/it.md +12 -10
  58. package/dist/dashboard/guide/ja.md +12 -10
  59. package/dist/dashboard/guide/ko.md +14 -12
  60. package/dist/dashboard/guide/nb.md +13 -11
  61. package/dist/dashboard/guide/nl.md +12 -10
  62. package/dist/dashboard/guide/pl.md +12 -10
  63. package/dist/dashboard/guide/pt.md +12 -10
  64. package/dist/dashboard/guide/ro.md +12 -10
  65. package/dist/dashboard/guide/ru.md +12 -10
  66. package/dist/dashboard/guide/sv.md +12 -10
  67. package/dist/dashboard/guide/tr.md +12 -10
  68. package/dist/dashboard/guide/uk.md +13 -11
  69. package/dist/dashboard/guide/zh.md +12 -10
  70. package/dist/dashboard/i18n/ar.json +80 -0
  71. package/dist/dashboard/i18n/cs.json +80 -0
  72. package/dist/dashboard/i18n/da.json +80 -0
  73. package/dist/dashboard/i18n/de.json +80 -0
  74. package/dist/dashboard/i18n/el.json +80 -0
  75. package/dist/dashboard/i18n/es.json +80 -0
  76. package/dist/dashboard/i18n/fi.json +80 -0
  77. package/dist/dashboard/i18n/fr.json +80 -0
  78. package/dist/dashboard/i18n/he.json +80 -0
  79. package/dist/dashboard/i18n/hi.json +80 -0
  80. package/dist/dashboard/i18n/hu.json +80 -0
  81. package/dist/dashboard/i18n/is.json +80 -0
  82. package/dist/dashboard/i18n/it.json +80 -0
  83. package/dist/dashboard/i18n/ja.json +80 -0
  84. package/dist/dashboard/i18n/ko.json +80 -0
  85. package/dist/dashboard/i18n/nb.json +80 -0
  86. package/dist/dashboard/i18n/nl.json +80 -0
  87. package/dist/dashboard/i18n/pl.json +80 -0
  88. package/dist/dashboard/i18n/pt.json +80 -0
  89. package/dist/dashboard/i18n/ro.json +80 -0
  90. package/dist/dashboard/i18n/ru.json +80 -0
  91. package/dist/dashboard/i18n/sv.json +80 -0
  92. package/dist/dashboard/i18n/tr.json +80 -0
  93. package/dist/dashboard/i18n/uk.json +80 -0
  94. package/dist/dashboard/i18n/zh.json +80 -0
  95. package/dist/dashboard/icons.js +4 -0
  96. package/dist/dashboard/labels.js +32 -0
  97. package/dist/dashboard/party.js +13 -5
  98. package/dist/dashboard/settings.js +89 -40
  99. package/dist/dashboard/setup.js +1 -1
  100. package/dist/dashboard/sheet.js +3 -2
  101. package/dist/dashboard/style.css +744 -6
  102. package/dist/dashboard/top.js +8 -4
  103. package/dist/server/dashboard/choices.d.ts +41 -0
  104. package/dist/server/dashboard/choices.js +176 -0
  105. package/dist/server/dashboard/index.js +17 -1
  106. package/dist/time/game-date.d.ts +9 -0
  107. package/dist/time/game-date.js +9 -0
  108. package/dist/time/index.d.ts +1 -1
  109. package/dist/time/index.js +1 -1
  110. package/instructions/dashboard-guide.md +1 -1
  111. package/package.json +1 -1
@@ -0,0 +1,343 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-runtime";
2
+ import { useEffect, useRef, useState } from "preact/hooks";
3
+ import { choicesAddress } from "./address.js";
4
+ import { changeChoices, readChoices, readView } from "./api.js";
5
+ import { useMedia } from "./card.js";
6
+ import { Icon, NotationIcons } from "./icons.js";
7
+ import { diceIn, shownNotation } from "./labels.js";
8
+ import { Markdown } from "./markdown.js";
9
+ import { sheetAddress, sideOf, Token } from "./party.js";
10
+ import { arrowStep, capitalized, foldedText, t } from "./text.js";
11
+ // From this width an option's page stands beside the choices; under it, in their place.
12
+ const wide = "(min-width: 900px)";
13
+ // From how many options a choice has its search, and the ones chosen over it.
14
+ const longList = 9;
15
+ // How long at most a roll's total waits for its dice, when they never land.
16
+ const longestRoll = 12_000;
17
+ /** Someone's sets of choices, waiting or confirmed, in the order the master made them. */
18
+ export function choicesOf(choices, who) {
19
+ return who === undefined ? [] : (choices?.sets ?? []).filter((set) => set.who === who);
20
+ }
21
+ /** Whether a set still waits for the player: not confirmed yet. */
22
+ export function waits(set) {
23
+ return set.confirmed === undefined;
24
+ }
25
+ /** The notice of a set of someone's choices on their sheet: a strip to its page with how far the player is; once confirmed, that the master writes them. */
26
+ export function ChoicesNotice({ set }) {
27
+ const confirmed = !waits(set);
28
+ // What the player must choose counts; an optional choice only when it is all there is.
29
+ const required = set.items.filter((item) => item.least > 0);
30
+ const counted = required.length > 0 ? required : set.items;
31
+ const done = counted.filter(settled).length;
32
+ return (_jsxs("a", { class: confirmed ? "choices-notice confirmed" : "choices-notice", href: choicesAddress(set.who), children: [_jsx(Icon, { name: confirmed ? "check" : "levelUp" }), _jsxs("span", { class: "choices-notice-words", children: [_jsx("span", { children: confirmed ? t("{title}: confirmed", { title: set.title }) : t("{title}: choices waiting", { title: set.title }) }), _jsx("small", { children: confirmed ? t("The master writes them on the sheet") : t("Whenever you like · {done} of {count} done", { done, count: counted.length }) })] }), _jsxs("span", { class: "choices-notice-go", children: [!confirmed && _jsx("span", { class: "choices-notice-word", children: t("Choose") }), _jsx(Icon, { name: "fold" })] })] }));
33
+ }
34
+ /**
35
+ * The page of someone's choices: the way back to their sheet, then each set of theirs with its steps, its choices and its end; the page of an option open
36
+ * beside them on a wide screen, in their place on a phone. `flying` is the roll whose dice are in the air, whose total waits for them.
37
+ */
38
+ export function ChoicesPage({ who, open, choices, member, version, flying, onChanged }) {
39
+ const besides = useMedia(wide);
40
+ const sets = choicesOf(choices, who);
41
+ const name = who ?? "";
42
+ // On a phone an option's page takes the place of the choices, with the way back to them alone.
43
+ const readingSet = open === undefined || besides ? undefined : sets.find((set) => openOption(set, open) !== undefined);
44
+ const back = (_jsxs("a", { class: "button quiet choices-back", href: member === undefined ? "#/party" : sheetAddress(member.name), children: [_jsx(Icon, { name: "fold" }), capitalized(t("{name}'s sheet", { name }))] }));
45
+ if (choices === undefined) {
46
+ return _jsx("p", { class: "choices-none", children: t("Reading…") });
47
+ }
48
+ if (sets.length === 0) {
49
+ return (_jsxs("section", { class: "choices", "aria-label": t("{name}'s choices", { name }), children: [back, _jsx("p", { class: "choices-none", children: t("{name} has no choices waiting: the master prepares them when the game asks for some, as at a new level.", { name }) })] }));
50
+ }
51
+ return (_jsxs("div", { class: "choices-page", children: [readingSet === undefined && back, open !== undefined && !sets.some((set) => openOption(set, open) !== undefined) && _jsx("p", { class: "choices-none", role: "status", children: t("No option here is called “{name}”.", { name: open }) }), (readingSet === undefined ? sets : [readingSet]).map((set, index) => (_jsx(ChoiceSet, { set: set, first: index === 0, member: member, physical: choices.physical, open: open, besides: besides, version: version, flying: flying, onChanged: onChanged }, set.id)))] }));
52
+ }
53
+ /** A set of choices: its head, its steps, its choices, the page of an option open, and its end with what is missing and the confirm. */
54
+ function ChoiceSet({ set, first, member, physical, open, besides, version, flying, onChanged }) {
55
+ const [problem, setProblem] = useState();
56
+ const [sending, setSending] = useState(false);
57
+ // The choice whose roll was sent: its total waits for the dice, seen in the air, to land.
58
+ const [rolling, setRolling] = useState();
59
+ const box = useRef(null);
60
+ const title = useRef(null);
61
+ const done = useRef(null);
62
+ const lastRead = useRef(undefined);
63
+ const confirmed = !waits(set);
64
+ const reading = open === undefined ? undefined : openOption(set, open);
65
+ const missing = set.items.map((item, index) => ({ item, index })).filter((one) => !answered(one.item));
66
+ const key = idOf(set);
67
+ // The page opened from the sheet's notice starts at its title, for a screen reader to read it.
68
+ useEffect(() => {
69
+ if (first && open === undefined) {
70
+ title.current?.focus({ preventScroll: true });
71
+ }
72
+ }, []);
73
+ // An option's page closed, the focus goes back to its Read, in sight on a phone.
74
+ useEffect(() => {
75
+ if (reading !== undefined) {
76
+ lastRead.current = reading.option.pages?.[0]?.name;
77
+ return;
78
+ }
79
+ const name = lastRead.current;
80
+ lastRead.current = undefined;
81
+ const link = name === undefined ? undefined : [...box.current?.querySelectorAll(".choice-read") ?? []].find((one) => one.dataset.name === name);
82
+ link?.focus({ preventScroll: true });
83
+ if (!besides) {
84
+ link?.scrollIntoView({ block: "center" });
85
+ }
86
+ }, [reading?.option.pages?.[0]?.name]);
87
+ // A roll's total shows once its dice, seen in the air, have landed; or after a while, when they never fly.
88
+ useEffect(() => {
89
+ if (rolling === undefined) {
90
+ return;
91
+ }
92
+ if (flying?.by === "player" && !rolling.seen) {
93
+ setRolling({ ...rolling, seen: true });
94
+ }
95
+ else if (flying === undefined && rolling.seen) {
96
+ setRolling(undefined);
97
+ }
98
+ }, [flying?.id, rolling?.seen, rolling?.item]);
99
+ useEffect(() => {
100
+ if (rolling === undefined) {
101
+ return;
102
+ }
103
+ const timer = window.setTimeout(() => setRolling(undefined), longestRoll);
104
+ return () => window.clearTimeout(timer);
105
+ }, [rolling?.item]);
106
+ const send = async (change, item) => {
107
+ setProblem(undefined);
108
+ const now = await changeChoices(change);
109
+ if (now === undefined || now === "changed") {
110
+ setProblem({ ...(item === undefined ? {} : { item }), text: now === undefined ? t("It did not reach the game: try again.") : t("The choices changed meanwhile: here they are as they are now.") });
111
+ if (now === "changed") {
112
+ void readChoices().then(onChanged, () => undefined);
113
+ }
114
+ return false;
115
+ }
116
+ onChanged(now);
117
+ return true;
118
+ };
119
+ const roll = async (item, option, faces) => {
120
+ if (faces === undefined) {
121
+ setRolling({ item, seen: false });
122
+ }
123
+ const taken = await send({ id: set.id, item, roll: option.text, ...(faces === undefined ? {} : { faces }) }, item);
124
+ if (!taken) {
125
+ setRolling(undefined);
126
+ }
127
+ return taken;
128
+ };
129
+ const focusItem = (index) => {
130
+ const heading = document.getElementById(`${key}-${index}`);
131
+ heading?.focus({ preventScroll: true });
132
+ heading?.closest(".choice-item")?.scrollIntoView({ block: "start", behavior: matchMedia("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth" });
133
+ };
134
+ const confirm = async () => {
135
+ if (missing.length > 0 || sending) {
136
+ if (missing[0] !== undefined) {
137
+ focusItem(missing[0].index);
138
+ }
139
+ return;
140
+ }
141
+ setSending(true);
142
+ const taken = await send({ id: set.id, confirm: true, said: t("I confirmed my choices: {title}.", { title: set.title }) });
143
+ setSending(false);
144
+ if (taken) {
145
+ requestAnimationFrame(() => done.current?.focus());
146
+ }
147
+ };
148
+ const link = optionLinks(set);
149
+ // On a phone, an option's page in place of the choices, with the way back to them.
150
+ if (reading !== undefined && !besides) {
151
+ return (_jsxs("section", { class: "choices", ref: box, "aria-label": t("{name}'s choices", { name: set.who }), children: [_jsxs("a", { class: "button quiet choices-back", href: choicesAddress(set.who), children: [_jsx(Icon, { name: "fold" }), t("Back to the choices")] }), _jsx(ChoiceReader, { set: set, at: reading.item, option: reading.option, page: reading.page, version: version, phone: true, link: link, closed: confirmed || rolling !== undefined, onPick: (answer) => void send({ id: set.id, item: reading.item, answer }, reading.item) })] }));
152
+ }
153
+ return (_jsxs("section", { class: "choices", ref: box, "aria-labelledby": `${key}-title`, children: [_jsxs("header", { class: "choices-head", children: [_jsx(Token, { member: member ?? { name: set.who, role: "other" }, large: true, side: member === undefined ? undefined : sideOf(member.role) }), _jsxs("div", { children: [_jsx("p", { class: "eyebrow accent", children: t("{name}'s choices", { name: set.who }) }), _jsx("h2", { id: `${key}-title`, tabIndex: -1, ref: title, dir: "auto", children: set.title }), _jsx("p", { class: "choices-lead", children: confirmed
154
+ ? t("Confirmed: they are the master's now, who writes them on the sheet and tells you.")
155
+ : t("Choose whenever you like: the story goes on meanwhile. Read the pages here; ask the master anything in the chat.") })] })] }), _jsx("ol", { class: "choices-steps", "aria-label": t("The choices"), children: set.items.map((item, index) => (_jsx("li", { class: settled(item) ? "done" : index === missing[0]?.index ? "now" : undefined, children: _jsxs("button", { type: "button", onClick: () => focusItem(index), children: [_jsx("span", { class: "step-dot num", dir: "ltr", "aria-hidden": "true", children: settled(item) ? _jsx(Icon, { name: "check" }) : item.most > 1 && item.answer.length > 0 ? `${item.answer.length}/${item.most}` : index + 1 }), _jsx("bdi", { children: item.question }), _jsx("span", { class: "visually-hidden", children: stateWords(item) })] }) }, index))) }), _jsxs("div", { class: reading === undefined ? "choices-body" : "choices-body reading", children: [_jsx("div", { class: "choices-items", children: set.items.map((item, index) => (_jsx(ChoiceItem, { set: set, item: item, at: index, physical: physical, closed: confirmed, rolling: rolling?.item === index, reading: reading?.item === index ? reading.option.text : undefined, problem: problem?.item === index ? problem.text : undefined, onPick: (answer) => void send({ id: set.id, item: index, answer }, index), onRoll: (option, faces) => roll(index, option, faces) }, index))) }), reading !== undefined && (_jsx(ChoiceReader, { set: set, at: reading.item, option: reading.option, page: reading.page, version: version, link: link, closed: confirmed || rolling !== undefined, onPick: (answer) => void send({ id: set.id, item: reading.item, answer }, reading.item) }, reading.option.text))] }), _jsx("footer", { class: "choices-foot", children: confirmed
156
+ ? (_jsxs("p", { class: "choices-done", tabIndex: -1, ref: done, children: [_jsx(Icon, { name: "check" }), t("Confirmed: they are the master's now, who writes them on the sheet and tells you.")] }))
157
+ : (_jsxs(_Fragment, { children: [missing.length > 0 && (_jsxs("p", { class: "choices-missing", children: [_jsx("span", { class: "eyebrow", children: t("Still to choose") }), missing.map((one) => (_jsxs("button", { type: "button", class: "setup-chip", onClick: () => focusItem(one.index), children: [_jsx("bdi", { children: one.item.question }), one.item.most > 1 && _jsx("span", { class: "num", children: ` · ${t("{count} of {most}", { count: one.item.answer.length, most: one.item.most })}` })] }, one.index)))] })), _jsxs("button", { type: "button", class: "button gold", "aria-disabled": missing.length > 0 || sending ? true : undefined, "aria-describedby": `${key}-after`, onClick: () => void confirm(), children: [_jsx(Icon, { name: "check" }), t("Confirm the choices")] }), problem !== undefined && problem.item === undefined && _jsx("p", { class: "choices-problem", role: "alert", children: problem.text }), _jsx("p", { class: "choices-after", id: `${key}-after`, children: t("Once you confirm, the master writes them on the sheet and tells you. Until then you can change everything but a roll made.") })] })) })] }));
158
+ }
159
+ /** A choice: its question and state, the ones chosen and a search over a long list, its options as cards, and what to know of it. */
160
+ function ChoiceItem({ set, item, at, physical, closed, rolling, reading, problem, onPick, onRoll }) {
161
+ const [search, setSearch] = useState("");
162
+ const field = useRef(null);
163
+ const key = `${idOf(set)}-${at}`;
164
+ // One among them is a radio; any other number, or one that may be none, a checkbox.
165
+ const single = item.least === 1 && item.most === 1;
166
+ const rolled = item.rolled !== undefined;
167
+ const full = !single && item.answer.length >= item.most;
168
+ const long = item.options.length >= longList;
169
+ const found = search.trim() === "" ? item.options : item.options.filter((option) => foldedText(`${option.label} ${(option.pages ?? []).map((page) => `${page.title} ${page.opening}`).join(" ")}`).includes(foldedText(search.trim())));
170
+ const chosen = item.options.filter((option) => item.answer.includes(option.text));
171
+ const shut = (option) => closed || rolled || rolling || (full && !item.answer.includes(option.text));
172
+ // The radio group's one stop: the option chosen, else the first that may be.
173
+ const chosenAt = found.findIndex((option) => item.answer.includes(option.text));
174
+ const stop = chosenAt >= 0 ? chosenAt : Math.max(0, found.findIndex((option) => !shut(option)));
175
+ const total = rolled ? / = (-?\d+)/.exec(item.rolled ?? "")?.[1] ?? item.rolled : undefined;
176
+ const choose = (option) => {
177
+ if (shut(option)) {
178
+ return;
179
+ }
180
+ if (option.notation !== undefined) {
181
+ if (physical) {
182
+ document.getElementById(`${key}-${item.options.indexOf(option)}-die-0`)?.focus();
183
+ }
184
+ else {
185
+ void onRoll(option);
186
+ }
187
+ return;
188
+ }
189
+ const has = item.answer.includes(option.text);
190
+ if (single) {
191
+ if (!has) {
192
+ onPick([option.text]);
193
+ }
194
+ return;
195
+ }
196
+ onPick(has ? item.answer.filter((one) => one !== option.text) : [...item.answer, option.text]);
197
+ };
198
+ // In a radio group the arrows move along the options, choosing as they go; never rolling: a roll is pressed.
199
+ const move = (event) => {
200
+ const step = arrowStep(event.key);
201
+ if (!single || step === 0 || !event.target.classList.contains("choice-pick")) {
202
+ return;
203
+ }
204
+ event.preventDefault();
205
+ const buttons = [...event.currentTarget.querySelectorAll(".choice-pick")];
206
+ const next = (buttons.indexOf(event.target) + step + buttons.length) % buttons.length;
207
+ buttons[next]?.focus();
208
+ const option = found[next];
209
+ if (option !== undefined && option.notation === undefined && !shut(option)) {
210
+ choose(option);
211
+ }
212
+ };
213
+ return (_jsxs("section", { class: "choice-item", "aria-labelledby": key, children: [_jsxs("header", { class: "choice-item-head", children: [_jsx("p", { class: "eyebrow", children: t("Choice {n} of {count}", { n: at + 1, count: set.items.length }) }), _jsx("h3", { id: key, tabIndex: -1, dir: "auto", children: item.question }), _jsx(ItemState, { item: item })] }), long && chosen.length > 0 && (_jsxs("div", { class: "choice-chosen", children: [_jsx("span", { class: "eyebrow", id: `${key}-chosen`, children: t("Chosen") }), _jsx("ul", { "aria-labelledby": `${key}-chosen`, children: chosen.map((option) => (_jsxs("li", { class: "chip", children: [_jsx("bdi", { children: option.label }), !closed && !rolled && !single && (_jsx("button", { type: "button", class: "icon-button", "aria-label": t("Take {item} off", { item: option.label }), "data-tip": t("Take {item} off", { item: option.label }), onClick: () => {
214
+ choose(option);
215
+ field.current?.focus();
216
+ }, children: _jsx(Icon, { name: "close" }) }))] }, option.text))) })] })), long && (_jsx("div", { class: "choice-find", children: _jsxs("span", { class: "search", children: [_jsx(Icon, { name: "search" }), _jsx("input", { ref: field, type: "search", value: search, placeholder: t("Search among {count}", { count: item.options.length }), "aria-label": t("Search the options of “{question}”", { question: item.question }), onInput: (event) => setSearch(event.currentTarget.value) })] }) })), found.length === 0 && (_jsxs("p", { class: "choices-none", role: "status", children: [t("Nothing matches “{query}”.", { query: search }), " ", _jsx("button", { type: "button", class: "button quiet", onClick: () => setSearch(""), children: t("Clear the search") })] })), _jsx("div", { class: "choice-options", role: single ? "radiogroup" : "group", "aria-labelledby": key, onKeyDown: move, children: found.map((option, index) => {
217
+ const checked = item.answer.includes(option.text);
218
+ const rollsHere = option.notation !== undefined;
219
+ return (_jsx(OptionCard, { id: `${key}-${item.options.indexOf(option)}`, option: option, role: single ? "radio" : "checkbox", checked: checked, closed: shut(option), tabIndex: single ? (index === stop ? 0 : -1) : undefined, read: option.text === reading, href: option.pages === undefined ? undefined : choicesAddress(set.who, option.pages[0].name), total: rollsHere && checked && rolled && !rolling ? total : undefined, about: rollsHere
220
+ ? rolling && checked
221
+ ? t("The dice are rolling…")
222
+ : checked && rolled
223
+ ? physical ? t("Rolled with your dice") : t("Rolled with the dashboard's dice")
224
+ : undefined
225
+ : undefined, hand: rollsHere && physical && !rolled && !closed && option.notation !== undefined
226
+ ? _jsx(HandDice, { notation: option.notation, id: `${key}-${item.options.indexOf(option)}`, onWrite: (faces) => onRoll(option, faces) })
227
+ : undefined, onChoose: () => choose(option) }, option.text));
228
+ }) }), rolled && _jsx("p", { class: "choice-note", children: t("A roll made stays.") }), full && !rolled && !closed && item.options.length > item.most && _jsx("p", { class: "choice-note", children: t("You chose {most}: take one off to choose another.", { most: item.most }) }), problem !== undefined && _jsx("p", { class: "choices-problem", role: "alert", children: problem })] }));
229
+ }
230
+ /** A choice's state beside its question: done, how many of how many, optional with none, or still to choose. */
231
+ function ItemState({ item }) {
232
+ if (settled(item)) {
233
+ return (_jsxs("span", { class: "choice-state done", children: [_jsx(Icon, { name: "check" }), t("Done")] }));
234
+ }
235
+ return _jsx("span", { class: item.least === 0 ? "choice-state optional" : "choice-state", children: stateWords(item) });
236
+ }
237
+ /** An option as a card: its mark and words, which choose it; the way to read the page it names; a roll's total, or the field for the player's own dice. */
238
+ function OptionCard({ id, option, role, checked, closed, tabIndex, read, href, total, about, hand, onChoose }) {
239
+ const opening = about ?? option.pages?.[0].opening;
240
+ const kinds = ["choice-card", checked ? "chosen" : "", closed && !checked ? "closed" : "", option.notation === undefined ? "" : "choice-roll", href === undefined ? "alone" : ""];
241
+ return (_jsxs("div", { class: kinds.filter((kind) => kind !== "").join(" "), children: [_jsxs("button", { type: "button", class: "choice-pick", role: role, "aria-checked": checked, "aria-disabled": closed ? true : undefined, tabIndex: tabIndex, "aria-labelledby": total === undefined ? `${id}-name` : `${id}-name ${id}-total`, "aria-describedby": opening === undefined || opening === "" ? undefined : `${id}-about`, onClick: onChoose, children: [_jsx("span", { class: role === "checkbox" ? "choice-mark square" : "choice-mark", "aria-hidden": "true", children: _jsx(Icon, { name: "check" }) }), _jsxs("span", { class: "choice-words", children: [_jsxs("strong", { id: `${id}-name`, class: option.notation === undefined ? undefined : "choice-dice", children: [option.notation !== undefined && _jsx(NotationIcons, { notation: option.notation }), _jsx("bdi", { children: option.label }), option.notation !== undefined && _jsx("bdi", { class: "num", children: shownNotation(option.notation) })] }), opening !== undefined && opening !== "" && _jsx("span", { class: "choice-about", id: `${id}-about`, children: opening })] }), total !== undefined && _jsx("span", { class: "choice-total num", id: `${id}-total`, children: total })] }), href !== undefined && option.pages !== undefined && (_jsx("a", { class: "icon-button choice-read tip-left", href: href, "data-name": option.pages[0].name, "aria-label": t("Read {name}", { name: option.label }), "data-tip": t("Read {name}", { name: option.label }), "aria-current": read ? "true" : undefined, children: _jsx(Icon, { name: "read" }) })), hand] }));
242
+ }
243
+ /** The field of a roll made with the player's own dice: a number for each die, as it landed, then Write. */
244
+ function HandDice({ notation, id, onWrite }) {
245
+ const dice = diceIn(notation).flatMap((kind) => Array.from({ length: Math.min(kind.count, 10) }, () => kind.sides));
246
+ const [values, setValues] = useState(() => dice.map(() => ""));
247
+ const [wrong, setWrong] = useState(false);
248
+ const [sending, setSending] = useState(false);
249
+ const range = (sides) => (sides === "F" ? [-1, 1] : [1, sides]);
250
+ const write = async (event) => {
251
+ event.preventDefault();
252
+ const faces = values.map((value) => Number(value.trim().replace("−", "-")));
253
+ const fits = faces.length > 0 && faces.every((face, index) => values[index].trim() !== "" && Number.isInteger(face) && face >= range(dice[index])[0] && face <= range(dice[index])[1]);
254
+ setWrong(!fits);
255
+ if (fits && !sending) {
256
+ setSending(true);
257
+ await onWrite(faces);
258
+ setSending(false);
259
+ }
260
+ };
261
+ return (_jsxs("form", { class: "choice-hand", onSubmit: (event) => void write(event), children: [_jsx("label", { for: `${id}-die-0`, children: t("With your own dice: what did you roll?") }), dice.map((sides, index) => (_jsx("input", { id: `${id}-die-${index}`, class: "num", inputMode: "numeric", maxLength: 4, placeholder: `${range(sides)[0]}–${range(sides)[1]}`, "aria-label": dice.length > 1 ? t("Die {n} of {count}", { n: index + 1, count: dice.length }) : undefined, "aria-invalid": wrong ? true : undefined, "aria-describedby": wrong ? `${id}-wrong` : undefined, value: values[index], onInput: (event) => {
262
+ const value = event.currentTarget.value;
263
+ setValues((before) => before.map((one, at) => (at === index ? value : one)));
264
+ } }, index))), _jsx("button", { type: "submit", class: "button", "aria-disabled": sending ? true : undefined, children: t("Write") }), wrong && _jsx("p", { class: "choices-problem", id: `${id}-wrong`, role: "alert", children: t("Write the number of each die, as it landed.") })] }));
265
+ }
266
+ /**
267
+ * A page an option names, read whole beside the choices or in their place: what it is for, its title, the way to choose it, the option's other pages, its
268
+ * text.
269
+ */
270
+ function ChoiceReader({ set, at, option, page, version, phone, link, closed, onPick }) {
271
+ const [text, setText] = useState();
272
+ const [problem, setProblem] = useState(false);
273
+ const reads = useRef(0);
274
+ const title = useRef(null);
275
+ const item = set.items[at];
276
+ const name = page.name;
277
+ const pages = option.pages ?? [];
278
+ const heading = page.name === pages[0]?.name ? option.label : page.title;
279
+ const key = `${idOf(set)}-reader`;
280
+ // Its whole text, read when it opens and again as the game changes, the last reading alone; its first sentence until then.
281
+ useEffect(() => {
282
+ const reading = ++reads.current;
283
+ readView(name).then((page) => {
284
+ if (reading === reads.current) {
285
+ setText(page.kind === "page" ? page.text : "");
286
+ setProblem(false);
287
+ }
288
+ }, () => reading === reads.current && setProblem(true));
289
+ }, [name, version]);
290
+ // Opened, its title has the focus, for a screen reader to read it; on a phone the page goes back to its top.
291
+ useEffect(() => {
292
+ title.current?.focus({ preventScroll: true });
293
+ if (phone === true) {
294
+ window.scrollTo({ top: 0 });
295
+ }
296
+ }, [name]);
297
+ if (item === undefined) {
298
+ return null;
299
+ }
300
+ const single = item.least === 1 && item.most === 1;
301
+ const checked = item.answer.includes(option.text);
302
+ const shut = closed || item.rolled !== undefined || (!single && !checked && item.answer.length >= item.most);
303
+ const count = single ? undefined : t("{count} of {most}", { count: item.answer.length, most: item.most });
304
+ return (_jsxs("article", { class: "browse-reader choices-reader", "aria-labelledby": `${key}-title`, children: [_jsxs("header", { class: "reader-head", children: [_jsxs("div", { children: [_jsxs("p", { class: "eyebrow", children: [_jsx("bdi", { children: item.question }), count !== undefined && _jsx("span", { class: "num", children: ` · ${count}` })] }), _jsx("h3", { id: `${key}-title`, tabIndex: -1, ref: title, dir: "auto", children: heading })] }), phone !== true && (_jsx("a", { class: "icon-button tip-left", href: choicesAddress(set.who), "aria-label": t("Close the page"), "data-tip": t("Close the page"), children: _jsx(Icon, { name: "close" }) }))] }), _jsx("p", { class: "reader-actions", children: single && checked
305
+ ? (_jsxs("span", { class: "choice-picked", children: [_jsx(Icon, { name: "check" }), t("Your choice")] }))
306
+ : (_jsxs("button", { type: "button", class: "button", "aria-disabled": shut ? true : undefined, onClick: () => !shut && onPick(single ? [option.text] : checked ? item.answer.filter((one) => one !== option.text) : [...item.answer, option.text]), children: [_jsx(Icon, { name: checked ? "minus" : "plus" }), checked ? t("Take {item} off", { item: option.label }) : t("Choose {name}", { name: option.label })] })) }), pages.length > 1 && (_jsx("nav", { class: "filter-chips choices-pages", "aria-label": t("The pages this option names"), children: pages.map((one) => (_jsx("a", { href: choicesAddress(set.who, one.name), "aria-current": one.name === page.name ? "page" : undefined, children: _jsx("bdi", { children: one.title }) }, one.name))) })), _jsxs("div", { class: "reader-text", children: [text === undefined && !problem && page.opening !== "" && _jsx("p", { children: page.opening }), text !== undefined && text.trim() !== "" && _jsx(Markdown, { text: text, link: link }), text !== undefined && text.trim() === "" && _jsx("p", { children: page.opening }), problem && _jsx("p", { class: "choices-none", children: t("This page could not be read now: try again in a moment.") })] })] }));
307
+ }
308
+ /** Whether a choice is answered as it allows: options enough, and the roll made when its option rolls. */
309
+ function answered(item) {
310
+ const rolls = item.answer.some((text) => item.options.find((option) => option.text === text)?.notation !== undefined);
311
+ return item.answer.length >= item.least && (!rolls || item.rolled !== undefined);
312
+ }
313
+ /** Whether a choice is done: answered with something picked; an optional one left empty is not, nor missing. */
314
+ function settled(item) {
315
+ return answered(item) && item.answer.length > 0;
316
+ }
317
+ /** A choice's state in words: done, how many of how many, optional, or to choose. */
318
+ function stateWords(item) {
319
+ if (settled(item)) {
320
+ return t("Done");
321
+ }
322
+ if (item.least === 0 && item.answer.length === 0) {
323
+ return t("Optional");
324
+ }
325
+ return item.most > 1 ? t("{count} of {most}", { count: item.answer.length, most: item.most }) : t("To choose");
326
+ }
327
+ /** The option of a set whose page is open, by the page's name, with its choice and that page; none when no option names it. */
328
+ function openOption(set, name) {
329
+ const named = (exact) => set.items.flatMap((item, index) => item.options.flatMap((option) => (option.pages ?? []).filter((page) => (exact ? page.name === name : foldedText(page.name) === foldedText(name))).map((page) => ({ item: index, option, page }))))[0];
330
+ return named(true) ?? named(false);
331
+ }
332
+ /** Where a link of an option's page leads: to a page an option of the set names; any other stays words. */
333
+ function optionLinks(set) {
334
+ const pages = new Map(set.items.flatMap((item) => item.options.flatMap((option) => (option.pages ?? []).map((page) => [foldedText(page.name), page.name]))));
335
+ return (name) => {
336
+ const page = pages.get(foldedText(name));
337
+ return page === undefined ? undefined : choicesAddress(set.who, page);
338
+ };
339
+ }
340
+ /** A set's id as the start of its elements' ids. */
341
+ function idOf(set) {
342
+ return `choices-${set.id.replace(/[^\w-]/g, "")}`;
343
+ }
@@ -1,4 +1,4 @@
1
- <!-- Translated from en.md, part by part, by npm run translate: c38df721 53ff5eaa 9f1774ef c64748a2 019e9516 8e136927 95c609b6 423af5fa 17577253 4c3ea82e 2731ea0e 59c1a762. Change the English, then run it again. -->
1
+ <!-- Translated from en.md, paragraph by paragraph, by npm run translate: cdcc612c,e51b18d7,be38a186 f2f35057,51f49a5b 128c5761,5e6cbafc,48febcc7,f0f71376,b1381f21,cb3f91d5 5faea867,7780116a,afad321d,99406ef2,f831ecd8,b6a6bfff,b5544596,5c016bb1,3afa0abc,ef6b72c1,bc923cc3,07c079ea,30f9af2f,60051919,8619db5f,06d7d789,e6f82f9e,6def7d66,f27372ca,d904fdec,8da0dbd5,197704ab,de62cd09,f7bd4d35,56b73d9b,d9fbeec2,b8c831ca,cb3f91d5 09eaf555,63d0c1fb,27c765d2,46692547,e2d161a6,25f9bdf8,d8c01f15,b0846f60,602a5e46,6fee496f,71124663,4bed5644,c2bbeff9,3de0391e,15e36217,cb7d8189,b2a29c8a,056b4e29,2ef22287,d61653a8,e47ab79b,f4c26681,20018bab,6c58220c,5f7b18e6,6a64e757,ad3fa941,57283bd2,e9fa262a,44639926,86179abe,323d8fa3,f8d6b2fd,18bc17d2,3bbb14f4,2b2d7c37,65ff2775,623c2986,0fac97e5,d3afc486,cb3f91d5 ec2eeb06,92e343cc,aa0e26a1,da0fad21,cb3f91d5 5dafa85b,c5ec9f44,2e849e73,35a85f2e,607c7f74,95ffeabc,7687ded0,4ee5ae41,fd2934d1,177ddff0,025009be,c8315e19,cb3f91d5 40941750,f3b2d1f6,cb3f91d5 30c03e82,209b159b,6ea1911c,b8e71497,32482cb4,65c75baa,cb3f91d5 eac34391,4ee44b3b,487e04c0,c6ebe0c0,cb3f91d5 2f86bef9,9402592c,cb3f91d5 519ce5ee,de58bc03,b830ae6c,697b0622,180f77d8,e0f88bdb,1e0ccfed,05fde17f,5070d986,891d9bc7,5b0bb1d2,600db53a,6b115391,5db3836c,252805d8,df64a3bb,e214ff4a. Change the English, then run it again. -->
2
2
  # RPG Engine: الدليل الكامل
3
3
 
4
4
  يتيح لك **RPG Engine** لعب لعبة أدوار على الطاولة مع **ذكاء اصطناعي في دور مدير اللعبة**. تتحدث مع مدير اللعبة في **محادثة**. أما RPG Engine فيعمل خلف الكواليس: **يتذكر العالم**، و**يرمي النرد**، و**يمسك الحسابات**. بجانب المحادثة تُبقي صفحة مفتوحة في المتصفح، هي **لوحة التحكم**، وفيها ورقة شخصيتك والنرد والخرائط وسجلك.
@@ -9,8 +9,8 @@
9
9
 
10
10
  1. ثبّت **Node.js** من [nodejs.org](https://nodejs.org) (نسخة LTS).
11
11
  2. ثبّت **وكيل ذكاء اصطناعي**، وهو البرنامج الذي يعمل فيه مدير اللعبة، وسجّل الدخول: مثل Claude Code أو Codex ([2.4](#24-connect-your-ai)).
12
- 3. في الطرفية، ثبّت RPG Engine: `npm install -g rpg-engine`.
13
- 4. أنشئ حملة: `rpg init "The Salt Isles"`.
12
+ 3. في طرفية جديدة، فُتحت بعد تثبيت Node.js، ثبّت RPG Engine: `npm install -g rpg-engine`. إذا ظهر في Windows أن تشغيل السكربتات معطّل، فاكتب مرة واحدة `Set-ExecutionPolicy -Scope CurrentUser RemoteSigned`، وأجب بنعم، ثم أعد المحاولة.
13
+ 4. افتح الطرفية في المجلد الذي تحفظ فيه ألعابك (انقر عليه بزر الفأرة الأيمن، **فتح في Terminal**)، وأنشئ حملة، واكتب اسمها دائمًا: `rpg init "The Salt Isles"`. يرد RPG Engine بسطرين بالإنجليزية: كل شيء على ما يرام.
14
14
  5. ادخل المجلد الجديد بالأمر `cd "The Salt Isles"`، ثم شغّل وكيلك فيه: `claude` لـ Claude Code، و`codex` لـ Codex. أجب بنعم عندما يسأل هل تثق بالمجلد ([2.4](#24-connect-your-ai))، ثم اكتب *مرحبًا! لنبدأ.* يرد مدير اللعبة برابط لوحة التحكم.
15
15
 
16
16
  ## 1. ما هو RPG Engine <!-- icon: about -->
@@ -39,7 +39,7 @@
39
39
 
40
40
  - حاسوب بنظام Windows أو macOS أو Linux، ومتصفح ويب.
41
41
  - **Node.js 24** أو أحدث، من [nodejs.org](https://nodejs.org). يأتي معه `npm`، وهو الذي يثبّت RPG Engine.
42
- - **طرفية**: في Windows، Terminal أو PowerShell. وفي macOS، Terminal. لفتح طرفية داخل مجلد، انقر على المجلد بزر الفأرة الأيمن واختر **فتح في Terminal** (Windows) أو **الخدمات > محطة طرفية جديدة في المجلد** (macOS).
42
+ - **طرفية**: في Windows، Terminal أو PowerShell. وفي macOS، Terminal. لفتح طرفية داخل مجلد، انقر على المجلد بزر الفأرة الأيمن واختر **فتح في Terminal** (Windows) أو **الخدمات > محطة طرفية جديدة في المجلد** (macOS). إذا ظهر في Windows أن تشغيل السكربتات معطّل، فاكتب مرة واحدة `Set-ExecutionPolicy -Scope CurrentUser RemoteSigned` وأجب بنعم.
43
43
  - **وكيل ذكاء اصطناعي** يؤدي دور مدير اللعبة ([2.4](#24-connect-your-ai))، مع **أكبر نموذج** يقدمه. النموذج الصغير أسهل في الإقناع بكشف الأسرار أو بتجاوز القواعد.
44
44
 
45
45
  ### 2.2 التثبيت
@@ -48,7 +48,7 @@
48
48
  npm install -g rpg-engine
49
49
  ```
50
50
 
51
- الأمر `rpg --version` يتحقق من نجاح التثبيت. تستخدم `rpg` مرة واحدة لكل حملة، لإنشائها. بعد ذلك يشغّل وكيلك RPG Engine من تلقاء نفسه.
51
+ الأمر `rpg --version` يتحقق من نجاح التثبيت. إذا عرض npm تحديث نفسه، فيمكنك تجاهل ذلك. تستخدم `rpg` مرة واحدة لكل حملة، لإنشائها. بعد ذلك يشغّل وكيلك RPG Engine من تلقاء نفسه. الأمر `rpg` وحده لا يفتح شيئًا: مدير اللعبة هو من يعطيك لوحة التحكم.
52
52
 
53
53
  ### 2.3 إنشاء حملة
54
54
 
@@ -58,13 +58,13 @@ npm install -g rpg-engine
58
58
  rpg init "The Salt Isles"
59
59
  ```
60
60
 
61
- ينشئ هذا المجلد `The Salt Isles` وفيه حملة جديدة. ادخل إليه بالأمر `cd "The Salt Isles"`. تذكّر مكانه، فستعود إليه في كل مرة تلعب فيها. أما كل شيء آخر فتختاره لاحقًا، في الدردشة أو في لوحة المتابعة. الأمر `rpg init --help` يعرض الخيارات التي يمكن تحديدها الآن، مثل `--language it` أو `--difficulty hard`.
61
+ ينشئ هذا المجلد `The Salt Isles` وفيه حملة جديدة. ادخل إليه بالأمر `cd "The Salt Isles"`. اكتب الاسم دائمًا: بدونه يصبح المجلد الذي أنت فيه هو الحملة، إلى جانب كل ما فيه أصلًا. تذكّر مكانه، فستعود إليه في كل مرة تلعب فيها. أما كل شيء آخر فتختاره لاحقًا، في الدردشة أو في لوحة التحكم.
62
62
 
63
63
  لا يستطيع مدير اللعبة إنشاء الحملة عنك. قبل `init` لا يوجد ما يدل وكيلك على مكان RPG Engine.
64
64
 
65
65
  ### 2.4 ربط الذكاء الاصطناعي
66
66
 
67
- يعمل مدير اللعبة داخل **وكيل ذكاء اصطناعي**. هو تطبيق ذكاء اصطناعي، في الطرفية أو على سطح المكتب، يستطيع العمل مع الملفات على حاسوبك، مثل Claude Code أو Codex. الدردشة العادية مثل claude.ai أو ChatGPT، أو تطبيق الهاتف، لا تكفي. فمدير اللعبة يحتاج إلى الوصول إلى ملفات الحملة على حاسوبك. لكل وكيل خطته وتسجيل دخوله: Claude Code يحتاج إلى خطة Claude مدفوعة، وCodex إلى تسجيل دخول ChatGPT. تثبّت الوكيل مرة واحدة، من صفحته: [Claude Code](https://code.claude.com/docs/en/setup)، [Codex](https://learn.chatgpt.com/docs/codex/cli).
67
+ يعمل مدير اللعبة داخل **وكيل ذكاء اصطناعي**. هو تطبيق ذكاء اصطناعي، في الطرفية أو على سطح المكتب، يستطيع العمل مع الملفات على حاسوبك، مثل Claude Code أو Codex. الدردشة العادية مثل claude.ai أو ChatGPT، أو تطبيق الهاتف، لا تكفي. فمدير اللعبة يحتاج إلى الوصول إلى ملفات الحملة على حاسوبك. لكل وكيل خطته وتسجيل دخوله: Claude Code يحتاج إلى خطة Claude مدفوعة، وCodex إلى تسجيل دخول ChatGPT. تثبّت الوكيل مرة واحدة، من صفحته: [Claude Code](https://code.claude.com/docs/en/setup)، [Codex](https://developers.openai.com/codex).
68
68
 
69
69
  - **Claude Code**: في مجلد الحملة اكتب `claude`. عندما يسأل هل تثق بالمجلد، اختر **Yes, I trust this folder**. انتبه: الجواب المحدد مسبقًا هو *No, exit*. في الحملة أيضًا خطّاف صغير، `rpg --listen`، لا يظهر في هذا السؤال. وهو يخبر مدير اللعبة فورًا حين تتصرف من لوحة المتابعة.
70
70
  - **Codex**: في مجلد الحملة اكتب `codex`، ووافق عندما يسأل هل تثق بالمجلد. وفي تطبيقه المكتبي، تأكد من الإعدادات أن الذاكرة معطلة لدردشات اللعبة.
@@ -145,7 +145,7 @@ rpg init "The Salt Isles"
145
145
 
146
146
  ### 3.4 الوقت والسفر والعالم المتحرك
147
147
 
148
- يحتفظ RPG Engine بالتاريخ، ولا يمرّ وقت بين الجلسات. قل إنكم ترتاحون، *نأخذ راحة طويلة*، وحين يوافق مدير اللعبة تعيد الراحة ما يجب أن تعيده. في الراحة القصيرة قد يسألك مدير اللعبة على لوحة التحكم كم من نرد نقاط الإصابة تصرف: ارمِها واحدًا بعد الآخر، وانظر كم يشفي كل منها، وتوقف متى شئت. قل إلى أين تذهبون، *نسلك الطريق شمالًا إلى Rocca*، فيحسب RPG Engine الطريق والمسافة والأيام، ويتوقف عند وقوع شيء في الطريق. تُحسب النقود بعملات اللعبة، مع الباقي.
148
+ يحتفظ RPG Engine بالتاريخ. بين الجلسات يتوقف وقت اللعبة، إلا إذا اخترتَ في **الإعدادات** أن تتركه يمرّ، كأن يمرّ يوم من أيام اللعبة عن كل أسبوع غياب، أو طلبتَ ذلك من مدير اللعبة. قل إنكم ترتاحون، *نأخذ راحة طويلة*، وحين يوافق مدير اللعبة تعيد الراحة ما يجب أن تعيده. في الراحة القصيرة قد يسألك مدير اللعبة على لوحة التحكم كم من نرد نقاط الإصابة تصرف: ارمِها واحدًا بعد الآخر، وانظر كم يشفي كل منها، وتوقف متى شئت. قل إلى أين تذهبون، *نسلك الطريق شمالًا إلى Rocca*، فيحسب RPG Engine الطريق والمسافة والأيام، ويتوقف عند وقوع شيء في الطريق. تُحسب النقود بعملات اللعبة، مع الباقي.
149
149
 
150
150
  للأشرار خطط لها مواعيد نهائية. في كل يوم جديد يحرّك مدير اللعبة التهديدات التي تقدّم بها الوقت، وترى علاماتها، لا الساعة نفسها.
151
151
 
@@ -203,7 +203,7 @@ rpg init "The Salt Isles"
203
203
 
204
204
  صفحة على حاسوبك الخاص، لا تُفتح إلا في متصفح هذا الحاسوب، وتبقى حية ما دامت المحادثة مفتوحة. عند إغلاق المحادثة تعرض *Not connected*، وتعود من تلقاء نفسها مع المحادثة التالية.
205
205
 
206
- - **الفريق**: ورقة شخصيتك وأوراق رفاقك. انقر على رقم لترمي به. مرّر المؤشر فوقه لترى من أين جاء، وحين يشير سهم إلى حجر النرد، لترى ما يحسّن الرمية أو يضعفها. بجانبه تظهر الرميات.
206
+ - **الفريق**: ورقة شخصيتك وأوراق رفاقك. انقر على رقم لترمي به. مرّر المؤشر فوقه لترى من أين جاء، وحين يشير سهم إلى حجر النرد، لترى ما يحسّن الرمية أو يضعفها. وحين يُعدّ مدير اللعبة خيارات لك، كما عند بلوغ مستوى جديد، يفتحها إشعار على الورقة: اختر متى شئت، واقرأ الصفحات التي تسمّيها الخيارات، وارمِ حيث يتطلب الخيار رمية، ثم أكّد. وتستمر القصة في هذه الأثناء. بجانبه تظهر الرميات.
207
207
  - **المشهد**: أين أنت، وصورته وخريطته، ومن حاضر فيه، وما الذي يجري. وفي القتال: الأدوار وبطاقة شخصيتك.
208
208
  - **السجل**: المهمات، والقصة، ويوميات رفاقك، وملاحظاتك.
209
209
  - **العالم**: خريطة العالم، وما تعرفه شخصيتك، والوثائق التي عُثر عليها، والتقويم.
@@ -304,12 +304,14 @@ rpg init "The Salt Isles"
304
304
 
305
305
  **يبدو أن مدير اللعبة لا يعرف اللعبة.** لم يحمّل وكيلك RPG Engine. تحقق من أنك شغّلته في مجلد الحملة وأنك وثقت به. في Claude Code، اكتب `/mcp` وأعد ربط `rpg`. في Codex، يجب أن يعرض الأمر `codex mcp list` في مجلد الحملة `rpg`. وإن لم يُعثر على `rpg --version`، ثبّت RPG Engine من جديد ([2.2](#22-install)).
306
306
 
307
+ **لا يجد Windows الأمر `claude`.** يخبرك مثبّته بذلك في ملاحظة صفراء، مع المجلد الذي وُضع فيه: أضف ذلك المجلد إلى PATH (خصائص النظام > متغيرات البيئة)، ثم افتح طرفية جديدة.
308
+
307
309
  **التحديث.** شغّل `npm install -g rpg-engine` مرة أخرى، ثم افتح محادثة جديدة: مدير اللعبة العامل يحتفظ بالإصدار الذي بدأ به.
308
310
 
309
311
  **يتذكر مدير اللعبة شيئًا ألغيته.** افتح محادثة جديدة واضغط **فتحت محادثة جديدة** في نقاط الحفظ.
310
312
 
311
313
  **لا تظهر صور.** الإعدادات > الصور تبيّن هل يستطيع هذا الحاسوب صنعها، وكيف.
312
314
 
313
- **يفشل التثبيت، أو لا يبدأ `rpg`.** يجب أن يعرض `node --version` الإصدار 22 أو أحدث. في Windows، أبقِ RPG Engine وحملاتك بعيدًا عن المسارات التي تحتوي على `&`.
315
+ **يفشل التثبيت، أو لا يبدأ `rpg`.** يجب أن يعرض `node --version` الإصدار 24 أو أحدث. إذا ظهر في Windows أن تشغيل السكربتات معطّل، فراجع [2.1](#21-what-you-need). في Windows، أبقِ RPG Engine وحملاتك بعيدًا عن المسارات التي تحتوي على `&`.
314
316
 
315
317
  **تغيّر رابط لوحة التحكم.** أخذ برنامج آخر العنوان المعتاد. يعطيك مدير اللعبة الرابط الجديد.
@@ -1,4 +1,4 @@
1
- <!-- Translated from en.md, part by part, by npm run translate: c38df721 53ff5eaa 9f1774ef c64748a2 019e9516 8e136927 95c609b6 423af5fa 17577253 4c3ea82e 2731ea0e 59c1a762. Change the English, then run it again. -->
1
+ <!-- Translated from en.md, paragraph by paragraph, by npm run translate: cdcc612c,e51b18d7,be38a186 f2f35057,51f49a5b 128c5761,5e6cbafc,48febcc7,f0f71376,b1381f21,cb3f91d5 5faea867,7780116a,afad321d,99406ef2,f831ecd8,b6a6bfff,b5544596,5c016bb1,3afa0abc,ef6b72c1,bc923cc3,07c079ea,30f9af2f,60051919,8619db5f,06d7d789,e6f82f9e,6def7d66,f27372ca,d904fdec,8da0dbd5,197704ab,de62cd09,f7bd4d35,56b73d9b,d9fbeec2,b8c831ca,cb3f91d5 09eaf555,63d0c1fb,27c765d2,46692547,e2d161a6,25f9bdf8,d8c01f15,b0846f60,602a5e46,6fee496f,71124663,4bed5644,c2bbeff9,3de0391e,15e36217,cb7d8189,b2a29c8a,056b4e29,2ef22287,d61653a8,e47ab79b,f4c26681,20018bab,6c58220c,5f7b18e6,6a64e757,ad3fa941,57283bd2,e9fa262a,44639926,86179abe,323d8fa3,f8d6b2fd,18bc17d2,3bbb14f4,2b2d7c37,65ff2775,623c2986,0fac97e5,d3afc486,cb3f91d5 ec2eeb06,92e343cc,aa0e26a1,da0fad21,cb3f91d5 5dafa85b,c5ec9f44,2e849e73,35a85f2e,607c7f74,95ffeabc,7687ded0,4ee5ae41,fd2934d1,177ddff0,025009be,c8315e19,cb3f91d5 40941750,f3b2d1f6,cb3f91d5 30c03e82,209b159b,6ea1911c,b8e71497,32482cb4,65c75baa,cb3f91d5 eac34391,4ee44b3b,487e04c0,c6ebe0c0,cb3f91d5 2f86bef9,9402592c,cb3f91d5 519ce5ee,de58bc03,b830ae6c,697b0622,180f77d8,e0f88bdb,1e0ccfed,05fde17f,5070d986,891d9bc7,5b0bb1d2,600db53a,6b115391,5db3836c,252805d8,df64a3bb,e214ff4a. Change the English, then run it again. -->
2
2
  # RPG Engine: kompletní průvodce
3
3
 
4
4
  **RPG Engine** ti umožní hrát stolní hru na hrdiny s **AI jako Pánem jeskyně**. S Pánem jeskyně si povídáš v **chatu**. RPG Engine pracuje v pozadí: **pamatuje si svět**, **hází kostkami** a **vede účty**. Vedle chatu máš v prohlížeči otevřenou stránku, **dashboard**, s deníkem postavy, kostkami, mapami a kronikou.
@@ -9,8 +9,8 @@ Tento průvodce je pro hráče: programovat umět nemusíš.
9
9
 
10
10
  1. Nainstaluj **Node.js** z [nodejs.org](https://nodejs.org) (verze LTS).
11
11
  2. Nainstaluj **AI agenta**, program, ve kterém Pán jeskyně běží, a přihlas se: například Claude Code nebo Codex ([2.4](#24-connect-your-ai)).
12
- 3. V terminálu nainstaluj RPG Engine: `npm install -g rpg-engine`.
13
- 4. Vytvoř kampaň: `rpg init "The Salt Isles"`.
12
+ 3. V novém terminálu, otevřeném až po instalaci Node.js, nainstaluj RPG Engine: `npm install -g rpg-engine`. Pokud Windows odpoví, že spouštění skriptů je zakázané, napiš jednou `Set-ExecutionPolicy -Scope CurrentUser RemoteSigned`, odpověz ano a zkus to znovu.
13
+ 4. Otevři terminál ve složce, kam ukládáš své hry (klikni na ni pravým tlačítkem a zvol **Otevřít v Terminálu**), a vytvoř kampaň, vždy i s jejím názvem: `rpg init "The Salt Isles"`. RPG Engine odpoví dvěma řádky v angličtině: vše je v pořádku.
14
14
  5. Přejdi do nové složky, `cd "The Salt Isles"`, a spusť tam svého agenta: `claude` pro Claude Code, `codex` pro Codex. Když se zeptá, jestli složce důvěřuješ, potvrď ([2.4](#24-connect-your-ai)). Pak napiš *Ahoj! Pojďme začít.* Pán jeskyně odpoví odkazem na tvůj dashboard.
15
15
 
16
16
  ## 1. O hře RPG Engine <!-- icon: about -->
@@ -39,7 +39,7 @@ Hra přichází jako herní systém, balíček, který Pán jeskyně nainstaluje
39
39
 
40
40
  - Počítač s Windows, macOS nebo Linuxem a webový prohlížeč.
41
41
  - **Node.js 24** nebo novější, z [nodejs.org](https://nodejs.org). Přináší `npm`, kterým se instaluje RPG Engine.
42
- - **Terminál**: ve Windows Terminál nebo PowerShell, v macOS Terminál. Terminál ve složce otevřeš tak, že na složku klikneš pravým tlačítkem a zvolíš **Otevřít v Terminálu** (Windows) nebo **Služby > Nový terminál ve složce** (macOS).
42
+ - **Terminál**: ve Windows Terminál nebo PowerShell, v macOS Terminál. Terminál ve složce otevřeš tak, že na složku klikneš pravým tlačítkem a zvolíš **Otevřít v Terminálu** (Windows) nebo **Služby > Nový terminál ve složce** (macOS). Pokud Windows odpoví, že spouštění skriptů je zakázané, napiš jednou `Set-ExecutionPolicy -Scope CurrentUser RemoteSigned` a odpověz ano.
43
43
  - **AI agent** pro Pána jeskyně ([2.4](#24-connect-your-ai)) s **největším modelem**, který nabízí: malý model se snáze nechá přemluvit k prozrazení tajemství nebo k ohnutí pravidel.
44
44
 
45
45
  ### 2.2 Instalace
@@ -48,7 +48,7 @@ Hra přichází jako herní systém, balíček, který Pán jeskyně nainstaluje
48
48
  npm install -g rpg-engine
49
49
  ```
50
50
 
51
- Příkaz `rpg --version` ověří, že instalace proběhla. Příkaz `rpg` použiješ jednou pro každou kampaň, když ji vytváříš. Potom už RPG Engine spouští tvůj agent sám.
51
+ Příkaz `rpg --version` ověří, že instalace proběhla. Pokud ti npm nabídne, že se aktualizuje, můžeš to ignorovat. Příkaz `rpg` použiješ jednou pro každou kampaň, když ji vytváříš. Potom už RPG Engine spouští tvůj agent sám. Samotný `rpg` nic neotevře: dashboard ti dá Pán jeskyně.
52
52
 
53
53
  ### 2.3 Vytvoření kampaně
54
54
 
@@ -58,13 +58,13 @@ Otevři terminál ve složce, kam ukládáš své hry ([2.1](#21-what-you-need)
58
58
  rpg init "The Salt Isles"
59
59
  ```
60
60
 
61
- Tím vznikne složka `The Salt Isles` s novou kampaní. Přejdi do ní příkazem `cd "The Salt Isles"`. Zapamatuj si, kde leží: vracíš se do ní při každé hře. Vše ostatní zvolíš později, v chatu nebo na dashboardu. Příkaz `rpg init --help` vypíše volby, kterými můžeš některé věci určit hned, například `--language it` nebo `--difficulty hard`.
61
+ Tím vznikne složka `The Salt Isles` s novou kampaní. Přejdi do ní příkazem `cd "The Salt Isles"`. Název piš vždy: bez něj se kampaní stane složka, ve které právě jsi, vedle všeho, co už obsahuje. Zapamatuj si, kde leží: vracíš se do ní při každé hře. Vše ostatní zvolíš později, v chatu nebo na dashboardu.
62
62
 
63
63
  Pán jeskyně kampaň za tebe vytvořit nemůže: před příkazem `init` nic neříká tvému agentovi, kde RPG Engine najde.
64
64
 
65
65
  ### 2.4 Připojení AI
66
66
 
67
- Pán jeskyně běží v **AI agentovi**: je to AI aplikace, v terminálu nebo na ploše, která umí pracovat se soubory v tvém počítači, například Claude Code nebo Codex. Obyčejný chat jako claude.ai nebo ChatGPT, případně aplikace v telefonu, nestačí: Pán jeskyně se musí dostat k souborům kampaně v tvém počítači. Každý agent potřebuje vlastní tarif a přihlášení: Claude Code placený tarif Claude, Codex přihlášení do ChatGPT. Nainstaluješ ho jednou, z jeho vlastní stránky: [Claude Code](https://code.claude.com/docs/en/setup), [Codex](https://learn.chatgpt.com/docs/codex/cli).
67
+ Pán jeskyně běží v **AI agentovi**: je to AI aplikace, v terminálu nebo na ploše, která umí pracovat se soubory v tvém počítači, například Claude Code nebo Codex. Obyčejný chat jako claude.ai nebo ChatGPT, případně aplikace v telefonu, nestačí: Pán jeskyně se musí dostat k souborům kampaně v tvém počítači. Každý agent potřebuje vlastní tarif a přihlášení: Claude Code placený tarif Claude, Codex přihlášení do ChatGPT. Nainstaluješ ho jednou, z jeho vlastní stránky: [Claude Code](https://code.claude.com/docs/en/setup), [Codex](https://developers.openai.com/codex).
68
68
 
69
69
  - **Claude Code**: ve složce kampaně napiš `claude`. Když se zeptá, jestli složce důvěřuješ, zvol **Yes, I trust this folder**. Pozor, předvolená odpověď je *No, exit*. Kampaň má také malý hook, `rpg --listen`, který otázka neukazuje: okamžitě sdělí Pánu jeskyně, když něco uděláš na dashboardu.
70
70
  - **Codex**: ve složce kampaně napiš `codex` a na otázku, jestli složce důvěřuješ, odpověz ano. V jeho desktopové aplikaci zkontroluj v nastavení, že jsou paměti pro chaty hry vypnuté.
@@ -145,7 +145,7 @@ V boji Pán jeskyně vypráví každý tah, který není tvůj, a zastaví se ta
145
145
 
146
146
  ### 3.4 Čas, cestování a svět, který se hýbe
147
147
 
148
- RPG Engine hlídá datum. Mezi sezeními neběží čas. Řekni, že odpočíváš, *Dopřejeme si dlouhý odpočinek*, a jakmile Pán jeskyně souhlasí, odpočinek vrátí, co má. Při krátkém odpočinku se tě Pán jeskyně může na dashboardu zeptat, kolik kostek životů utratíš: hoď je po jedné, uvidíš, kolik každá vyléčí, a přestaň, kdy chceš. Řekni, kam jdeš, *Vydáme se po cestě na sever k Rocce*, a RPG Engine spočítá cestu, vzdálenost i dny. Zastaví se, když se cestou něco stane. Peníze se počítají v herních mincích, včetně drobných.
148
+ RPG Engine hlídá datum. Mezi sezeními herní čas stojí, pokud v **Nastavení** nezvolíš, že má běžet, například den ve hře za každý týden pryč, nebo o to nepožádáš Pána jeskyně. Řekni, že odpočíváš, *Dopřejeme si dlouhý odpočinek*, a jakmile Pán jeskyně souhlasí, odpočinek vrátí, co má. Při krátkém odpočinku se tě Pán jeskyně může na dashboardu zeptat, kolik kostek životů utratíš: hoď je po jedné, uvidíš, kolik každá vyléčí, a přestaň, kdy chceš. Řekni, kam jdeš, *Vydáme se po cestě na sever k Rocce*, a RPG Engine spočítá cestu, vzdálenost i dny. Zastaví se, když se cestou něco stane. Peníze se počítají v herních mincích, včetně drobných.
149
149
 
150
150
  Padouši mají plány s termíny. Každý nový den Pán jeskyně posune hrozby, které čas pokročil, a ty vidíš jejich znamení, nikdy ne samotné hodiny.
151
151
 
@@ -203,7 +203,7 @@ Každé nastavení lze změnit, v chatu nebo v **Nastavení**. Rozhodnutí, kter
203
203
 
204
204
  Stránka na tvém počítači, kterou otevřeš jen v prohlížeči na tomto počítači. Funguje, dokud je chat otevřený. Když se chat zavře, zobrazí *Not connected*. S dalším chatem se vrátí sama.
205
205
 
206
- - **Družina**: tvůj deník postavy a deníky tvých společníků. Kliknutím na číslo si hodíš. Když na něj najedeš myší, uvidíš, odkud se bere, a pokud šipka u kostky něco označuje, také co hod zlepšuje nebo zhoršuje. Vedle jsou hody.
206
+ - **Družina**: tvůj deník postavy a deníky tvých společníků. Kliknutím na číslo si hodíš. Když na něj najedeš myší, uvidíš, odkud se bere, a pokud šipka u kostky něco označuje, také co hod zlepšuje nebo zhoršuje. Když pro tebe Pán jeskyně připraví volby, například při novém levelu, otevřeš je oznámením v deníku postavy. Vybereš, kdy chceš, přečteš si stránky, které možnosti uvádějí, hodíš si, kde to možnost vyžaduje, a pak volbu potvrdíš. Příběh mezitím pokračuje. Vedle jsou hody.
207
207
  - **Scéna**: kde jsi, obrázek a mapa místa, kdo tam je a co se děje. V boji tu najdeš tahy a kartu své postavy.
208
208
  - **Kronika**: úkoly, příběh, deníky tvých společníků a tvé poznámky.
209
209
  - **Svět**: mapa světa, co tvá postava ví, nalezené dokumenty a kalendář.
@@ -304,12 +304,14 @@ Každý příkaz, který Pán jeskyně používá, jde spustit i ve složce kamp
304
304
 
305
305
  **Pán jeskyně jako by hru neznal.** Tvůj agent nenačetl RPG Engine. Zkontroluj, že jsi ho spustil(a) ve složce kampaně a že jsi jí důvěřoval(a). V Claude Code napiš `/mcp` a znovu připoj `rpg`. V Codexu musí `codex mcp list` ve složce kampaně ukázat `rpg`. Pokud se `rpg --version` nenajde, nainstaluj RPG Engine znovu ([2.2](#22-install)).
306
306
 
307
+ **Windows nenajde `claude`.** Instalátor to oznámí ve žluté poznámce a uvede složku, do které se nainstaloval: přidej tu složku do PATH (Vlastnosti systému > Proměnné prostředí) a pak otevři nový terminál.
308
+
307
309
  **Aktualizace.** Spusť znovu `npm install -g rpg-engine` a potom otevři nový chat: běžící Pán jeskyně si drží verzi, se kterou začal.
308
310
 
309
311
  **Pán jeskyně si pamatuje něco, co jsem vrátil(a) zpět.** Otevři nový chat a v Uložených hrách stiskni **Nový chat otevřen**.
310
312
 
311
313
  **Neobjevují se žádné obrázky.** Nastavení > Obrázky říká, jestli je tento počítač umí vytvářet, a jak.
312
314
 
313
- **Instalace selže, nebo `rpg` nechce začít.** `node --version` musí hlásit 22 nebo novější. Ve Windows nech RPG Engine a své kampaně mimo cesty, které obsahují `&`.
315
+ **Instalace selže, nebo `rpg` nechce začít.** `node --version` musí hlásit 24 nebo novější. Pokud Windows odpoví, že spouštění skriptů je zakázané, viz [2.1](#21-what-you-need). Ve Windows nech RPG Engine a své kampaně mimo cesty, které obsahují `&`.
314
316
 
315
317
  **Odkaz na dashboard se změnil.** Obvyklou adresu zabral jiný program. Nový odkaz ti dá Pán jeskyně.