@shipload/sdk 0.2.1 → 0.3.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/lib/shipload.d.ts +77 -9
- package/lib/shipload.js +325 -17
- package/lib/shipload.js.map +1 -1
- package/lib/shipload.m.js +291 -16
- package/lib/shipload.m.js.map +1 -1
- package/package.json +1 -1
- package/src/contracts/server.ts +48 -10
- package/src/errors.ts +9 -0
- package/src/goods.ts +113 -0
- package/src/hash.ts +6 -2
- package/src/index-module.ts +3 -0
- package/src/market.ts +58 -0
- package/src/rolls.ts +8 -0
- package/src/shipload.ts +59 -1
- package/src/state.ts +0 -0
- package/src/travel.ts +39 -3
- package/src/types.ts +15 -0
package/lib/shipload.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Blob, ABI, Struct, Name, UInt64, NameType, UInt64Type, Action, Int64,
|
|
1
|
+
import { Blob, ABI, Struct, Name, UInt64, NameType, UInt64Type, Action, Int64, UInt16, Checksum256, UInt32, TimePoint, UInt8, BlockTimestamp, Int64Type, Checksum256Type, UInt16Type, Checksum512, APIClient } from '@wharfkit/antelope';
|
|
2
2
|
import { Contract as Contract$2, PartialBy, ContractArgs, ActionOptions, Table } from '@wharfkit/contract';
|
|
3
|
+
import { ChainDefinition } from '@wharfkit/session';
|
|
3
4
|
|
|
4
5
|
declare const abiBlob$1: Blob;
|
|
5
6
|
declare const abi$1: ABI;
|
|
@@ -99,7 +100,6 @@ declare namespace Types {
|
|
|
99
100
|
id: UInt64;
|
|
100
101
|
}
|
|
101
102
|
class buygoods extends Struct {
|
|
102
|
-
buyer: Name;
|
|
103
103
|
ship_id: UInt64;
|
|
104
104
|
good_id: UInt64;
|
|
105
105
|
quantity: UInt64;
|
|
@@ -109,6 +109,7 @@ declare namespace Types {
|
|
|
109
109
|
ship_id: UInt64;
|
|
110
110
|
good_id: UInt64;
|
|
111
111
|
quantity: UInt64;
|
|
112
|
+
loaded: UInt64;
|
|
112
113
|
}
|
|
113
114
|
class cleartable extends Struct {
|
|
114
115
|
table_name: Name;
|
|
@@ -126,6 +127,10 @@ declare namespace Types {
|
|
|
126
127
|
id: UInt64;
|
|
127
128
|
destination: coordinates;
|
|
128
129
|
}
|
|
130
|
+
class good_price extends Struct {
|
|
131
|
+
id: UInt16;
|
|
132
|
+
price: UInt64;
|
|
133
|
+
}
|
|
129
134
|
class hash extends Struct {
|
|
130
135
|
value: string;
|
|
131
136
|
}
|
|
@@ -142,13 +147,19 @@ declare namespace Types {
|
|
|
142
147
|
quantity: UInt16;
|
|
143
148
|
thrust: UInt32;
|
|
144
149
|
}
|
|
150
|
+
class marketprice extends Struct {
|
|
151
|
+
location: coordinates;
|
|
152
|
+
good_id: UInt16;
|
|
153
|
+
}
|
|
154
|
+
class marketprices extends Struct {
|
|
155
|
+
location: coordinates;
|
|
156
|
+
}
|
|
145
157
|
class player_row extends Struct {
|
|
146
158
|
owner: Name;
|
|
147
159
|
balance: UInt64;
|
|
148
160
|
debt: UInt64;
|
|
149
161
|
}
|
|
150
162
|
class sellgoods extends Struct {
|
|
151
|
-
seller: Name;
|
|
152
163
|
ship_id: UInt64;
|
|
153
164
|
good_id: UInt64;
|
|
154
165
|
quantity: UInt64;
|
|
@@ -157,10 +168,12 @@ declare namespace Types {
|
|
|
157
168
|
key: Name;
|
|
158
169
|
value: UInt64;
|
|
159
170
|
}
|
|
171
|
+
class ship_state extends Struct {
|
|
172
|
+
energy: UInt32;
|
|
173
|
+
}
|
|
160
174
|
class ship_stats extends Struct {
|
|
161
175
|
capacity: UInt32;
|
|
162
176
|
drain: UInt32;
|
|
163
|
-
energy: UInt32;
|
|
164
177
|
mass: UInt64;
|
|
165
178
|
orbit: UInt16;
|
|
166
179
|
recharge: UInt32;
|
|
@@ -178,6 +191,7 @@ declare namespace Types {
|
|
|
178
191
|
location: coordinates;
|
|
179
192
|
skin: UInt8;
|
|
180
193
|
tier: UInt8;
|
|
194
|
+
state: ship_state;
|
|
181
195
|
stats: ship_stats;
|
|
182
196
|
loaders: loader_stats;
|
|
183
197
|
travelplan?: travel_plan;
|
|
@@ -251,7 +265,6 @@ declare namespace ActionParams {
|
|
|
251
265
|
id: UInt64Type;
|
|
252
266
|
}
|
|
253
267
|
interface buygoods {
|
|
254
|
-
buyer: NameType;
|
|
255
268
|
ship_id: UInt64Type;
|
|
256
269
|
good_id: UInt64Type;
|
|
257
270
|
quantity: UInt64Type;
|
|
@@ -278,8 +291,14 @@ declare namespace ActionParams {
|
|
|
278
291
|
interface join {
|
|
279
292
|
account: NameType;
|
|
280
293
|
}
|
|
294
|
+
interface marketprice {
|
|
295
|
+
location: Type.coordinates;
|
|
296
|
+
good_id: UInt16Type;
|
|
297
|
+
}
|
|
298
|
+
interface marketprices {
|
|
299
|
+
location: Type.coordinates;
|
|
300
|
+
}
|
|
281
301
|
interface sellgoods {
|
|
282
|
-
seller: NameType;
|
|
283
302
|
ship_id: UInt64Type;
|
|
284
303
|
good_id: UInt64Type;
|
|
285
304
|
quantity: UInt64Type;
|
|
@@ -306,6 +325,8 @@ interface ActionNameParams {
|
|
|
306
325
|
hash: ActionParams.hash;
|
|
307
326
|
init: ActionParams.init;
|
|
308
327
|
join: ActionParams.join;
|
|
328
|
+
marketprice: ActionParams.marketprice;
|
|
329
|
+
marketprices: ActionParams.marketprices;
|
|
309
330
|
sellgoods: ActionParams.sellgoods;
|
|
310
331
|
test: ActionParams.test;
|
|
311
332
|
travel: ActionParams.travel;
|
|
@@ -315,6 +336,8 @@ type ActionNames = keyof ActionNameParams;
|
|
|
315
336
|
interface ActionReturnValues {
|
|
316
337
|
esttravel: Types.travel_summary;
|
|
317
338
|
hash: Checksum512;
|
|
339
|
+
marketprice: Types.good_price;
|
|
340
|
+
marketprices: Types.good_price[];
|
|
318
341
|
}
|
|
319
342
|
type ActionReturnNames = keyof ActionReturnValues;
|
|
320
343
|
declare class Contract extends Contract$2 {
|
|
@@ -356,7 +379,8 @@ declare namespace server {
|
|
|
356
379
|
};
|
|
357
380
|
}
|
|
358
381
|
|
|
359
|
-
declare function hash(seed: Checksum256Type, string: string):
|
|
382
|
+
declare function hash(seed: Checksum256Type, string: string): Checksum512;
|
|
383
|
+
declare function hashBytes(seed: Checksum256Type, string: string): Uint8Array;
|
|
360
384
|
|
|
361
385
|
interface Coordinates {
|
|
362
386
|
x: number;
|
|
@@ -374,16 +398,60 @@ interface Distance {
|
|
|
374
398
|
destination: Coordinates;
|
|
375
399
|
distance: number;
|
|
376
400
|
}
|
|
401
|
+
interface Good {
|
|
402
|
+
id: UInt16;
|
|
403
|
+
name: string;
|
|
404
|
+
description: string;
|
|
405
|
+
base_price: UInt64;
|
|
406
|
+
mass: UInt64;
|
|
407
|
+
}
|
|
408
|
+
interface GoodPrice {
|
|
409
|
+
id: UInt16;
|
|
410
|
+
price: UInt64;
|
|
411
|
+
}
|
|
377
412
|
|
|
378
|
-
declare function
|
|
413
|
+
declare function distanceTraveled(ship: Types.ship_row): number;
|
|
414
|
+
declare function distanceBetweenPoints(x1: number, y1: number, x2: number, y2: number): number;
|
|
379
415
|
declare function lerp(origin: Coordinates, destination: Coordinates, time: number): {
|
|
380
416
|
x: number;
|
|
381
417
|
y: number;
|
|
382
418
|
};
|
|
383
419
|
declare function rotation(origin: Coordinates, destination: Coordinates): number;
|
|
384
420
|
declare function hasPlanet(seed: Checksum256, coords: Coordinates): boolean;
|
|
421
|
+
declare function findNearbyPlanets(seed: Checksum256, origin: Coordinates, maxDistance?: number): Distance[];
|
|
422
|
+
|
|
423
|
+
declare const goods: Good[];
|
|
424
|
+
declare function getGood(good_id: UInt16Type): Good;
|
|
385
425
|
|
|
426
|
+
declare function marketprice(location: Coordinates, good_id: UInt16Type, gameSeed: Checksum256Type, epochSeed: Checksum256Type): Promise<UInt64>;
|
|
427
|
+
declare function marketprices(location: Coordinates, gameSeed: Checksum256Type, epochSeed: Checksum256Type): Promise<GoodPrice[]>;
|
|
428
|
+
declare function priceFromRoll(basePrice: UInt64Type, roll: number): UInt64;
|
|
429
|
+
|
|
430
|
+
declare const ERROR_SYSTEM_NOT_INITIALIZED = "System not initialized";
|
|
431
|
+
declare const GOOD_DOES_NOT_EXIST = "Good does not exist";
|
|
432
|
+
declare const GOOD_NOT_AVAILABLE_AT_LOCATION = "Good not available at location";
|
|
433
|
+
declare const PLAYER_NOT_FOUND = "Player not found";
|
|
434
|
+
declare const SHIP_NOT_FOUND = "Ship not found";
|
|
435
|
+
declare const SHIP_CANNOT_BUY_TRAVELING = "Ship cannot buy while traveling";
|
|
436
|
+
declare const INSUFFICIENT_BALANCE = "Insufficient balance";
|
|
437
|
+
declare const INSUFFICIENT_GOOD_QUANTITY = "Insufficient good quantity";
|
|
438
|
+
declare const REQUIRES_MORE_THAN_ONE = "Requires more than one";
|
|
439
|
+
|
|
440
|
+
interface ShiploadOptions {
|
|
441
|
+
contractName?: string;
|
|
442
|
+
client?: APIClient;
|
|
443
|
+
}
|
|
444
|
+
interface ShiploadConstructorOptions extends ShiploadOptions {
|
|
445
|
+
serverContract: Contract$2;
|
|
446
|
+
}
|
|
386
447
|
declare class Shipload {
|
|
448
|
+
private client;
|
|
449
|
+
private server;
|
|
450
|
+
constructor(chain: ChainDefinition, { client, serverContract }: ShiploadConstructorOptions);
|
|
451
|
+
static load(chain: ChainDefinition, shiploadOptions: ShiploadOptions): Promise<Shipload>;
|
|
452
|
+
getState(): Promise<Types.state_row>;
|
|
453
|
+
marketprice(location: Coordinates, good_id: number): Promise<UInt64>;
|
|
454
|
+
marketprices(location: Coordinates): Promise<GoodPrice[]>;
|
|
387
455
|
}
|
|
388
456
|
|
|
389
|
-
export { CameraPosition, Coordinates, Dimensions, Distance, platform as PlatformContract, server as ServerContract, Shipload as default,
|
|
457
|
+
export { CameraPosition, Coordinates, Dimensions, Distance, ERROR_SYSTEM_NOT_INITIALIZED, GOOD_DOES_NOT_EXIST, GOOD_NOT_AVAILABLE_AT_LOCATION, Good, GoodPrice, INSUFFICIENT_BALANCE, INSUFFICIENT_GOOD_QUANTITY, PLAYER_NOT_FOUND, platform as PlatformContract, REQUIRES_MORE_THAN_ONE, SHIP_CANNOT_BUY_TRAVELING, SHIP_NOT_FOUND, server as ServerContract, Shipload as default, distanceBetweenPoints, distanceTraveled, findNearbyPlanets, getGood, goods, hasPlanet, hash, hashBytes, lerp, marketprice, marketprices, priceFromRoll, rotation };
|
package/lib/shipload.js
CHANGED
|
@@ -4,7 +4,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var tslib = require('tslib');
|
|
6
6
|
var antelope = require('@wharfkit/antelope');
|
|
7
|
-
var
|
|
7
|
+
var ContractKit = require('@wharfkit/contract');
|
|
8
|
+
|
|
9
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
|
+
|
|
11
|
+
var ContractKit__default = /*#__PURE__*/_interopDefaultLegacy(ContractKit);
|
|
8
12
|
|
|
9
13
|
const abiBlob$1 = antelope.Blob.from('DmVvc2lvOjphYmkvMS4yAAcKY2xlYXJ0YWJsZQADCnRhYmxlX25hbWUEbmFtZQVzY29wZQVuYW1lPwhtYXhfcm93cwd1aW50NjQ/C2NvbXBhbnlfcm93AAIHYWNjb3VudARuYW1lBG5hbWUGc3RyaW5nBmVuYWJsZQABB2VuYWJsZWQEYm9vbAxmb3VuZGNvbXBhbnkAAgdhY2NvdW50BG5hbWUEbmFtZQZzdHJpbmcJc3RhdGVfcm93AAEHZW5hYmxlZARib29sBHRlc3QAAQRkYXRhBnN0cmluZwR3aXBlAAAFAICKx+RrVEQKY2xlYXJ0YWJsZQAAAAAAqHjMVAZlbmFibGXzAS0tLQoKc3BlY192ZXJzaW9uOiAiMC4yLjAiCnRpdGxlOiBlbmFibGUKc3VtbWFyeTogJ0VuYWJsZS9kaXNhYmxlIHBsYXRmb3JtJwppY29uOiBodHRwczovL2F2YXRhcnMuZ2l0aHVidXNlcmNvbnRlbnQuY29tL3UvMTU4MTEzNzgyI2QzYmYyOTBmZGRlZGRiYjdkMzJhYTg5N2U5ZjdlOWUxM2EyYWU0NDk1NjE0MmUyM2ViNDdiNzcwOTZhMmVhOGQKCi0tLQoKRW5hYmxlIG9yIGRpc2FibGUgdGhlIHBsYXRmb3JtIGNvbnRyYWN0LuCnqZKiNDVdDGZvdW5kY29tcGFueYMCLS0tCgpzcGVjX3ZlcnNpb246ICIwLjIuMCIKdGl0bGU6IGZvdW5kY29tcGFueQpzdW1tYXJ5OiAnRm91bmQgYSBuZXcgY29tcGFueScKaWNvbjogaHR0cHM6Ly9hdmF0YXJzLmdpdGh1YnVzZXJjb250ZW50LmNvbS91LzE1ODExMzc4MiNkM2JmMjkwZmRkZWRkYmI3ZDMyYWE4OTdlOWY3ZTllMTNhMmFlNDQ5NTYxNDJlMjNlYjQ3Yjc3MDk2YTJlYThkCgotLS0KCkZvdW5kIGEgbmV3IGNvbXBhbnkgaW4gdGhlIFNoaXBsb2FkIHBsYXRmb3JtIGNvbnRyYWN0LgAAAAAAkLHKBHRlc3QAAAAAAACgquMEd2lwZQACAAAAwE9TJUUDaTY0AAALY29tcGFueV9yb3cAAAAAAJVNxgNpNjQAAAlzdGF0ZV9yb3cBE1NoaXBsb2FkIChQbGF0Zm9ybSkTU2hpcGxvYWQgKFBsYXRmb3JtKQAAAAA=');
|
|
10
14
|
const abi$1 = antelope.ABI.from(abiBlob$1);
|
|
@@ -87,7 +91,7 @@ const TableMap$1 = {
|
|
|
87
91
|
company: Types$1.company_row,
|
|
88
92
|
state: Types$1.state_row,
|
|
89
93
|
};
|
|
90
|
-
class Contract$1 extends
|
|
94
|
+
class Contract$1 extends ContractKit.Contract {
|
|
91
95
|
constructor(args) {
|
|
92
96
|
super({
|
|
93
97
|
client: args.client,
|
|
@@ -112,7 +116,7 @@ var platform = /*#__PURE__*/Object.freeze({
|
|
|
112
116
|
Contract: Contract$1
|
|
113
117
|
});
|
|
114
118
|
|
|
115
|
-
const abiBlob = antelope.Blob.from('
|
|
119
|
+
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XJ5OiAnTW92ZSBhIHNoaXAnCmljb246IGh0dHBzOi8vYXZhdGFycy5naXRodWJ1c2VyY29udGVudC5jb20vdS8xNDcyOTI4NjE/cz00MDAmdT0zYjFhZjY2ZTkwZGQ4NTFmNGQ3YzA5NmVkNmEyZmJiNGI5ZTE5MGRhCgotLS0KCkluaXRpYXRlIHRyYXZlbCBvZiBhIHNoaXAgZnJvbSBpdHMgY3VycmVudCBsb2NhdGlvbiB0byBhIG5ldyBkZXN0aW5hdGlvbi4KCi0tLQAAAAAAoKrjBHdpcGWyAS0tLQoKc3BlY192ZXJzaW9uOiAiMC4yLjAiCnRpdGxlOiB3aXBlCnN1bW1hcnk6ICdERUJVRzogd2lwZSBhY3Rpb24nCmljb246IGh0dHBzOi8vYXZhdGFycy5naXRodWJ1c2VyY29udGVudC5jb20vdS8xNDcyOTI4NjE/cz00MDAmdT0zYjFhZjY2ZTkwZGQ4NTFmNGQ3YzA5NmVkNmEyZmJiNGI5ZTE5MGRhCgotLS0GAAAAAADKrkEDaTY0AAAJY2FyZ29fcm93AAAAAFzlTawDaTY0AAAKcGxheWVyX3JvdwAAAApNpa3CA2k2NAAADHNlcXVlbmNlX3JvdwAAAAAAUF3DA2k2NAAACHNoaXBfcm93AAAAAACVTcYDaTY0AAAJc3RhdGVfcm93AAAAwF8jpcYDaTY0AAALc3VtbWFyeV9yb3cBEVNoaXBsb2FkIChTZXJ2ZXIpEVNoaXBsb2FkIChTZXJ2ZXIpAAAABAAAiGqbmzNWDnRyYXZlbF9zdW1tYXJ5AAAAAADQsGkLY2hlY2tzdW01MTIAFHK3ZgWvkQpnb29kX3ByaWNlgBVyt2YFr5EMZ29vZF9wcmljZVtd');
|
|
116
120
|
const abi = antelope.ABI.from(abiBlob);
|
|
117
121
|
var Types;
|
|
118
122
|
(function (Types) {
|
|
@@ -136,9 +140,6 @@ var Types;
|
|
|
136
140
|
Types.arrive = arrive;
|
|
137
141
|
let buygoods = class buygoods extends antelope.Struct {
|
|
138
142
|
};
|
|
139
|
-
tslib.__decorate([
|
|
140
|
-
antelope.Struct.field(antelope.Name)
|
|
141
|
-
], buygoods.prototype, "buyer", void 0);
|
|
142
143
|
tslib.__decorate([
|
|
143
144
|
antelope.Struct.field(antelope.UInt64)
|
|
144
145
|
], buygoods.prototype, "ship_id", void 0);
|
|
@@ -166,6 +167,9 @@ var Types;
|
|
|
166
167
|
tslib.__decorate([
|
|
167
168
|
antelope.Struct.field(antelope.UInt64)
|
|
168
169
|
], cargo_row.prototype, "quantity", void 0);
|
|
170
|
+
tslib.__decorate([
|
|
171
|
+
antelope.Struct.field(antelope.UInt64)
|
|
172
|
+
], cargo_row.prototype, "loaded", void 0);
|
|
169
173
|
cargo_row = tslib.__decorate([
|
|
170
174
|
antelope.Struct.type('cargo_row')
|
|
171
175
|
], cargo_row);
|
|
@@ -218,6 +222,18 @@ var Types;
|
|
|
218
222
|
antelope.Struct.type('esttravel')
|
|
219
223
|
], esttravel);
|
|
220
224
|
Types.esttravel = esttravel;
|
|
225
|
+
let good_price = class good_price extends antelope.Struct {
|
|
226
|
+
};
|
|
227
|
+
tslib.__decorate([
|
|
228
|
+
antelope.Struct.field(antelope.UInt16)
|
|
229
|
+
], good_price.prototype, "id", void 0);
|
|
230
|
+
tslib.__decorate([
|
|
231
|
+
antelope.Struct.field(antelope.UInt64)
|
|
232
|
+
], good_price.prototype, "price", void 0);
|
|
233
|
+
good_price = tslib.__decorate([
|
|
234
|
+
antelope.Struct.type('good_price')
|
|
235
|
+
], good_price);
|
|
236
|
+
Types.good_price = good_price;
|
|
221
237
|
let hash = class hash extends antelope.Struct {
|
|
222
238
|
};
|
|
223
239
|
tslib.__decorate([
|
|
@@ -266,6 +282,27 @@ var Types;
|
|
|
266
282
|
antelope.Struct.type('loader_stats')
|
|
267
283
|
], loader_stats);
|
|
268
284
|
Types.loader_stats = loader_stats;
|
|
285
|
+
let marketprice = class marketprice extends antelope.Struct {
|
|
286
|
+
};
|
|
287
|
+
tslib.__decorate([
|
|
288
|
+
antelope.Struct.field(coordinates)
|
|
289
|
+
], marketprice.prototype, "location", void 0);
|
|
290
|
+
tslib.__decorate([
|
|
291
|
+
antelope.Struct.field(antelope.UInt16)
|
|
292
|
+
], marketprice.prototype, "good_id", void 0);
|
|
293
|
+
marketprice = tslib.__decorate([
|
|
294
|
+
antelope.Struct.type('marketprice')
|
|
295
|
+
], marketprice);
|
|
296
|
+
Types.marketprice = marketprice;
|
|
297
|
+
let marketprices = class marketprices extends antelope.Struct {
|
|
298
|
+
};
|
|
299
|
+
tslib.__decorate([
|
|
300
|
+
antelope.Struct.field(coordinates)
|
|
301
|
+
], marketprices.prototype, "location", void 0);
|
|
302
|
+
marketprices = tslib.__decorate([
|
|
303
|
+
antelope.Struct.type('marketprices')
|
|
304
|
+
], marketprices);
|
|
305
|
+
Types.marketprices = marketprices;
|
|
269
306
|
let player_row = class player_row extends antelope.Struct {
|
|
270
307
|
};
|
|
271
308
|
tslib.__decorate([
|
|
@@ -283,9 +320,6 @@ var Types;
|
|
|
283
320
|
Types.player_row = player_row;
|
|
284
321
|
let sellgoods = class sellgoods extends antelope.Struct {
|
|
285
322
|
};
|
|
286
|
-
tslib.__decorate([
|
|
287
|
-
antelope.Struct.field(antelope.Name)
|
|
288
|
-
], sellgoods.prototype, "seller", void 0);
|
|
289
323
|
tslib.__decorate([
|
|
290
324
|
antelope.Struct.field(antelope.UInt64)
|
|
291
325
|
], sellgoods.prototype, "ship_id", void 0);
|
|
@@ -311,6 +345,15 @@ var Types;
|
|
|
311
345
|
antelope.Struct.type('sequence_row')
|
|
312
346
|
], sequence_row);
|
|
313
347
|
Types.sequence_row = sequence_row;
|
|
348
|
+
let ship_state = class ship_state extends antelope.Struct {
|
|
349
|
+
};
|
|
350
|
+
tslib.__decorate([
|
|
351
|
+
antelope.Struct.field(antelope.UInt32)
|
|
352
|
+
], ship_state.prototype, "energy", void 0);
|
|
353
|
+
ship_state = tslib.__decorate([
|
|
354
|
+
antelope.Struct.type('ship_state')
|
|
355
|
+
], ship_state);
|
|
356
|
+
Types.ship_state = ship_state;
|
|
314
357
|
let ship_stats = class ship_stats extends antelope.Struct {
|
|
315
358
|
};
|
|
316
359
|
tslib.__decorate([
|
|
@@ -319,9 +362,6 @@ var Types;
|
|
|
319
362
|
tslib.__decorate([
|
|
320
363
|
antelope.Struct.field(antelope.UInt32)
|
|
321
364
|
], ship_stats.prototype, "drain", void 0);
|
|
322
|
-
tslib.__decorate([
|
|
323
|
-
antelope.Struct.field(antelope.UInt32)
|
|
324
|
-
], ship_stats.prototype, "energy", void 0);
|
|
325
365
|
tslib.__decorate([
|
|
326
366
|
antelope.Struct.field(antelope.UInt64)
|
|
327
367
|
], ship_stats.prototype, "mass", void 0);
|
|
@@ -373,6 +413,9 @@ var Types;
|
|
|
373
413
|
tslib.__decorate([
|
|
374
414
|
antelope.Struct.field(antelope.UInt8)
|
|
375
415
|
], ship_row.prototype, "tier", void 0);
|
|
416
|
+
tslib.__decorate([
|
|
417
|
+
antelope.Struct.field(ship_state)
|
|
418
|
+
], ship_row.prototype, "state", void 0);
|
|
376
419
|
tslib.__decorate([
|
|
377
420
|
antelope.Struct.field(ship_stats)
|
|
378
421
|
], ship_row.prototype, "stats", void 0);
|
|
@@ -503,7 +546,7 @@ const TableMap = {
|
|
|
503
546
|
state: Types.state_row,
|
|
504
547
|
summary: Types.summary_row,
|
|
505
548
|
};
|
|
506
|
-
class Contract extends
|
|
549
|
+
class Contract extends ContractKit.Contract {
|
|
507
550
|
constructor(args) {
|
|
508
551
|
super({
|
|
509
552
|
client: args.client,
|
|
@@ -533,16 +576,24 @@ var server = /*#__PURE__*/Object.freeze({
|
|
|
533
576
|
|
|
534
577
|
function hash(seed, string) {
|
|
535
578
|
const bytes = antelope.Bytes.from(`${seed}${string}`, 'utf8');
|
|
536
|
-
return
|
|
579
|
+
return antelope.Checksum512.hash(bytes);
|
|
580
|
+
}
|
|
581
|
+
function hashBytes(seed, string) {
|
|
582
|
+
return hash(seed, string).array;
|
|
537
583
|
}
|
|
538
584
|
|
|
539
|
-
function
|
|
585
|
+
function distanceTraveled(ship) {
|
|
540
586
|
if (ship.travelplan) {
|
|
541
587
|
const { departure, duration } = ship.travelplan;
|
|
542
588
|
return (+new Date() - +departure.toDate()) / (Number(duration) * 1000);
|
|
543
589
|
}
|
|
544
590
|
return 0;
|
|
545
591
|
}
|
|
592
|
+
function distanceBetweenPoints(x1, y1, x2, y2) {
|
|
593
|
+
const x = Math.pow(x1 - x2, 2);
|
|
594
|
+
const y = Math.pow(y1 - y2, 2);
|
|
595
|
+
return Math.sqrt(x + y);
|
|
596
|
+
}
|
|
546
597
|
function lerp(origin, destination, time) {
|
|
547
598
|
return {
|
|
548
599
|
x: (1 - time) * origin.x + time * destination.x,
|
|
@@ -554,18 +605,275 @@ function rotation(origin, destination) {
|
|
|
554
605
|
}
|
|
555
606
|
function hasPlanet(seed, coords) {
|
|
556
607
|
const str = ['system', coords.x, coords.y].join('-');
|
|
557
|
-
return hash(seed, str).slice(0, 2) === '00';
|
|
608
|
+
return String(hash(seed, str)).slice(0, 2) === '00';
|
|
609
|
+
}
|
|
610
|
+
function findNearbyPlanets(seed, origin, maxDistance = 20) {
|
|
611
|
+
const nearbySystems = [];
|
|
612
|
+
const xMin = origin.x - maxDistance;
|
|
613
|
+
const xMax = origin.x + maxDistance;
|
|
614
|
+
const yMin = origin.y - maxDistance;
|
|
615
|
+
const yMax = origin.y + maxDistance;
|
|
616
|
+
for (let x = xMin; x <= xMax; x++) {
|
|
617
|
+
for (let y = yMin; y <= yMax; y++) {
|
|
618
|
+
const samePlace = x === origin.x && y === origin.y;
|
|
619
|
+
if (!samePlace) {
|
|
620
|
+
const distance = distanceBetweenPoints(origin.x, origin.y, x, y);
|
|
621
|
+
if (distance <= maxDistance) {
|
|
622
|
+
const system = hasPlanet(seed, { x, y });
|
|
623
|
+
if (system) {
|
|
624
|
+
nearbySystems.push({ origin, destination: { x, y }, distance });
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
return nearbySystems;
|
|
558
631
|
}
|
|
559
632
|
|
|
633
|
+
const goods = [
|
|
634
|
+
{
|
|
635
|
+
id: antelope.UInt16.from(1),
|
|
636
|
+
name: 'FizzGlo',
|
|
637
|
+
description: 'Pops with flavor! A neon drink that makes your burps glow.',
|
|
638
|
+
base_price: antelope.UInt64.from(200),
|
|
639
|
+
mass: antelope.UInt64.from(500),
|
|
640
|
+
},
|
|
641
|
+
{
|
|
642
|
+
id: antelope.UInt16.from(2),
|
|
643
|
+
name: 'ZapSnacks',
|
|
644
|
+
description: 'Electric taste! Spicy edible energy sparks for a tongue-tingling experience.',
|
|
645
|
+
base_price: antelope.UInt64.from(300),
|
|
646
|
+
mass: antelope.UInt64.from(2000),
|
|
647
|
+
},
|
|
648
|
+
{
|
|
649
|
+
id: antelope.UInt16.from(3),
|
|
650
|
+
name: 'Blob Buddies',
|
|
651
|
+
description: 'Squishy friends! Clingy, cute and mood-matching pet blobs for every home!',
|
|
652
|
+
base_price: antelope.UInt64.from(400),
|
|
653
|
+
mass: antelope.UInt64.from(10000),
|
|
654
|
+
},
|
|
655
|
+
{
|
|
656
|
+
id: antelope.UInt16.from(4),
|
|
657
|
+
name: 'TuneTooth',
|
|
658
|
+
description: 'Whistle while you eat! Edible instrument treats that play tunes when chewed.',
|
|
659
|
+
base_price: antelope.UInt64.from(600),
|
|
660
|
+
mass: antelope.UInt64.from(3000),
|
|
661
|
+
},
|
|
662
|
+
{
|
|
663
|
+
id: antelope.UInt16.from(5),
|
|
664
|
+
name: 'SunPods',
|
|
665
|
+
description: 'Miniature suns in your pocket providing on-demand light & warmth.',
|
|
666
|
+
base_price: antelope.UInt64.from(800),
|
|
667
|
+
mass: antelope.UInt64.from(1000),
|
|
668
|
+
},
|
|
669
|
+
{
|
|
670
|
+
id: antelope.UInt16.from(6),
|
|
671
|
+
name: 'Fuzzix',
|
|
672
|
+
description: 'Pocket-sized quantum fluff generator for instant comfy.',
|
|
673
|
+
base_price: antelope.UInt64.from(1000),
|
|
674
|
+
mass: antelope.UInt64.from(4000),
|
|
675
|
+
},
|
|
676
|
+
{
|
|
677
|
+
id: antelope.UInt16.from(7),
|
|
678
|
+
name: 'GlowGo',
|
|
679
|
+
description: 'Ingestible bioluminescent jelly, your inside glows in the dark!',
|
|
680
|
+
base_price: antelope.UInt64.from(140),
|
|
681
|
+
mass: antelope.UInt64.from(3000),
|
|
682
|
+
},
|
|
683
|
+
{
|
|
684
|
+
id: antelope.UInt16.from(8),
|
|
685
|
+
name: 'KrackleKaps',
|
|
686
|
+
description: 'Capsules packed with tiny firecrackers, spice up meals and parties.',
|
|
687
|
+
base_price: antelope.UInt64.from(180),
|
|
688
|
+
mass: antelope.UInt64.from(2000),
|
|
689
|
+
},
|
|
690
|
+
{
|
|
691
|
+
id: antelope.UInt16.from(9),
|
|
692
|
+
name: 'PlasmaMints',
|
|
693
|
+
description: 'Hypercharged candy giving plasma breath capable of cutting through steel.',
|
|
694
|
+
base_price: antelope.UInt64.from(220),
|
|
695
|
+
mass: antelope.UInt64.from(500),
|
|
696
|
+
},
|
|
697
|
+
{
|
|
698
|
+
id: antelope.UInt16.from(10),
|
|
699
|
+
name: 'TimeTreats',
|
|
700
|
+
description: 'Confectionery morsels releasing slow-mo effect over a limited period.',
|
|
701
|
+
base_price: antelope.UInt64.from(250),
|
|
702
|
+
mass: antelope.UInt64.from(3000),
|
|
703
|
+
},
|
|
704
|
+
{
|
|
705
|
+
id: antelope.UInt16.from(11),
|
|
706
|
+
name: 'QuantumQuencher',
|
|
707
|
+
description: 'Bottled hyper-fluid quenching thirst across multiple parallel realities simultaneously.',
|
|
708
|
+
base_price: antelope.UInt64.from(300),
|
|
709
|
+
mass: antelope.UInt64.from(6000),
|
|
710
|
+
},
|
|
711
|
+
{
|
|
712
|
+
id: antelope.UInt16.from(12),
|
|
713
|
+
name: 'TransmatterTruffles',
|
|
714
|
+
description: 'Delectable chocolates instantly teleporting consumers short distances.',
|
|
715
|
+
base_price: antelope.UInt64.from(350),
|
|
716
|
+
mass: antelope.UInt64.from(4000),
|
|
717
|
+
},
|
|
718
|
+
{
|
|
719
|
+
id: antelope.UInt16.from(13),
|
|
720
|
+
name: 'MemoryGum',
|
|
721
|
+
description: 'Chewable gum storing or replaying memories while being chewed.',
|
|
722
|
+
base_price: antelope.UInt64.from(400),
|
|
723
|
+
mass: antelope.UInt64.from(500),
|
|
724
|
+
},
|
|
725
|
+
{
|
|
726
|
+
id: antelope.UInt16.from(14),
|
|
727
|
+
name: 'SymbioSnack',
|
|
728
|
+
description: 'Edible alien larvae adopting owner’s taste preference upon consumption.',
|
|
729
|
+
base_price: antelope.UInt64.from(500),
|
|
730
|
+
mass: antelope.UInt64.from(1000),
|
|
731
|
+
},
|
|
732
|
+
];
|
|
733
|
+
function getGood(good_id) {
|
|
734
|
+
const good = goods.find((g) => g.id.equals(good_id));
|
|
735
|
+
if (!good) {
|
|
736
|
+
throw new Error('Good does not exist');
|
|
737
|
+
}
|
|
738
|
+
return good;
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
function roll(game_seed, roll_seed) {
|
|
742
|
+
const byteArray = hashBytes(game_seed, roll_seed);
|
|
743
|
+
return (byteArray[0] << 8) | byteArray[1];
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
function marketprice(location, good_id, gameSeed, epochSeed) {
|
|
747
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
748
|
+
const good = getGood(good_id);
|
|
749
|
+
const rollSeed = `${location.x}${epochSeed}${location.y}${good_id}`;
|
|
750
|
+
const rollValue = roll(gameSeed, rollSeed);
|
|
751
|
+
return priceFromRoll(good.base_price, rollValue);
|
|
752
|
+
});
|
|
753
|
+
}
|
|
754
|
+
function marketprices(location, gameSeed, epochSeed) {
|
|
755
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
756
|
+
return Promise.all(goods.map((good) => tslib.__awaiter(this, void 0, void 0, function* () {
|
|
757
|
+
const price = yield marketprice(location, good.id, gameSeed, epochSeed);
|
|
758
|
+
return { price, id: good.id };
|
|
759
|
+
})));
|
|
760
|
+
});
|
|
761
|
+
}
|
|
762
|
+
function priceFromRoll(basePrice, roll) {
|
|
763
|
+
basePrice = Number(basePrice);
|
|
764
|
+
let price;
|
|
765
|
+
if (roll < 13) {
|
|
766
|
+
price = basePrice * 2.25;
|
|
767
|
+
}
|
|
768
|
+
else if (roll < 176) {
|
|
769
|
+
price = basePrice * 1.75;
|
|
770
|
+
}
|
|
771
|
+
else if (roll < 996) {
|
|
772
|
+
price = basePrice * 1.4;
|
|
773
|
+
}
|
|
774
|
+
else if (roll < 2966) {
|
|
775
|
+
price = basePrice * 1.225;
|
|
776
|
+
}
|
|
777
|
+
else if (roll < 19568) {
|
|
778
|
+
price = basePrice * 1.07;
|
|
779
|
+
}
|
|
780
|
+
else if (roll < 45988) {
|
|
781
|
+
price = 0;
|
|
782
|
+
}
|
|
783
|
+
else if (roll < 62508) {
|
|
784
|
+
price = basePrice * 0.925;
|
|
785
|
+
}
|
|
786
|
+
else if (roll < 64518) {
|
|
787
|
+
price = basePrice * 0.77;
|
|
788
|
+
}
|
|
789
|
+
else if (roll < 65437) {
|
|
790
|
+
price = basePrice * 0.595;
|
|
791
|
+
}
|
|
792
|
+
else if (roll < 65523) {
|
|
793
|
+
price = basePrice * 0.41;
|
|
794
|
+
}
|
|
795
|
+
else {
|
|
796
|
+
price = basePrice * 0.285;
|
|
797
|
+
}
|
|
798
|
+
return antelope.UInt64.from(price);
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
const ERROR_SYSTEM_NOT_INITIALIZED = 'System not initialized';
|
|
802
|
+
const GOOD_DOES_NOT_EXIST = 'Good does not exist';
|
|
803
|
+
const GOOD_NOT_AVAILABLE_AT_LOCATION = 'Good not available at location';
|
|
804
|
+
const PLAYER_NOT_FOUND = 'Player not found';
|
|
805
|
+
const SHIP_NOT_FOUND = 'Ship not found';
|
|
806
|
+
const SHIP_CANNOT_BUY_TRAVELING = 'Ship cannot buy while traveling';
|
|
807
|
+
const INSUFFICIENT_BALANCE = 'Insufficient balance';
|
|
808
|
+
const INSUFFICIENT_GOOD_QUANTITY = 'Insufficient good quantity';
|
|
809
|
+
const REQUIRES_MORE_THAN_ONE = 'Requires more than one';
|
|
810
|
+
|
|
560
811
|
class Shipload {
|
|
812
|
+
constructor(chain, { client, serverContract }) {
|
|
813
|
+
this.client = client || new antelope.APIClient({ url: chain.url });
|
|
814
|
+
this.server = serverContract
|
|
815
|
+
? serverContract
|
|
816
|
+
: new Contract({ client: this.client });
|
|
817
|
+
}
|
|
818
|
+
static load(chain, shiploadOptions) {
|
|
819
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
820
|
+
let server$1 = new Contract({
|
|
821
|
+
client: new antelope.APIClient({ url: chain.url }),
|
|
822
|
+
});
|
|
823
|
+
if (shiploadOptions.contractName) {
|
|
824
|
+
const client = shiploadOptions.client || new antelope.APIClient({ url: chain.url });
|
|
825
|
+
const contractKit = new ContractKit__default["default"]({ client });
|
|
826
|
+
server$1 = yield contractKit.load(shiploadOptions.contractName);
|
|
827
|
+
}
|
|
828
|
+
return new Shipload(chain, Object.assign(Object.assign({}, shiploadOptions), { serverContract: server$1 }));
|
|
829
|
+
});
|
|
830
|
+
}
|
|
831
|
+
getState() {
|
|
832
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
833
|
+
const state = yield this.server.table('state').get();
|
|
834
|
+
if (!state) {
|
|
835
|
+
throw new Error(ERROR_SYSTEM_NOT_INITIALIZED);
|
|
836
|
+
}
|
|
837
|
+
return state;
|
|
838
|
+
});
|
|
839
|
+
}
|
|
840
|
+
marketprice(location, good_id) {
|
|
841
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
842
|
+
const { seed, epochseed } = yield this.getState();
|
|
843
|
+
return marketprice(location, good_id, seed, epochseed);
|
|
844
|
+
});
|
|
845
|
+
}
|
|
846
|
+
marketprices(location) {
|
|
847
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
848
|
+
const { seed, epochseed } = yield this.getState();
|
|
849
|
+
return marketprices(location, seed, epochseed);
|
|
850
|
+
});
|
|
851
|
+
}
|
|
561
852
|
}
|
|
562
853
|
|
|
854
|
+
exports.ERROR_SYSTEM_NOT_INITIALIZED = ERROR_SYSTEM_NOT_INITIALIZED;
|
|
855
|
+
exports.GOOD_DOES_NOT_EXIST = GOOD_DOES_NOT_EXIST;
|
|
856
|
+
exports.GOOD_NOT_AVAILABLE_AT_LOCATION = GOOD_NOT_AVAILABLE_AT_LOCATION;
|
|
857
|
+
exports.INSUFFICIENT_BALANCE = INSUFFICIENT_BALANCE;
|
|
858
|
+
exports.INSUFFICIENT_GOOD_QUANTITY = INSUFFICIENT_GOOD_QUANTITY;
|
|
859
|
+
exports.PLAYER_NOT_FOUND = PLAYER_NOT_FOUND;
|
|
563
860
|
exports.PlatformContract = platform;
|
|
861
|
+
exports.REQUIRES_MORE_THAN_ONE = REQUIRES_MORE_THAN_ONE;
|
|
862
|
+
exports.SHIP_CANNOT_BUY_TRAVELING = SHIP_CANNOT_BUY_TRAVELING;
|
|
863
|
+
exports.SHIP_NOT_FOUND = SHIP_NOT_FOUND;
|
|
564
864
|
exports.ServerContract = server;
|
|
565
865
|
exports["default"] = Shipload;
|
|
566
|
-
exports.
|
|
866
|
+
exports.distanceBetweenPoints = distanceBetweenPoints;
|
|
867
|
+
exports.distanceTraveled = distanceTraveled;
|
|
868
|
+
exports.findNearbyPlanets = findNearbyPlanets;
|
|
869
|
+
exports.getGood = getGood;
|
|
870
|
+
exports.goods = goods;
|
|
567
871
|
exports.hasPlanet = hasPlanet;
|
|
568
872
|
exports.hash = hash;
|
|
873
|
+
exports.hashBytes = hashBytes;
|
|
569
874
|
exports.lerp = lerp;
|
|
875
|
+
exports.marketprice = marketprice;
|
|
876
|
+
exports.marketprices = marketprices;
|
|
877
|
+
exports.priceFromRoll = priceFromRoll;
|
|
570
878
|
exports.rotation = rotation;
|
|
571
879
|
//# sourceMappingURL=shipload.js.map
|