@shipload/sdk 0.3.16 → 0.4.1

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/src/goods.ts CHANGED
@@ -7,71 +7,71 @@ const goods: GoodType[] = [
7
7
  id: 1,
8
8
  name: 'FizzGlo',
9
9
  description: 'Pops with flavor! A neon drink that makes your burps glow.',
10
- base_price: 200,
11
- mass: 5000,
12
- },
13
- {
14
- id: 2,
15
- name: 'ZapSnacks',
16
- description: 'Electric taste! Spicy edible energy sparks for a tongue-tingling experience.',
17
- base_price: 300,
18
- mass: 2000,
10
+ base_price: 20,
11
+ mass: 4500,
19
12
  },
13
+ // {
14
+ // id: 2,
15
+ // name: 'ZapSnacks',
16
+ // description: 'Electric taste! Spicy edible energy sparks for a tongue-tingling experience.',
17
+ // base_price: 30,
18
+ // mass: 7000,
19
+ // },
20
20
  {
21
21
  id: 3,
22
22
  name: 'Blob Buddies',
23
23
  description: 'Squishy friends! Clingy, cute and mood-matching pet blobs for every home!',
24
- base_price: 400,
25
- mass: 10000,
24
+ base_price: 40,
25
+ mass: 9500,
26
26
  },
27
27
  {
28
28
  id: 4,
29
29
  name: 'TuneTooth',
30
30
  description: 'Whistle while you eat! Edible instrument treats that play tunes when chewed.',
31
- base_price: 600,
32
- mass: 3000,
31
+ base_price: 60,
32
+ mass: 14000,
33
33
  },
34
34
  {
35
35
  id: 5,
36
36
  name: 'SunPods',
37
37
  description: 'Miniature suns in your pocket providing on-demand light & warmth.',
38
- base_price: 800,
39
- mass: 1000,
40
- },
41
- {
42
- id: 6,
43
- name: 'Fuzzix',
44
- description: 'Pocket-sized quantum fluff generator for instant comfy.',
45
- base_price: 1000,
46
- mass: 4000,
38
+ base_price: 80,
39
+ mass: 19000,
47
40
  },
41
+ // {
42
+ // id: 6,
43
+ // name: 'Fuzzix',
44
+ // description: 'Pocket-sized quantum fluff generator for instant comfy.',
45
+ // base_price: 100,
46
+ // mass: 24000,
47
+ // },
48
48
  {
49
49
  id: 7,
50
50
  name: 'GlowGo',
51
51
  description: 'Ingestible bioluminescent jelly, your inside glows in the dark!',
52
52
  base_price: 140,
53
- mass: 10000,
54
- },
55
- {
56
- id: 8,
57
- name: 'KrackleKaps',
58
- description: 'Capsules packed with tiny firecrackers, spice up meals and parties.',
59
- base_price: 180,
60
- mass: 2000,
53
+ mass: 33500,
61
54
  },
55
+ // {
56
+ // id: 8,
57
+ // name: 'KrackleKaps',
58
+ // description: 'Capsules packed with tiny firecrackers, spice up meals and parties.',
59
+ // base_price: 180,
60
+ // mass: 43500,
61
+ // },
62
62
  {
63
63
  id: 9,
64
64
  name: 'PlasmaMints',
65
65
  description: 'Hypercharged candy giving plasma breath capable of cutting through steel.',
66
66
  base_price: 220,
67
- mass: 500,
67
+ mass: 53500,
68
68
  },
69
69
  {
70
70
  id: 10,
71
71
  name: 'TimeTreats',
72
72
  description: 'Confectionery morsels releasing slow-mo effect over a limited period.',
73
73
  base_price: 250,
74
- mass: 3000,
74
+ mass: 60500,
75
75
  },
76
76
  {
77
77
  id: 11,
@@ -79,28 +79,28 @@ const goods: GoodType[] = [
79
79
  description:
80
80
  'Bottled hyper-fluid quenching thirst across multiple parallel realities simultaneously.',
81
81
  base_price: 300,
82
- mass: 6000,
83
- },
84
- {
85
- id: 12,
86
- name: 'TransmatterTruffles',
87
- description: 'Delectable chocolates instantly teleporting consumers short distances.',
88
- base_price: 350,
89
- mass: 4000,
82
+ mass: 73000,
90
83
  },
84
+ // {
85
+ // id: 12,
86
+ // name: 'TransmatterTruffles',
87
+ // description: 'Delectable chocolates instantly teleporting consumers short distances.',
88
+ // base_price: 350,
89
+ // mass: 85500,
90
+ // },
91
91
  {
92
92
  id: 13,
93
93
  name: 'MemoryGum',
94
94
  description: 'Chewable gum storing or replaying memories while being chewed.',
95
95
  base_price: 400,
96
- mass: 500,
96
+ mass: 97500,
97
97
  },
98
98
  {
99
99
  id: 14,
100
100
  name: 'SymbioSnack',
101
101
  description: 'Edible alien larvae adopting owner’s taste preference upon consumption.',
102
102
  base_price: 500,
103
- mass: 10000,
103
+ mass: 12250,
104
104
  },
105
105
  ]
