@shipload/sdk 2.0.0-rc2 → 2.0.0-rc20

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.
Files changed (80) hide show
  1. package/README.md +1 -349
  2. package/lib/shipload.d.ts +1658 -1126
  3. package/lib/shipload.js +6847 -3082
  4. package/lib/shipload.js.map +1 -1
  5. package/lib/shipload.m.js +6468 -2793
  6. package/lib/shipload.m.js.map +1 -1
  7. package/package.json +6 -4
  8. package/src/capabilities/crafting.ts +22 -0
  9. package/src/capabilities/gathering.ts +36 -0
  10. package/src/capabilities/guards.ts +3 -8
  11. package/src/capabilities/hauling.ts +22 -0
  12. package/src/capabilities/index.ts +4 -1
  13. package/src/capabilities/modules.ts +57 -0
  14. package/src/capabilities/storage.ts +101 -9
  15. package/src/contracts/server.ts +717 -293
  16. package/src/data/capabilities.ts +408 -0
  17. package/src/data/categories.ts +55 -0
  18. package/src/data/colors.ts +71 -0
  19. package/src/data/items.json +17 -0
  20. package/src/data/locations.ts +53 -0
  21. package/src/data/nebula-adjectives.json +211 -0
  22. package/src/data/nebula-nouns.json +151 -0
  23. package/src/data/recipes.ts +587 -0
  24. package/src/data/syllables.json +1386 -780
  25. package/src/data/tiers.ts +45 -0
  26. package/src/derivation/crafting.ts +287 -0
  27. package/src/derivation/index.ts +30 -0
  28. package/src/derivation/location-size.ts +15 -0
  29. package/src/derivation/resources.ts +136 -0
  30. package/src/derivation/stats.ts +146 -0
  31. package/src/derivation/stratum.ts +134 -0
  32. package/src/derivation/tiers.ts +54 -0
  33. package/src/entities/cargo-utils.ts +10 -68
  34. package/src/entities/container.ts +37 -0
  35. package/src/entities/entity-inventory.ts +13 -13
  36. package/src/entities/inventory-accessor.ts +2 -6
  37. package/src/entities/location.ts +5 -200
  38. package/src/entities/makers.ts +136 -17
  39. package/src/entities/player.ts +1 -274
  40. package/src/entities/ship-deploy.ts +258 -0
  41. package/src/entities/ship.ts +28 -34
  42. package/src/entities/warehouse.ts +35 -7
  43. package/src/errors.ts +59 -5
  44. package/src/format.ts +12 -0
  45. package/src/index-module.ts +233 -50
  46. package/src/managers/actions.ts +138 -88
  47. package/src/managers/context.ts +19 -9
  48. package/src/managers/index.ts +0 -1
  49. package/src/managers/locations.ts +2 -85
  50. package/src/market/items.ts +93 -0
  51. package/src/nft/description.ts +176 -0
  52. package/src/nft/deserializers.ts +81 -0
  53. package/src/nft/index.ts +2 -0
  54. package/src/resolution/describe-module.ts +165 -0
  55. package/src/resolution/display-name.ts +39 -0
  56. package/src/resolution/resolve-item.ts +343 -0
  57. package/src/scheduling/projection.ts +220 -67
  58. package/src/scheduling/schedule.ts +2 -2
  59. package/src/shipload.ts +10 -5
  60. package/src/subscriptions/connection.ts +154 -0
  61. package/src/subscriptions/debug.ts +17 -0
  62. package/src/subscriptions/index.ts +5 -0
  63. package/src/subscriptions/manager.ts +240 -0
  64. package/src/subscriptions/mappers.ts +28 -0
  65. package/src/subscriptions/types.ts +143 -0
  66. package/src/travel/travel.ts +30 -17
  67. package/src/types/capabilities.ts +11 -14
  68. package/src/types/entity-traits.ts +3 -4
  69. package/src/types/entity.ts +9 -6
  70. package/src/types.ts +61 -55
  71. package/src/utils/system.ts +66 -53
  72. package/src/capabilities/extraction.ts +0 -37
  73. package/src/data/goods.json +0 -23
  74. package/src/managers/trades.ts +0 -119
  75. package/src/market/goods.ts +0 -31
  76. package/src/market/market.ts +0 -208
  77. package/src/market/rolls.ts +0 -8
  78. package/src/trading/collect.ts +0 -938
  79. package/src/trading/deal.ts +0 -207
  80. package/src/trading/trade.ts +0 -203
