@nano133/nanoterra 0.9.0 → 0.9.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/CHANGELOG.md +40 -0
- package/README.md +55 -7
- package/ai/SPEC.md +6 -0
- package/dist/player-signin/panel/index.d.ts +2 -2
- package/dist/player-signin/panel/index.js +3 -2
- package/dist/player-signin/panel/mount.d.ts +1 -1
- package/dist/player-signin/panel/mount.js +5 -3
- package/dist/player-signin/panel/view.d.ts +3 -0
- package/dist/player-signin/panel/view.js +49 -46
- package/dist/player-signin/panel/words.d.ts +96 -1
- package/dist/player-signin/panel/words.js +109 -24
- package/dist/shop/panel/index.d.ts +2 -0
- package/dist/shop/panel/index.js +3 -0
- package/dist/shop/panel/looks.d.ts +3 -0
- package/dist/shop/panel/looks.js +11 -11
- package/dist/shop/panel/mount.d.ts +18 -2
- package/dist/shop/panel/mount.js +48 -21
- package/dist/shop/panel/pay.d.ts +3 -0
- package/dist/shop/panel/pay.js +38 -25
- package/dist/shop/panel/words.d.ts +89 -0
- package/dist/shop/panel/words.js +79 -0
- package/package.json +1 -1
- package/src/player-signin/panel/index.ts +4 -3
- package/src/player-signin/panel/mount.ts +6 -4
- package/src/player-signin/panel/style.css +22 -17
- package/src/player-signin/panel/view.ts +60 -55
- package/src/player-signin/panel/words.ts +202 -24
- package/src/shop/panel/index.ts +4 -0
- package/src/shop/panel/looks.ts +14 -14
- package/src/shop/panel/mount.ts +60 -21
- package/src/shop/panel/pay.ts +51 -30
- package/src/shop/panel/style.css +24 -20
- package/src/shop/panel/words.ts +172 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
// Every word that the shop's sheets show: the looks sheet, Buy and the pay sheet. A game gives `words` to `mountShop` (or to `looksView` and `payPanel`)
|
|
2
|
+
// with the keys it wants to change, in its own words or language; the rest stay these. A text with a value in it is a function of that value.
|
|
3
|
+
//
|
|
4
|
+
// Two things a game cannot change, because a player's money depends on them: the stamp "TEST MODE: DO NOT PAY" (it is not a key), and the words
|
|
5
|
+
// "Powered by CoinGecko" while CoinGecko is one of the price feeds (CoinGecko's API terms ask for them: `priceLine` adds them when `prices` leaves
|
|
6
|
+
// them out).
|
|
7
|
+
//
|
|
8
|
+
// The defaults are short on purpose (Wes, 2026-11-01: fewer words): the pay sheet shows at most 30 words, and no sentence has more than 10.
|
|
9
|
+
|
|
10
|
+
import type { Hat } from "../../looks/look.js";
|
|
11
|
+
|
|
12
|
+
export type ShopWords = {
|
|
13
|
+
// ---- the looks sheet ----
|
|
14
|
+
/** The sheet's title, the Looks key's word and the sheet's name for a screen reader. The option `title` wins over it. */
|
|
15
|
+
title: string;
|
|
16
|
+
/** The close key's name for a screen reader. */
|
|
17
|
+
close: string;
|
|
18
|
+
/** The tabs' name for a screen reader. */
|
|
19
|
+
kinds: string;
|
|
20
|
+
/** The outfits' tab. */
|
|
21
|
+
outfits: string;
|
|
22
|
+
/** The tab of a wear slot of the game's own ("shovel"). The option `slots` wins over it. */
|
|
23
|
+
slotTab: (slot: string) => string;
|
|
24
|
+
/** The plain choice of a wear slot ("No shovel"). The option `slots` wins over it. */
|
|
25
|
+
slotPlain: (slot: string) => string;
|
|
26
|
+
/** The line under an outfit: what it changes (its hat, or the colour only). */
|
|
27
|
+
outfitLine: (hat: Hat | null) => string;
|
|
28
|
+
/** The line under an item of a wear slot. */
|
|
29
|
+
itemLine: (slot: string) => string;
|
|
30
|
+
/** Added to the line of a free look, and the plain choice's line. */
|
|
31
|
+
free: string;
|
|
32
|
+
/** Added to the line of a look the player owns. */
|
|
33
|
+
yours: string;
|
|
34
|
+
wear: string;
|
|
35
|
+
wearing: string;
|
|
36
|
+
/** The Buy key, with the look's price ("$0.25"). */
|
|
37
|
+
buy: (price: string) => string;
|
|
38
|
+
/** Under the list. */
|
|
39
|
+
looksNote: string;
|
|
40
|
+
/** Under the list and at Buy, while nobody is signed in. */
|
|
41
|
+
signInFirst: string;
|
|
42
|
+
|
|
43
|
+
// ---- Buy ----
|
|
44
|
+
/** The title of Buy and of the pay sheet. */
|
|
45
|
+
buyTitle: (look: string) => string;
|
|
46
|
+
making: string;
|
|
47
|
+
/** An order that did not start, with no words from the server. */
|
|
48
|
+
orderFailed: string;
|
|
49
|
+
/** The words of a refusal: the server's own (`text`, in English) and its HTTP status (0: no answer). Default: the server's words. */
|
|
50
|
+
refusal: (text: string, status: number) => string;
|
|
51
|
+
/** The key back to the looks. */
|
|
52
|
+
back: string;
|
|
53
|
+
/** The key that signs in again after "Sign in first." (401). */
|
|
54
|
+
signIn: string;
|
|
55
|
+
|
|
56
|
+
// ---- the pay sheet ----
|
|
57
|
+
/** The line under the title. */
|
|
58
|
+
lookLine: (look: string) => string;
|
|
59
|
+
/** The amount in XNO, large ("0.25 XNO"). */
|
|
60
|
+
amount: (xno: string) => string;
|
|
61
|
+
/** The amount in dollars, beside it ("= $0.25"). */
|
|
62
|
+
usd: (usd: string) => string;
|
|
63
|
+
/** Above the amount, live only: the player must send this exact amount. */
|
|
64
|
+
sendExactly: string;
|
|
65
|
+
/** Under the stamp in test mode: nothing can be paid here. */
|
|
66
|
+
testNote: string;
|
|
67
|
+
/** The wallet key in test mode, off, with its reason. */
|
|
68
|
+
walletOff: string;
|
|
69
|
+
/** The wallet key (live). */
|
|
70
|
+
wallet: string;
|
|
71
|
+
/** The QR code's name for a screen reader. */
|
|
72
|
+
qrLabel: (xno: string) => string;
|
|
73
|
+
/** The fold with the amount and the address to type by hand. */
|
|
74
|
+
byHand: string;
|
|
75
|
+
amountLabel: string;
|
|
76
|
+
/** The address's label in the fold. */
|
|
77
|
+
toLabel: string;
|
|
78
|
+
/** In the fold: another amount does not match the order. */
|
|
79
|
+
byHandNote: string;
|
|
80
|
+
copy: string;
|
|
81
|
+
copied: string;
|
|
82
|
+
copyFailed: string;
|
|
83
|
+
/** The time left (live only): the order ends then. */
|
|
84
|
+
endsIn: (time: string) => string;
|
|
85
|
+
waiting: string;
|
|
86
|
+
noConnection: string;
|
|
87
|
+
stillWaiting: string;
|
|
88
|
+
checkAgain: string;
|
|
89
|
+
paid: string;
|
|
90
|
+
paidLine: (look: string) => string;
|
|
91
|
+
/** A payment after the order ended: it gives no look, and the creator sends it back. */
|
|
92
|
+
paidLate: string;
|
|
93
|
+
/** The order ended: a payment sent in time still counts. */
|
|
94
|
+
expired: string;
|
|
95
|
+
/** The price's sources ("CoinGecko", "Kraken", "KuCoin"). "Powered by CoinGecko" is added when CoinGecko is one and the words leave it out. */
|
|
96
|
+
prices: (sources: readonly string[]) => string;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const HATS: Record<Hat, string> = { cap: "with a cap", beanie: "with a beanie", crown: "with a crown", tophat: "with a top hat" };
|
|
100
|
+
const spaced = (slot: string) => slot.replace(/-/g, " ");
|
|
101
|
+
|
|
102
|
+
/** CoinGecko's words: its API terms ask for them wherever its price shows. */
|
|
103
|
+
export const COINGECKO_CREDIT = "Powered by CoinGecko";
|
|
104
|
+
|
|
105
|
+
export const SHOP_WORDS: ShopWords = {
|
|
106
|
+
title: "Looks",
|
|
107
|
+
close: "Close",
|
|
108
|
+
kinds: "Kinds of looks",
|
|
109
|
+
outfits: "Outfits",
|
|
110
|
+
slotTab: (slot) => spaced(slot.charAt(0).toUpperCase() + slot.slice(1)),
|
|
111
|
+
slotPlain: (slot) => `No ${spaced(slot)}`,
|
|
112
|
+
outfitLine: (hat) => (hat ? HATS[hat] : "colour only"),
|
|
113
|
+
itemLine: (slot) => spaced(slot),
|
|
114
|
+
free: "free",
|
|
115
|
+
yours: "yours",
|
|
116
|
+
wear: "Wear",
|
|
117
|
+
wearing: "Wearing",
|
|
118
|
+
buy: (price) => `Buy ${price}`,
|
|
119
|
+
looksNote: "Looks never change play. Pay in Nano, straight to the creator.",
|
|
120
|
+
signInFirst: "Sign in first to buy a look.",
|
|
121
|
+
|
|
122
|
+
buyTitle: (look) => `Buy ${look}`,
|
|
123
|
+
making: "Making your order…",
|
|
124
|
+
orderFailed: "The order did not start. Try again.",
|
|
125
|
+
refusal: (text) => text,
|
|
126
|
+
back: "Back",
|
|
127
|
+
signIn: "Sign in",
|
|
128
|
+
|
|
129
|
+
lookLine: () => "It never changes play.",
|
|
130
|
+
amount: (xno) => `${xno} XNO`,
|
|
131
|
+
usd: (usd) => `= ${usd}`,
|
|
132
|
+
sendExactly: "Send exactly",
|
|
133
|
+
testNote: "Nothing can be paid here.",
|
|
134
|
+
walletOff: "Wallet off: test mode",
|
|
135
|
+
wallet: "Open wallet",
|
|
136
|
+
qrLabel: (xno) => `QR code to pay ${xno} XNO`,
|
|
137
|
+
byHand: "Enter by hand",
|
|
138
|
+
amountLabel: "Amount",
|
|
139
|
+
toLabel: "To",
|
|
140
|
+
byHandNote: "Another amount does not match.",
|
|
141
|
+
copy: "Copy",
|
|
142
|
+
copied: "Copied",
|
|
143
|
+
copyFailed: "Copy failed",
|
|
144
|
+
endsIn: (time) => `Ends in ${time}.`,
|
|
145
|
+
waiting: "Waiting for payment…",
|
|
146
|
+
noConnection: "No connection. Trying again…",
|
|
147
|
+
stillWaiting: "Still waiting. Already paid? Press Check again.",
|
|
148
|
+
checkAgain: "Check again",
|
|
149
|
+
paid: "Paid. Thank you!",
|
|
150
|
+
paidLine: (look) => `${look} is yours.`,
|
|
151
|
+
paidLate: "Paid after the order ended, so no look. The creator sends it back.",
|
|
152
|
+
expired: "This order ended. Paid in time? Wait here: it still counts.",
|
|
153
|
+
prices: (sources) => {
|
|
154
|
+
const others = sources.filter((s) => s !== "CoinGecko");
|
|
155
|
+
const credit = sources.includes("CoinGecko") ? ` ${COINGECKO_CREDIT}.` : "";
|
|
156
|
+
return others.length ? `Price: ${others.join(", ")}.${credit}` : credit.trim();
|
|
157
|
+
},
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
/** The game's words over the defaults. A key the game leaves out, or gives as undefined, keeps its default. */
|
|
161
|
+
export function shopWords(over?: Partial<ShopWords>): ShopWords {
|
|
162
|
+
const out = { ...SHOP_WORDS };
|
|
163
|
+
for (const [k, v] of Object.entries(over ?? {})) if (v !== undefined && k in SHOP_WORDS) (out as Record<string, unknown>)[k] = v;
|
|
164
|
+
return out;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** The price's line: the game's words, with "Powered by CoinGecko" added when CoinGecko is a source and the words leave it out. */
|
|
168
|
+
export function priceLine(words: ShopWords, sources: readonly string[]): string {
|
|
169
|
+
const line = words.prices(sources).trim();
|
|
170
|
+
if (!sources.includes("CoinGecko") || line.includes(COINGECKO_CREDIT)) return line;
|
|
171
|
+
return `${line}${line ? " " : ""}${COINGECKO_CREDIT}.`;
|
|
172
|
+
}
|