@shipload/sdk 1.0.0-next.17 → 1.0.0-next.18
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 +17 -3
- package/lib/shipload.js +163 -90
- package/lib/shipload.js.map +1 -1
- package/lib/shipload.m.js +160 -92
- package/lib/shipload.m.js.map +1 -1
- package/lib/testing.d.ts +3 -1
- package/lib/testing.js +31 -25
- package/lib/testing.js.map +1 -1
- package/lib/testing.m.js +32 -26
- package/lib/testing.m.js.map +1 -1
- package/package.json +1 -1
- package/src/capabilities/gathering.ts +2 -1
- package/src/contracts/server.ts +7 -1
- package/src/data/items.json +24 -24
- package/src/data/recipes.json +64 -48
- package/src/derivation/index.ts +7 -2
- package/src/derivation/reserve-regen.ts +34 -0
- package/src/derivation/resources.ts +9 -1
- package/src/derivation/stratum.ts +10 -10
- package/src/derivation/tiers.ts +28 -7
- package/src/index-module.ts +7 -1
package/src/data/recipes.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
[
|
|
2
2
|
{
|
|
3
3
|
"outputItemId": 10001,
|
|
4
|
-
"outputMass":
|
|
4
|
+
"outputMass": 420000,
|
|
5
5
|
"inputs": [
|
|
6
6
|
{
|
|
7
7
|
"category": "ore",
|
|
8
8
|
"tier": 1,
|
|
9
|
-
"quantity":
|
|
9
|
+
"quantity": 20
|
|
10
10
|
}
|
|
11
11
|
],
|
|
12
12
|
"statSlots": [
|
|
@@ -31,12 +31,12 @@
|
|
|
31
31
|
},
|
|
32
32
|
{
|
|
33
33
|
"outputItemId": 10002,
|
|
34
|
-
"outputMass":
|
|
34
|
+
"outputMass": 600000,
|
|
35
35
|
"inputs": [
|
|
36
36
|
{
|
|
37
37
|
"category": "regolith",
|
|
38
38
|
"tier": 1,
|
|
39
|
-
"quantity":
|
|
39
|
+
"quantity": 30
|
|
40
40
|
},
|
|
41
41
|
{
|
|
42
42
|
"category": "biomass",
|
|
@@ -66,12 +66,12 @@
|
|
|
66
66
|
},
|
|
67
67
|
{
|
|
68
68
|
"outputItemId": 10003,
|
|
69
|
-
"outputMass":
|
|
69
|
+
"outputMass": 390000,
|
|
70
70
|
"inputs": [
|
|
71
71
|
{
|
|
72
72
|
"category": "gas",
|
|
73
73
|
"tier": 1,
|
|
74
|
-
"quantity":
|
|
74
|
+
"quantity": 65
|
|
75
75
|
}
|
|
76
76
|
],
|
|
77
77
|
"statSlots": [
|
|
@@ -96,12 +96,17 @@
|
|
|
96
96
|
},
|
|
97
97
|
{
|
|
98
98
|
"outputItemId": 10004,
|
|
99
|
-
"outputMass":
|
|
99
|
+
"outputMass": 600000,
|
|
100
100
|
"inputs": [
|
|
101
101
|
{
|
|
102
102
|
"category": "crystal",
|
|
103
103
|
"tier": 1,
|
|
104
|
-
"quantity":
|
|
104
|
+
"quantity": 25
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"category": "biomass",
|
|
108
|
+
"tier": 1,
|
|
109
|
+
"quantity": 15
|
|
105
110
|
}
|
|
106
111
|
],
|
|
107
112
|
"statSlots": [
|
|
@@ -126,12 +131,17 @@
|
|
|
126
131
|
},
|
|
127
132
|
{
|
|
128
133
|
"outputItemId": 10005,
|
|
129
|
-
"outputMass":
|
|
134
|
+
"outputMass": 600000,
|
|
130
135
|
"inputs": [
|
|
131
136
|
{
|
|
132
137
|
"category": "ore",
|
|
133
138
|
"tier": 1,
|
|
134
|
-
"quantity":
|
|
139
|
+
"quantity": 20
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
"category": "gas",
|
|
143
|
+
"tier": 1,
|
|
144
|
+
"quantity": 30
|
|
135
145
|
}
|
|
136
146
|
],
|
|
137
147
|
"statSlots": [
|
|
@@ -156,12 +166,12 @@
|
|
|
156
166
|
},
|
|
157
167
|
{
|
|
158
168
|
"outputItemId": 10006,
|
|
159
|
-
"outputMass":
|
|
169
|
+
"outputMass": 420000,
|
|
160
170
|
"inputs": [
|
|
161
171
|
{
|
|
162
172
|
"category": "crystal",
|
|
163
173
|
"tier": 1,
|
|
164
|
-
"quantity":
|
|
174
|
+
"quantity": 30
|
|
165
175
|
}
|
|
166
176
|
],
|
|
167
177
|
"statSlots": [
|
|
@@ -186,12 +196,12 @@
|
|
|
186
196
|
},
|
|
187
197
|
{
|
|
188
198
|
"outputItemId": 10007,
|
|
189
|
-
"outputMass":
|
|
199
|
+
"outputMass": 420000,
|
|
190
200
|
"inputs": [
|
|
191
201
|
{
|
|
192
202
|
"category": "biomass",
|
|
193
203
|
"tier": 1,
|
|
194
|
-
"quantity":
|
|
204
|
+
"quantity": 25
|
|
195
205
|
}
|
|
196
206
|
],
|
|
197
207
|
"statSlots": [
|
|
@@ -216,12 +226,12 @@
|
|
|
216
226
|
},
|
|
217
227
|
{
|
|
218
228
|
"outputItemId": 10008,
|
|
219
|
-
"outputMass":
|
|
229
|
+
"outputMass": 400000,
|
|
220
230
|
"inputs": [
|
|
221
231
|
{
|
|
222
232
|
"category": "regolith",
|
|
223
233
|
"tier": 1,
|
|
224
|
-
"quantity":
|
|
234
|
+
"quantity": 45
|
|
225
235
|
}
|
|
226
236
|
],
|
|
227
237
|
"statSlots": [
|
|
@@ -246,12 +256,17 @@
|
|
|
246
256
|
},
|
|
247
257
|
{
|
|
248
258
|
"outputItemId": 10009,
|
|
249
|
-
"outputMass":
|
|
259
|
+
"outputMass": 590000,
|
|
250
260
|
"inputs": [
|
|
251
261
|
{
|
|
252
262
|
"category": "gas",
|
|
253
263
|
"tier": 1,
|
|
254
|
-
"quantity":
|
|
264
|
+
"quantity": 40
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
"category": "regolith",
|
|
268
|
+
"tier": 1,
|
|
269
|
+
"quantity": 40
|
|
255
270
|
}
|
|
256
271
|
],
|
|
257
272
|
"statSlots": [
|
|
@@ -276,12 +291,17 @@
|
|
|
276
291
|
},
|
|
277
292
|
{
|
|
278
293
|
"outputItemId": 10010,
|
|
279
|
-
"outputMass":
|
|
294
|
+
"outputMass": 590000,
|
|
280
295
|
"inputs": [
|
|
281
296
|
{
|
|
282
297
|
"category": "crystal",
|
|
283
298
|
"tier": 1,
|
|
284
|
-
"quantity":
|
|
299
|
+
"quantity": 20
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
"category": "ore",
|
|
303
|
+
"tier": 1,
|
|
304
|
+
"quantity": 15
|
|
285
305
|
}
|
|
286
306
|
],
|
|
287
307
|
"statSlots": [
|
|
@@ -306,7 +326,7 @@
|
|
|
306
326
|
},
|
|
307
327
|
{
|
|
308
328
|
"outputItemId": 10100,
|
|
309
|
-
"outputMass":
|
|
329
|
+
"outputMass": 940000,
|
|
310
330
|
"inputs": [
|
|
311
331
|
{
|
|
312
332
|
"itemId": 10003,
|
|
@@ -335,11 +355,11 @@
|
|
|
335
355
|
},
|
|
336
356
|
{
|
|
337
357
|
"outputItemId": 10101,
|
|
338
|
-
"outputMass":
|
|
358
|
+
"outputMass": 1440000,
|
|
339
359
|
"inputs": [
|
|
340
360
|
{
|
|
341
361
|
"itemId": 10004,
|
|
342
|
-
"quantity":
|
|
362
|
+
"quantity": 6
|
|
343
363
|
}
|
|
344
364
|
],
|
|
345
365
|
"statSlots": [
|
|
@@ -364,11 +384,11 @@
|
|
|
364
384
|
},
|
|
365
385
|
{
|
|
366
386
|
"outputItemId": 10102,
|
|
367
|
-
"outputMass":
|
|
387
|
+
"outputMass": 1220000,
|
|
368
388
|
"inputs": [
|
|
369
389
|
{
|
|
370
390
|
"itemId": 10005,
|
|
371
|
-
"quantity":
|
|
391
|
+
"quantity": 3
|
|
372
392
|
},
|
|
373
393
|
{
|
|
374
394
|
"itemId": 10006,
|
|
@@ -416,22 +436,18 @@
|
|
|
416
436
|
},
|
|
417
437
|
{
|
|
418
438
|
"outputItemId": 10103,
|
|
419
|
-
"outputMass":
|
|
439
|
+
"outputMass": 1010000,
|
|
420
440
|
"inputs": [
|
|
421
|
-
{
|
|
422
|
-
"itemId": 10002,
|
|
423
|
-
"quantity": 3
|
|
424
|
-
},
|
|
425
441
|
{
|
|
426
442
|
"itemId": 10007,
|
|
427
|
-
"quantity":
|
|
443
|
+
"quantity": 6
|
|
428
444
|
}
|
|
429
445
|
],
|
|
430
446
|
"statSlots": [
|
|
431
447
|
{
|
|
432
448
|
"sources": [
|
|
433
449
|
{
|
|
434
|
-
"inputIndex":
|
|
450
|
+
"inputIndex": 0,
|
|
435
451
|
"statIndex": 1
|
|
436
452
|
}
|
|
437
453
|
]
|
|
@@ -439,7 +455,7 @@
|
|
|
439
455
|
{
|
|
440
456
|
"sources": [
|
|
441
457
|
{
|
|
442
|
-
"inputIndex":
|
|
458
|
+
"inputIndex": 0,
|
|
443
459
|
"statIndex": 0
|
|
444
460
|
}
|
|
445
461
|
]
|
|
@@ -449,7 +465,7 @@
|
|
|
449
465
|
},
|
|
450
466
|
{
|
|
451
467
|
"outputItemId": 10104,
|
|
452
|
-
"outputMass":
|
|
468
|
+
"outputMass": 1190000,
|
|
453
469
|
"inputs": [
|
|
454
470
|
{
|
|
455
471
|
"itemId": 10008,
|
|
@@ -482,15 +498,15 @@
|
|
|
482
498
|
},
|
|
483
499
|
{
|
|
484
500
|
"outputItemId": 10105,
|
|
485
|
-
"outputMass":
|
|
501
|
+
"outputMass": 1220000,
|
|
486
502
|
"inputs": [
|
|
487
503
|
{
|
|
488
504
|
"itemId": 10001,
|
|
489
|
-
"quantity":
|
|
505
|
+
"quantity": 3
|
|
490
506
|
},
|
|
491
507
|
{
|
|
492
508
|
"itemId": 10002,
|
|
493
|
-
"quantity":
|
|
509
|
+
"quantity": 3
|
|
494
510
|
}
|
|
495
511
|
],
|
|
496
512
|
"statSlots": [
|
|
@@ -531,7 +547,7 @@
|
|
|
531
547
|
},
|
|
532
548
|
{
|
|
533
549
|
"outputItemId": 10106,
|
|
534
|
-
"outputMass":
|
|
550
|
+
"outputMass": 1430000,
|
|
535
551
|
"inputs": [
|
|
536
552
|
{
|
|
537
553
|
"itemId": 10004,
|
|
@@ -575,15 +591,15 @@
|
|
|
575
591
|
},
|
|
576
592
|
{
|
|
577
593
|
"outputItemId": 10107,
|
|
578
|
-
"outputMass":
|
|
594
|
+
"outputMass": 1420000,
|
|
579
595
|
"inputs": [
|
|
580
596
|
{
|
|
581
597
|
"itemId": 10010,
|
|
582
|
-
"quantity":
|
|
598
|
+
"quantity": 3
|
|
583
599
|
},
|
|
584
600
|
{
|
|
585
601
|
"itemId": 10009,
|
|
586
|
-
"quantity":
|
|
602
|
+
"quantity": 3
|
|
587
603
|
}
|
|
588
604
|
],
|
|
589
605
|
"statSlots": [
|
|
@@ -607,11 +623,11 @@
|
|
|
607
623
|
},
|
|
608
624
|
{
|
|
609
625
|
"outputItemId": 10108,
|
|
610
|
-
"outputMass":
|
|
626
|
+
"outputMass": 970000,
|
|
611
627
|
"inputs": [
|
|
612
628
|
{
|
|
613
629
|
"itemId": 10003,
|
|
614
|
-
"quantity":
|
|
630
|
+
"quantity": 3
|
|
615
631
|
},
|
|
616
632
|
{
|
|
617
633
|
"itemId": 10007,
|
|
@@ -656,7 +672,7 @@
|
|
|
656
672
|
},
|
|
657
673
|
{
|
|
658
674
|
"outputItemId": 10200,
|
|
659
|
-
"outputMass":
|
|
675
|
+
"outputMass": 1490000,
|
|
660
676
|
"inputs": [
|
|
661
677
|
{
|
|
662
678
|
"itemId": 10001,
|
|
@@ -705,7 +721,7 @@
|
|
|
705
721
|
},
|
|
706
722
|
{
|
|
707
723
|
"outputItemId": 10201,
|
|
708
|
-
"outputMass":
|
|
724
|
+
"outputMass": 2300000,
|
|
709
725
|
"inputs": [
|
|
710
726
|
{
|
|
711
727
|
"itemId": 10001,
|
|
@@ -754,7 +770,7 @@
|
|
|
754
770
|
},
|
|
755
771
|
{
|
|
756
772
|
"outputItemId": 10202,
|
|
757
|
-
"outputMass":
|
|
773
|
+
"outputMass": 5760000,
|
|
758
774
|
"inputs": [
|
|
759
775
|
{
|
|
760
776
|
"itemId": 10001,
|
|
@@ -803,7 +819,7 @@
|
|
|
803
819
|
},
|
|
804
820
|
{
|
|
805
821
|
"outputItemId": 10203,
|
|
806
|
-
"outputMass":
|
|
822
|
+
"outputMass": 4440000,
|
|
807
823
|
"inputs": [
|
|
808
824
|
{
|
|
809
825
|
"itemId": 10001,
|
|
@@ -852,7 +868,7 @@
|
|
|
852
868
|
},
|
|
853
869
|
{
|
|
854
870
|
"outputItemId": 10204,
|
|
855
|
-
"outputMass":
|
|
871
|
+
"outputMass": 5540000,
|
|
856
872
|
"inputs": [
|
|
857
873
|
{
|
|
858
874
|
"itemId": 10001,
|
package/src/derivation/index.ts
CHANGED
|
@@ -17,7 +17,9 @@ export {
|
|
|
17
17
|
DEPTH_THRESHOLD_T5,
|
|
18
18
|
LOCATION_MIN_DEPTH,
|
|
19
19
|
LOCATION_MAX_DEPTH,
|
|
20
|
-
|
|
20
|
+
yieldThresholdAt,
|
|
21
|
+
YIELD_FRACTION_SHALLOW,
|
|
22
|
+
YIELD_FRACTION_DEEP,
|
|
21
23
|
PLANET_SUBTYPE_GAS_GIANT,
|
|
22
24
|
PLANET_SUBTYPE_ROCKY,
|
|
23
25
|
PLANET_SUBTYPE_TERRESTRIAL,
|
|
@@ -26,8 +28,11 @@ export {
|
|
|
26
28
|
PLANET_SUBTYPE_INDUSTRIAL,
|
|
27
29
|
} from './resources'
|
|
28
30
|
|
|
29
|
-
export {RESERVE_TIERS, TIER_ROLL_MAX, rollTier, rollWithinTier} from './tiers'
|
|
31
|
+
export {RESERVE_TIERS, TIER_ROLL_MAX, tierOfReserve, rollTier, rollWithinTier} from './tiers'
|
|
30
32
|
export type {ReserveTier, TierRange} from './tiers'
|
|
31
33
|
|
|
34
|
+
export {getEffectiveReserve} from './reserve-regen'
|
|
35
|
+
export type {EffectiveReserveInput} from './reserve-regen'
|
|
36
|
+
|
|
32
37
|
export * from './stats'
|
|
33
38
|
export * from './crafting'
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type {BlockTimestamp, UInt32} from '@wharfkit/antelope'
|
|
2
|
+
|
|
3
|
+
export interface EffectiveReserveInput {
|
|
4
|
+
remaining: UInt32 | number
|
|
5
|
+
max_reserve: UInt32 | number
|
|
6
|
+
last_block: BlockTimestamp
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function toNumber(value: UInt32 | number): number {
|
|
10
|
+
return typeof value === 'number' ? value : Number(value)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function slotsBetween(now: BlockTimestamp, last: BlockTimestamp): number {
|
|
14
|
+
const nowMs = now.toMilliseconds()
|
|
15
|
+
const lastMs = last.toMilliseconds()
|
|
16
|
+
if (nowMs <= lastMs) return 0
|
|
17
|
+
return Math.floor((nowMs - lastMs) / 500)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function getEffectiveReserve(
|
|
21
|
+
row: EffectiveReserveInput,
|
|
22
|
+
now: BlockTimestamp,
|
|
23
|
+
epochSeconds: number
|
|
24
|
+
): number {
|
|
25
|
+
const remaining = toNumber(row.remaining)
|
|
26
|
+
const max = toNumber(row.max_reserve)
|
|
27
|
+
if (remaining >= max) return max
|
|
28
|
+
const epochSlots = epochSeconds * 2
|
|
29
|
+
if (epochSlots === 0) return remaining
|
|
30
|
+
const elapsed = slotsBetween(now, row.last_block)
|
|
31
|
+
const regen = Math.floor((max * elapsed) / epochSlots)
|
|
32
|
+
const effective = remaining + regen
|
|
33
|
+
return effective >= max ? max : effective
|
|
34
|
+
}
|
|
@@ -15,7 +15,15 @@ export const DEPTH_THRESHOLD_T10 = 63000
|
|
|
15
15
|
export const LOCATION_MIN_DEPTH = 500
|
|
16
16
|
export const LOCATION_MAX_DEPTH = 65535
|
|
17
17
|
|
|
18
|
-
export const
|
|
18
|
+
export const YIELD_FRACTION_SHALLOW = 0.0025
|
|
19
|
+
export const YIELD_FRACTION_DEEP = 0.0005
|
|
20
|
+
|
|
21
|
+
export function yieldThresholdAt(stratum: number): number {
|
|
22
|
+
const clamped = stratum > 65535 ? 65535 : stratum
|
|
23
|
+
const t = clamped / 65535
|
|
24
|
+
const fraction = YIELD_FRACTION_SHALLOW + (YIELD_FRACTION_DEEP - YIELD_FRACTION_SHALLOW) * t
|
|
25
|
+
return Math.floor(fraction * 0xffffffff)
|
|
26
|
+
}
|
|
19
27
|
|
|
20
28
|
export const PLANET_SUBTYPE_GAS_GIANT = 0
|
|
21
29
|
export const PLANET_SUBTYPE_ROCKY = 1
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {Bytes, Checksum256, type Checksum256Type} from '@wharfkit/antelope'
|
|
2
2
|
import {hash512} from '../utils/hash'
|
|
3
3
|
import {Coordinates, type CoordinatesType} from '../types'
|
|
4
|
-
import {
|
|
4
|
+
import {getItem} from '../data/catalog'
|
|
5
|
+
import {getEligibleResources, getResourceWeight, yieldThresholdAt} from './resources'
|
|
5
6
|
import {RESERVE_TIERS, rollTier, rollWithinTier} from './tiers'
|
|
6
7
|
|
|
7
8
|
export interface StratumInfo {
|
|
@@ -33,15 +34,8 @@ export function deriveStratum(
|
|
|
33
34
|
|
|
34
35
|
const rawReserve = ((bytes[0] << 24) | (bytes[1] << 16) | (bytes[2] << 8) | bytes[3]) >>> 0
|
|
35
36
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const tierRoll = ((bytes[18] << 8) | bytes[19]) >>> 0
|
|
39
|
-
const withinRoll = ((bytes[20] << 8) | bytes[21]) >>> 0
|
|
40
|
-
const tier = rollTier(tierRoll, stratum)
|
|
41
|
-
reserve = rollWithinTier(withinRoll, RESERVE_TIERS[tier])
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (reserve === 0) return {itemId: 0, seed: 0n, richness: 0, reserve: 0}
|
|
37
|
+
if (rawReserve > yieldThresholdAt(stratum))
|
|
38
|
+
return {itemId: 0, seed: 0n, richness: 0, reserve: 0}
|
|
45
39
|
|
|
46
40
|
const eligible = getEligibleResources(locationType, subtype, stratum)
|
|
47
41
|
if (eligible.length === 0) return {itemId: 0, seed: 0n, richness: 0, reserve: 0}
|
|
@@ -66,6 +60,12 @@ export function deriveStratum(
|
|
|
66
60
|
}
|
|
67
61
|
}
|
|
68
62
|
|
|
63
|
+
const tierRoll = ((bytes[18] << 8) | bytes[19]) >>> 0
|
|
64
|
+
const withinRoll = ((bytes[20] << 8) | bytes[21]) >>> 0
|
|
65
|
+
const tier = rollTier(tierRoll, stratum)
|
|
66
|
+
const unitMass = getItem(selectedItemId).mass
|
|
67
|
+
const reserve = rollWithinTier(withinRoll, RESERVE_TIERS[tier], unitMass)
|
|
68
|
+
|
|
69
69
|
const seedBigInt =
|
|
70
70
|
(BigInt(bytes[8]) << 56n) |
|
|
71
71
|
(BigInt(bytes[9]) << 48n) |
|
package/src/derivation/tiers.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import {getItem} from '../data/catalog'
|
|
2
|
+
|
|
1
3
|
export type ReserveTier = 'small' | 'medium' | 'large' | 'massive' | 'motherlode'
|
|
2
4
|
|
|
3
5
|
export interface TierRange {
|
|
@@ -6,11 +8,11 @@ export interface TierRange {
|
|
|
6
8
|
}
|
|
7
9
|
|
|
8
10
|
export const RESERVE_TIERS: Record<ReserveTier, TierRange> = {
|
|
9
|
-
small: {min:
|
|
10
|
-
medium: {min:
|
|
11
|
-
large: {min:
|
|
12
|
-
massive: {min:
|
|
13
|
-
motherlode: {min:
|
|
11
|
+
small: {min: 3_600_000, max: 14_400_000},
|
|
12
|
+
medium: {min: 24_000_000, max: 48_000_000},
|
|
13
|
+
large: {min: 96_000_000, max: 168_000_000},
|
|
14
|
+
massive: {min: 240_000_000, max: 600_000_000},
|
|
15
|
+
motherlode: {min: 960_000_000, max: 2_400_000_000},
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
const SHALLOW_THRESHOLDS = {
|
|
@@ -47,8 +49,27 @@ export function rollTier(tierRoll: number, stratum: number): ReserveTier {
|
|
|
47
49
|
return 'motherlode'
|
|
48
50
|
}
|
|
49
51
|
|
|
50
|
-
export function rollWithinTier(
|
|
52
|
+
export function rollWithinTier(
|
|
53
|
+
withinRoll: number,
|
|
54
|
+
range: TierRange,
|
|
55
|
+
resourceUnitMass: number
|
|
56
|
+
): number {
|
|
51
57
|
const u = withinRoll / 65535
|
|
52
58
|
const skewed = u * u
|
|
53
|
-
|
|
59
|
+
const depositMass = range.min + skewed * (range.max - range.min)
|
|
60
|
+
return Math.max(1, Math.floor(depositMass / resourceUnitMass))
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const RESERVE_TIER_ENTRIES = Object.entries(RESERVE_TIERS) as Array<[ReserveTier, TierRange]>
|
|
64
|
+
|
|
65
|
+
export function tierOfReserve(reserve: number, itemId: number): ReserveTier | null {
|
|
66
|
+
if (reserve <= 0) return null
|
|
67
|
+
const unitMass = getItem(itemId).mass
|
|
68
|
+
if (unitMass <= 0) return null
|
|
69
|
+
const impliedMassLow = reserve * unitMass
|
|
70
|
+
const impliedMassHigh = impliedMassLow + unitMass
|
|
71
|
+
for (const [tier, range] of RESERVE_TIER_ENTRIES) {
|
|
72
|
+
if (impliedMassHigh > range.min && impliedMassLow <= range.max) return tier
|
|
73
|
+
}
|
|
74
|
+
return null
|
|
54
75
|
}
|
package/src/index-module.ts
CHANGED
|
@@ -97,6 +97,9 @@ export {
|
|
|
97
97
|
DEPTH_THRESHOLD_T5,
|
|
98
98
|
LOCATION_MIN_DEPTH,
|
|
99
99
|
LOCATION_MAX_DEPTH,
|
|
100
|
+
yieldThresholdAt,
|
|
101
|
+
YIELD_FRACTION_SHALLOW,
|
|
102
|
+
YIELD_FRACTION_DEEP,
|
|
100
103
|
PLANET_SUBTYPE_GAS_GIANT,
|
|
101
104
|
PLANET_SUBTYPE_ROCKY,
|
|
102
105
|
PLANET_SUBTYPE_TERRESTRIAL,
|
|
@@ -107,9 +110,12 @@ export {
|
|
|
107
110
|
|
|
108
111
|
export type {StratumInfo, ResourceStats, DerivedStratum} from './derivation'
|
|
109
112
|
|
|
110
|
-
export {RESERVE_TIERS, TIER_ROLL_MAX, rollTier, rollWithinTier} from './derivation'
|
|
113
|
+
export {RESERVE_TIERS, TIER_ROLL_MAX, tierOfReserve, rollTier, rollWithinTier} from './derivation'
|
|
111
114
|
export type {ReserveTier, TierRange} from './derivation'
|
|
112
115
|
|
|
116
|
+
export {getEffectiveReserve} from './derivation'
|
|
117
|
+
export type {EffectiveReserveInput} from './derivation'
|
|
118
|
+
|
|
113
119
|
export {getStatDefinitions, getStatName, resolveStats} from './derivation'
|
|
114
120
|
export type {StatDefinition, NamedStats} from './derivation'
|
|
115
121
|
|