@@ -1,35 +1,132 @@
1
- import {Name, UInt16, UInt32, UInt64} from '@wharfkit/antelope'
1
+ import {Name, UInt16, UInt32, UInt64, UInt8} from '@wharfkit/antelope'
2
2
  import {ServerContract} from '../contracts'
3
- import {Ship, ShipStateInput} from './ship'
4
- import {Warehouse, WarehouseStateInput} from './warehouse'
3
+ import {PackedModuleInput, Ship, ShipStateInput} from './ship'
4
+ import {computeWarehouseCapabilities, Warehouse, WarehouseStateInput} from './warehouse'
5
5
  import {Container, ContainerStateInput} from './container'
6
+ import {
7
+ getEntitySlotLayout,
8
+ getModuleRecipeByItemId,
9
+ ITEM_SHIP_T1_PACKED,
10
+ ITEM_WAREHOUSE_T1_PACKED,
11
+ } from '../data/recipes'
12
+ import {getModuleCapabilityType, MODULE_STORAGE, moduleAccepts} from '../capabilities/modules'
13
+ import {computeShipCapabilities, computeStorageCapabilities} from './ship-deploy'
14
+ import {decodeCraftedItemStats} from '../derivation/crafting'
15
+
16
+ function assignModulesToSlots(
17
+ packedEntityItemId: number,
18
+ modules: PackedModuleInput[],
19
+ entityLabel: string
20
+ ): ServerContract.Types.module_entry[] {
21
+ const slots = getEntitySlotLayout(packedEntityItemId)
22
+ const result: Array<{type: number; installed?: ServerContract.Types.packed_module}> = slots.map(
23
+ (s) => ({type: s.type, installed: undefined})
24
+ )
25
+
26
+ for (const mod of modules) {
27
+ const itemId = Number(UInt16.from(mod.itemId).value.toString())
28
+ const modType = getModuleCapabilityType(itemId)
29
+ const slotIdx = result.findIndex((r) => !r.installed && moduleAccepts(r.type, modType))
30
+ if (slotIdx === -1) {
31
+ const recipe = getModuleRecipeByItemId(itemId)
32
+ const modName = recipe?.name ?? `item ${itemId}`
33
+ throw new Error(
34
+ `No compatible slot for module ${modName} (type ${modType}) on ${entityLabel}`
35
+ )
36
+ }
37
+ result[slotIdx].installed = ServerContract.Types.packed_module.from({
38
+ item_id: UInt16.from(mod.itemId),
39
+ stats: UInt64.from(mod.stats),
40
+ })
41
+ }
42
+
43
+ return result.map((r) =>
44
+ ServerContract.Types.module_entry.from({
45
+ type: UInt8.from(r.type),
46
+ installed: r.installed,
47
+ })
48
+ )
49
+ }
50
+
51
+ function decodePackedInput(m: PackedModuleInput): {itemId: number; stats: bigint} {
52
+ return {
53
+ itemId: Number(UInt16.from(m.itemId).value.toString()),
54
+ stats: BigInt(UInt64.from(m.stats).toString()),
55
+ }
56
+ }
57
+
58
+ function computeStorageBonus(
59
+ decoded: {itemId: number; stats: bigint}[],
60
+ baseCapacity: number
61
+ ): number {
62
+ let totalBonus = 0
63
+ for (const m of decoded) {
64
+ if (getModuleCapabilityType(m.itemId) !== MODULE_STORAGE) continue
65
+ const stats = decodeCraftedItemStats(m.itemId, m.stats)
66
+ const {capacityBonus} = computeStorageCapabilities(stats, baseCapacity)
67
+ totalBonus += capacityBonus
68
+ }
69
+ return totalBonus
70
+ }
71
+
72
+ function deriveShipFromModules(
73
+ modules: PackedModuleInput[],
74
+ baseCapacity: number
75
+ ): {
76
+ capabilities: ReturnType<typeof computeShipCapabilities>
77
+ finalCapacity: number
78
+ } {
79
+ const decoded = modules.map(decodePackedInput)
80
+ const capabilities = computeShipCapabilities(decoded)
81
+ const totalBonus = computeStorageBonus(decoded, baseCapacity)
82
+ return {capabilities, finalCapacity: baseCapacity + totalBonus}
83
+ }
6
84
 
