diff options
author | Julien Dessaux | 2024-04-05 00:42:30 +0200 |
---|---|---|
committer | Julien Dessaux | 2024-04-07 23:01:52 +0200 |
commit | 234770b611df32178382b557df396db220070a7f (patch) | |
tree | 8c768846716eaf892ff75abe84d0f5c00e8519ff /nodejs/model | |
parent | [node] Fixed basic procurement trading loop (diff) | |
download | spacetraders-234770b611df32178382b557df396db220070a7f.tar.gz spacetraders-234770b611df32178382b557df396db220070a7f.tar.bz2 spacetraders-234770b611df32178382b557df396db220070a7f.zip |
[node] Big Ships lib refactoring
Diffstat (limited to 'nodejs/model')
-rw-r--r-- | nodejs/model/agent.ts | 8 | ||||
-rw-r--r-- | nodejs/model/api.ts | 31 | ||||
-rw-r--r-- | nodejs/model/cargo.ts | 17 | ||||
-rw-r--r-- | nodejs/model/common.ts | 5 | ||||
-rw-r--r-- | nodejs/model/contract.ts | 22 | ||||
-rw-r--r-- | nodejs/model/errors.ts | 8 | ||||
-rw-r--r-- | nodejs/model/market.ts | 19 | ||||
-rw-r--r-- | nodejs/model/ship.ts | 62 | ||||
-rw-r--r-- | nodejs/model/system.ts | 30 |
9 files changed, 0 insertions, 202 deletions
diff --git a/nodejs/model/agent.ts b/nodejs/model/agent.ts deleted file mode 100644 index dce6424..0000000 --- a/nodejs/model/agent.ts +++ /dev/null @@ -1,8 +0,0 @@ -export type Agent = { - accountId: string; - credits: number; - headquarters: string; - shipCount: number; - startingFaction: string; - symbol: string; -}; diff --git a/nodejs/model/api.ts b/nodejs/model/api.ts deleted file mode 100644 index 69c7ee1..0000000 --- a/nodejs/model/api.ts +++ /dev/null @@ -1,31 +0,0 @@ -export type APIError = { - error: string; - code: number; - data: unknown; -}; - -export type Meta = { - limit: number; - page: number; - total: number; -} - -export type Request = { - endpoint: string; // the path part of the url to call - method?: string; // HTTP method for `fetch` call, defaults to 'GET' - page?: number; // run a paginated request starting from this page until all the following pages are fetched - payload?: { [key:string]: any}; // optional json object that will be sent along the request - priority?: number; // optional priority value, defaults to 10. lower than 10 means the message will be sent faster -}; - -export type RequestPromise<T> = { - reject: (reason?: any) => void; - request: Request; - resolve: (value: Response<T> | PromiseLike<Response<T>>) => void; -}; - -export type Response<T> = { - data: T; - error?: APIError; - meta?: Meta; -} diff --git a/nodejs/model/cargo.ts b/nodejs/model/cargo.ts deleted file mode 100644 index 869fa49..0000000 --- a/nodejs/model/cargo.ts +++ /dev/null @@ -1,17 +0,0 @@ -export type Inventory = { - description: string; - name: string; - symbol: string; - units: number; -}; - -export type Cargo = { - "capacity": number; - "units": number; - "inventory": Array<Inventory>; -}; - -// Custom type, not from space traders api -export type CargoManifest = { - [key: string]: number; -}; diff --git a/nodejs/model/common.ts b/nodejs/model/common.ts deleted file mode 100644 index 1712ad8..0000000 --- a/nodejs/model/common.ts +++ /dev/null @@ -1,5 +0,0 @@ -export type CommonThing = { - description: string; - name: string; - symbol: string; -}; diff --git a/nodejs/model/contract.ts b/nodejs/model/contract.ts deleted file mode 100644 index eb7add4..0000000 --- a/nodejs/model/contract.ts +++ /dev/null @@ -1,22 +0,0 @@ -export type Contract = { - id: string; - factionSymbol: string; - type: string; - terms: { - deadline: Date; - payment: { - onAccepted: number; - onFulfilled: number; - }, - deliver: Array<{ - tradeSymbol: string; - destinationSymbol: string; - unitsRequired: number; - unitsFulfilled: number; - }>; - }; - accepted: boolean; - fulfilled: boolean; - expiration: Date; - deadlineToAccept: Date; -}; diff --git a/nodejs/model/errors.ts b/nodejs/model/errors.ts deleted file mode 100644 index 6002ae6..0000000 --- a/nodejs/model/errors.ts +++ /dev/null @@ -1,8 +0,0 @@ -export type RateLimitError = { - type: string; - retryAfter: number; - limitBurst: number; - limitPerSecond: number; - remaining: number; - reset: Date; -}; diff --git a/nodejs/model/market.ts b/nodejs/model/market.ts deleted file mode 100644 index 1ba70c1..0000000 --- a/nodejs/model/market.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { CommonThing } from 'common.ts'; - -export type TradeGood = CommonThing & { - activity: string; - purchasePrice: number; - sellPrice: number; - supply: string; - tradeVolume: number; - type: string; -}; - -export type Market = { - symbol: string; - exchange: Array<CommonThing>; - exports: Array<CommonThing>; - imports: Array<CommonThing>; - //transactions: Array<Transaction>; - tradeGoods: Array<TradeGood>; -}; diff --git a/nodejs/model/ship.ts b/nodejs/model/ship.ts deleted file mode 100644 index bf40767..0000000 --- a/nodejs/model/ship.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { Cargo } from './cargo.ts'; - -export type Cooldown = { - shipSymbol: string; - totalSeconds: number; - remainingSeconds: number; -}; - -export type Consummed = { - amount: number; - timestamp: Date; -}; - -export type Fuel = { - capacity: number; - consummed: Consummed; - current: number; -}; - -export type Nav = { - flightMode: string; - route: Route; - status: string; - systemSymbol: string; - waypointSymbol: string; -}; - -export type Registration = { - factionSymbol: string; - name: string; - role: string; -}; - -export type Route = { - arrival: Date; - departureTime: Date; - destination: RouteEndpoint; - origin: RouteEndpoint; -}; - -export type RouteEndpoint = { - type: string; - symbol: string; - systemSymbol: string; - x: number; - y: number; -}; - -export type Ship = { - cargo: Cargo; - cooldown: Cooldown; - // crew - // engine - // frame - fuel: Fuel; - // modules - // mounts - nav: Nav; - // reactor - registration: Registration; - symbol: string; -}; diff --git a/nodejs/model/system.ts b/nodejs/model/system.ts deleted file mode 100644 index b90560f..0000000 --- a/nodejs/model/system.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { CommonThing } from 'common.ts'; - -export type Chart = { - waypointSymbol: string; - submittedBy: string; - submittedOn: Date; -}; - -export type System = { - symbol: string; - sectorSymbol: string; - type: string; - x: number; - y: number; - waypoints: Array<Waypoint>; -}; - -export type Waypoint = { - chart: Chart; - factions: Array<{symbol: string;}>; - isUnderConstruction: boolean; - modifiers: Array<CommonThing>; - orbitals: Array<{symbol: string;}>; - orbits: string; - symbol: string; - traits: Array<CommonThing>; - type: string; - x: number; - y: number; -}; |