106
106
 
package/src/travel.ts CHANGED
@@ -11,13 +11,14 @@ import {
11
11
 
12
12
  import {PlatformContract, ServerContract} from './contracts'
13
13
  import {hash512} from './hash'
14
- import {Distance, PRECISION} from './types'
14
+ import {Distance, PRECISION, TRAVEL_MAXMASS_PENALTY} from './types'
15
15
  import {getGood} from './goods'
16
16
 
17
17
  export function travelplanDuration(travelplan: ServerContract.Types.travel_plan) {
18
18
  return UInt32.from(travelplan.flighttime)
19
19
  .adding(travelplan.rechargetime)
20
20
  .adding(travelplan.loadtime)
21
+ .adding(travelplan.masspenalty)
21
22
  }
22
23
 
23
24
  export function distanceTraveled(
@@ -132,6 +133,7 @@ export function travelplan(
132
133
  const loadtime = calc_ship_loadtime(ship, cargos)
133
134
  const flighttime = calc_ship_flighttime(ship, mass, distance)
134
135
  const rechargetime = recharge ? calc_ship_rechargetime(ship) : 0
136
+ const masspenalty = calc_mass_penalty(ship, mass)
135
137
  const energyusage = calc_energyusage(distance, ship.stats.drain) // Energy usage from ship and flighttime
136
138
 
137
139
  return ServerContract.Types.travel_plan.from({
@@ -141,12 +143,22 @@ export function travelplan(
141
143
  loadtime,
142
144
  flighttime,
143
145
  rechargetime,
146
+ masspenalty,
144
147
  // TODO: Remove below, used for debugging
145
148
  energyusage,
146
149
  mass,
147
150
  })
148
151
  }
149
152
 
153
+ export function calc_mass_penalty(ship: ServerContract.Types.ship_row, mass: UInt64Type): UInt32 {
154
+ const current = Number(mass)
155
+ const maximum = Number(ship.stats.maxmass)
156
+ if (mass > ship.stats.maxmass) {
157
+ return UInt32.from(((current - maximum) / 1000 / PRECISION) * TRAVEL_MAXMASS_PENALTY)
158
+ }
159
+ return UInt32.from(0)
160
+ }
161
+
150
162
  export function calc_rechargetime(
151
163
  capacity: UInt32Type,
152
164
  energy: UInt32Type,
@@ -173,7 +185,7 @@ export function calc_ship_loadtime(
173
185
  const mass_load = UInt64.from(0)
174
186
  const mass_unload = UInt64.from(0)
175
187
  for (const cargo of cargos) {
176
- const cargo_delta = Number(cargo.quantity) - Number(cargo.loaded)
188
+ const cargo_delta = Number(cargo.owned) - Number(cargo.loaded)
177
189
  if (cargo_delta !== 0) {
178
190
  const good_mass = getGood(cargo.good_id).mass
179
191
  const cargo_mass = good_mass.multiplying(Math.abs(cargo_delta))
@@ -242,7 +254,7 @@ export function calc_ship_mass(
242
254
  }
243
255
 
244
256
  for (const cargo of cargos) {
245
- mass.add(getGood(cargo.good_id).mass.multiplying(cargo.quantity))
257
+ mass.add(getGood(cargo.good_id).mass.multiplying(cargo.owned))
246
258
  }
247
259
 
248
260
  return mass
package/src/types.ts CHANGED
@@ -2,6 +2,7 @@ import {UInt16, UInt16Type, UInt64, UInt64Type} from '@wharfkit/antelope'
2
2
  import {ServerContract} from './contracts'
3
3
 
4
4
  export const PRECISION = 10000
5
+ export const TRAVEL_MAXMASS_PENALTY = 5 // Penalty (in seconds) for exceeding the maximum mass per 1000 unit
5
6
 
6
7
  export interface CameraPosition extends ServerContract.ActionParams.Type.coordinates {
7
8
  z: number