7
85
  export function makeShip(state: ShipStateInput): Ship {
8
- const entityInfo = ServerContract.Types.entity_info.from({
86
+ const info: Record<string, unknown> = {
9
87
  type: Name.from('ship'),
10
88
  id: UInt64.from(state.id),
11
89
  owner: Name.from(state.owner),
12
90
  entity_name: state.name,
13
91
  coordinates: ServerContract.Types.coordinates.from(state.coordinates),
14
- hullmass: UInt32.from(state.hullmass),
15
- capacity: UInt32.from(state.capacity),
16
- energy: UInt16.from(state.energy),
17
92
  cargomass: UInt32.from(0),
18
93
  cargo: state.cargo || [],
19
94
  is_idle: !state.schedule,
20
95
  current_task_elapsed: UInt32.from(0),
21
96
  current_task_remaining: UInt32.from(0),
22
97
  pending_tasks: [],
23
- engines: state.engines,
24
- generator: state.generator,
25
- loaders: state.loaders,
26
- schedule: state.schedule,
27
- })
98
+ }
99
+ if (state.hullmass !== undefined) info.hullmass = UInt32.from(state.hullmass)
100
+ if (state.energy !== undefined) info.energy = UInt16.from(state.energy)
101
+ if (state.schedule) info.schedule = state.schedule
102
+
103
+ let moduleEntries: ServerContract.Types.module_entry[] = []
104
+ if (state.modules && state.modules.length > 0) {
105
+ moduleEntries = assignModulesToSlots(ITEM_SHIP_T1_PACKED, state.modules, 'Ship T1')
106
+ const {capabilities, finalCapacity} = deriveShipFromModules(
107
+ state.modules,
108
+ state.capacity ?? 0
109
+ )
110
+ if (capabilities.engines) info.engines = capabilities.engines
111
+ if (capabilities.generator) info.generator = capabilities.generator
112
+ if (capabilities.gatherer) info.gatherer = capabilities.gatherer
113
+ if (capabilities.hauler) info.hauler = capabilities.hauler
114
+ if (capabilities.loaders) info.loaders = capabilities.loaders
115
+ if (capabilities.crafter) info.crafter = capabilities.crafter
116
+ if (state.capacity !== undefined) info.capacity = UInt32.from(finalCapacity)
117
+ } else {
118
+ moduleEntries = assignModulesToSlots(ITEM_SHIP_T1_PACKED, [], 'Ship T1')
119
+ if (state.capacity !== undefined) info.capacity = UInt32.from(state.capacity)
120
+ }
121
+
122
+ info.modules = moduleEntries
123
+
124
+ const entityInfo = ServerContract.Types.entity_info.from(info)
28
125
  return new Ship(entityInfo)
29
126
  }
30
127
 
