@shipload/sdk 1.0.0-next.5 → 1.0.0-next.6
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 +8 -2
- package/lib/shipload.js +104 -27
- package/lib/shipload.js.map +1 -1
- package/lib/shipload.m.js +104 -28
- package/lib/shipload.m.js.map +1 -1
- package/package.json +1 -1
- package/src/derivation/index.ts +1 -0
- package/src/derivation/resources.ts +89 -18
- package/src/index-module.ts +1 -0
- package/src/types.ts +1 -0
- package/src/utils/system.ts +21 -8
package/package.json
CHANGED
package/src/derivation/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {getItem} from '../data/catalog'
|
|
2
|
+
import {LocationType} from '../types'
|
|
2
3
|
|
|
3
4
|
export const DEPTH_THRESHOLD_T1 = 0
|
|
4
5
|
export const DEPTH_THRESHOLD_T2 = 1500
|
|
@@ -75,37 +76,107 @@ export function getResourceWeight(itemId: number, stratum: number): number {
|
|
|
75
76
|
}
|
|
76
77
|
}
|
|
77
78
|
|
|
78
|
-
const
|
|
79
|
-
const
|
|
80
|
-
const
|
|
81
|
-
const
|
|
82
|
-
const
|
|
83
|
-
const ICY_RESOURCES = [101, 301, 302, 401, 403, 501, 502]
|
|
84
|
-
const OCEAN_RESOURCES = [201, 203, 301, 303, 501, 502, 503]
|
|
85
|
-
const INDUSTRIAL_RESOURCES = [101, 102, 103, 201, 203, 402, 403]
|
|
79
|
+
const RESOURCE_ORE = 0
|
|
80
|
+
const RESOURCE_GAS = 1
|
|
81
|
+
const RESOURCE_REGOLITH = 2
|
|
82
|
+
const RESOURCE_BIOMASS = 3
|
|
83
|
+
const RESOURCE_CRYSTAL = 4
|
|
86
84
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
85
|
+
interface LocationProfileEntry {
|
|
86
|
+
category: number
|
|
87
|
+
maxTier: number
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function categoryBaseId(category: number): number {
|
|
91
|
+
switch (category) {
|
|
92
|
+
case RESOURCE_ORE:
|
|
93
|
+
return 100
|
|
94
|
+
case RESOURCE_CRYSTAL:
|
|
95
|
+
return 200
|
|
96
|
+
case RESOURCE_GAS:
|
|
97
|
+
return 300
|
|
98
|
+
case RESOURCE_REGOLITH:
|
|
99
|
+
return 400
|
|
100
|
+
case RESOURCE_BIOMASS:
|
|
101
|
+
return 500
|
|
102
|
+
default:
|
|
103
|
+
return 0
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function resourceId(category: number, tier: number): number {
|
|
108
|
+
return categoryBaseId(category) + tier
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export function getLocationProfile(locationType: number, subtype: number): LocationProfileEntry[] {
|
|
112
|
+
if (locationType === LocationType.ASTEROID) {
|
|
113
|
+
return [
|
|
114
|
+
{category: RESOURCE_ORE, maxTier: 5},
|
|
115
|
+
{category: RESOURCE_CRYSTAL, maxTier: 5},
|
|
116
|
+
]
|
|
117
|
+
}
|
|
118
|
+
if (locationType === LocationType.NEBULA) {
|
|
119
|
+
return [
|
|
120
|
+
{category: RESOURCE_GAS, maxTier: 5},
|
|
121
|
+
{category: RESOURCE_REGOLITH, maxTier: 5},
|
|
122
|
+
]
|
|
123
|
+
}
|
|
124
|
+
if (locationType === LocationType.ICE_FIELD) {
|
|
125
|
+
return [
|
|
126
|
+
{category: RESOURCE_GAS, maxTier: 5},
|
|
127
|
+
{category: RESOURCE_BIOMASS, maxTier: 5},
|
|
128
|
+
]
|
|
129
|
+
}
|
|
130
|
+
if (locationType === LocationType.PLANET) {
|
|
91
131
|
switch (subtype) {
|
|
92
132
|
case PLANET_SUBTYPE_GAS_GIANT:
|
|
93
|
-
return
|
|
133
|
+
return [
|
|
134
|
+
{category: RESOURCE_GAS, maxTier: 10},
|
|
135
|
+
{category: RESOURCE_CRYSTAL, maxTier: 3},
|
|
136
|
+
]
|
|
94
137
|
case PLANET_SUBTYPE_ROCKY:
|
|
95
|
-
return
|
|
138
|
+
return [
|
|
139
|
+
{category: RESOURCE_REGOLITH, maxTier: 10},
|
|
140
|
+
{category: RESOURCE_ORE, maxTier: 3},
|
|
141
|
+
]
|
|
96
142
|
case PLANET_SUBTYPE_TERRESTRIAL:
|
|
97
|
-
return
|
|
143
|
+
return [
|
|
144
|
+
{category: RESOURCE_ORE, maxTier: 10},
|
|
145
|
+
{category: RESOURCE_BIOMASS, maxTier: 3},
|
|
146
|
+
]
|
|
98
147
|
case PLANET_SUBTYPE_ICY:
|
|
99
|
-
return
|
|
148
|
+
return [
|
|
149
|
+
{category: RESOURCE_CRYSTAL, maxTier: 10},
|
|
150
|
+
{category: RESOURCE_REGOLITH, maxTier: 3},
|
|
151
|
+
]
|
|
100
152
|
case PLANET_SUBTYPE_OCEAN:
|
|
101
|
-
return
|
|
153
|
+
return [
|
|
154
|
+
{category: RESOURCE_BIOMASS, maxTier: 10},
|
|
155
|
+
{category: RESOURCE_GAS, maxTier: 3},
|
|
156
|
+
]
|
|
102
157
|
case PLANET_SUBTYPE_INDUSTRIAL:
|
|
103
|
-
return
|
|
158
|
+
return [
|
|
159
|
+
{category: RESOURCE_ORE, maxTier: 3},
|
|
160
|
+
{category: RESOURCE_CRYSTAL, maxTier: 3},
|
|
161
|
+
{category: RESOURCE_REGOLITH, maxTier: 3},
|
|
162
|
+
{category: RESOURCE_BIOMASS, maxTier: 3},
|
|
163
|
+
]
|
|
104
164
|
}
|
|
105
165
|
}
|
|
106
166
|
return []
|
|
107
167
|
}
|
|
108
168
|
|
|
169
|
+
export function getLocationCandidates(locationType: number, subtype: number): number[] {
|
|
170
|
+
const profile = getLocationProfile(locationType, subtype)
|
|
171
|
+
const ids: number[] = []
|
|
172
|
+
for (const {category, maxTier} of profile) {
|
|
173
|
+
for (let tier = 1; tier <= maxTier; tier++) {
|
|
174
|
+
ids.push(resourceId(category, tier))
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return ids
|
|
178
|
+
}
|
|
179
|
+
|
|
109
180
|
export function getEligibleResources(
|
|
110
181
|
locationType: number,
|
|
111
182
|
subtype: number,
|
package/src/index-module.ts
CHANGED
package/src/types.ts
CHANGED
package/src/utils/system.ts
CHANGED
|
@@ -22,12 +22,10 @@ export function getLocationType(
|
|
|
22
22
|
return LocationType.EMPTY
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
if (hashResult.array[1] < 96)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
return LocationType.NEBULA
|
|
25
|
+
if (hashResult.array[1] < 96) return LocationType.PLANET
|
|
26
|
+
if (hashResult.array[1] < 149) return LocationType.ASTEROID
|
|
27
|
+
if (hashResult.array[1] < 202) return LocationType.NEBULA
|
|
28
|
+
return LocationType.ICE_FIELD
|
|
31
29
|
}
|
|
32
30
|
|
|
33
31
|
export function isGatherableLocation(locationType: LocationType): boolean {
|
|
@@ -44,6 +42,8 @@ export function getLocationTypeName(type: LocationType): string {
|
|
|
44
42
|
return 'Asteroid'
|
|
45
43
|
case LocationType.NEBULA:
|
|
46
44
|
return 'Nebula'
|
|
45
|
+
case LocationType.ICE_FIELD:
|
|
46
|
+
return 'Ice Field'
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -76,6 +76,15 @@ function generateNebulaName(hashResult: Checksum512): string {
|
|
|
76
76
|
return `${nebulaAdjectives[adjIdx]} ${nebulaNouns[nounIdx]}`
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
function generateIceFieldName(hashResult: Checksum512): string {
|
|
80
|
+
const A = 65
|
|
81
|
+
const letter1 = String.fromCharCode(A + (hashResult.array[0] % 26))
|
|
82
|
+
const letter2 = String.fromCharCode(A + (hashResult.array[1] % 26))
|
|
83
|
+
const subId = (hashResult.array[2] % 9) + 1
|
|
84
|
+
const num = (uint16(hashResult, 3) % 9000) + 1000
|
|
85
|
+
return `${letter1}${letter2}-${subId}/${num}`
|
|
86
|
+
}
|
|
87
|
+
|
|
79
88
|
export function getSystemName(gameSeed: Checksum256Type, location: CoordinatesType): string {
|
|
80
89
|
const seed = Checksum256.from(gameSeed)
|
|
81
90
|
const locationType = getLocationType(seed, location)
|
|
@@ -91,6 +100,8 @@ export function getSystemName(gameSeed: Checksum256Type, location: CoordinatesTy
|
|
|
91
100
|
return generateAsteroidName(hashResult)
|
|
92
101
|
case LocationType.NEBULA:
|
|
93
102
|
return generateNebulaName(hashResult)
|
|
103
|
+
case LocationType.ICE_FIELD:
|
|
104
|
+
return generateIceFieldName(hashResult)
|
|
94
105
|
default:
|
|
95
106
|
return generatePlanetName(hashResult)
|
|
96
107
|
}
|
|
@@ -123,10 +134,12 @@ export function deriveLocationStatic(
|
|
|
123
134
|
|
|
124
135
|
if (hashResult.array[1] < 96) {
|
|
125
136
|
loc.type = UInt8.from(LocationType.PLANET)
|
|
126
|
-
} else if (hashResult.array[1] <
|
|
137
|
+
} else if (hashResult.array[1] < 149) {
|
|
127
138
|
loc.type = UInt8.from(LocationType.ASTEROID)
|
|
128
|
-
} else {
|
|
139
|
+
} else if (hashResult.array[1] < 202) {
|
|
129
140
|
loc.type = UInt8.from(LocationType.NEBULA)
|
|
141
|
+
} else {
|
|
142
|
+
loc.type = UInt8.from(LocationType.ICE_FIELD)
|
|
130
143
|
}
|
|
131
144
|
|
|
132
145
|
loc.subtype = UInt8.from(
|