@shipload/sdk 1.0.0-next.11 → 1.0.0-next.13
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 +779 -984
- package/lib/shipload.js +2203 -2738
- package/lib/shipload.js.map +1 -1
- package/lib/shipload.m.js +2186 -2712
- package/lib/shipload.m.js.map +1 -1
- package/lib/testing.d.ts +713 -0
- package/lib/testing.js +3065 -0
- package/lib/testing.js.map +1 -0
- package/lib/testing.m.js +3059 -0
- package/lib/testing.m.js.map +1 -0
- package/package.json +14 -1
- package/src/data/kind-registry.json +78 -0
- package/src/data/kind-registry.ts +133 -0
- package/src/derivation/capabilities.ts +397 -0
- package/src/derivation/crafting.ts +1 -1
- package/src/entities/entity.ts +98 -0
- package/src/entities/makers.ts +75 -228
- package/src/index-module.ts +30 -34
- package/src/managers/entities.ts +18 -114
- package/src/managers/index.ts +1 -1
- package/src/nft/atomicdata.ts +2 -0
- package/src/nft/description.ts +1 -1
- package/src/resolution/resolve-item.ts +3 -2
- package/src/subscriptions/manager.ts +2 -5
- package/src/subscriptions/mappers.ts +3 -12
- package/src/testing/catalog-hash.ts +19 -0
- package/src/testing/index.ts +2 -0
- package/src/testing/projection-parity.ts +143 -0
- package/src/types/index.ts +0 -1
- package/src/types.ts +0 -9
- package/src/entities/container.ts +0 -123
- package/src/entities/extractor.ts +0 -144
- package/src/entities/factory.ts +0 -135
- package/src/entities/nexus.ts +0 -29
- package/src/entities/ship-deploy.ts +0 -316
- package/src/entities/ship.ts +0 -221
- package/src/entities/warehouse.ts +0 -136
- package/src/types/entity-traits.ts +0 -171
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import {Name} from '@wharfkit/antelope'
|
|
2
|
-
import {
|
|
3
|
-
ITEM_CONTAINER_T1_PACKED,
|
|
4
|
-
ITEM_CONTAINER_T2_PACKED,
|
|
5
|
-
ITEM_EXTRACTOR_T1_PACKED,
|
|
6
|
-
ITEM_FACTORY_T1_PACKED,
|
|
7
|
-
ITEM_SHIP_T1_PACKED,
|
|
8
|
-
ITEM_WAREHOUSE_T1_PACKED,
|
|
9
|
-
} from '../data/item-ids'
|
|
10
|
-
|
|
11
|
-
export const ENTITY_SHIP = Name.from('ship')
|
|
12
|
-
export const ENTITY_WAREHOUSE = Name.from('warehouse')
|
|
13
|
-
export const ENTITY_EXTRACTOR = Name.from('extractor')
|
|
14
|
-
export const ENTITY_FACTORY = Name.from('factory')
|
|
15
|
-
export const ENTITY_CONTAINER = Name.from('container')
|
|
16
|
-
export const ENTITY_NEXUS = Name.from('nexus')
|
|
17
|
-
|
|
18
|
-
export enum EntityClass {
|
|
19
|
-
OrbitalVessel = 0,
|
|
20
|
-
PlanetaryStructure = 1,
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function getEntityClass(entityType: Name | EntityTypeName): EntityClass {
|
|
24
|
-
const typeName = typeof entityType === 'string' ? entityType : entityType.toString()
|
|
25
|
-
switch (typeName) {
|
|
26
|
-
case 'ship':
|
|
27
|
-
case 'container':
|
|
28
|
-
case 'nexus':
|
|
29
|
-
return EntityClass.OrbitalVessel
|
|
30
|
-
case 'warehouse':
|
|
31
|
-
case 'extractor':
|
|
32
|
-
case 'factory':
|
|
33
|
-
return EntityClass.PlanetaryStructure
|
|
34
|
-
default:
|
|
35
|
-
throw new Error(`Entity type has no class: ${typeName}`)
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export function getPackedEntityType(itemId: number): Name | null {
|
|
40
|
-
switch (itemId) {
|
|
41
|
-
case ITEM_SHIP_T1_PACKED:
|
|
42
|
-
return ENTITY_SHIP
|
|
43
|
-
case ITEM_CONTAINER_T1_PACKED:
|
|
44
|
-
case ITEM_CONTAINER_T2_PACKED:
|
|
45
|
-
return ENTITY_CONTAINER
|
|
46
|
-
case ITEM_WAREHOUSE_T1_PACKED:
|
|
47
|
-
return ENTITY_WAREHOUSE
|
|
48
|
-
case ITEM_EXTRACTOR_T1_PACKED:
|
|
49
|
-
return ENTITY_EXTRACTOR
|
|
50
|
-
case ITEM_FACTORY_T1_PACKED:
|
|
51
|
-
return ENTITY_FACTORY
|
|
52
|
-
default:
|
|
53
|
-
return null
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export type EntityTypeName = 'ship' | 'warehouse' | 'extractor' | 'factory' | 'container' | 'nexus'
|
|
58
|
-
|
|
59
|
-
export interface EntityTraits {
|
|
60
|
-
typeName: Name
|
|
61
|
-
isMovable: boolean
|
|
62
|
-
hasEnergy: boolean
|
|
63
|
-
hasLoaders: boolean
|
|
64
|
-
hasModules: boolean
|
|
65
|
-
notFoundError: string
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export const shipTraits: EntityTraits = {
|
|
69
|
-
typeName: ENTITY_SHIP,
|
|
70
|
-
isMovable: true,
|
|
71
|
-
hasEnergy: true,
|
|
72
|
-
hasLoaders: true,
|
|
73
|
-
hasModules: true,
|
|
74
|
-
|
|
75
|
-
notFoundError: 'ship not found',
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export const warehouseTraits: EntityTraits = {
|
|
79
|
-
typeName: ENTITY_WAREHOUSE,
|
|
80
|
-
isMovable: false,
|
|
81
|
-
hasEnergy: false,
|
|
82
|
-
hasLoaders: true,
|
|
83
|
-
hasModules: true,
|
|
84
|
-
|
|
85
|
-
notFoundError: 'warehouse not found',
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export const extractorTraits: EntityTraits = {
|
|
89
|
-
typeName: ENTITY_EXTRACTOR,
|
|
90
|
-
isMovable: false,
|
|
91
|
-
hasEnergy: true,
|
|
92
|
-
hasLoaders: false,
|
|
93
|
-
hasModules: true,
|
|
94
|
-
|
|
95
|
-
notFoundError: 'extractor not found',
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export const factoryTraits: EntityTraits = {
|
|
99
|
-
typeName: ENTITY_FACTORY,
|
|
100
|
-
isMovable: false,
|
|
101
|
-
hasEnergy: true,
|
|
102
|
-
hasLoaders: false,
|
|
103
|
-
hasModules: true,
|
|
104
|
-
|
|
105
|
-
notFoundError: 'factory not found',
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export const containerTraits: EntityTraits = {
|
|
109
|
-
typeName: ENTITY_CONTAINER,
|
|
110
|
-
isMovable: true,
|
|
111
|
-
hasEnergy: false,
|
|
112
|
-
hasLoaders: false,
|
|
113
|
-
hasModules: false,
|
|
114
|
-
|
|
115
|
-
notFoundError: 'container not found',
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export const nexusTraits: EntityTraits = {
|
|
119
|
-
typeName: ENTITY_NEXUS,
|
|
120
|
-
isMovable: false,
|
|
121
|
-
hasEnergy: false,
|
|
122
|
-
hasLoaders: false,
|
|
123
|
-
hasModules: false,
|
|
124
|
-
|
|
125
|
-
notFoundError: 'nexus not found',
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
export function getEntityTraits(entityType: Name | EntityTypeName): EntityTraits {
|
|
129
|
-
const typeName = typeof entityType === 'string' ? entityType : entityType.toString()
|
|
130
|
-
|
|
131
|
-
switch (typeName) {
|
|
132
|
-
case 'ship':
|
|
133
|
-
return shipTraits
|
|
134
|
-
case 'warehouse':
|
|
135
|
-
return warehouseTraits
|
|
136
|
-
case 'extractor':
|
|
137
|
-
return extractorTraits
|
|
138
|
-
case 'factory':
|
|
139
|
-
return factoryTraits
|
|
140
|
-
case 'container':
|
|
141
|
-
return containerTraits
|
|
142
|
-
case 'nexus':
|
|
143
|
-
return nexusTraits
|
|
144
|
-
default:
|
|
145
|
-
throw new Error(`Unknown entity type: ${typeName}`)
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
export function isShip(entity: {type?: Name}): boolean {
|
|
150
|
-
return entity.type?.equals(ENTITY_SHIP) ?? false
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
export function isWarehouse(entity: {type?: Name}): boolean {
|
|
154
|
-
return entity.type?.equals(ENTITY_WAREHOUSE) ?? false
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
export function isExtractor(entity: {type?: Name}): boolean {
|
|
158
|
-
return entity.type?.equals(ENTITY_EXTRACTOR) ?? false
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
export function isFactory(entity: {type?: Name}): boolean {
|
|
162
|
-
return entity.type?.equals(ENTITY_FACTORY) ?? false
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
export function isContainer(entity: {type?: Name}): boolean {
|
|
166
|
-
return entity.type?.equals(ENTITY_CONTAINER) ?? false
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
export function isNexus(entity: {type?: Name}): boolean {
|
|
170
|
-
return entity.type?.equals(ENTITY_NEXUS) ?? false
|
|
171
|
-
}
|