31
128
  export function makeWarehouse(state: WarehouseStateInput): Warehouse {
32
- const entityInfo = ServerContract.Types.entity_info.from({
129
+ const info: Record<string, unknown> = {
33
130
  type: Name.from('warehouse'),
34
131
  id: UInt64.from(state.id),
35
132
  owner: Name.from(state.owner),
@@ -38,13 +135,34 @@ export function makeWarehouse(state: WarehouseStateInput): Warehouse {
38
135
  capacity: UInt32.from(state.capacity),
39
136
  cargomass: UInt32.from(0),
40
137
  cargo: state.cargo || [],
41
- loaders: state.loaders,
42
138
  is_idle: !state.schedule,
43
139
  current_task_elapsed: UInt32.from(0),
44
140
  current_task_remaining: UInt32.from(0),
45
141
  pending_tasks: [],
46
- schedule: state.schedule,
47
- })
142
+ }
143
+ if (state.hullmass !== undefined) info.hullmass = UInt32.from(state.hullmass)
144
+ if (state.schedule) info.schedule = state.schedule
145
+
146
+ let moduleEntries: ServerContract.Types.module_entry[] = []
147
+ if (state.modules && state.modules.length > 0) {
148
+ moduleEntries = assignModulesToSlots(
149
+ ITEM_WAREHOUSE_T1_PACKED,
150
+ state.modules,
151
+ 'Warehouse T1'
152
+ )
153
+ const decoded = state.modules.map(decodePackedInput)
154
+ const capabilities = computeWarehouseCapabilities(decoded)
155
+ if (capabilities.loaders) info.loaders = capabilities.loaders
156
+
157
+ const totalBonus = computeStorageBonus(decoded, state.capacity)
158
+ info.capacity = UInt32.from(state.capacity + totalBonus)
159
+ } else {
160
+ moduleEntries = assignModulesToSlots(ITEM_WAREHOUSE_T1_PACKED, [], 'Warehouse T1')
161
+ }
162
+
163
+ info.modules = moduleEntries
164
+
165
+ const entityInfo = ServerContract.Types.entity_info.from(info)
48
166
  return new Warehouse(entityInfo)
49
167
  }
50
168
 
@@ -58,7 +176,8 @@ export function makeContainer(state: ContainerStateInput): Container {
58
176
  hullmass: UInt32.from(state.hullmass),
59
177
  capacity: UInt32.from(state.capacity),
60
178
  cargomass: UInt32.from(state.cargomass || 0),
61
- cargo: [],
179
+ cargo: state.cargo || [],
180
+ modules: [],
62
181
  is_idle: !state.schedule,
63
182
  current_task_elapsed: UInt32.from(0),
64
183
  current_task_remaining: UInt32.from(0),
@@ -1,288 +1,15 @@
1
- import {
2
- Int64,
3
- Int64Type,
4
- Name,
5
- NameType,
6
- UInt32,
7
- UInt32Type,
8
- UInt64,
9
- UInt64Type,
10
- } from '@wharfkit/antelope'
1
+ import {Name, NameType} from '@wharfkit/antelope'
11
2
  import {ServerContract} from '../contracts'
12
3
 
13
4
  export interface PlayerStateInput {
14
5
  owner: NameType
15
- balance: UInt64Type
16
- debt: UInt32Type
17
- networth: Int64Type
18
6
  }
19
7
 
20
- /**
21
- * Player helper class extending player_row with computed financial properties.
22
- * Provides easy access to balance, debt, networth, and loan calculations.
23
- */
24
8
  export class Player extends ServerContract.Types.player_row {
25
- /**
26
- * Construct a Player instance from individual state pieces.
27
- * Used by UI's ReactivePlayer to reconstruct Player from reactive state.
28
- */
29
9
  static fromState(state: PlayerStateInput): Player {
30
10
  const playerRow = ServerContract.Types.player_row.from({
31
11
  owner: Name.from(state.owner),
32
- balance: UInt64.from(state.balance),
33
- debt: UInt32.from(state.debt),
34
- networth: Int64.from(state.networth),
35
12
  })
36
13
  return new Player(playerRow)
37
14
  }
38
- // Constants for game rules (match smart contract)
39
- private static readonly MAX_LOAN = 1000000
40
- // Contract formula: 2500 * pow(5, sequence - 1) = 500 * pow(5, sequence)
41
- private static readonly BASE_SHIP_COST = 500
42
- private static readonly SHIP_COST_MULTIPLIER = 5
43
-
44
- // Optional ship count for nextShipCost calculation
45
- private _shipCount?: number
46
-
47
- /**
48
- * Set the current ship count (needed for nextShipCost calculation)
49
- */
50
- setShipCount(count: number): void {
51
- this._shipCount = count
52
- }
53
-
54
- /**
55
- * Get the current ship count (if set)
56
- */
57
- get shipCount(): number | undefined {
58
- return this._shipCount
59
- }
60
-
61
- /**
62
- * Calculate the cost of the next ship based on current ship count
63
- * Matches contract: pow(5, sequence) * 100
64
- * @param shipCount - Optional ship count (uses cached value if not provided)
65
- */
66
- getNextShipCost(shipCount?: number): UInt64 {
67
- const count = shipCount ?? this._shipCount ?? 0
68
- const cost = Math.pow(Player.SHIP_COST_MULTIPLIER, count) * Player.BASE_SHIP_COST
69
- return UInt64.from(Math.floor(cost))
70
- }
71
-
72
- /**
73
- * Get the cost of the next ship based on cached ship count
74
- */
75
- get nextShipCost(): UInt64 {
76
- return this.getNextShipCost()
77
- }
78
-
79
- /**
80
- * Check if player can afford to buy a ship
81
- * @param shipCount - Optional ship count (uses cached value if not provided)
82
- */
83
- canBuyShip(shipCount?: number): boolean {
84
- return UInt64.from(this.balance).gte(this.getNextShipCost(shipCount))
85
- }
86
-
87
- /**
88
- * Calculate available loan amount (max loan - current debt)
89
- */
90
- get availableLoan(): UInt64 {
91
- const maxLoan = UInt64.from(Player.MAX_LOAN)
92
- if (UInt64.from(this.debt).gte(maxLoan)) {
93
- return UInt64.from(0)
94
- }
95
- return maxLoan.subtracting(this.debt)
96
- }
97
-
98
- /**
99
- * Check if player can take out a loan
100
- */
101
- get canTakeLoan(): boolean {
102
- return this.availableLoan.gt(UInt64.zero)
103
- }
104
-
105
- /**
106
- * Check if player can pay back loan
107
- */
108
- get canPayLoan(): boolean {
109
- return UInt64.from(this.debt).gt(UInt64.zero) && UInt64.from(this.balance).gt(UInt64.zero)
110
- }
111
-
112
- /**
113
- * Calculate maximum payback amount (min of debt and balance)
114
- */
115
- get maxPayback(): UInt64 {
116
- return UInt64.from(this.debt).lt(this.balance) ? this.debt : this.balance
117
- }
118
-
119
- /**
120
- * Get the maximum loan amount (constant)
121
- */
122
- static get MAX_LOAN_LIMIT(): number {
123
- return Player.MAX_LOAN
124
- }
125
-
126
- /**
127
- * Check if player is in debt
128
- */
129
- get hasDebt(): boolean {
130
- return UInt64.from(this.debt).gt(UInt64.zero)
131
- }
132
-
133
- /**
134
- * Check if player is solvent (positive networth)
135
- */
136
- get isSolvent(): boolean {
137
- return this.networth.gte(Int64.zero)
138
- }
139
-
140
- /**
141
- * Create an optimistic update for balance changes
142
- * Uses integer math to match contract
143
- * @param delta - Amount to change (can be negative)
144
- */
145
- withBalanceChange(delta: UInt64 | number): Player {
146
- const newPlayer = Player.from(this)
147
- const amount = typeof delta === 'number' ? UInt64.from(Math.abs(delta)) : delta
148
-
149
- if (typeof delta === 'number' && delta < 0) {
150
- // Subtract, ensuring we don't go below 0
151
- newPlayer.balance = UInt64.from(this.balance).gte(amount)
152
- ? this.balance.subtracting(amount)
153
- : UInt64.from(0)
154
- } else {
155
- // Add
156
- newPlayer.balance = this.balance.adding(amount)
157
- }
158
-
159
- // Calculate networth as Int64 (can be negative)
160
- const balanceInt = Int64.from(newPlayer.balance)
161
- const debtInt = Int64.from(newPlayer.debt)
162
- newPlayer.networth = balanceInt.subtracting(debtInt)
163
- return newPlayer
164
- }
165
-
166
- /**
167
- * Create an optimistic update for debt changes
168
- * Uses integer math to match contract
169
- * @param delta - Amount to change (can be negative)
170
- */
171
- withDebtChange(delta: UInt64 | number): Player {
172
- const newPlayer = Player.from(this)
173
- const amount = typeof delta === 'number' ? UInt64.from(Math.abs(delta)) : delta
174
-
175
- if (typeof delta === 'number' && delta < 0) {
176
- // Subtract, ensuring we don't go below 0
177
- newPlayer.debt = UInt64.from(this.debt).gte(amount)
178
- ? this.debt.subtracting(amount)
179
- : UInt64.from(0)
180
- } else {
181
- // Add
182
- newPlayer.debt = this.debt.adding(amount)
183
- }
184
-
185
- // Calculate networth as Int64 (can be negative)
186
- const balanceInt = Int64.from(newPlayer.balance)
187
- const debtInt = Int64.from(newPlayer.debt)
188
- newPlayer.networth = balanceInt.subtracting(debtInt)
189
- return newPlayer
190
- }
191
-
192
- /**
193
- * Create an optimistic update for taking a loan
194
- */
195
- withLoan(amount: UInt64): Player {
196
- const newPlayer = Player.from(this)
197
- newPlayer.balance = this.balance.adding(amount)
198
- newPlayer.debt = this.debt.adding(amount)
199
- // Calculate networth as Int64 (can be negative)
200
- const balanceInt = Int64.from(newPlayer.balance)
201
- const debtInt = Int64.from(newPlayer.debt)
202
- newPlayer.networth = balanceInt.subtracting(debtInt)
203
- return newPlayer
204
- }
205
-
206
- /**
207
- * Create an optimistic update for paying back a loan
208
- */
209
- withLoanPayment(amount: UInt64): Player {
210
- const actualPayment = this.maxPayback.lt(amount) ? this.maxPayback : amount
211
- const newPlayer = Player.from(this)
212
- newPlayer.balance = this.balance.subtracting(actualPayment)
213
- newPlayer.debt = this.debt.subtracting(actualPayment)
214
- // Calculate networth as Int64 (can be negative)
215
- const balanceInt = Int64.from(newPlayer.balance)
216
- const debtInt = Int64.from(newPlayer.debt)
217
- newPlayer.networth = balanceInt.subtracting(debtInt)
218
- return newPlayer
219
- }
220
-
221
- /**
222
- * Simulate networth update from selling goods.
223
- * Matches contract: networth += (sellPrice - paid * quantity)
224
- * Contract reference: market.cpp:75
225
- *
226
- * @param sellPrice - Total revenue from sale (price * quantity)
227
- * @param paidPerUnit - Average cost per unit paid (from cargo.paid)
228
- * @param quantity - Quantity being sold
229
- * @returns New player with updated networth
230
- *
231
- * @example
232
- * // Sold 10 units at 150 each (revenue=1500), paid 100 per unit
233
- * const newPlayer = player.withSaleNetworth(
234
- * UInt64.from(1500),
235
- * UInt64.from(100),
236
- * UInt32.from(10)
237
- * )
238
- * // Networth increases by: 1500 - (100*10) = 500
239
- */
240
- withSaleNetworth(sellPrice: UInt64, paidPerUnit: UInt64, quantity: UInt64): Player {
241
- // Match contract: price - paid * quantity
242
- const cost = paidPerUnit.multiplying(quantity)
243
- const profit = sellPrice.gte(cost) ? sellPrice.subtracting(cost) : Int64.from(0)
244
-
245
- const newPlayer = Player.from(this)
246
- newPlayer.networth = Int64.from(this.networth).adding(profit)
247
- return newPlayer
248
- }
249
-
250
- /**
251
- * Simulate complete sell goods transaction.
252
- * Updates both balance (adds revenue) and networth (adds profit).
253
- * Matches contract actions: update_balance + update_networth
254
- *
255
- * @param sellPrice - Total revenue from sale (price * quantity)
256
- * @param paidPerUnit - Average cost per unit paid (from cargo.paid)
257
- * @param quantity - Quantity being sold
258
- * @returns New player with updated balance and networth
259
- */
260
- withSellGoods(sellPrice: UInt64, paidPerUnit: UInt64, quantity: UInt64): Player {
261
- const cost = paidPerUnit.multiplying(quantity)
262
- const profit = sellPrice.gte(cost) ? sellPrice.subtracting(cost) : Int64.from(0)
263
-
264
- const newPlayer = Player.from(this)
265
- newPlayer.balance = this.balance.adding(sellPrice)
266
- newPlayer.networth = Int64.from(this.networth).adding(profit)
267
- return newPlayer
268
- }
269
-
270
- /**
271
- * Simulate complete buy goods transaction.
272
- * Updates balance (subtracts cost).
273
- *
274
- * @param purchaseCost - Total cost of purchase (price * quantity)
275
- * @returns New player with updated balance
276
- */
277
- withBuyGoods(purchaseCost: UInt64): Player {
278
- const newPlayer = Player.from(this)
279
- newPlayer.balance = UInt64.from(this.balance).gte(purchaseCost)
280
- ? this.balance.subtracting(purchaseCost)
281
- : UInt64.from(0)
282
- // Calculate networth as Int64 (can be negative)
283
- const balanceInt = Int64.from(newPlayer.balance)
284
- const debtInt = Int64.from(newPlayer.debt)
285
- newPlayer.networth = balanceInt.subtracting(debtInt)
286
- return newPlayer
287
- }
288
15
  }