@mauricode/token-derby 2.5.1 → 2.5.3
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/dist/bin.js +111 -87
- package/dist/bin.js.map +1 -1
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -420,8 +420,8 @@ var HEARTBEAT_RETRY_DELAYS_MS = [1e3, 2e3, 4e3, 8e3, 15e3];
|
|
|
420
420
|
// src/version.ts
|
|
421
421
|
import { createRequire } from "module";
|
|
422
422
|
function readVersion() {
|
|
423
|
-
if ("2.5.
|
|
424
|
-
return "2.5.
|
|
423
|
+
if ("2.5.3".length > 0) {
|
|
424
|
+
return "2.5.3";
|
|
425
425
|
}
|
|
426
426
|
try {
|
|
427
427
|
const req = createRequire(import.meta.url);
|
|
@@ -592,7 +592,7 @@ var HATS = [
|
|
|
592
592
|
{ id: "spartan_helmet", name: "Spartan Helmet", rarity: "epic", width: 11, anchor_x: 23, rows: ["...........", "........Q..", ".......QQ..", ".....QQQQ..", "....QQQQQ..", "..QQQQQQ...", ".QQQAA.....", "QQAAAAAAA..", "Q.AAAAAAA..", "..AQQQQQA.."], variants: [{ A: "#B0BEC5", Q: "#B71C1C" }, { A: "#B0BEC5", Q: "#b2b51c" }, { A: "#B0BEC5", Q: "#b5611c" }] },
|
|
593
593
|
{ id: "conquistador_full", name: "Conquistador Helm", rarity: "epic", width: 11, anchor_x: 23, rows: ["...........", "...........", "...........", "...........", ".....A.....", "....AAA....", "...AAAAA...", "..AAAAAAA..", "...AQQQA...", "...AQQQA..."], variants: [{ A: "#B0BEC5", Q: "#FFD700" }, { A: "#B0BEC5", Q: "#0040ff" }, { A: "#B0BEC5", Q: "#36123b" }] },
|
|
594
594
|
// ── LEGENDARY (5) ──────────────────────────────────────────────────────
|
|
595
|
-
{ id: "rainbow_crown", name: "Rainbow Crown", rarity: "legendary", width: 11, anchor_x: 23, rows: ["...........", "...........", ".....A.....", "....
|
|
595
|
+
{ id: "rainbow_crown", name: "Rainbow Crown", rarity: "legendary", width: 11, anchor_x: 23, rows: ["...........", "...........", ".....A.....", "....AAA....", "....AQA....", "....AAA....", "...AAQAA...", "...AAAAA...", "..AAAQAAA..", "..AAAAAAA.."], colors: { A: "#FFD700", Q: "#553f3f" }, animation: { type: "cycle", frames: ["#FF0000", "#FF7F00", "#FFFF00", "#00FF00", "#0000FF", "#8B00FF"], fps: 8 } },
|
|
596
596
|
{ id: "inferno_cap", name: "Inferno Cap", rarity: "legendary", width: 11, anchor_x: 23, rows: ["...........", "....AAA....", "...AAAAA...", "....AAA....", ".....Q.....", "A....Q....A", "A...QQQ...A", ".A..QQQ..A.", "..AAAAAAA..", "..AAAAAAA.."], colors: { A: "#FF4500", Q: "#FFD700" }, animation: { type: "cycle", frames: ["#FF0000", "#FF2200", "#FF4500", "#FF6600", "#FF8C00", "#FFA500"], fps: 12 } },
|
|
597
597
|
{ id: "void_hood", name: "Void Hood", rarity: "legendary", width: 11, anchor_x: 23, rows: ["...........", "...........", "...........", "...AAA.....", "..AAAAAA...", ".AAAAAAA...", ".AAAAAAAA..", "AAAAAAAAA..", "AAAAQQQAA..", "AAAAQQQAA.."], colors: { A: "#1A0033", Q: "#d9cfe3" }, animation: { type: "cycle", frames: ["#0D0019", "#1A0033", "#2D004D", "#3D0066", "#2D004D", "#1A0033"], fps: 3 } },
|
|
598
598
|
{ id: "prismatic_jester", name: "Prismatic Jester", rarity: "legendary", width: 11, anchor_x: 23, rows: ["...........", "..Q.Q.Q.Q..", "Q..A.A.A..Q", ".Q.A.A.A.Q.", "..AQAQAQA..", "..AQAQAQA..", "..AAAAAAA..", "..AAAAAAA..", "..AAAAAAA..", "..AAAAAAA.."], colors: { A: "#FF0000", Q: "#0000FF" }, animation: { type: "cycle", frames: ["#FF0000", "#FF7F00", "#FFFF00", "#00FF00", "#0000FF", "#8B00FF", "#FF00FF", "#00FFFF"], fps: 15 } },
|
|
@@ -939,7 +939,7 @@ async function stableDeleteCommand(name) {
|
|
|
939
939
|
}
|
|
940
940
|
|
|
941
941
|
// src/commands/stable-edit.ts
|
|
942
|
-
import
|
|
942
|
+
import React7 from "react";
|
|
943
943
|
import { render as render3 } from "ink";
|
|
944
944
|
|
|
945
945
|
// src/ui/HatPicker.tsx
|
|
@@ -1046,23 +1046,81 @@ function PreviewArea({ focused, colors }) {
|
|
|
1046
1046
|
return /* @__PURE__ */ jsx5(HorseSprite, { sprite: MAIN_SPRITE, colors, hat: { hat, variant: focused.collected.variant ?? 0 } });
|
|
1047
1047
|
}
|
|
1048
1048
|
|
|
1049
|
+
// src/ui/HorsePicker.tsx
|
|
1050
|
+
import { useState as useState4 } from "react";
|
|
1051
|
+
import { Box as Box6, Text as Text6, useInput as useInput3 } from "ink";
|
|
1052
|
+
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1053
|
+
function HorsePicker({ horses, onPick, onCancel }) {
|
|
1054
|
+
const [idx, setIdx] = useState4(0);
|
|
1055
|
+
useInput3((input, key) => {
|
|
1056
|
+
if (key.escape) {
|
|
1057
|
+
onCancel();
|
|
1058
|
+
return;
|
|
1059
|
+
}
|
|
1060
|
+
if (horses.length === 0) return;
|
|
1061
|
+
if (key.upArrow) {
|
|
1062
|
+
setIdx((idx - 1 + horses.length) % horses.length);
|
|
1063
|
+
return;
|
|
1064
|
+
}
|
|
1065
|
+
if (key.downArrow) {
|
|
1066
|
+
setIdx((idx + 1) % horses.length);
|
|
1067
|
+
return;
|
|
1068
|
+
}
|
|
1069
|
+
if (key.return) {
|
|
1070
|
+
onPick(horses[idx]);
|
|
1071
|
+
return;
|
|
1072
|
+
}
|
|
1073
|
+
});
|
|
1074
|
+
if (horses.length === 0) {
|
|
1075
|
+
return /* @__PURE__ */ jsxs4(Box6, { flexDirection: "column", children: [
|
|
1076
|
+
/* @__PURE__ */ jsx6(Text6, { children: "No horses in your stable." }),
|
|
1077
|
+
/* @__PURE__ */ jsx6(Text6, { dimColor: true, children: "Run `token-derby stable create` to make one." })
|
|
1078
|
+
] });
|
|
1079
|
+
}
|
|
1080
|
+
return /* @__PURE__ */ jsxs4(Box6, { flexDirection: "column", children: [
|
|
1081
|
+
/* @__PURE__ */ jsx6(Text6, { children: "Pick a horse to race:" }),
|
|
1082
|
+
horses.map((h, i) => /* @__PURE__ */ jsxs4(Box6, { flexDirection: "column", children: [
|
|
1083
|
+
/* @__PURE__ */ jsx6(Box6, { flexDirection: "row", children: /* @__PURE__ */ jsxs4(Text6, { children: [
|
|
1084
|
+
i === idx ? "\u25BA" : " ",
|
|
1085
|
+
" ",
|
|
1086
|
+
h.name,
|
|
1087
|
+
" ",
|
|
1088
|
+
/* @__PURE__ */ jsxs4(Text6, { color: "cyan", children: [
|
|
1089
|
+
"[Lvl. ",
|
|
1090
|
+
levelFromXp(h.xp),
|
|
1091
|
+
"]"
|
|
1092
|
+
] })
|
|
1093
|
+
] }) }),
|
|
1094
|
+
/* @__PURE__ */ jsxs4(Box6, { flexDirection: "row", children: [
|
|
1095
|
+
/* @__PURE__ */ jsx6(Text6, { children: " " }),
|
|
1096
|
+
/* @__PURE__ */ jsx6(HorseSprite, { sprite: MINI_SPRITE, colors: h.colors })
|
|
1097
|
+
] })
|
|
1098
|
+
] }, h.stable_horse_id)),
|
|
1099
|
+
/* @__PURE__ */ jsx6(Box6, { marginTop: 1, children: /* @__PURE__ */ jsx6(Text6, { dimColor: true, children: "\u2191/\u2193 choose \xB7 Enter pick \xB7 Esc cancel" }) })
|
|
1100
|
+
] });
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1049
1103
|
// src/commands/stable-edit.ts
|
|
1050
1104
|
async function stableEditCommand(name) {
|
|
1051
|
-
if (!name) {
|
|
1052
|
-
console.error("Usage: token-derby stable edit <name>");
|
|
1053
|
-
return 2;
|
|
1054
|
-
}
|
|
1055
1105
|
const horses = await fetchStable();
|
|
1056
1106
|
if (!horses) return 1;
|
|
1057
|
-
const existing = horses
|
|
1058
|
-
if (
|
|
1107
|
+
const existing = await pickHorseToEdit(horses, name);
|
|
1108
|
+
if (existing === "not_found") {
|
|
1059
1109
|
console.error(`No horse named "${name}" in your stable.`);
|
|
1060
1110
|
return 1;
|
|
1061
1111
|
}
|
|
1112
|
+
if (existing === "empty") {
|
|
1113
|
+
console.log("No horses in your stable. Run `token-derby stable create` to make one.");
|
|
1114
|
+
return 0;
|
|
1115
|
+
}
|
|
1116
|
+
if (existing === "cancelled") {
|
|
1117
|
+
console.log("Cancelled.");
|
|
1118
|
+
return 1;
|
|
1119
|
+
}
|
|
1062
1120
|
let exitCode = 0;
|
|
1063
1121
|
let liveColors = existing.colors;
|
|
1064
1122
|
const app = render3(
|
|
1065
|
-
|
|
1123
|
+
React7.createElement(HorseCreator, {
|
|
1066
1124
|
initialColors: existing.colors,
|
|
1067
1125
|
initialName: existing.name,
|
|
1068
1126
|
lockName: true,
|
|
@@ -1094,7 +1152,7 @@ async function stableEditCommand(name) {
|
|
|
1094
1152
|
if (exitCode === 0 && existing.hats && existing.hats.length > 0) {
|
|
1095
1153
|
const equipResult = await new Promise((resolve) => {
|
|
1096
1154
|
const app2 = render3(
|
|
1097
|
-
|
|
1155
|
+
React7.createElement(HatPicker, {
|
|
1098
1156
|
hats: existing.hats,
|
|
1099
1157
|
equipped: existing.equipped_hat ?? null,
|
|
1100
1158
|
colors: liveColors,
|
|
@@ -1133,6 +1191,29 @@ async function fetchStable() {
|
|
|
1133
1191
|
throw e;
|
|
1134
1192
|
}
|
|
1135
1193
|
}
|
|
1194
|
+
async function pickHorseToEdit(horses, name) {
|
|
1195
|
+
if (name) {
|
|
1196
|
+
const found = horses.find((h) => h.name === name);
|
|
1197
|
+
return found ?? "not_found";
|
|
1198
|
+
}
|
|
1199
|
+
if (horses.length === 0) return "empty";
|
|
1200
|
+
const picked = await new Promise((resolve) => {
|
|
1201
|
+
const app = render3(
|
|
1202
|
+
React7.createElement(HorsePicker, {
|
|
1203
|
+
horses,
|
|
1204
|
+
onPick: (h) => {
|
|
1205
|
+
app.unmount();
|
|
1206
|
+
resolve(h);
|
|
1207
|
+
},
|
|
1208
|
+
onCancel: () => {
|
|
1209
|
+
app.unmount();
|
|
1210
|
+
resolve(null);
|
|
1211
|
+
}
|
|
1212
|
+
})
|
|
1213
|
+
);
|
|
1214
|
+
});
|
|
1215
|
+
return picked ?? "cancelled";
|
|
1216
|
+
}
|
|
1136
1217
|
|
|
1137
1218
|
// src/commands/create.ts
|
|
1138
1219
|
import * as readline2 from "readline/promises";
|
|
@@ -1222,60 +1303,6 @@ function isIso(s) {
|
|
|
1222
1303
|
import React9 from "react";
|
|
1223
1304
|
import { render as render4 } from "ink";
|
|
1224
1305
|
|
|
1225
|
-
// src/ui/HorsePicker.tsx
|
|
1226
|
-
import { useState as useState4 } from "react";
|
|
1227
|
-
import { Box as Box6, Text as Text6, useInput as useInput3 } from "ink";
|
|
1228
|
-
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1229
|
-
function HorsePicker({ horses, onPick, onCancel }) {
|
|
1230
|
-
const [idx, setIdx] = useState4(0);
|
|
1231
|
-
useInput3((input, key) => {
|
|
1232
|
-
if (key.escape) {
|
|
1233
|
-
onCancel();
|
|
1234
|
-
return;
|
|
1235
|
-
}
|
|
1236
|
-
if (horses.length === 0) return;
|
|
1237
|
-
if (key.upArrow) {
|
|
1238
|
-
setIdx((idx - 1 + horses.length) % horses.length);
|
|
1239
|
-
return;
|
|
1240
|
-
}
|
|
1241
|
-
if (key.downArrow) {
|
|
1242
|
-
setIdx((idx + 1) % horses.length);
|
|
1243
|
-
return;
|
|
1244
|
-
}
|
|
1245
|
-
if (key.return) {
|
|
1246
|
-
onPick(horses[idx]);
|
|
1247
|
-
return;
|
|
1248
|
-
}
|
|
1249
|
-
});
|
|
1250
|
-
if (horses.length === 0) {
|
|
1251
|
-
return /* @__PURE__ */ jsxs4(Box6, { flexDirection: "column", children: [
|
|
1252
|
-
/* @__PURE__ */ jsx6(Text6, { children: "No horses in your stable." }),
|
|
1253
|
-
/* @__PURE__ */ jsx6(Text6, { dimColor: true, children: "Run `token-derby stable create` to make one." })
|
|
1254
|
-
] });
|
|
1255
|
-
}
|
|
1256
|
-
return /* @__PURE__ */ jsxs4(Box6, { flexDirection: "column", children: [
|
|
1257
|
-
/* @__PURE__ */ jsx6(Text6, { children: "Pick a horse to race:" }),
|
|
1258
|
-
horses.map((h, i) => /* @__PURE__ */ jsxs4(Box6, { flexDirection: "column", children: [
|
|
1259
|
-
/* @__PURE__ */ jsx6(Box6, { flexDirection: "row", children: /* @__PURE__ */ jsxs4(Text6, { children: [
|
|
1260
|
-
i === idx ? "\u25BA" : " ",
|
|
1261
|
-
" ",
|
|
1262
|
-
h.name,
|
|
1263
|
-
" ",
|
|
1264
|
-
/* @__PURE__ */ jsxs4(Text6, { color: "cyan", children: [
|
|
1265
|
-
"[Lvl. ",
|
|
1266
|
-
levelFromXp(h.xp),
|
|
1267
|
-
"]"
|
|
1268
|
-
] })
|
|
1269
|
-
] }) }),
|
|
1270
|
-
/* @__PURE__ */ jsxs4(Box6, { flexDirection: "row", children: [
|
|
1271
|
-
/* @__PURE__ */ jsx6(Text6, { children: " " }),
|
|
1272
|
-
/* @__PURE__ */ jsx6(HorseSprite, { sprite: MINI_SPRITE, colors: h.colors })
|
|
1273
|
-
] })
|
|
1274
|
-
] }, h.stable_horse_id)),
|
|
1275
|
-
/* @__PURE__ */ jsx6(Box6, { marginTop: 1, children: /* @__PURE__ */ jsx6(Text6, { dimColor: true, children: "\u2191/\u2193 choose \xB7 Enter pick \xB7 Esc cancel" }) })
|
|
1276
|
-
] });
|
|
1277
|
-
}
|
|
1278
|
-
|
|
1279
1306
|
// src/stable/active-race.ts
|
|
1280
1307
|
import * as fs2 from "fs/promises";
|
|
1281
1308
|
import * as path3 from "path";
|
|
@@ -2331,27 +2358,24 @@ async function rollCommand() {
|
|
|
2331
2358
|
console.log("No rolls available. Level up a horse to earn a roll!");
|
|
2332
2359
|
return 0;
|
|
2333
2360
|
}
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
console.log("Cancelled.");
|
|
2351
|
-
return 0;
|
|
2352
|
-
}
|
|
2353
|
-
chosen = picked;
|
|
2361
|
+
const picked = await new Promise((resolve) => {
|
|
2362
|
+
const app = render5(React13.createElement(RollHorsePicker, {
|
|
2363
|
+
horses: eligible,
|
|
2364
|
+
onPick: (h) => {
|
|
2365
|
+
app.unmount();
|
|
2366
|
+
resolve(h);
|
|
2367
|
+
},
|
|
2368
|
+
onCancel: () => {
|
|
2369
|
+
app.unmount();
|
|
2370
|
+
resolve(null);
|
|
2371
|
+
}
|
|
2372
|
+
}));
|
|
2373
|
+
});
|
|
2374
|
+
if (!picked) {
|
|
2375
|
+
console.log("Cancelled.");
|
|
2376
|
+
return 0;
|
|
2354
2377
|
}
|
|
2378
|
+
let chosen = picked;
|
|
2355
2379
|
while (true) {
|
|
2356
2380
|
let result;
|
|
2357
2381
|
try {
|
|
@@ -2606,7 +2630,7 @@ Maintenance:
|
|
|
2606
2630
|
Stable management:
|
|
2607
2631
|
token-derby stable create Make a new horse (interactive)
|
|
2608
2632
|
token-derby stable list Show your saved horses
|
|
2609
|
-
token-derby stable edit
|
|
2633
|
+
token-derby stable edit [name] Edit an existing horse's colors (interactive picker if no name)
|
|
2610
2634
|
token-derby stable delete <name> Remove a horse from your stable
|
|
2611
2635
|
|
|
2612
2636
|
Organisations:
|