@shipload/sdk 2.0.0-rc5 → 2.0.0-rc6
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 +376 -1008
- package/lib/shipload.js +712 -1948
- package/lib/shipload.js.map +1 -1
- package/lib/shipload.m.js +694 -1924
- package/lib/shipload.m.js.map +1 -1
- package/package.json +1 -1
- package/src/capabilities/crafting.ts +10 -0
- package/src/capabilities/guards.ts +0 -5
- package/src/capabilities/index.ts +1 -0
- package/src/capabilities/storage.ts +0 -8
- package/src/contracts/server.ts +103 -220
- package/src/data/items.json +15 -15
- package/src/data/recipes.ts +129 -0
- package/src/derivation/crafting.ts +120 -0
- package/src/derivation/index.ts +1 -0
- package/src/derivation/stats.ts +91 -15
- package/src/derivation/stratum.ts +2 -2
- package/src/entities/cargo-utils.ts +6 -64
- package/src/entities/container.ts +18 -0
- package/src/entities/entity-inventory.ts +0 -4
- package/src/entities/inventory-accessor.ts +0 -4
- package/src/entities/location.ts +2 -197
- package/src/entities/player.ts +1 -274
- package/src/entities/ship.ts +0 -21
- package/src/entities/warehouse.ts +0 -4
- package/src/index-module.ts +34 -41
- package/src/managers/actions.ts +38 -90
- package/src/managers/context.ts +0 -9
- package/src/managers/index.ts +0 -1
- package/src/managers/locations.ts +2 -85
- package/src/market/items.ts +0 -1
- package/src/scheduling/projection.ts +0 -10
- package/src/shipload.ts +0 -5
- package/src/types/capabilities.ts +1 -9
- package/src/types/entity-traits.ts +3 -4
- package/src/types/entity.ts +0 -1
- package/src/types.ts +5 -25
- package/src/utils/system.ts +5 -4
- package/src/managers/trades.ts +0 -119
- package/src/market/market.ts +0 -195
- package/src/market/rolls.ts +0 -8
- package/src/trading/collect.ts +0 -938
- package/src/trading/deal.ts +0 -207
- package/src/trading/trade.ts +0 -203
package/src/market/market.ts
DELETED
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
import {CoordinatesType, ItemPrice} from '../types'
|
|
2
|
-
import {getItem, getItems} from './items'
|
|
3
|
-
import {Checksum256Type, UInt16, UInt16Type, UInt32} from '@wharfkit/antelope'
|
|
4
|
-
import {roll} from './rolls'
|
|
5
|
-
import {ServerContract} from '../contracts'
|
|
6
|
-
|
|
7
|
-
export enum Rarities {
|
|
8
|
-
legendary = 'LEGENDARY',
|
|
9
|
-
epic = 'EPIC',
|
|
10
|
-
rare = 'RARE',
|
|
11
|
-
uncommon = 'UNCOMMON',
|
|
12
|
-
common = 'COMMON',
|
|
13
|
-
trash = 'TRASH',
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface Rarity {
|
|
17
|
-
rarity: Rarities
|
|
18
|
-
minMultiplier: number
|
|
19
|
-
maxMultiplier: number
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function getRarity(
|
|
23
|
-
gameSeed: Checksum256Type,
|
|
24
|
-
epochSeed: Checksum256Type,
|
|
25
|
-
location: CoordinatesType,
|
|
26
|
-
goodId: UInt16Type
|
|
27
|
-
): Rarity {
|
|
28
|
-
const seed = `${epochSeed}${location.x}${location.y}${goodId}rarity`
|
|
29
|
-
const rarityRoll = roll(gameSeed, seed)
|
|
30
|
-
|
|
31
|
-
if (rarityRoll < 13) {
|
|
32
|
-
return {
|
|
33
|
-
rarity: Rarities.legendary,
|
|
34
|
-
minMultiplier: 2.25,
|
|
35
|
-
maxMultiplier: 3.0,
|
|
36
|
-
}
|
|
37
|
-
} else if (rarityRoll < 176) {
|
|
38
|
-
return {
|
|
39
|
-
rarity: Rarities.epic,
|
|
40
|
-
minMultiplier: 1.75,
|
|
41
|
-
maxMultiplier: 2.25,
|
|
42
|
-
}
|
|
43
|
-
} else if (rarityRoll < 996) {
|
|
44
|
-
return {
|
|
45
|
-
rarity: Rarities.rare,
|
|
46
|
-
minMultiplier: 1.4,
|
|
47
|
-
maxMultiplier: 1.75,
|
|
48
|
-
}
|
|
49
|
-
} else if (rarityRoll < 2966) {
|
|
50
|
-
return {
|
|
51
|
-
rarity: Rarities.uncommon,
|
|
52
|
-
minMultiplier: 1.225,
|
|
53
|
-
maxMultiplier: 1.4,
|
|
54
|
-
}
|
|
55
|
-
} else if (rarityRoll < 19568) {
|
|
56
|
-
return {
|
|
57
|
-
rarity: Rarities.common,
|
|
58
|
-
minMultiplier: 1.07,
|
|
59
|
-
maxMultiplier: 1.225,
|
|
60
|
-
}
|
|
61
|
-
} else if (rarityRoll < 45988) {
|
|
62
|
-
return {
|
|
63
|
-
rarity: Rarities.trash,
|
|
64
|
-
minMultiplier: 1,
|
|
65
|
-
maxMultiplier: 1.07,
|
|
66
|
-
}
|
|
67
|
-
} else if (rarityRoll < 62508) {
|
|
68
|
-
return {
|
|
69
|
-
rarity: Rarities.common,
|
|
70
|
-
minMultiplier: 0.925,
|
|
71
|
-
maxMultiplier: 1,
|
|
72
|
-
}
|
|
73
|
-
} else if (rarityRoll < 64518) {
|
|
74
|
-
return {
|
|
75
|
-
rarity: Rarities.uncommon,
|
|
76
|
-
minMultiplier: 0.77,
|
|
77
|
-
maxMultiplier: 0.925,
|
|
78
|
-
}
|
|
79
|
-
} else if (rarityRoll < 65437) {
|
|
80
|
-
return {
|
|
81
|
-
rarity: Rarities.rare,
|
|
82
|
-
minMultiplier: 0.595,
|
|
83
|
-
maxMultiplier: 0.77,
|
|
84
|
-
}
|
|
85
|
-
} else if (rarityRoll < 65523) {
|
|
86
|
-
return {
|
|
87
|
-
rarity: Rarities.epic,
|
|
88
|
-
minMultiplier: 0.41,
|
|
89
|
-
maxMultiplier: 0.595,
|
|
90
|
-
}
|
|
91
|
-
} else {
|
|
92
|
-
return {
|
|
93
|
-
rarity: Rarities.legendary,
|
|
94
|
-
minMultiplier: 0.285,
|
|
95
|
-
maxMultiplier: 0.41,
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export function getRarityMultiplier(
|
|
101
|
-
gameSeed: Checksum256Type,
|
|
102
|
-
epochSeed: Checksum256Type,
|
|
103
|
-
location: CoordinatesType,
|
|
104
|
-
goodId: UInt16Type
|
|
105
|
-
): number {
|
|
106
|
-
const rarity = getRarity(gameSeed, epochSeed, location, goodId)
|
|
107
|
-
const range = rarity.maxMultiplier - rarity.minMultiplier
|
|
108
|
-
const seed = `${epochSeed}${location.x}${location.y}${goodId}raritymultiplier`
|
|
109
|
-
const r = roll(gameSeed, seed)
|
|
110
|
-
return rarity.minMultiplier + (r / 65535) * range
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export function getLocationMultiplier(
|
|
114
|
-
gameSeed: Checksum256Type,
|
|
115
|
-
location: CoordinatesType,
|
|
116
|
-
goodId: UInt16Type
|
|
117
|
-
): number {
|
|
118
|
-
const seed = `${location.x}${location.y}${goodId}locationmultiplier`
|
|
119
|
-
const r = roll(gameSeed, seed)
|
|
120
|
-
if (r < 13) {
|
|
121
|
-
return 0.75
|
|
122
|
-
} else if (r < 176) {
|
|
123
|
-
return 0.8
|
|
124
|
-
} else if (r < 996) {
|
|
125
|
-
return 0.85
|
|
126
|
-
} else if (r < 2966) {
|
|
127
|
-
return 0.9
|
|
128
|
-
} else if (r < 19568) {
|
|
129
|
-
return 0.95
|
|
130
|
-
} else if (r < 45988) {
|
|
131
|
-
return 1
|
|
132
|
-
} else if (r < 62508) {
|
|
133
|
-
return 1.05
|
|
134
|
-
} else if (r < 64518) {
|
|
135
|
-
return 1.1
|
|
136
|
-
} else if (r < 65437) {
|
|
137
|
-
return 1.15
|
|
138
|
-
} else if (r < 65523) {
|
|
139
|
-
return 1.2
|
|
140
|
-
} else {
|
|
141
|
-
return 1.25
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export function getSupply(
|
|
146
|
-
gameSeed: Checksum256Type,
|
|
147
|
-
state: ServerContract.Types.state_row,
|
|
148
|
-
location: CoordinatesType,
|
|
149
|
-
goodId: UInt16Type
|
|
150
|
-
): number {
|
|
151
|
-
const seed = `${state.seed}${location.x}${location.y}${goodId}supply`
|
|
152
|
-
const r = roll(gameSeed, seed)
|
|
153
|
-
const percent = r / 65535
|
|
154
|
-
const epoch = 1 + Number(state.epoch) / 90
|
|
155
|
-
const ship = 1
|
|
156
|
-
const goodIdNum = Number(goodId)
|
|
157
|
-
const base = Math.floor(128 / goodIdNum)
|
|
158
|
-
return Math.floor(base * percent * ship * epoch)
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
export function marketPrice(
|
|
162
|
-
location: ServerContract.ActionParams.Type.coordinates,
|
|
163
|
-
goodId: UInt16Type,
|
|
164
|
-
gameSeed: Checksum256Type,
|
|
165
|
-
state: ServerContract.Types.state_row
|
|
166
|
-
): ItemPrice {
|
|
167
|
-
const item = getItem(goodId)
|
|
168
|
-
let price = Number(item.base_price)
|
|
169
|
-
|
|
170
|
-
const rarityMultiplier = getRarityMultiplier(gameSeed, state.seed, location, goodId)
|
|
171
|
-
price *= rarityMultiplier
|
|
172
|
-
|
|
173
|
-
// Location multiplier of the deal (static, based on game seed)
|
|
174
|
-
// Small impact range on price, from 1.0x to 1.5x
|
|
175
|
-
const locationMultiplier = getLocationMultiplier(gameSeed, location, goodId)
|
|
176
|
-
price *= locationMultiplier
|
|
177
|
-
|
|
178
|
-
// Determine the current supply of the good at the location
|
|
179
|
-
const supply = getSupply(gameSeed, state, location, goodId)
|
|
180
|
-
|
|
181
|
-
return ItemPrice.from({
|
|
182
|
-
id: goodId,
|
|
183
|
-
item,
|
|
184
|
-
price: UInt32.from(price),
|
|
185
|
-
supply: UInt16.from(supply),
|
|
186
|
-
})
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
export function marketPrices(
|
|
190
|
-
location: ServerContract.ActionParams.Type.coordinates,
|
|
191
|
-
gameSeed: Checksum256Type,
|
|
192
|
-
state: ServerContract.Types.state_row
|
|
193
|
-
): ItemPrice[] {
|
|
194
|
-
return getItems().map((item) => marketPrice(location, item.id, gameSeed, state))
|
|
195
|
-
}
|
package/src/market/rolls.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import {Checksum256Type} from '@wharfkit/antelope'
|
|
2
|
-
import {hash512} from '../utils/hash'
|
|
3
|
-
|
|
4
|
-
export function roll(gameSeed: Checksum256Type, rollSeed: string): number {
|
|
5
|
-
const hash = hash512(gameSeed, rollSeed)
|
|
6
|
-
// Combine the first two bytes to form a uint16_t value
|
|
7
|
-
return (hash.array[0] << 8) | hash.array[1]
|
|
8
|
-
}
|