@shipload/sdk 0.3.3 → 0.3.5
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 +66 -30
- package/lib/shipload.js +280 -119
- package/lib/shipload.js.map +1 -1
- package/lib/shipload.m.js +262 -115
- package/lib/shipload.m.js.map +1 -1
- package/package.json +1 -1
- package/src/contracts/server.ts +36 -12
- package/src/epoch.ts +2 -2
- package/src/goods.ts +57 -46
- package/src/market.ts +7 -6
- package/src/shipload.ts +48 -13
- package/src/travel.ts +178 -18
- package/src/types.ts +12 -7
package/lib/shipload.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Blob, ABI, Struct, Name, UInt64, Checksum256, UInt32, TimePointSec, Checksum256Type, UInt32Type, NameType, UInt64Type, Action, UInt16, Int64, TimePoint, UInt8, Int64Type, UInt16Type, Checksum512, APIClient } from '@wharfkit/antelope';
|
|
1
|
+
import { Blob, ABI, Struct, Name, UInt64, Checksum256, UInt32, TimePointSec, Checksum256Type, UInt32Type, NameType, UInt64Type, Action, UInt16, Int64, TimePoint, UInt8, Float64, Int64Type, UInt16Type, Checksum512, APIClient } from '@wharfkit/antelope';
|
|
2
2
|
import { Contract as Contract$2, PartialBy, ContractArgs, ActionOptions, Table } from '@wharfkit/contract';
|
|
3
3
|
import { ChainDefinition } from '@wharfkit/session';
|
|
4
4
|
|
|
@@ -161,7 +161,6 @@ declare namespace Types {
|
|
|
161
161
|
commit: Checksum256;
|
|
162
162
|
}
|
|
163
163
|
class arrive extends Struct {
|
|
164
|
-
owner: Name;
|
|
165
164
|
id: UInt64;
|
|
166
165
|
}
|
|
167
166
|
class buygoods extends Struct {
|
|
@@ -248,9 +247,14 @@ declare namespace Types {
|
|
|
248
247
|
thrust: UInt64;
|
|
249
248
|
}
|
|
250
249
|
class travel_plan extends Struct {
|
|
251
|
-
destination: coordinates;
|
|
252
250
|
departure: TimePoint;
|
|
253
|
-
|
|
251
|
+
destination: coordinates;
|
|
252
|
+
flighttime: UInt32;
|
|
253
|
+
loadtime: UInt32;
|
|
254
|
+
rechargetime: UInt32;
|
|
255
|
+
mass: UInt64;
|
|
256
|
+
energyusage: UInt32;
|
|
257
|
+
distance: UInt64;
|
|
254
258
|
}
|
|
255
259
|
class ship_row extends Struct {
|
|
256
260
|
id: UInt64;
|
|
@@ -272,7 +276,6 @@ declare namespace Types {
|
|
|
272
276
|
commit: Checksum256;
|
|
273
277
|
}
|
|
274
278
|
class travel extends Struct {
|
|
275
|
-
owner: Name;
|
|
276
279
|
id: UInt64;
|
|
277
280
|
destination: coordinates;
|
|
278
281
|
recharge: boolean;
|
|
@@ -284,13 +287,19 @@ declare namespace Types {
|
|
|
284
287
|
destination: coordinates;
|
|
285
288
|
distance: UInt64;
|
|
286
289
|
totalmass: UInt64;
|
|
287
|
-
acceleration:
|
|
290
|
+
acceleration: Float64;
|
|
288
291
|
flighttime: UInt64;
|
|
289
292
|
energyusage: UInt64;
|
|
290
293
|
rechargetime: UInt64;
|
|
291
294
|
loadtime: UInt64;
|
|
292
295
|
time: UInt64;
|
|
293
296
|
}
|
|
297
|
+
class travelplan extends Struct {
|
|
298
|
+
id: UInt64;
|
|
299
|
+
origin: coordinates;
|
|
300
|
+
destination: coordinates;
|
|
301
|
+
recharge: boolean;
|
|
302
|
+
}
|
|
294
303
|
class traveltime extends Struct {
|
|
295
304
|
id: UInt64;
|
|
296
305
|
destination: coordinates;
|
|
@@ -326,7 +335,6 @@ declare namespace ActionParams {
|
|
|
326
335
|
commit: Checksum256Type;
|
|
327
336
|
}
|
|
328
337
|
interface arrive {
|
|
329
|
-
owner: NameType;
|
|
330
338
|
id: UInt64Type;
|
|
331
339
|
}
|
|
332
340
|
interface buygoods {
|
|
@@ -373,11 +381,16 @@ declare namespace ActionParams {
|
|
|
373
381
|
quantity: UInt64Type;
|
|
374
382
|
}
|
|
375
383
|
interface travel {
|
|
376
|
-
owner: NameType;
|
|
377
384
|
id: UInt64Type;
|
|
378
385
|
destination: Type.coordinates;
|
|
379
386
|
recharge: boolean;
|
|
380
387
|
}
|
|
388
|
+
interface travelplan {
|
|
389
|
+
id: UInt64Type;
|
|
390
|
+
origin: Type.coordinates;
|
|
391
|
+
destination: Type.coordinates;
|
|
392
|
+
recharge: boolean;
|
|
393
|
+
}
|
|
381
394
|
interface traveltime {
|
|
382
395
|
id: UInt64Type;
|
|
383
396
|
destination: Type.coordinates;
|
|
@@ -401,6 +414,7 @@ interface ActionNameParams {
|
|
|
401
414
|
salt: ActionParams.salt;
|
|
402
415
|
sellgoods: ActionParams.sellgoods;
|
|
403
416
|
travel: ActionParams.travel;
|
|
417
|
+
travelplan: ActionParams.travelplan;
|
|
404
418
|
traveltime: ActionParams.traveltime;
|
|
405
419
|
wipe: ActionParams.wipe;
|
|
406
420
|
}
|
|
@@ -410,6 +424,7 @@ interface ActionReturnValues {
|
|
|
410
424
|
hash512: Checksum512;
|
|
411
425
|
marketprice: Types.good_price;
|
|
412
426
|
marketprices: Types.good_price[];
|
|
427
|
+
travelplan: Types.travel_plan;
|
|
413
428
|
traveltime: Types.travel_summary;
|
|
414
429
|
}
|
|
415
430
|
type ActionReturnNames = keyof ActionReturnValues;
|
|
@@ -452,16 +467,13 @@ declare namespace server {
|
|
|
452
467
|
};
|
|
453
468
|
}
|
|
454
469
|
|
|
455
|
-
declare function getCurrentEpoch(game: Types$1.game_row):
|
|
470
|
+
declare function getCurrentEpoch(game: Types$1.game_row): number;
|
|
456
471
|
|
|
457
472
|
declare function hash(seed: Checksum256Type, string: string): Checksum512;
|
|
458
473
|
declare function hash512(seed: Checksum256Type, string: string): Checksum512;
|
|
459
474
|
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
y: number;
|
|
463
|
-
}
|
|
464
|
-
interface CameraPosition extends Coordinates {
|
|
475
|
+
declare const PRECISION = 10000;
|
|
476
|
+
interface CameraPosition extends ActionParams.Type.coordinates {
|
|
465
477
|
z: number;
|
|
466
478
|
}
|
|
467
479
|
interface Dimensions {
|
|
@@ -480,24 +492,45 @@ interface Good {
|
|
|
480
492
|
base_price: UInt64;
|
|
481
493
|
mass: UInt64;
|
|
482
494
|
}
|
|
495
|
+
interface GoodType {
|
|
496
|
+
id: UInt16Type;
|
|
497
|
+
name: string;
|
|
498
|
+
description: string;
|
|
499
|
+
base_price: UInt64Type;
|
|
500
|
+
mass: UInt64Type;
|
|
501
|
+
}
|
|
483
502
|
interface GoodPrice {
|
|
484
|
-
|
|
503
|
+
good: Good;
|
|
485
504
|
price: UInt64;
|
|
486
505
|
}
|
|
487
506
|
|
|
488
|
-
declare function
|
|
489
|
-
declare function
|
|
490
|
-
declare function
|
|
507
|
+
declare function travelplanDuration(travelplan: Types.travel_plan): UInt32;
|
|
508
|
+
declare function distanceTraveled(ship: Types.ship_row, current?: Date): number;
|
|
509
|
+
declare function distanceBetweenCoordinates(origin: ActionParams.Type.coordinates, destination: ActionParams.Type.coordinates): UInt64;
|
|
510
|
+
declare function distanceBetweenPoints(x1: Int64Type, y1: Int64Type, x2: Int64Type, y2: Int64Type): UInt64;
|
|
491
511
|
declare function lerp(origin: ActionParams.Type.coordinates, destination: ActionParams.Type.coordinates, time: number): ActionParams.Type.coordinates;
|
|
492
512
|
declare function rotation(origin: ActionParams.Type.coordinates, destination: ActionParams.Type.coordinates): number;
|
|
493
|
-
declare function
|
|
494
|
-
declare function findNearbyPlanets(seed: Checksum256, origin: ActionParams.Type.coordinates, maxDistance?:
|
|
513
|
+
declare function hasSystem(seed: Checksum256, coordinates: ActionParams.Type.coordinates): boolean;
|
|
514
|
+
declare function findNearbyPlanets(seed: Checksum256, origin: ActionParams.Type.coordinates, maxDistance?: UInt64Type): Distance[];
|
|
515
|
+
declare function travelplan(game: Types$1.game_row, ship: Types.ship_row, cargos: Types.cargo_row[], origin: ActionParams.Type.coordinates, destination: ActionParams.Type.coordinates, recharge: boolean): Types.travel_plan;
|
|
516
|
+
declare function calc_rechargetime(capacity: UInt32Type, energy: UInt32Type, recharge: UInt32Type): UInt32;
|
|
517
|
+
declare function calc_ship_rechargetime(ship: Types.ship_row): UInt32;
|
|
518
|
+
declare function calc_ship_loadtime(ship: Types.ship_row, cargos: Types.cargo_row[]): UInt32;
|
|
519
|
+
declare function calc_flighttime(distance: UInt64Type, acceleration: number): UInt32;
|
|
520
|
+
declare function calc_loader_flighttime(ship: Types.ship_row, mass: UInt64): UInt32;
|
|
521
|
+
declare function calc_loader_acceleration(ship: Types.ship_row, mass: UInt64): number;
|
|
522
|
+
declare function calc_ship_flighttime(ship: Types.ship_row, mass: UInt64, distance: UInt64): UInt32;
|
|
523
|
+
declare function calc_ship_acceleration(ship: Types.ship_row, mass: UInt64): number;
|
|
524
|
+
declare function calc_acceleration(thrust: number, mass: number): number;
|
|
525
|
+
declare function calc_ship_mass(ship: Types.ship_row, cargos: Types.cargo_row[]): UInt64;
|
|
526
|
+
declare function calc_energyusage(drain: UInt32Type, flighttime: UInt32Type): UInt32;
|
|
495
527
|
|
|
496
|
-
declare const
|
|
528
|
+
declare const goodIds: any[];
|
|
497
529
|
declare function getGood(good_id: UInt16Type): Good;
|
|
530
|
+
declare function getGoods(): Good[];
|
|
498
531
|
|
|
499
|
-
declare function marketprice(location:
|
|
500
|
-
declare function marketprices(location:
|
|
532
|
+
declare function marketprice(location: ActionParams.Type.coordinates, good_id: UInt16Type, gameSeed: Checksum256Type, epochSeed: Checksum256Type): Promise<UInt64>;
|
|
533
|
+
declare function marketprices(location: ActionParams.Type.coordinates, gameSeed: Checksum256Type, epochSeed: Checksum256Type): Promise<GoodPrice[]>;
|
|
501
534
|
declare function priceFromRoll(basePrice: UInt64Type, roll: number): UInt64;
|
|
502
535
|
|
|
503
536
|
declare const ERROR_SYSTEM_NOT_INITIALIZED = "System not initialized";
|
|
@@ -516,19 +549,22 @@ interface ShiploadOptions {
|
|
|
516
549
|
client?: APIClient;
|
|
517
550
|
}
|
|
518
551
|
interface ShiploadConstructorOptions extends ShiploadOptions {
|
|
519
|
-
platformContract
|
|
520
|
-
serverContract
|
|
552
|
+
platformContract?: Contract$2;
|
|
553
|
+
serverContract?: Contract$2;
|
|
521
554
|
}
|
|
522
555
|
declare class Shipload {
|
|
523
556
|
client: APIClient;
|
|
524
557
|
server: Contract$2;
|
|
525
558
|
platform: Contract$2;
|
|
526
|
-
constructor(chain: ChainDefinition,
|
|
527
|
-
static load(chain: ChainDefinition, shiploadOptions
|
|
559
|
+
constructor(chain: ChainDefinition, constructorOptions?: ShiploadConstructorOptions);
|
|
560
|
+
static load(chain: ChainDefinition, shiploadOptions?: ShiploadOptions): Promise<Shipload>;
|
|
528
561
|
getGame(): Promise<Types$1.game_row>;
|
|
529
562
|
getState(): Promise<Types.state_row>;
|
|
530
|
-
marketprice(location:
|
|
531
|
-
marketprices(location:
|
|
563
|
+
marketprice(location: ActionParams.Type.coordinates, good_id: number): Promise<UInt64>;
|
|
564
|
+
marketprices(location: ActionParams.Type.coordinates): Promise<GoodPrice[]>;
|
|
565
|
+
hasSystem(location: ActionParams.Type.coordinates): Promise<boolean>;
|
|
566
|
+
findNearbyPlanets(origin: ActionParams.Type.coordinates, maxDistance?: UInt16Type): Promise<Distance[]>;
|
|
567
|
+
travelplan(ship: Types.ship_row, origin: ActionParams.Type.coordinates, destination: ActionParams.Type.coordinates, recharge?: boolean): Promise<Types.travel_plan>;
|
|
532
568
|
}
|
|
533
569
|
|
|
534
|
-
export { CameraPosition,
|
|
570
|
+
export { CameraPosition, Dimensions, Distance, ERROR_SYSTEM_NOT_INITIALIZED, GOOD_DOES_NOT_EXIST, GOOD_NOT_AVAILABLE_AT_LOCATION, Good, GoodPrice, GoodType, INSUFFICIENT_BALANCE, INSUFFICIENT_GOOD_QUANTITY, PLAYER_NOT_FOUND, PRECISION, platform as PlatformContract, REQUIRES_MORE_THAN_ONE, SHIP_CANNOT_BUY_TRAVELING, SHIP_NOT_FOUND, server as ServerContract, calc_acceleration, calc_energyusage, calc_flighttime, calc_loader_acceleration, calc_loader_flighttime, calc_rechargetime, calc_ship_acceleration, calc_ship_flighttime, calc_ship_loadtime, calc_ship_mass, calc_ship_rechargetime, Shipload as default, distanceBetweenCoordinates, distanceBetweenPoints, distanceTraveled, findNearbyPlanets, getCurrentEpoch, getGood, getGoods, goodIds, hasSystem, hash, hash512, lerp, marketprice, marketprices, priceFromRoll, rotation, travelplan, travelplanDuration };
|