@dotmon/core 0.1.0
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.
- package/LICENSE +21 -0
- package/dist/chunk-QBHMZDDB.js +358 -0
- package/dist/index.cjs +369 -0
- package/dist/index.d.cts +27 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +1 -0
- package/dist/locales/en.cjs +29 -0
- package/dist/locales/en.d.cts +7 -0
- package/dist/locales/en.d.ts +7 -0
- package/dist/locales/en.js +27 -0
- package/dist/locales/index.cjs +13 -0
- package/dist/locales/index.d.cts +11 -0
- package/dist/locales/index.d.ts +11 -0
- package/dist/locales/index.js +11 -0
- package/dist/locales/ja.cjs +29 -0
- package/dist/locales/ja.d.cts +7 -0
- package/dist/locales/ja.d.ts +7 -0
- package/dist/locales/ja.js +27 -0
- package/dist/render/index.cjs +628 -0
- package/dist/render/index.d.cts +42 -0
- package/dist/render/index.d.ts +42 -0
- package/dist/render/index.js +348 -0
- package/dist/stats-BMnyxbee.d.ts +17 -0
- package/dist/stats-Cs0yRJTk.d.cts +17 -0
- package/dist/types-CsVv0MnX.d.cts +12 -0
- package/dist/types-DYNij_HS.d.ts +12 -0
- package/dist/types-kWKrAd-B.d.cts +27 -0
- package/dist/types-kWKrAd-B.d.ts +27 -0
- package/package.json +67 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/hash.ts
|
|
4
|
+
function fnv1a(str) {
|
|
5
|
+
let hash = 2166136261;
|
|
6
|
+
for (let i = 0; i < str.length; i++) {
|
|
7
|
+
hash ^= str.charCodeAt(i);
|
|
8
|
+
hash = Math.imul(hash, 16777619);
|
|
9
|
+
}
|
|
10
|
+
return hash >>> 0;
|
|
11
|
+
}
|
|
12
|
+
function mulberry32(seed) {
|
|
13
|
+
let a = seed;
|
|
14
|
+
return () => {
|
|
15
|
+
a |= 0;
|
|
16
|
+
a = a + 1831565813 | 0;
|
|
17
|
+
let t = Math.imul(a ^ a >>> 15, 1 | a);
|
|
18
|
+
t = t + Math.imul(t ^ t >>> 7, 61 | t) ^ t;
|
|
19
|
+
return ((t ^ t >>> 14) >>> 0) / 4294967296;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// src/presets.ts
|
|
24
|
+
var presets = {
|
|
25
|
+
mochi: { connected: true, symmetric: true, outline: true, face: true, legs: "auto" },
|
|
26
|
+
retro: { connected: false, symmetric: true, outline: true, face: false, legs: "none" },
|
|
27
|
+
chaos: { connected: false, symmetric: false, outline: true, face: true, legs: "none" }
|
|
28
|
+
};
|
|
29
|
+
function resolveOptions(options = {}) {
|
|
30
|
+
const base = presets[options.preset ?? "mochi"];
|
|
31
|
+
return {
|
|
32
|
+
connected: options.connected ?? base.connected,
|
|
33
|
+
symmetric: options.symmetric ?? base.symmetric,
|
|
34
|
+
outline: options.outline ?? base.outline,
|
|
35
|
+
face: options.face ?? base.face,
|
|
36
|
+
legs: options.legs ?? base.legs
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function presetKeyFromOpts(o) {
|
|
40
|
+
if (o.connected && o.symmetric) return "mochi";
|
|
41
|
+
if (!o.connected && o.symmetric) return "retro";
|
|
42
|
+
if (!o.connected && !o.symmetric && o.outline && o.face) return "chaos";
|
|
43
|
+
return "custom";
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// src/stats.ts
|
|
47
|
+
var NATURE_IDS = [
|
|
48
|
+
"cheerful",
|
|
49
|
+
// ようき
|
|
50
|
+
"easygoing",
|
|
51
|
+
// のんびり
|
|
52
|
+
"timid",
|
|
53
|
+
// おくびょう
|
|
54
|
+
"stubborn",
|
|
55
|
+
// がんこ
|
|
56
|
+
"headstrong",
|
|
57
|
+
// いじっぱり
|
|
58
|
+
"gentle",
|
|
59
|
+
// おっとり
|
|
60
|
+
"playful",
|
|
61
|
+
// やんちゃ
|
|
62
|
+
"calm",
|
|
63
|
+
// れいせい
|
|
64
|
+
"shy",
|
|
65
|
+
// てれや
|
|
66
|
+
"hungry",
|
|
67
|
+
// はらぺこ
|
|
68
|
+
"sleepyhead",
|
|
69
|
+
// ねぼすけ
|
|
70
|
+
"whimsical"
|
|
71
|
+
// きまぐれ
|
|
72
|
+
];
|
|
73
|
+
function getStats(seed, options = {}) {
|
|
74
|
+
const o = resolveOptions(options);
|
|
75
|
+
const r = mulberry32(fnv1a(seed + "::status"));
|
|
76
|
+
const key = presetKeyFromOpts(o);
|
|
77
|
+
const tier = key === "chaos" ? 2 : key === "retro" ? 1 : 0;
|
|
78
|
+
const lo = [1, 38, 66][tier];
|
|
79
|
+
const hi = [19, 76, 99][tier];
|
|
80
|
+
const roll = () => Math.round(lo + r() * (hi - lo));
|
|
81
|
+
const lv = Math.max(1, roll());
|
|
82
|
+
const nature = NATURE_IDS[Math.floor(r() * NATURE_IDS.length)];
|
|
83
|
+
const hp = roll() * 8 + Math.floor(r() * 8);
|
|
84
|
+
const mp = roll() * 4 + Math.floor(r() * 4);
|
|
85
|
+
const atk = roll();
|
|
86
|
+
const def = roll();
|
|
87
|
+
const spd = roll();
|
|
88
|
+
const luck = Math.round(1 + r() * 98);
|
|
89
|
+
return { lv, nature, hp, mp, atk, def, spd, luck };
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// src/generate.ts
|
|
93
|
+
var SIZE = 16;
|
|
94
|
+
var HALF = 8;
|
|
95
|
+
function generateSvg(seed, options = {}) {
|
|
96
|
+
const o = resolveOptions(options);
|
|
97
|
+
const view = options.view ?? "front";
|
|
98
|
+
const frame = options.frame ?? 0;
|
|
99
|
+
const rand = mulberry32(fnv1a(seed));
|
|
100
|
+
const pick = (arr) => arr[Math.floor(rand() * arr.length)];
|
|
101
|
+
const g = Array.from({ length: SIZE }, () => new Array(SIZE).fill(0));
|
|
102
|
+
const hue = Math.floor(rand() * 12) * 30;
|
|
103
|
+
const sat = 55 + rand() * 25;
|
|
104
|
+
const lig = 55 + rand() * 12;
|
|
105
|
+
const top = 2 + Math.floor(rand() * 2);
|
|
106
|
+
const bottom = 12 + Math.floor(rand() * 2);
|
|
107
|
+
const height = bottom - top + 1;
|
|
108
|
+
if (o.connected) {
|
|
109
|
+
const widths = [];
|
|
110
|
+
let w = 2 + Math.floor(rand() * 2);
|
|
111
|
+
for (let i = 0; i < height; i++) {
|
|
112
|
+
const progress = i / height;
|
|
113
|
+
let step;
|
|
114
|
+
const r = rand();
|
|
115
|
+
if (progress < 0.6) step = r < 0.55 ? 1 : r < 0.85 ? 0 : -1;
|
|
116
|
+
else step = r < 0.35 ? 1 : r < 0.6 ? 0 : -1;
|
|
117
|
+
w = Math.max(1, Math.min(7, w + step));
|
|
118
|
+
widths.push(w);
|
|
119
|
+
}
|
|
120
|
+
for (let i = 1; i < height - 1; i++) {
|
|
121
|
+
if (rand() < 0.18 && widths[i] > 2) widths[i] -= 1;
|
|
122
|
+
}
|
|
123
|
+
for (let i = 0; i < height; i++) {
|
|
124
|
+
for (let x = HALF - widths[i]; x < HALF; x++) g[top + i][x] = 1;
|
|
125
|
+
}
|
|
126
|
+
} else {
|
|
127
|
+
for (let y = top; y <= bottom; y++) {
|
|
128
|
+
for (let x = 1; x < HALF; x++) {
|
|
129
|
+
if (rand() < 0.45) g[y][x] = 1;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
for (let y = 0; y < SIZE; y++) {
|
|
134
|
+
for (let x = 0; x < HALF; x++) {
|
|
135
|
+
if (o.symmetric) {
|
|
136
|
+
g[y][SIZE - 1 - x] = g[y][x];
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (!o.symmetric) {
|
|
141
|
+
for (let y = top; y <= bottom; y++) {
|
|
142
|
+
for (let x = HALF; x < SIZE - 1; x++) {
|
|
143
|
+
g[y][x] = rand() < 0.45 ? 1 : 0;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if (o.connected && o.symmetric && rand() < 0.55) {
|
|
148
|
+
const hornStyle = pick(["stub", "long", "ear"]);
|
|
149
|
+
let topRow = top;
|
|
150
|
+
while (topRow <= bottom && !g[topRow].some((v) => v)) topRow++;
|
|
151
|
+
const xs = [];
|
|
152
|
+
for (let x = 0; x < HALF; x++) if (g[topRow][x]) xs.push(x);
|
|
153
|
+
if (xs.length) {
|
|
154
|
+
const hx = xs[0] + (xs.length > 2 ? 1 : 0);
|
|
155
|
+
const len = hornStyle === "long" ? 2 : 1;
|
|
156
|
+
for (let d = 1; d <= len; d++) {
|
|
157
|
+
if (topRow - d >= 0) {
|
|
158
|
+
const col = hornStyle === "ear" ? 1 : 5;
|
|
159
|
+
g[topRow - d][hx] = col;
|
|
160
|
+
g[topRow - d][SIZE - 1 - hx] = col;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if (o.face) {
|
|
166
|
+
let topRow = 0;
|
|
167
|
+
while (topRow < SIZE && !g[topRow].some((v) => v === 1)) topRow++;
|
|
168
|
+
let botRow = SIZE - 1;
|
|
169
|
+
while (botRow > 0 && !g[botRow].some((v) => v === 1)) botRow--;
|
|
170
|
+
const eyeRow = Math.min(botRow - 2, topRow + Math.max(1, Math.round((botRow - topRow) * 0.32)));
|
|
171
|
+
const cols = [];
|
|
172
|
+
for (let x = 0; x < SIZE; x++) if (g[eyeRow][x] === 1) cols.push(x);
|
|
173
|
+
if (cols.length >= 1) {
|
|
174
|
+
const side = view === "left" || view === "right";
|
|
175
|
+
const cx = (SIZE - 1) / 2;
|
|
176
|
+
const eyeStyle = pick(["dot", "wide", "sleepy"]);
|
|
177
|
+
const stamp = (x) => {
|
|
178
|
+
if (view === "back") return;
|
|
179
|
+
if (eyeStyle === "dot") {
|
|
180
|
+
g[eyeRow][x] = 4;
|
|
181
|
+
} else if (eyeStyle === "wide") {
|
|
182
|
+
g[eyeRow][x] = 3;
|
|
183
|
+
if (g[eyeRow + 1]) g[eyeRow + 1][x] = 4;
|
|
184
|
+
} else {
|
|
185
|
+
g[eyeRow][x] = 2;
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
const twoEyes = cols.length >= 4;
|
|
189
|
+
if (side) {
|
|
190
|
+
stamp(cols[Math.min(1, cols.length - 1)]);
|
|
191
|
+
} else if (twoEyes) {
|
|
192
|
+
const gap = Math.max(1, Math.min(3, Math.floor(cols.length / 3)));
|
|
193
|
+
stamp(Math.floor(cx - gap));
|
|
194
|
+
stamp(Math.ceil(cx + gap));
|
|
195
|
+
} else {
|
|
196
|
+
stamp(Math.round(cx));
|
|
197
|
+
}
|
|
198
|
+
const mRow = eyeRow + 2 + (eyeStyle === "wide" ? 1 : 0);
|
|
199
|
+
const mW = twoEyes ? pick([1, 1, 3]) : 1;
|
|
200
|
+
if (view !== "back" && mRow <= botRow) {
|
|
201
|
+
if (side) {
|
|
202
|
+
let m0 = 0;
|
|
203
|
+
while (m0 < SIZE && g[mRow][m0] !== 1) m0++;
|
|
204
|
+
for (let x = m0; x < m0 + mW && x < SIZE; x++) {
|
|
205
|
+
if (g[mRow][x] === 1) g[mRow][x] = 4;
|
|
206
|
+
}
|
|
207
|
+
} else {
|
|
208
|
+
for (let x = Math.round(cx - (mW - 1) / 2); x <= Math.round(cx + (mW - 1) / 2); x++) {
|
|
209
|
+
if (g[mRow][x] === 1) g[mRow][x] = 4;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
const legCols = [];
|
|
216
|
+
let drawnLegStyle = null;
|
|
217
|
+
if (o.connected && o.symmetric) {
|
|
218
|
+
const rolled = pick(["none", "two", "two", "two", "many"]);
|
|
219
|
+
const legStyle = o.legs === "auto" ? rolled : o.legs;
|
|
220
|
+
if (legStyle !== "none") {
|
|
221
|
+
let botRow = SIZE - 1;
|
|
222
|
+
while (botRow > 0 && !g[botRow].some((v) => v === 1)) botRow--;
|
|
223
|
+
const maxLen = SIZE - 2 - botRow;
|
|
224
|
+
const xs = [];
|
|
225
|
+
for (let x = 0; x < HALF; x++) if (g[botRow][x] === 1) xs.push(x);
|
|
226
|
+
if (xs.length && maxLen >= 1) {
|
|
227
|
+
const draw = (x, len) => {
|
|
228
|
+
for (let d = 1; d <= len; d++) {
|
|
229
|
+
g[botRow + d][x] = 1;
|
|
230
|
+
g[botRow + d][SIZE - 1 - x] = 1;
|
|
231
|
+
}
|
|
232
|
+
legCols.push({ x, len, botRow });
|
|
233
|
+
};
|
|
234
|
+
if (legStyle === "two") {
|
|
235
|
+
const lx = xs.length > 2 ? xs[1] : xs[0];
|
|
236
|
+
const len = Math.min(maxLen, 1 + Math.floor(rand() * 2));
|
|
237
|
+
if (view === "left" || view === "right") {
|
|
238
|
+
for (let d = 1; d <= len; d++) g[botRow + d][7] = 1;
|
|
239
|
+
legCols.push({ x: 7, len, botRow });
|
|
240
|
+
} else {
|
|
241
|
+
draw(lx, len);
|
|
242
|
+
}
|
|
243
|
+
drawnLegStyle = "two";
|
|
244
|
+
} else {
|
|
245
|
+
for (let i = 0; i < xs.length; i += 2) {
|
|
246
|
+
const len = Math.min(maxLen, rand() < 0.5 ? 2 : 1);
|
|
247
|
+
draw(xs[i], len);
|
|
248
|
+
}
|
|
249
|
+
drawnLegStyle = "many";
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
const drawn = drawnLegStyle ?? "none";
|
|
255
|
+
if (frame > 0) {
|
|
256
|
+
if (drawnLegStyle === "two" && legCols.length) {
|
|
257
|
+
const c = legCols[0];
|
|
258
|
+
if (frame === 1) g[c.botRow + c.len][c.x] = 0;
|
|
259
|
+
else g[c.botRow + c.len][SIZE - 1 - c.x] = 0;
|
|
260
|
+
} else if (drawnLegStyle === "many" && legCols.length > 1) {
|
|
261
|
+
for (let i = frame === 1 ? 1 : 0; i < legCols.length; i += 2) {
|
|
262
|
+
const c = legCols[i];
|
|
263
|
+
g[c.botRow + c.len][c.x] = 0;
|
|
264
|
+
g[c.botRow + c.len][SIZE - 1 - c.x] = 0;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
if (frame === 2) {
|
|
268
|
+
let tR = 0;
|
|
269
|
+
while (tR < SIZE && !g[tR].some((v) => v)) tR++;
|
|
270
|
+
let bR = SIZE - 1;
|
|
271
|
+
while (bR > 0 && !g[bR].some((v) => v)) bR--;
|
|
272
|
+
if (bR - tR > 3) {
|
|
273
|
+
const mid = Math.floor((tR + bR) / 2);
|
|
274
|
+
for (let y = mid; y > tR; y--) g[y] = g[y - 1].slice();
|
|
275
|
+
g[tR] = new Array(SIZE).fill(0);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
if (o.outline) {
|
|
280
|
+
const isBody = (y, x) => y >= 0 && y < SIZE && x >= 0 && x < SIZE && g[y][x] !== 0 && g[y][x] !== 9;
|
|
281
|
+
const marks = [];
|
|
282
|
+
for (let y = 0; y < SIZE; y++) {
|
|
283
|
+
for (let x = 0; x < SIZE; x++) {
|
|
284
|
+
if (g[y][x] === 0 && (isBody(y - 1, x) || isBody(y + 1, x) || isBody(y, x - 1) || isBody(y, x + 1))) {
|
|
285
|
+
marks.push([y, x]);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
for (const [y, x] of marks) g[y][x] = 9;
|
|
290
|
+
}
|
|
291
|
+
if (view === "right") for (const row of g) row.reverse();
|
|
292
|
+
const colors = {
|
|
293
|
+
1: `hsl(${hue} ${sat}% ${lig}%)`,
|
|
294
|
+
2: `hsl(${hue} ${sat}% ${Math.max(18, lig - 24)}%)`,
|
|
295
|
+
3: "#fdfdf5",
|
|
296
|
+
4: "#1a1a24",
|
|
297
|
+
5: `hsl(${(hue + 165) % 360} ${sat}% ${lig}%)`,
|
|
298
|
+
9: "#1a1a24"
|
|
299
|
+
};
|
|
300
|
+
let rects = "";
|
|
301
|
+
for (let y = 0; y < SIZE; y++) {
|
|
302
|
+
let x = 0;
|
|
303
|
+
while (x < SIZE) {
|
|
304
|
+
const v = g[y][x];
|
|
305
|
+
if (v === 0) {
|
|
306
|
+
x++;
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
309
|
+
let x2 = x;
|
|
310
|
+
while (x2 + 1 < SIZE && g[y][x2 + 1] === v) x2++;
|
|
311
|
+
rects += `<rect x="${x}" y="${y}" width="${x2 - x + 1}" height="1" fill="${colors[v]}"/>`;
|
|
312
|
+
x = x2 + 1;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" shape-rendering="crispEdges">${rects}</svg>`;
|
|
316
|
+
return { svg, drawnLegStyle: drawn, size: SIZE };
|
|
317
|
+
}
|
|
318
|
+
function createMonster(seed, options = {}) {
|
|
319
|
+
const resolved = resolveOptions(options);
|
|
320
|
+
const cache = /* @__PURE__ */ new Map();
|
|
321
|
+
const get = (view = "front", frame = 0) => {
|
|
322
|
+
const key = view + ":" + frame;
|
|
323
|
+
let r = cache.get(key);
|
|
324
|
+
if (!r) {
|
|
325
|
+
r = generateSvg(seed, { ...resolved, view, frame });
|
|
326
|
+
cache.set(key, r);
|
|
327
|
+
}
|
|
328
|
+
return r;
|
|
329
|
+
};
|
|
330
|
+
let stats = null;
|
|
331
|
+
return {
|
|
332
|
+
seed,
|
|
333
|
+
opts: resolved,
|
|
334
|
+
svg: (view, frame) => get(view, frame).svg,
|
|
335
|
+
result: get,
|
|
336
|
+
get drawnLegStyle() {
|
|
337
|
+
return get().drawnLegStyle;
|
|
338
|
+
},
|
|
339
|
+
get stats() {
|
|
340
|
+
if (!stats) stats = getStats(seed, resolved);
|
|
341
|
+
return stats;
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
// src/names.ts
|
|
347
|
+
var SYL_A_JA = ["\u30E2", "\u30DD", "\u30D4", "\u30D7", "\u30C1\u30E3", "\u30DF", "\u30DC", "\u30AC", "\u30EB", "\u30CB\u30E3", "\u30BA", "\u30C9\u30F3", "\u30DA", "\u30AD\u30E5", "\u30DB"];
|
|
348
|
+
var SYL_B_JA = ["\u30B3", "\u30ED\u30F3", "\u30BF", "\u30D4", "\u30E0\u30EB", "\u30DC\u30F3", "\u30C1", "\u30CB", "\u30B4\u30F3", "\u30B9\u30B1", "\u30EA\u30F3", "\u30DA\u30F3", "\u30DD\u30DD", "\u30BE\u30FC"];
|
|
349
|
+
var SYL_A_EN = ["Mo", "Po", "Pi", "Pu", "Cha", "Mi", "Bo", "Ga", "Ru", "Nya", "Zu", "Don", "Pe", "Kyu", "Ho"];
|
|
350
|
+
var SYL_B_EN = ["ko", "ron", "ta", "pi", "muru", "bon", "chi", "ni", "gon", "suke", "rin", "pen", "popo", "zo"];
|
|
351
|
+
function randomName(locale = "en") {
|
|
352
|
+
const i = Math.floor(Math.random() * SYL_A_JA.length);
|
|
353
|
+
const j = Math.floor(Math.random() * SYL_B_JA.length);
|
|
354
|
+
return locale === "ja" ? SYL_A_JA[i] + SYL_B_JA[j] : SYL_A_EN[i] + SYL_B_EN[j];
|
|
355
|
+
}
|
|
356
|
+
function safeFileName(seed) {
|
|
357
|
+
return "monster-" + seed.replace(/[\\/:*?"<>|\s]/g, "_");
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
exports.NATURE_IDS = NATURE_IDS;
|
|
361
|
+
exports.SIZE = SIZE;
|
|
362
|
+
exports.createMonster = createMonster;
|
|
363
|
+
exports.generateSvg = generateSvg;
|
|
364
|
+
exports.getStats = getStats;
|
|
365
|
+
exports.presetKeyFromOpts = presetKeyFromOpts;
|
|
366
|
+
exports.presets = presets;
|
|
367
|
+
exports.randomName = randomName;
|
|
368
|
+
exports.resolveOptions = resolveOptions;
|
|
369
|
+
exports.safeFileName = safeFileName;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { G as GenerateOptions, R as ResolvedOpts, V as View, F as Frame, a as GenerateResult, L as LegStyle, P as Preset, b as Locale } from './types-kWKrAd-B.cjs';
|
|
2
|
+
export { c as Legs } from './types-kWKrAd-B.cjs';
|
|
3
|
+
import { S as Stats } from './stats-Cs0yRJTk.cjs';
|
|
4
|
+
export { N as NATURE_IDS, a as NatureId, g as getStats } from './stats-Cs0yRJTk.cjs';
|
|
5
|
+
|
|
6
|
+
declare const SIZE = 16;
|
|
7
|
+
declare function generateSvg(seed: string, options?: GenerateOptions): GenerateResult;
|
|
8
|
+
/** 全ビュー/フレームをlazyキャッシュする便利ファサード */
|
|
9
|
+
declare function createMonster(seed: string, options?: GenerateOptions): {
|
|
10
|
+
seed: string;
|
|
11
|
+
opts: ResolvedOpts;
|
|
12
|
+
svg: (view?: View, frame?: Frame) => string;
|
|
13
|
+
result: (view?: View, frame?: Frame) => GenerateResult;
|
|
14
|
+
readonly drawnLegStyle: LegStyle;
|
|
15
|
+
readonly stats: Stats;
|
|
16
|
+
};
|
|
17
|
+
type Monster = ReturnType<typeof createMonster>;
|
|
18
|
+
|
|
19
|
+
declare const presets: Record<Preset, ResolvedOpts>;
|
|
20
|
+
declare function resolveOptions(options?: GenerateOptions): ResolvedOpts;
|
|
21
|
+
/** 解決済みオプションから最も近いプリセットキーを逆引き(ステータスtier等に使用) */
|
|
22
|
+
declare function presetKeyFromOpts(o: ResolvedOpts): Preset | "custom";
|
|
23
|
+
|
|
24
|
+
declare function randomName(locale?: Locale): string;
|
|
25
|
+
declare function safeFileName(seed: string): string;
|
|
26
|
+
|
|
27
|
+
export { Frame, GenerateOptions, GenerateResult, LegStyle, Locale, type Monster, Preset, ResolvedOpts, SIZE, Stats, View, createMonster, generateSvg, presetKeyFromOpts, presets, randomName, resolveOptions, safeFileName };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { G as GenerateOptions, R as ResolvedOpts, V as View, F as Frame, a as GenerateResult, L as LegStyle, P as Preset, b as Locale } from './types-kWKrAd-B.js';
|
|
2
|
+
export { c as Legs } from './types-kWKrAd-B.js';
|
|
3
|
+
import { S as Stats } from './stats-BMnyxbee.js';
|
|
4
|
+
export { N as NATURE_IDS, a as NatureId, g as getStats } from './stats-BMnyxbee.js';
|
|
5
|
+
|
|
6
|
+
declare const SIZE = 16;
|
|
7
|
+
declare function generateSvg(seed: string, options?: GenerateOptions): GenerateResult;
|
|
8
|
+
/** 全ビュー/フレームをlazyキャッシュする便利ファサード */
|
|
9
|
+
declare function createMonster(seed: string, options?: GenerateOptions): {
|
|
10
|
+
seed: string;
|
|
11
|
+
opts: ResolvedOpts;
|
|
12
|
+
svg: (view?: View, frame?: Frame) => string;
|
|
13
|
+
result: (view?: View, frame?: Frame) => GenerateResult;
|
|
14
|
+
readonly drawnLegStyle: LegStyle;
|
|
15
|
+
readonly stats: Stats;
|
|
16
|
+
};
|
|
17
|
+
type Monster = ReturnType<typeof createMonster>;
|
|
18
|
+
|
|
19
|
+
declare const presets: Record<Preset, ResolvedOpts>;
|
|
20
|
+
declare function resolveOptions(options?: GenerateOptions): ResolvedOpts;
|
|
21
|
+
/** 解決済みオプションから最も近いプリセットキーを逆引き(ステータスtier等に使用) */
|
|
22
|
+
declare function presetKeyFromOpts(o: ResolvedOpts): Preset | "custom";
|
|
23
|
+
|
|
24
|
+
declare function randomName(locale?: Locale): string;
|
|
25
|
+
declare function safeFileName(seed: string): string;
|
|
26
|
+
|
|
27
|
+
export { Frame, GenerateOptions, GenerateResult, LegStyle, Locale, type Monster, Preset, ResolvedOpts, SIZE, Stats, View, createMonster, generateSvg, presetKeyFromOpts, presets, randomName, resolveOptions, safeFileName };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { NATURE_IDS, SIZE, createMonster, generateSvg, getStats, presetKeyFromOpts, presets, randomName, resolveOptions, safeFileName } from './chunk-QBHMZDDB.js';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/locales/en.ts
|
|
4
|
+
var en = {
|
|
5
|
+
natures: {
|
|
6
|
+
cheerful: "Cheerful",
|
|
7
|
+
easygoing: "Easygoing",
|
|
8
|
+
timid: "Timid",
|
|
9
|
+
stubborn: "Stubborn",
|
|
10
|
+
headstrong: "Headstrong",
|
|
11
|
+
gentle: "Gentle",
|
|
12
|
+
playful: "Playful",
|
|
13
|
+
calm: "Calm",
|
|
14
|
+
shy: "Shy",
|
|
15
|
+
hungry: "Hungry",
|
|
16
|
+
sleepyhead: "Sleepyhead",
|
|
17
|
+
whimsical: "Whimsical"
|
|
18
|
+
},
|
|
19
|
+
stats: { lv: "Lv", hp: "HP", mp: "MP", atk: "Attack", def: "Defense", spd: "Speed", luck: "Luck" },
|
|
20
|
+
legs: { auto: "Auto", none: "None", two: "Two legs", many: "Many legs" },
|
|
21
|
+
presets: { mochi: "Mochi", retro: "Retro", chaos: "Chaos" },
|
|
22
|
+
presetDescriptions: {
|
|
23
|
+
mochi: "Round, cuddly, and ready to be raised",
|
|
24
|
+
retro: "Straight out of an old handheld game",
|
|
25
|
+
chaos: "Something is off. You can't look away"
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
exports.en = en;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// src/locales/en.ts
|
|
2
|
+
var en = {
|
|
3
|
+
natures: {
|
|
4
|
+
cheerful: "Cheerful",
|
|
5
|
+
easygoing: "Easygoing",
|
|
6
|
+
timid: "Timid",
|
|
7
|
+
stubborn: "Stubborn",
|
|
8
|
+
headstrong: "Headstrong",
|
|
9
|
+
gentle: "Gentle",
|
|
10
|
+
playful: "Playful",
|
|
11
|
+
calm: "Calm",
|
|
12
|
+
shy: "Shy",
|
|
13
|
+
hungry: "Hungry",
|
|
14
|
+
sleepyhead: "Sleepyhead",
|
|
15
|
+
whimsical: "Whimsical"
|
|
16
|
+
},
|
|
17
|
+
stats: { lv: "Lv", hp: "HP", mp: "MP", atk: "Attack", def: "Defense", spd: "Speed", luck: "Luck" },
|
|
18
|
+
legs: { auto: "Auto", none: "None", two: "Two legs", many: "Many legs" },
|
|
19
|
+
presets: { mochi: "Mochi", retro: "Retro", chaos: "Chaos" },
|
|
20
|
+
presetDescriptions: {
|
|
21
|
+
mochi: "Round, cuddly, and ready to be raised",
|
|
22
|
+
retro: "Straight out of an old handheld game",
|
|
23
|
+
chaos: "Something is off. You can't look away"
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { en };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/locales/index.ts
|
|
4
|
+
function pickLocale(candidates, supported, fallback) {
|
|
5
|
+
for (const c of candidates) {
|
|
6
|
+
const lang = c.toLowerCase().split("-")[0];
|
|
7
|
+
const hit = supported.find((s) => s.toLowerCase() === lang);
|
|
8
|
+
if (hit) return hit;
|
|
9
|
+
}
|
|
10
|
+
return fallback;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
exports.pickLocale = pickLocale;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { L as LocaleDict } from '../types-CsVv0MnX.cjs';
|
|
2
|
+
import '../stats-Cs0yRJTk.cjs';
|
|
3
|
+
import '../types-kWKrAd-B.cjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* ブラウザ言語等の候補リストから対応ロケールの最良一致を返す純関数。
|
|
7
|
+
* 例: pickLocale(navigator.languages, ["en", "ja"], "en") → "ja"(日本語ブラウザ)
|
|
8
|
+
*/
|
|
9
|
+
declare function pickLocale<T extends string>(candidates: readonly string[], supported: readonly T[], fallback: T): T;
|
|
10
|
+
|
|
11
|
+
export { pickLocale };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { L as LocaleDict } from '../types-DYNij_HS.js';
|
|
2
|
+
import '../stats-BMnyxbee.js';
|
|
3
|
+
import '../types-kWKrAd-B.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* ブラウザ言語等の候補リストから対応ロケールの最良一致を返す純関数。
|
|
7
|
+
* 例: pickLocale(navigator.languages, ["en", "ja"], "en") → "ja"(日本語ブラウザ)
|
|
8
|
+
*/
|
|
9
|
+
declare function pickLocale<T extends string>(candidates: readonly string[], supported: readonly T[], fallback: T): T;
|
|
10
|
+
|
|
11
|
+
export { pickLocale };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// src/locales/index.ts
|
|
2
|
+
function pickLocale(candidates, supported, fallback) {
|
|
3
|
+
for (const c of candidates) {
|
|
4
|
+
const lang = c.toLowerCase().split("-")[0];
|
|
5
|
+
const hit = supported.find((s) => s.toLowerCase() === lang);
|
|
6
|
+
if (hit) return hit;
|
|
7
|
+
}
|
|
8
|
+
return fallback;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { pickLocale };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/locales/ja.ts
|
|
4
|
+
var ja = {
|
|
5
|
+
natures: {
|
|
6
|
+
cheerful: "\u3088\u3046\u304D",
|
|
7
|
+
easygoing: "\u306E\u3093\u3073\u308A",
|
|
8
|
+
timid: "\u304A\u304F\u3073\u3087\u3046",
|
|
9
|
+
stubborn: "\u304C\u3093\u3053",
|
|
10
|
+
headstrong: "\u3044\u3058\u3063\u3071\u308A",
|
|
11
|
+
gentle: "\u304A\u3063\u3068\u308A",
|
|
12
|
+
playful: "\u3084\u3093\u3061\u3083",
|
|
13
|
+
calm: "\u308C\u3044\u305B\u3044",
|
|
14
|
+
shy: "\u3066\u308C\u3084",
|
|
15
|
+
hungry: "\u306F\u3089\u307A\u3053",
|
|
16
|
+
sleepyhead: "\u306D\u307C\u3059\u3051",
|
|
17
|
+
whimsical: "\u304D\u307E\u3050\u308C"
|
|
18
|
+
},
|
|
19
|
+
stats: { lv: "Lv", hp: "HP", mp: "MP", atk: "\u3053\u3046\u3052\u304D", def: "\u307C\u3046\u304E\u3087", spd: "\u3059\u3070\u3084\u3055", luck: "\u3046\u3093" },
|
|
20
|
+
legs: { auto: "\u304A\u307E\u304B\u305B", none: "\u306A\u3057", two: "\u4E8C\u8DB3", many: "\u591A\u8DB3" },
|
|
21
|
+
presets: { mochi: "\u3082\u3061\u3082\u3061", retro: "\u30EC\u30C8\u30ED", chaos: "\u30AB\u30AA\u30B9" },
|
|
22
|
+
presetDescriptions: {
|
|
23
|
+
mochi: "\u307E\u308B\u3063\u3068\u304B\u308F\u3044\u3044\u3001\u305D\u3060\u3066\u305F\u304F\u306A\u308B\u5B50",
|
|
24
|
+
retro: "\u3080\u304B\u3057\u306E\u30B2\u30FC\u30E0\u306B\u3044\u305D\u3046\u306A\u30C9\u30C3\u30C8\u7D75",
|
|
25
|
+
chaos: "\u306A\u306B\u304B\u304C\u304A\u304B\u3057\u3044\u3002\u3067\u3082\u30AF\u30BB\u306B\u306A\u308B"
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
exports.ja = ja;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// src/locales/ja.ts
|
|
2
|
+
var ja = {
|
|
3
|
+
natures: {
|
|
4
|
+
cheerful: "\u3088\u3046\u304D",
|
|
5
|
+
easygoing: "\u306E\u3093\u3073\u308A",
|
|
6
|
+
timid: "\u304A\u304F\u3073\u3087\u3046",
|
|
7
|
+
stubborn: "\u304C\u3093\u3053",
|
|
8
|
+
headstrong: "\u3044\u3058\u3063\u3071\u308A",
|
|
9
|
+
gentle: "\u304A\u3063\u3068\u308A",
|
|
10
|
+
playful: "\u3084\u3093\u3061\u3083",
|
|
11
|
+
calm: "\u308C\u3044\u305B\u3044",
|
|
12
|
+
shy: "\u3066\u308C\u3084",
|
|
13
|
+
hungry: "\u306F\u3089\u307A\u3053",
|
|
14
|
+
sleepyhead: "\u306D\u307C\u3059\u3051",
|
|
15
|
+
whimsical: "\u304D\u307E\u3050\u308C"
|
|
16
|
+
},
|
|
17
|
+
stats: { lv: "Lv", hp: "HP", mp: "MP", atk: "\u3053\u3046\u3052\u304D", def: "\u307C\u3046\u304E\u3087", spd: "\u3059\u3070\u3084\u3055", luck: "\u3046\u3093" },
|
|
18
|
+
legs: { auto: "\u304A\u307E\u304B\u305B", none: "\u306A\u3057", two: "\u4E8C\u8DB3", many: "\u591A\u8DB3" },
|
|
19
|
+
presets: { mochi: "\u3082\u3061\u3082\u3061", retro: "\u30EC\u30C8\u30ED", chaos: "\u30AB\u30AA\u30B9" },
|
|
20
|
+
presetDescriptions: {
|
|
21
|
+
mochi: "\u307E\u308B\u3063\u3068\u304B\u308F\u3044\u3044\u3001\u305D\u3060\u3066\u305F\u304F\u306A\u308B\u5B50",
|
|
22
|
+
retro: "\u3080\u304B\u3057\u306E\u30B2\u30FC\u30E0\u306B\u3044\u305D\u3046\u306A\u30C9\u30C3\u30C8\u7D75",
|
|
23
|
+
chaos: "\u306A\u306B\u304B\u304C\u304A\u304B\u3057\u3044\u3002\u3067\u3082\u30AF\u30BB\u306B\u306A\u308B"
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { ja };
|