@crowdedkingdoms/crowdyjs 18.12.0-dev.1 → 18.13.0-dev.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.
- package/MIGRATION.md +25 -0
- package/README.md +7 -1
- package/dist/generated/graphql-schema.d.ts +4 -4
- package/dist/generated/graphql-schema.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/kit/index.d.ts +2 -0
- package/dist/kit/index.d.ts.map +1 -1
- package/dist/kit/index.js +2 -0
- package/dist/kit/kit.d.ts +40 -1
- package/dist/kit/kit.d.ts.map +1 -1
- package/dist/kit/kit.js +71 -1
- package/dist/kit/modules/market.d.ts +159 -0
- package/dist/kit/modules/market.d.ts.map +1 -0
- package/dist/kit/modules/market.js +141 -0
- package/dist/kit/modules/player.d.ts +264 -0
- package/dist/kit/modules/player.d.ts.map +1 -0
- package/dist/kit/modules/player.js +258 -0
- package/dist/kit/protocol.d.ts +2 -0
- package/dist/kit/protocol.d.ts.map +1 -1
- package/dist/kit/protocol.js +2 -0
- package/dist/kit/runtime.d.ts.map +1 -1
- package/dist/kit/runtime.js +6 -1
- package/dist/live-coding/assets/browser-authoring-index.json +1 -1
- package/dist/live-coding/assets/manifest.json +1 -1
- package/dist/live-coding/browser-authoring-index.generated.d.ts.map +1 -1
- package/dist/live-coding/browser-authoring-index.generated.js +1474 -4
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
* never an untrusted browser.
|
|
47
47
|
*/
|
|
48
48
|
/** The published package version. Mirrors `package.json`. */
|
|
49
|
-
export declare const VERSION = "18.
|
|
49
|
+
export declare const VERSION = "18.13.0-dev.1";
|
|
50
50
|
export { LbCookieStore } from './lb-cookie-store.js';
|
|
51
51
|
export { CrowdyClient, createCrowdyClient, type CrowdyClientConfig, } from './crowdy-client.js';
|
|
52
52
|
export { CROWDY_DEFAULT_TIER, CROWDY_DEFAULT_HOST, CROWDY_DEFAULT_HTTP_ORIGIN, CROWDY_DEFAULT_WS_ORIGIN, } from './default-origin.js';
|
package/dist/index.js
CHANGED
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
* never an untrusted browser.
|
|
47
47
|
*/
|
|
48
48
|
/** The published package version. Mirrors `package.json`. */
|
|
49
|
-
export const VERSION = '18.
|
|
49
|
+
export const VERSION = '18.13.0-dev.1';
|
|
50
50
|
export { LbCookieStore } from './lb-cookie-store.js';
|
|
51
51
|
export { CrowdyClient, createCrowdyClient, } from './crowdy-client.js';
|
|
52
52
|
// The tier this build defaults to, exported so a consumer can PRINT what it is
|
package/dist/kit/index.d.ts
CHANGED
|
@@ -22,4 +22,6 @@ export { InstanceRun, InstancesKit, type InstanceMember, type InstanceRoom, type
|
|
|
22
22
|
export { ArenaMatch, ArenasKit, type ArenaBlast, type ArenaFighter, type ArenaShot, type ArenaView, } from './modules/arenas.js';
|
|
23
23
|
export { BallMatch, Race, RacingKit, type BallPlayer, type BallState, type BallView, type RaceGate, type RaceGhost, type RaceRacer, type RaceView, } from './modules/racing.js';
|
|
24
24
|
export { TerritoryKit, TerritoryMap, ZoneMatch, type TerritoryPoint, type TerritoryView, type ZoneContender, type ZoneView, } from './modules/territory.js';
|
|
25
|
+
export { AchievementsKit, CraftingKit, InventoryKit, LootKit, PlayerKit, ProductionKit, ProgressionKit, QuestsKit, WalletKit, type AchievementView, type EconBundle, type EconRecipe, type EconStack, type InventoryView, type LootRoll, type LootTableView, type PlayerEarned, type PlayerEvent, type PlayerProfile, type PlayerRules, type PlayerView, type ProductionView, type ProgressView, type QuestObjectiveView, type QuestView, type WalletView, } from './modules/player.js';
|
|
26
|
+
export { MarketCore, MarketHandle, MarketsKit, ShopHandle, ShopsKit, TradeDesk, TradesKit, type MarketBook, type MarketOrder, type MarketPlaced, type MarketQuote, type MarketTrade, type MarketTradeSide, type MarketView, type VendorOfferView, type VendorView, } from './modules/market.js';
|
|
25
27
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/kit/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/kit/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,GAC1B,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,aAAa,EACb,QAAQ,EACR,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,cAAc,GACpB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,iBAAiB,EACjB,SAAS,EACT,YAAY,EACZ,mBAAmB,EACnB,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,eAAe,EACf,aAAa,EACb,WAAW,EACX,QAAQ,EACR,eAAe,EACf,eAAe,EACf,YAAY,EACZ,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,cAAc,GACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,qBAAqB,EACrB,UAAU,EACV,KAAK,cAAc,EACnB,KAAK,iBAAiB,GACvB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,gBAAgB,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EACL,gBAAgB,EAChB,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,KAAK,aAAa,EAClB,KAAK,kBAAkB,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,aAAa,EACb,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,aAAa,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,WAAW,EACX,mBAAmB,EACnB,KAAK,gBAAgB,EACrB,KAAK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K,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,UAAU,GAChB,MAAM,qBAAqB,CAAC"}
|
package/dist/kit/index.js
CHANGED
|
@@ -22,3 +22,5 @@ export { InstanceRun, InstancesKit, } from './modules/instances.js';
|
|
|
22
22
|
export { ArenaMatch, ArenasKit, } from './modules/arenas.js';
|
|
23
23
|
export { BallMatch, Race, RacingKit, } from './modules/racing.js';
|
|
24
24
|
export { TerritoryKit, TerritoryMap, ZoneMatch, } from './modules/territory.js';
|
|
25
|
+
export { AchievementsKit, CraftingKit, InventoryKit, LootKit, PlayerKit, ProductionKit, ProgressionKit, QuestsKit, WalletKit, } from './modules/player.js';
|
|
26
|
+
export { MarketCore, MarketHandle, MarketsKit, ShopHandle, ShopsKit, TradeDesk, TradesKit, } from './modules/market.js';
|
package/dist/kit/kit.d.ts
CHANGED
|
@@ -8,8 +8,10 @@ import { ArenasKit } from './modules/arenas.js';
|
|
|
8
8
|
import { EncountersKit } from './modules/encounters.js';
|
|
9
9
|
import { InstancesKit } from './modules/instances.js';
|
|
10
10
|
import { LeaderboardsKit } from './modules/leaderboards.js';
|
|
11
|
+
import { MarketsKit, ShopsKit, TradesKit } from './modules/market.js';
|
|
11
12
|
import { MatchmakingKit } from './modules/matchmaking.js';
|
|
12
13
|
import { MinigamesKit } from './modules/minigames.js';
|
|
14
|
+
import { AchievementsKit, CraftingKit, InventoryKit, LootKit, PlayerKit, ProductionKit, ProgressionKit, QuestsKit, WalletKit } from './modules/player.js';
|
|
13
15
|
import { NpcsKit } from './modules/npcs.js';
|
|
14
16
|
import { EmotesKit, SpectateKit } from './modules/presence.js';
|
|
15
17
|
import { RacingKit } from './modules/racing.js';
|
|
@@ -54,6 +56,10 @@ export interface GameKitNodeTypes {
|
|
|
54
56
|
/** Control points (`territory`) and shrinking circles (`zone`). */
|
|
55
57
|
territory?: string;
|
|
56
58
|
zone?: string;
|
|
59
|
+
/** Each player's own hub (`player`): inventory, wallet, progression, crafting, loot. */
|
|
60
|
+
player?: string;
|
|
61
|
+
/** Markets (`market`): vendors, order books, trades. */
|
|
62
|
+
market?: string;
|
|
57
63
|
}
|
|
58
64
|
/** Options for {@link GameKitClient}. */
|
|
59
65
|
export interface GameKitOptions extends KitRuntimeOptions {
|
|
@@ -89,7 +95,10 @@ export declare class ShardKit {
|
|
|
89
95
|
* starter hubs (the root {@link world} with liveops, {@link matchmaking} queues with parties,
|
|
90
96
|
* game {@link sessions}, areas of {@link npcs} with mobs and pets, {@link leaderboards}, card
|
|
91
97
|
* {@link tables}, {@link tactics} battles, {@link encounters}, {@link minigames}, private
|
|
92
|
-
* {@link instances}, {@link arenas}, {@link racing}, {@link territory}
|
|
98
|
+
* {@link instances}, {@link arenas}, {@link racing}, {@link territory}; the economy:
|
|
99
|
+
* {@link player}, {@link inventory}, {@link wallet}, {@link progression}, {@link achievements},
|
|
100
|
+
* {@link quests}, {@link crafting}, {@link loot}, {@link production}, {@link market},
|
|
101
|
+
* {@link shops}, {@link trades}), the {@link topology}
|
|
93
102
|
* that deploys them, the client-side conventions ({@link spectate}, {@link emotes},
|
|
94
103
|
* {@link shards}), and {@link social} (parties, guilds, chat over teams and channels).
|
|
95
104
|
*
|
|
@@ -124,6 +133,9 @@ export declare class GameKitClient {
|
|
|
124
133
|
private arenasKit;
|
|
125
134
|
private racingKit;
|
|
126
135
|
private territoryKit;
|
|
136
|
+
private playerKit;
|
|
137
|
+
private readonly economy;
|
|
138
|
+
private readonly markets;
|
|
127
139
|
constructor(appId: Scalars['BigInt']['input'], gameApps: GameAppsAPI, options?: GameKitOptions, domains?: GameKitDomains);
|
|
128
140
|
/** The root world hub: conditions, resource nodes, liveops. */
|
|
129
141
|
get world(): WorldKit;
|
|
@@ -151,6 +163,33 @@ export declare class GameKitClient {
|
|
|
151
163
|
get racing(): RacingKit;
|
|
152
164
|
/** Control points factions capture, and shrinking circles. */
|
|
153
165
|
get territory(): TerritoryKit;
|
|
166
|
+
/**
|
|
167
|
+
* The caller's own `player` hub: what they own and what they did. The economy lives in hub
|
|
168
|
+
* state and is not a ledger. The modules below are views of it.
|
|
169
|
+
*/
|
|
170
|
+
get player(): PlayerKit;
|
|
171
|
+
private view;
|
|
172
|
+
/** The player's items: stacks in slots, and mail for what did not fit. */
|
|
173
|
+
get inventory(): InventoryKit;
|
|
174
|
+
/** The player's soft currencies. */
|
|
175
|
+
get wallet(): WalletKit;
|
|
176
|
+
/** Experience, levels and public profiles. */
|
|
177
|
+
get progression(): ProgressionKit;
|
|
178
|
+
get achievements(): AchievementsKit;
|
|
179
|
+
/** Quests, first-session tutorials among them. */
|
|
180
|
+
get quests(): QuestsKit;
|
|
181
|
+
get crafting(): CraftingKit;
|
|
182
|
+
/** Loot tables with pity. */
|
|
183
|
+
get loot(): LootKit;
|
|
184
|
+
/** Idle production that catches up on the time away. */
|
|
185
|
+
get production(): ProductionKit;
|
|
186
|
+
private marketCore;
|
|
187
|
+
/** Markets' order books. */
|
|
188
|
+
get market(): MarketsKit;
|
|
189
|
+
/** Markets' vendors. */
|
|
190
|
+
get shops(): ShopsKit;
|
|
191
|
+
/** Trades between two players at a market. */
|
|
192
|
+
get trades(): TradesKit;
|
|
154
193
|
/** Composing and deploying the app's tree of starter hubs (developers). */
|
|
155
194
|
get topology(): KitTopology;
|
|
156
195
|
/** Keeping a viewer with no avatar where the world's messages reach it. */
|
package/dist/kit/kit.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kit.d.ts","sourceRoot":"","sources":["../../src/kit/kit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,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AAwB;IACxB,IAAI,KAAK,IAAI,QAAQ,CAEpB;IAED,8CAA8C;IAC9C,IAAI,MAAM,IAAI,SAAS,CAEtB;IAED,2EAA2E;IAC3E,IAAI,QAAQ,IAAI,WAAW,CAE1B;IAED,2EAA2E;IAC3E,IAAI,QAAQ,IAAI,WAAW,CAE1B;IAED,qEAAqE;IACrE,IAAI,MAAM,IAAI,SAAS,CAEtB;IAED,4CAA4C;IAC5C,IAAI,MAAM,IAAI,QAAQ,CAErB;IAED,iEAAiE;IACjE,KAAK,IAAI,IAAI;CAGd"}
|
package/dist/kit/kit.js
CHANGED
|
@@ -2,8 +2,10 @@ import { ArenasKit } from './modules/arenas.js';
|
|
|
2
2
|
import { EncountersKit } from './modules/encounters.js';
|
|
3
3
|
import { InstancesKit } from './modules/instances.js';
|
|
4
4
|
import { LeaderboardsKit } from './modules/leaderboards.js';
|
|
5
|
+
import { MarketCore, MarketsKit, ShopsKit, TradesKit } from './modules/market.js';
|
|
5
6
|
import { MatchmakingKit } from './modules/matchmaking.js';
|
|
6
7
|
import { MinigamesKit } from './modules/minigames.js';
|
|
8
|
+
import { AchievementsKit, CraftingKit, InventoryKit, LootKit, PlayerKit, ProductionKit, ProgressionKit, QuestsKit, WalletKit, } from './modules/player.js';
|
|
7
9
|
import { NpcsKit } from './modules/npcs.js';
|
|
8
10
|
import { EmotesKit, SpectateKit } from './modules/presence.js';
|
|
9
11
|
import { RacingKit } from './modules/racing.js';
|
|
@@ -32,7 +34,10 @@ export class ShardKit {
|
|
|
32
34
|
* starter hubs (the root {@link world} with liveops, {@link matchmaking} queues with parties,
|
|
33
35
|
* game {@link sessions}, areas of {@link npcs} with mobs and pets, {@link leaderboards}, card
|
|
34
36
|
* {@link tables}, {@link tactics} battles, {@link encounters}, {@link minigames}, private
|
|
35
|
-
* {@link instances}, {@link arenas}, {@link racing}, {@link territory}
|
|
37
|
+
* {@link instances}, {@link arenas}, {@link racing}, {@link territory}; the economy:
|
|
38
|
+
* {@link player}, {@link inventory}, {@link wallet}, {@link progression}, {@link achievements},
|
|
39
|
+
* {@link quests}, {@link crafting}, {@link loot}, {@link production}, {@link market},
|
|
40
|
+
* {@link shops}, {@link trades}), the {@link topology}
|
|
36
41
|
* that deploys them, the client-side conventions ({@link spectate}, {@link emotes},
|
|
37
42
|
* {@link shards}), and {@link social} (parties, guilds, chat over teams and channels).
|
|
38
43
|
*
|
|
@@ -64,6 +69,17 @@ export class GameKitClient {
|
|
|
64
69
|
this.arenasKit = null;
|
|
65
70
|
this.racingKit = null;
|
|
66
71
|
this.territoryKit = null;
|
|
72
|
+
this.playerKit = null;
|
|
73
|
+
this.economy = new Map();
|
|
74
|
+
this.markets = new Map();
|
|
75
|
+
this.marketCore = (key) => {
|
|
76
|
+
let core = this.markets.get(key);
|
|
77
|
+
if (!core) {
|
|
78
|
+
core = new MarketCore(this.runtime, this.options.nodes?.market ?? 'market', key);
|
|
79
|
+
this.markets.set(key, core);
|
|
80
|
+
}
|
|
81
|
+
return core;
|
|
82
|
+
};
|
|
67
83
|
this.social = new SocialKit(appId, domains.teams, domains.channels, domains.udp, gameApps, options.social);
|
|
68
84
|
this.runtime = new KitRuntime(String(appId), domains.exec, options, domains.whoAmI);
|
|
69
85
|
}
|
|
@@ -123,6 +139,60 @@ export class GameKitClient {
|
|
|
123
139
|
get territory() {
|
|
124
140
|
return (this.territoryKit ?? (this.territoryKit = new TerritoryKit(this.runtime, this.options.nodes?.territory, this.options.nodes?.zone)));
|
|
125
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* The caller's own `player` hub: what they own and what they did. The economy lives in hub
|
|
144
|
+
* state and is not a ledger. The modules below are views of it.
|
|
145
|
+
*/
|
|
146
|
+
get player() {
|
|
147
|
+
return (this.playerKit ?? (this.playerKit = new PlayerKit(this.runtime, this.options.nodes?.player)));
|
|
148
|
+
}
|
|
149
|
+
view(name, make) {
|
|
150
|
+
if (!this.economy.has(name))
|
|
151
|
+
this.economy.set(name, make(this.player));
|
|
152
|
+
return this.economy.get(name);
|
|
153
|
+
}
|
|
154
|
+
/** The player's items: stacks in slots, and mail for what did not fit. */
|
|
155
|
+
get inventory() {
|
|
156
|
+
return this.view('inventory', (p) => new InventoryKit(p));
|
|
157
|
+
}
|
|
158
|
+
/** The player's soft currencies. */
|
|
159
|
+
get wallet() {
|
|
160
|
+
return this.view('wallet', (p) => new WalletKit(p));
|
|
161
|
+
}
|
|
162
|
+
/** Experience, levels and public profiles. */
|
|
163
|
+
get progression() {
|
|
164
|
+
return this.view('progression', (p) => new ProgressionKit(p));
|
|
165
|
+
}
|
|
166
|
+
get achievements() {
|
|
167
|
+
return this.view('achievements', (p) => new AchievementsKit(p));
|
|
168
|
+
}
|
|
169
|
+
/** Quests, first-session tutorials among them. */
|
|
170
|
+
get quests() {
|
|
171
|
+
return this.view('quests', (p) => new QuestsKit(p));
|
|
172
|
+
}
|
|
173
|
+
get crafting() {
|
|
174
|
+
return this.view('crafting', (p) => new CraftingKit(p));
|
|
175
|
+
}
|
|
176
|
+
/** Loot tables with pity. */
|
|
177
|
+
get loot() {
|
|
178
|
+
return this.view('loot', (p) => new LootKit(p));
|
|
179
|
+
}
|
|
180
|
+
/** Idle production that catches up on the time away. */
|
|
181
|
+
get production() {
|
|
182
|
+
return this.view('production', (p) => new ProductionKit(p));
|
|
183
|
+
}
|
|
184
|
+
/** Markets' order books. */
|
|
185
|
+
get market() {
|
|
186
|
+
return this.view('market', () => new MarketsKit(this.marketCore));
|
|
187
|
+
}
|
|
188
|
+
/** Markets' vendors. */
|
|
189
|
+
get shops() {
|
|
190
|
+
return this.view('shops', () => new ShopsKit(this.marketCore));
|
|
191
|
+
}
|
|
192
|
+
/** Trades between two players at a market. */
|
|
193
|
+
get trades() {
|
|
194
|
+
return this.view('trades', () => new TradesKit(this.marketCore));
|
|
195
|
+
}
|
|
126
196
|
/** Composing and deploying the app's tree of starter hubs (developers). */
|
|
127
197
|
get topology() {
|
|
128
198
|
return (this.topologyKit ?? (this.topologyKit = new KitTopology(String(this.appId), this.domains.exec)));
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { HubState, PrivateState } from '../mirror.js';
|
|
2
|
+
import type { KitRuntime } from '../runtime.js';
|
|
3
|
+
import type { EconBundle } from './player.js';
|
|
4
|
+
export interface VendorOfferView {
|
|
5
|
+
item: string;
|
|
6
|
+
price: EconBundle;
|
|
7
|
+
/** Left on the shelf; null for no limit. */
|
|
8
|
+
stock: number | null;
|
|
9
|
+
per_player: number | null;
|
|
10
|
+
/** What the vendor pays for one; null when it does not buy them. */
|
|
11
|
+
buys_for: EconBundle | null;
|
|
12
|
+
}
|
|
13
|
+
export interface VendorView {
|
|
14
|
+
id: string;
|
|
15
|
+
offers: VendorOfferView[];
|
|
16
|
+
restocked_at: number;
|
|
17
|
+
}
|
|
18
|
+
export interface MarketQuote {
|
|
19
|
+
bid: number | null;
|
|
20
|
+
ask: number | null;
|
|
21
|
+
last: number | null;
|
|
22
|
+
}
|
|
23
|
+
/** What the `market` topic carries. */
|
|
24
|
+
export interface MarketView {
|
|
25
|
+
vendors: VendorView[];
|
|
26
|
+
currency: string;
|
|
27
|
+
quotes: Record<string, MarketQuote>;
|
|
28
|
+
open_trades: number;
|
|
29
|
+
pending_steps: number;
|
|
30
|
+
}
|
|
31
|
+
export interface MarketBook {
|
|
32
|
+
item: string;
|
|
33
|
+
currency: string;
|
|
34
|
+
/** `[price, count]` a level, best first. */
|
|
35
|
+
bids: Array<[number, number]>;
|
|
36
|
+
asks: Array<[number, number]>;
|
|
37
|
+
last: number | null;
|
|
38
|
+
}
|
|
39
|
+
export interface MarketOrder {
|
|
40
|
+
id: number;
|
|
41
|
+
player: number;
|
|
42
|
+
item: string;
|
|
43
|
+
side: 'buy' | 'sell';
|
|
44
|
+
price: number;
|
|
45
|
+
count: number;
|
|
46
|
+
/** What is still open. */
|
|
47
|
+
open: number;
|
|
48
|
+
/** The hold that backs it, in the player's hub. */
|
|
49
|
+
hold: string;
|
|
50
|
+
}
|
|
51
|
+
export interface MarketPlaced {
|
|
52
|
+
order: number;
|
|
53
|
+
/** `[price, count]` it traded at once. */
|
|
54
|
+
fills: Array<[number, number]>;
|
|
55
|
+
open: number;
|
|
56
|
+
}
|
|
57
|
+
export interface MarketTradeSide {
|
|
58
|
+
bundle: EconBundle;
|
|
59
|
+
hold: string | null;
|
|
60
|
+
accepted: boolean;
|
|
61
|
+
}
|
|
62
|
+
export interface MarketTrade {
|
|
63
|
+
id: number;
|
|
64
|
+
players: [number, number];
|
|
65
|
+
sides: [MarketTradeSide, MarketTradeSide];
|
|
66
|
+
state: 'open' | 'settling' | 'done' | 'cancelled';
|
|
67
|
+
expires_at: number;
|
|
68
|
+
offers: number;
|
|
69
|
+
}
|
|
70
|
+
/** One market hub's mirrors and calls, shared by its market, shop and trade handles. */
|
|
71
|
+
export declare class MarketCore {
|
|
72
|
+
readonly runtime: KitRuntime;
|
|
73
|
+
readonly nodeType: string;
|
|
74
|
+
readonly key: string;
|
|
75
|
+
readonly view: HubState<MarketView>;
|
|
76
|
+
/** The caller's open orders, read again when the market says they moved. */
|
|
77
|
+
readonly orders: PrivateState<MarketOrder[]>;
|
|
78
|
+
/** The caller's open and settling trades. */
|
|
79
|
+
readonly trades: PrivateState<MarketTrade[]>;
|
|
80
|
+
constructor(runtime: KitRuntime, nodeType: string, key: string);
|
|
81
|
+
change<T>(method: string, args: unknown): Promise<T>;
|
|
82
|
+
}
|
|
83
|
+
/** Markets' order books (the `market` starter): {@link at} a market by its name. */
|
|
84
|
+
export declare class MarketsKit {
|
|
85
|
+
private readonly core;
|
|
86
|
+
constructor(core: (key: string) => MarketCore);
|
|
87
|
+
at(key?: string): MarketHandle;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* A market's order books: limit orders matched at price-time priority. An order holds what it
|
|
91
|
+
* offers in the player's own hub until it fills or is cancelled; the market moves each fill
|
|
92
|
+
* between the two players' hubs.
|
|
93
|
+
*/
|
|
94
|
+
export declare class MarketHandle {
|
|
95
|
+
private readonly core;
|
|
96
|
+
constructor(core: MarketCore);
|
|
97
|
+
get view(): HubState<MarketView>;
|
|
98
|
+
get orders(): PrivateState<MarketOrder[]>;
|
|
99
|
+
watch(): Promise<MarketView>;
|
|
100
|
+
unwatch(): Promise<void>;
|
|
101
|
+
book(item: string): Promise<MarketBook>;
|
|
102
|
+
/**
|
|
103
|
+
* Places a limit order; a buy holds `price * count` of the market's currency, a sell the items.
|
|
104
|
+
* @throws {KitError} `insufficient`, `limit` (open orders), `not_found` (no book), `unavailable`.
|
|
105
|
+
*/
|
|
106
|
+
order(order: {
|
|
107
|
+
item: string;
|
|
108
|
+
side: 'buy' | 'sell';
|
|
109
|
+
price: number;
|
|
110
|
+
count: number;
|
|
111
|
+
}): Promise<MarketPlaced>;
|
|
112
|
+
/** Cancels an open order; what it still holds comes back. @throws {KitError} `not_found`. */
|
|
113
|
+
cancel(order: number): Promise<boolean>;
|
|
114
|
+
}
|
|
115
|
+
/** Markets' vendors (the `market` starter): {@link at} a market by its name. */
|
|
116
|
+
export declare class ShopsKit {
|
|
117
|
+
private readonly core;
|
|
118
|
+
constructor(core: (key: string) => MarketCore);
|
|
119
|
+
at(key?: string): ShopHandle;
|
|
120
|
+
}
|
|
121
|
+
/** A market's vendors: fixed prices, stock that restocks, a limit per player. */
|
|
122
|
+
export declare class ShopHandle {
|
|
123
|
+
private readonly core;
|
|
124
|
+
constructor(core: MarketCore);
|
|
125
|
+
get view(): HubState<MarketView>;
|
|
126
|
+
watch(): Promise<MarketView>;
|
|
127
|
+
unwatch(): Promise<void>;
|
|
128
|
+
vendors(): Promise<VendorView[]>;
|
|
129
|
+
/** Buys `count` (one by default). @throws {KitError} `insufficient` (gold or stock), `limit`, `full`, `not_found`, `unavailable`. */
|
|
130
|
+
buy(vendor: string, item: string, count?: number): Promise<EconBundle>;
|
|
131
|
+
/** Sells `count` (one by default). @throws {KitError} `forbidden` (it does not buy them), `insufficient`, `unavailable`. */
|
|
132
|
+
sell(vendor: string, item: string, count?: number): Promise<EconBundle>;
|
|
133
|
+
}
|
|
134
|
+
/** Trades between two players at a market: {@link at} a market by its name. */
|
|
135
|
+
export declare class TradesKit {
|
|
136
|
+
private readonly core;
|
|
137
|
+
constructor(core: (key: string) => MarketCore);
|
|
138
|
+
at(key?: string): TradeDesk;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Trades between two players: each offers a bundle, held in their own hub; when both accept
|
|
142
|
+
* the last offers, the market moves each to the other. A changed offer clears both acceptances.
|
|
143
|
+
*/
|
|
144
|
+
export declare class TradeDesk {
|
|
145
|
+
private readonly core;
|
|
146
|
+
constructor(core: MarketCore);
|
|
147
|
+
get mine(): PrivateState<MarketTrade[]>;
|
|
148
|
+
watch(): Promise<MarketTrade[]>;
|
|
149
|
+
unwatch(): Promise<void>;
|
|
150
|
+
/** Opens a trade with `player`; resolves with its id. */
|
|
151
|
+
open(player: number | string): Promise<number>;
|
|
152
|
+
/** Offers `bundle` (held at once; an empty one withdraws). @throws {KitError} `insufficient`, `forbidden`, `finished`. */
|
|
153
|
+
offer(trade: number, bundle: Partial<EconBundle>): Promise<boolean>;
|
|
154
|
+
/** Accepts the offers as they stand; resolves with the trade's state. @throws {KitError} `not_ready`, `finished`. */
|
|
155
|
+
accept(trade: number): Promise<MarketTrade['state']>;
|
|
156
|
+
/** Calls it off; what each offered comes back. */
|
|
157
|
+
decline(trade: number): Promise<boolean>;
|
|
158
|
+
}
|
|
159
|
+
//# sourceMappingURL=market.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"market.d.ts","sourceRoot":"","sources":["../../../src/kit/modules/market.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,WAAW,eAAe;IAC9B,IAAI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 +1,141 @@
|
|
|
1
|
+
import { HubState, PrivateState } from '../mirror.js';
|
|
2
|
+
const TOPIC = 'market';
|
|
3
|
+
/** One market hub's mirrors and calls, shared by its market, shop and trade handles. */
|
|
4
|
+
export class MarketCore {
|
|
5
|
+
constructor(runtime, nodeType, key) {
|
|
6
|
+
this.runtime = runtime;
|
|
7
|
+
this.nodeType = nodeType;
|
|
8
|
+
this.key = key;
|
|
9
|
+
this.view = new HubState(runtime, nodeType, key, TOPIC);
|
|
10
|
+
const source = { nodeType, key, topic: TOPIC };
|
|
11
|
+
this.orders = new PrivateState(runtime, { ...source, what: 'orders', read: () => runtime.call(nodeType, key, 'orders') });
|
|
12
|
+
this.trades = new PrivateState(runtime, { ...source, what: 'trades', read: () => runtime.call(nodeType, key, 'trades') });
|
|
13
|
+
}
|
|
14
|
+
change(method, args) {
|
|
15
|
+
return this.runtime.call(this.nodeType, this.key, method, args, { action: true });
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/** Markets' order books (the `market` starter): {@link at} a market by its name. */
|
|
19
|
+
export class MarketsKit {
|
|
20
|
+
constructor(core) {
|
|
21
|
+
this.core = core;
|
|
22
|
+
}
|
|
23
|
+
at(key = 'town') {
|
|
24
|
+
return new MarketHandle(this.core(key));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A market's order books: limit orders matched at price-time priority. An order holds what it
|
|
29
|
+
* offers in the player's own hub until it fills or is cancelled; the market moves each fill
|
|
30
|
+
* between the two players' hubs.
|
|
31
|
+
*/
|
|
32
|
+
export class MarketHandle {
|
|
33
|
+
constructor(core) {
|
|
34
|
+
this.core = core;
|
|
35
|
+
}
|
|
36
|
+
get view() {
|
|
37
|
+
return this.core.view;
|
|
38
|
+
}
|
|
39
|
+
get orders() {
|
|
40
|
+
return this.core.orders;
|
|
41
|
+
}
|
|
42
|
+
async watch() {
|
|
43
|
+
const [view] = await Promise.all([this.core.view.start(), this.core.orders.start()]);
|
|
44
|
+
return view;
|
|
45
|
+
}
|
|
46
|
+
async unwatch() {
|
|
47
|
+
await Promise.all([this.core.view.stop(), this.core.orders.stop()]);
|
|
48
|
+
}
|
|
49
|
+
book(item) {
|
|
50
|
+
return this.core.runtime.call(this.core.nodeType, this.core.key, 'book', { item });
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Places a limit order; a buy holds `price * count` of the market's currency, a sell the items.
|
|
54
|
+
* @throws {KitError} `insufficient`, `limit` (open orders), `not_found` (no book), `unavailable`.
|
|
55
|
+
*/
|
|
56
|
+
order(order) {
|
|
57
|
+
return this.core.change('order', order);
|
|
58
|
+
}
|
|
59
|
+
/** Cancels an open order; what it still holds comes back. @throws {KitError} `not_found`. */
|
|
60
|
+
cancel(order) {
|
|
61
|
+
return this.core.change('cancel', { order });
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/** Markets' vendors (the `market` starter): {@link at} a market by its name. */
|
|
65
|
+
export class ShopsKit {
|
|
66
|
+
constructor(core) {
|
|
67
|
+
this.core = core;
|
|
68
|
+
}
|
|
69
|
+
at(key = 'town') {
|
|
70
|
+
return new ShopHandle(this.core(key));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/** A market's vendors: fixed prices, stock that restocks, a limit per player. */
|
|
74
|
+
export class ShopHandle {
|
|
75
|
+
constructor(core) {
|
|
76
|
+
this.core = core;
|
|
77
|
+
}
|
|
78
|
+
get view() {
|
|
79
|
+
return this.core.view;
|
|
80
|
+
}
|
|
81
|
+
watch() {
|
|
82
|
+
return this.core.view.start();
|
|
83
|
+
}
|
|
84
|
+
unwatch() {
|
|
85
|
+
return this.core.view.stop();
|
|
86
|
+
}
|
|
87
|
+
vendors() {
|
|
88
|
+
return this.core.runtime.call(this.core.nodeType, this.core.key, 'vendors');
|
|
89
|
+
}
|
|
90
|
+
/** Buys `count` (one by default). @throws {KitError} `insufficient` (gold or stock), `limit`, `full`, `not_found`, `unavailable`. */
|
|
91
|
+
buy(vendor, item, count) {
|
|
92
|
+
return this.core.change('buy', count === undefined ? { vendor, item } : { vendor, item, count });
|
|
93
|
+
}
|
|
94
|
+
/** Sells `count` (one by default). @throws {KitError} `forbidden` (it does not buy them), `insufficient`, `unavailable`. */
|
|
95
|
+
sell(vendor, item, count) {
|
|
96
|
+
return this.core.change('sell', count === undefined ? { vendor, item } : { vendor, item, count });
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/** Trades between two players at a market: {@link at} a market by its name. */
|
|
100
|
+
export class TradesKit {
|
|
101
|
+
constructor(core) {
|
|
102
|
+
this.core = core;
|
|
103
|
+
}
|
|
104
|
+
at(key = 'town') {
|
|
105
|
+
return new TradeDesk(this.core(key));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Trades between two players: each offers a bundle, held in their own hub; when both accept
|
|
110
|
+
* the last offers, the market moves each to the other. A changed offer clears both acceptances.
|
|
111
|
+
*/
|
|
112
|
+
export class TradeDesk {
|
|
113
|
+
constructor(core) {
|
|
114
|
+
this.core = core;
|
|
115
|
+
}
|
|
116
|
+
get mine() {
|
|
117
|
+
return this.core.trades;
|
|
118
|
+
}
|
|
119
|
+
async watch() {
|
|
120
|
+
return this.core.trades.start();
|
|
121
|
+
}
|
|
122
|
+
unwatch() {
|
|
123
|
+
return this.core.trades.stop();
|
|
124
|
+
}
|
|
125
|
+
/** Opens a trade with `player`; resolves with its id. */
|
|
126
|
+
open(player) {
|
|
127
|
+
return this.core.change('trade', { with: Number(player) });
|
|
128
|
+
}
|
|
129
|
+
/** Offers `bundle` (held at once; an empty one withdraws). @throws {KitError} `insufficient`, `forbidden`, `finished`. */
|
|
130
|
+
offer(trade, bundle) {
|
|
131
|
+
return this.core.change('offer', { trade, bundle });
|
|
132
|
+
}
|
|
133
|
+
/** Accepts the offers as they stand; resolves with the trade's state. @throws {KitError} `not_ready`, `finished`. */
|
|
134
|
+
accept(trade) {
|
|
135
|
+
return this.core.change('accept', { trade });
|
|
136
|
+
}
|
|
137
|
+
/** Calls it off; what each offered comes back. */
|
|
138
|
+
decline(trade) {
|
|
139
|
+
return this.core.change('decline', { trade });
|
|
140
|
+
}
|
|
141
|
+
}
|