@shipload/sdk 0.7.1 → 2.0.0-rc10

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 (79) hide show
  1. package/lib/shipload.d.ts +2203 -288
  2. package/lib/shipload.js +8441 -2210
  3. package/lib/shipload.js.map +1 -1
  4. package/lib/shipload.m.js +8160 -2167
  5. package/lib/shipload.m.js.map +1 -1
  6. package/package.json +7 -6
  7. package/src/capabilities/crafting.ts +26 -0
  8. package/src/capabilities/extraction.ts +36 -0
  9. package/src/capabilities/guards.ts +38 -0
  10. package/src/capabilities/hauling.ts +22 -0
  11. package/src/capabilities/index.ts +8 -0
  12. package/src/capabilities/loading.ts +8 -0
  13. package/src/capabilities/modules.ts +57 -0
  14. package/src/capabilities/movement.ts +29 -0
  15. package/src/capabilities/storage.ts +72 -0
  16. package/src/contracts/server.ts +1217 -254
  17. package/src/data/capabilities.ts +408 -0
  18. package/src/data/categories.ts +58 -0
  19. package/src/data/colors.ts +52 -0
  20. package/src/data/items.json +17 -0
  21. package/src/data/locations.ts +53 -0
  22. package/src/data/nebula-adjectives.json +211 -0
  23. package/src/data/nebula-nouns.json +151 -0
  24. package/src/data/recipes.ts +571 -0
  25. package/src/data/syllables.json +1790 -0
  26. package/src/data/tiers.ts +45 -0
  27. package/src/derivation/crafting.ts +197 -0
  28. package/src/derivation/index.ts +28 -0
  29. package/src/derivation/location-size.ts +15 -0
  30. package/src/derivation/resources.ts +142 -0
  31. package/src/derivation/stats.ts +146 -0
  32. package/src/derivation/stratum.ts +118 -0
  33. package/src/entities/cargo-utils.ts +84 -0
  34. package/src/entities/container.ts +106 -0
  35. package/src/entities/entity-inventory.ts +39 -0
  36. package/src/entities/gamestate.ts +152 -0
  37. package/src/entities/inventory-accessor.ts +42 -0
  38. package/src/entities/location.ts +60 -0
  39. package/src/entities/makers.ts +72 -0
  40. package/src/entities/player.ts +15 -0
  41. package/src/entities/ship-deploy.ts +263 -0
  42. package/src/entities/ship.ts +199 -0
  43. package/src/entities/warehouse.ts +91 -0
  44. package/src/errors.ts +46 -9
  45. package/src/index-module.ts +302 -7
  46. package/src/managers/actions.ts +197 -0
  47. package/src/managers/base.ts +25 -0
  48. package/src/managers/context.ts +95 -0
  49. package/src/managers/entities.ts +103 -0
  50. package/src/managers/epochs.ts +47 -0
  51. package/src/managers/index.ts +8 -0
  52. package/src/managers/locations.ts +39 -0
  53. package/src/managers/players.ts +13 -0
  54. package/src/market/items.ts +30 -0
  55. package/src/nft/description.ts +175 -0
  56. package/src/nft/deserializers.ts +81 -0
  57. package/src/nft/index.ts +2 -0
  58. package/src/resolution/resolve-item.ts +313 -0
  59. package/src/scheduling/accessor.ts +82 -0
  60. package/src/{epoch.ts → scheduling/epoch.ts} +1 -1
  61. package/src/scheduling/projection.ts +322 -0
  62. package/src/scheduling/schedule.ts +179 -0
  63. package/src/shipload.ts +36 -159
  64. package/src/travel/travel.ts +499 -0
  65. package/src/types/capabilities.ts +71 -0
  66. package/src/types/entity-traits.ts +69 -0
  67. package/src/types/entity.ts +39 -0
  68. package/src/types/index.ts +3 -0
  69. package/src/types.ts +113 -35
  70. package/src/{hash.ts → utils/hash.ts} +1 -1
  71. package/src/utils/system.ts +155 -0
  72. package/src/goods.ts +0 -124
  73. package/src/market.ts +0 -214
  74. package/src/rolls.ts +0 -8
  75. package/src/ship.ts +0 -36
  76. package/src/state.ts +0 -0
  77. package/src/syllables.ts +0 -1184
  78. package/src/system.ts +0 -37
  79. package/src/travel.ts +0 -259
@@ -0,0 +1,84 @@
1
+ import {UInt32, UInt64, UInt64Type} from '@wharfkit/antelope'
2
+ import {EntityInventory} from './entity-inventory'
3
+ import {ServerContract} from '../contracts'
4
+
5
+ export interface CargoData {
6
+ cargo: EntityInventory[]
7
+ }
8
+
9
+ export function totalCargoMass(cargo: EntityInventory[]): UInt64 {
10
+ return cargo.reduce((sum, c) => {
11
+ return sum.adding(c.totalMass)
12
+ }, UInt64.from(0))
13
+ }
14
+
15
+ export function getCargoForItem(
16
+ cargo: EntityInventory[],
17
+ goodId: UInt64Type
18
+ ): EntityInventory | undefined {
19
+ return cargo.find((c) => c.item_id.equals(goodId))
20
+ }
21
+
22
+ export function hasSpace(
23
+ currentMass: UInt64,
24
+ maxCapacity: UInt64,
25
+ goodMass: UInt64,
26
+ quantity: number
27
+ ): boolean {
28
+ const additionalMass = goodMass.multiplying(quantity)
29
+ const totalMass = currentMass.adding(additionalMass)
30
+ return totalMass.lte(maxCapacity)
31
+ }
32
+
33
+ export function availableCapacity(currentMass: UInt64, maxCapacity: UInt64): UInt64 {
34
+ if (currentMass.gte(maxCapacity)) {
35
+ return UInt64.from(0)
36
+ }
37
+ return maxCapacity.subtracting(currentMass)
38
+ }
39
+
40
+ export function isFull(currentMass: UInt64, maxCapacity: UInt64): boolean {
41
+ return currentMass.gte(maxCapacity)
42
+ }
43
+
44
+ export function afterRemoveItems(
45
+ cargo: ServerContract.Types.cargo_item[],
46
+ goodsToRemove: Array<{goodId: number; quantity: number}>
47
+ ): EntityInventory[] {
48
+ if (cargo.length === 0) {
49
+ return []
50
+ }
51
+
52
+ return cargo.map((item) => {
53
+ const removeItem = goodsToRemove.find((s) => Number(item.item_id) === s.goodId)
54
+ if (!removeItem) {
55
+ return new EntityInventory(item)
56
+ }
57
+
58
+ const currentQty = Number(item.quantity)
59
+ const newQty = Math.max(0, currentQty - removeItem.quantity)
60
+
61
+ return new EntityInventory(
62
+ ServerContract.Types.cargo_item.from({
63
+ item_id: item.item_id,
64
+ quantity: UInt32.from(newQty),
65
+ })
66
+ )
67
+ })
68
+ }
69
+
70
+ export function afterRemoveAllItems(cargo: ServerContract.Types.cargo_item[]): EntityInventory[] {
71
+ if (cargo.length === 0) {
72
+ return []
73
+ }
74
+
75
+ return cargo.map(
76
+ (item) =>
77
+ new EntityInventory(
78
+ ServerContract.Types.cargo_item.from({
79
+ item_id: item.item_id,
80
+ quantity: UInt32.from(0),
81
+ })
82
+ )
83
+ )
84
+ }
@@ -0,0 +1,106 @@
1
+ import {UInt64, UInt64Type} from '@wharfkit/antelope'
2
+ import {ServerContract} from '../contracts'
3
+ import {CoordinatesType} from '../types'
4
+ import {Location} from './location'
5
+ import {ScheduleAccessor} from '../scheduling/accessor'
6
+ import * as schedule from '../scheduling/schedule'
7
+
8
+ export interface ContainerStateInput {
9
+ id: UInt64Type
10
+ owner: string
11
+ name: string
12
+ coordinates: CoordinatesType | {x: number; y: number; z?: number}
13
+ hullmass: number
14
+ capacity: number
15
+ cargomass?: number
16
+ schedule?: ServerContract.Types.schedule
17
+ }
18
+
19
+ export class Container extends ServerContract.Types.entity_info {
20
+ private _sched?: ScheduleAccessor
21
+
22
+ get name(): string {
23
+ return this.entity_name
24
+ }
25
+
26
+ get sched(): ScheduleAccessor {
27
+ return (this._sched ??= new ScheduleAccessor(this))
28
+ }
29
+
30
+ get isIdle(): boolean {
31
+ return this.is_idle
32
+ }
33
+
34
+ isLoading(now: Date): boolean {
35
+ return schedule.isLoading(this, now)
36
+ }
37
+
38
+ isUnloading(now: Date): boolean {
39
+ return schedule.isUnloading(this, now)
40
+ }
41
+
42
+ get location(): Location {
43
+ return Location.from(this.coordinates)
44
+ }
45
+
46
+ get totalMass(): UInt64 {
47
+ return UInt64.from(this.hullmass ?? 0).adding(this.cargomass)
48
+ }
49
+
50
+ get maxCapacity(): UInt64 {
51
+ return UInt64.from(this.capacity)
52
+ }
53
+
54
+ get availableCapacity(): UInt64 {
55
+ const cargo = UInt64.from(this.cargomass)
56
+ return cargo.gte(this.maxCapacity) ? UInt64.from(0) : this.maxCapacity.subtracting(cargo)
57
+ }
58
+
59
+ hasSpace(additionalMass: UInt64): boolean {
60
+ return UInt64.from(this.cargomass).adding(additionalMass).lte(this.maxCapacity)
61
+ }
62
+
63
+ get isFull(): boolean {
64
+ return UInt64.from(this.cargomass).gte(this.maxCapacity)
65
+ }
66
+
67
+ get orbitalAltitude(): number {
68
+ return this.coordinates.z?.toNumber() || 0
69
+ }
70
+ }
71
+
72
+ export function computeContainerCapabilities(stats: Record<string, number>): {
73
+ hullmass: number
74
+ capacity: number
75
+ } {
76
+ const density = stats['density'] ?? 500
77
+ const strength = stats['strength'] ?? 500
78
+ const ductility = stats['ductility'] ?? 500
79
+ const purity = stats['purity'] ?? 500
80
+
81
+ const hullmass = 25000 + 75 * density
82
+
83
+ const statSum = strength + ductility + purity
84
+ const exponent = statSum / 2997
85
+ const capacity = Math.floor(1000000 * Math.pow(10, exponent))
86
+
87
+ return {hullmass, capacity}
88
+ }
89
+
90
+ export function computeContainerT2Capabilities(stats: Record<string, number>): {
91
+ hullmass: number
92
+ capacity: number
93
+ } {
94
+ const strength = stats['strength'] ?? 0
95
+ const density = stats['density'] ?? 0
96
+ const ductility = stats['ductility'] ?? 0
97
+ const purity = stats['purity'] ?? 0
98
+
99
+ const hullmass = 20000 + 50 * density
100
+
101
+ const statSum = strength + ductility + purity
102
+ const exponent = statSum / 2500
103
+ const capacity = Math.floor(1500000 * Math.pow(10, exponent))
104
+
105
+ return {hullmass, capacity}
106
+ }
@@ -0,0 +1,39 @@
1
+ import {UInt32, UInt64} from '@wharfkit/antelope'
2
+ import {ServerContract} from '../contracts'
3
+ import {getItem} from '../market/items'
4
+ import {Item} from '../types'
5
+
6
+ export class EntityInventory extends ServerContract.Types.cargo_item {
7
+ private _item?: Item
8
+
9
+ get item(): Item {
10
+ if (!this._item) {
11
+ this._item = getItem(this.item_id)
12
+ }
13
+ return this._item
14
+ }
15
+
16
+ get good(): Item {
17
+ return this.item
18
+ }
19
+
20
+ get name(): string {
21
+ return this.item.name
22
+ }
23
+
24
+ get unitMass(): UInt32 {
25
+ return this.item.mass
26
+ }
27
+
28
+ get totalMass(): UInt64 {
29
+ return UInt64.from(this.unitMass).multiplying(this.quantity)
30
+ }
31
+
32
+ get hasCargo(): boolean {
33
+ return UInt32.from(this.quantity).gt(UInt32.from(0))
34
+ }
35
+
36
+ get isEmpty(): boolean {
37
+ return UInt32.from(this.quantity).equals(UInt32.from(0))
38
+ }
39
+ }
@@ -0,0 +1,152 @@
1
+ import {Checksum256, Int64, UInt64} from '@wharfkit/antelope'
2
+ import {PlatformContract, ServerContract} from '../contracts'
3
+ import {EpochInfo, getCurrentEpoch, getEpochInfo} from '../scheduling/epoch'
4
+ import {hasSystem} from '../utils/system'
5
+
6
+ /**
7
+ * GameState class extends the state_row from the server contract
8
+ * with helper methods for epoch management and system generation
9
+ */
10
+ export class GameState extends ServerContract.Types.state_row {
11
+ private _game?: PlatformContract.Types.game_row
12
+
13
+ /**
14
+ * Create a GameState instance from a state_row
15
+ */
16
+ static from(
17
+ state: ServerContract.Types.state_row,
18
+ game?: PlatformContract.Types.game_row
19
+ ): GameState {
20
+ const gameState = Object.create(GameState.prototype) as GameState
21
+ Object.assign(gameState, state)
22
+ gameState._game = game
23
+ return gameState
24
+ }
25
+
26
+ /**
27
+ * Set the game configuration (needed for epoch calculations)
28
+ */
29
+ setGame(game: PlatformContract.Types.game_row): void {
30
+ this._game = game
31
+ }
32
+
33
+ /**
34
+ * Get the current epoch number from the state
35
+ */
36
+ get currentEpoch(): UInt64 {
37
+ return this.epoch
38
+ }
39
+
40
+ /**
41
+ * Get the epoch seed (used for market pricing and system generation)
42
+ */
43
+ get epochSeed(): Checksum256 {
44
+ return this.seed
45
+ }
46
+
47
+ /**
48
+ * Get the game seed (from game config, if available)
49
+ */
50
+ get gameSeed(): Checksum256 | undefined {
51
+ return this._game?.config.seed
52
+ }
53
+
54
+ /**
55
+ * Check if the game is currently enabled
56
+ */
57
+ get isEnabled(): boolean {
58
+ return this.enabled
59
+ }
60
+
61
+ /**
62
+ * Get the total number of ships in the game
63
+ */
64
+ get shipCount(): number {
65
+ return Number(this.ships)
66
+ }
67
+
68
+ /**
69
+ * Get the current salt value (used for random number generation)
70
+ */
71
+ get currentSalt(): UInt64 {
72
+ return this.salt
73
+ }
74
+
75
+ /**
76
+ * Get the commit hash for the next epoch
77
+ */
78
+ get nextEpochCommit(): Checksum256 {
79
+ return this.commit
80
+ }
81
+
82
+ /**
83
+ * Calculate the current epoch from game config (if game is set)
84
+ * This might differ from state.epoch if the blockchain hasn't advanced yet
85
+ */
86
+ get calculatedCurrentEpoch(): UInt64 | undefined {
87
+ if (!this._game) {
88
+ return undefined
89
+ }
90
+ return getCurrentEpoch(this._game)
91
+ }
92
+
93
+ /**
94
+ * Get epoch info (start/end times) for the current epoch
95
+ */
96
+ get currentEpochInfo(): EpochInfo | undefined {
97
+ if (!this._game) {
98
+ return undefined
99
+ }
100
+ return getEpochInfo(this._game, this.epoch)
101
+ }
102
+
103
+ /**
104
+ * Get epoch info for a specific epoch number
105
+ */
106
+ getEpochInfo(epoch: UInt64): EpochInfo | undefined {
107
+ if (!this._game) {
108
+ return undefined
109
+ }
110
+ return getEpochInfo(this._game, epoch)
111
+ }
112
+
113
+ /**
114
+ * Check if a system exists at given coordinates
115
+ * Requires game seed from game config
116
+ */
117
+ hasSystemAt(x: number, y: number): boolean {
118
+ if (!this._game) {
119
+ return false
120
+ }
121
+ return hasSystem(this._game.config.seed, {x: Int64.from(x), y: Int64.from(y)})
122
+ }
123
+
124
+ /**
125
+ * Check if a system exists at coordinates object
126
+ */
127
+ hasSystemAtCoords(coords: ServerContract.Types.coordinates): boolean {
128
+ if (!this._game) {
129
+ return false
130
+ }
131
+ return hasSystem(this._game.config.seed, coords)
132
+ }
133
+
134
+ /**
135
+ * Get a summary of the game state
136
+ */
137
+ get summary(): {
138
+ enabled: boolean
139
+ epoch: string
140
+ ships: number
141
+ hasSeed: boolean
142
+ hasCommit: boolean
143
+ } {
144
+ return {
145
+ enabled: this.enabled,
146
+ epoch: this.epoch.toString(),
147
+ ships: this.shipCount,
148
+ hasSeed: !this.seed.equals(Checksum256.from('0'.repeat(64))),
149
+ hasCommit: !this.commit.equals(Checksum256.from('0'.repeat(64))),
150
+ }
151
+ }
152
+ }
@@ -0,0 +1,42 @@
1
+ import {UInt64, UInt64Type} from '@wharfkit/antelope'
2
+ import {EntityInventory} from './entity-inventory'
3
+ import {HasCargo} from '../capabilities/storage'
4
+
5
+ export type {HasCargo}
6
+
7
+ export class InventoryAccessor {
8
+ private _items?: EntityInventory[]
9
+
10
+ constructor(private readonly entity: HasCargo) {}
11
+
12
+ get items(): EntityInventory[] {
13
+ if (!this._items) {
14
+ this._items = this.entity.cargo.map((item) => new EntityInventory(item))
15
+ }
16
+ return this._items
17
+ }
18
+
19
+ get totalMass(): UInt64 {
20
+ return this.items.reduce((sum, c) => sum.adding(c.totalMass), UInt64.from(0))
21
+ }
22
+
23
+ forItem(goodId: UInt64Type): EntityInventory | undefined {
24
+ return this.items.find((c) => c.item_id.equals(goodId))
25
+ }
26
+
27
+ get sellable(): EntityInventory[] {
28
+ return this.items.filter((c) => c.hasCargo)
29
+ }
30
+
31
+ get hasSellable(): boolean {
32
+ return this.items.some((c) => c.hasCargo)
33
+ }
34
+
35
+ get sellableCount(): number {
36
+ return this.items.filter((c) => c.hasCargo).length
37
+ }
38
+ }
39
+
40
+ export function createInventoryAccessor(entity: HasCargo): InventoryAccessor {
41
+ return new InventoryAccessor(entity)
42
+ }
@@ -0,0 +1,60 @@
1
+ import {Checksum256, Checksum256Type, UInt16Type, UInt64} from '@wharfkit/antelope'
2
+ import {Coordinates, CoordinatesType, Distance, LocationType} from '../types'
3
+ import {getLocationType, hasSystem, isExtractableLocation} from '../utils/system'
4
+ import {findNearbyPlanets} from '../travel/travel'
5
+
6
+ export class Location {
7
+ readonly coordinates: Coordinates
8
+ private _gameSeed?: Checksum256
9
+ private _hasSystem?: boolean
10
+ private _epoch?: UInt64
11
+
12
+ constructor(coordinates: CoordinatesType) {
13
+ this.coordinates = Coordinates.from(coordinates)
14
+ }
15
+
16
+ static from(coordinates: CoordinatesType): Location {
17
+ return new Location(Coordinates.from(coordinates))
18
+ }
19
+
20
+ hasSystemAt(gameSeed: Checksum256Type): boolean {
21
+ const seed = Checksum256.from(gameSeed)
22
+ if (this._hasSystem === undefined || !this._gameSeed?.equals(seed)) {
23
+ this._gameSeed = seed
24
+ this._hasSystem = hasSystem(seed, this.coordinates)
25
+ }
26
+ return this._hasSystem
27
+ }
28
+
29
+ getLocationTypeAt(gameSeed: Checksum256Type): LocationType {
30
+ return getLocationType(gameSeed, this.coordinates)
31
+ }
32
+
33
+ isExtractableAt(gameSeed: Checksum256Type): boolean {
34
+ return isExtractableLocation(this.getLocationTypeAt(gameSeed))
35
+ }
36
+
37
+ findNearby(gameSeed: Checksum256Type, maxDistance: UInt16Type = 20): Distance[] {
38
+ return findNearbyPlanets(Checksum256.from(gameSeed), this.coordinates, maxDistance)
39
+ }
40
+
41
+ equals(other: CoordinatesType | Location): boolean {
42
+ const otherCoords = other instanceof Location ? other.coordinates : Coordinates.from(other)
43
+ return this.coordinates.equals(otherCoords)
44
+ }
45
+
46
+ get epoch(): UInt64 | undefined {
47
+ return this._epoch
48
+ }
49
+
50
+ clearCache(): void {
51
+ this._epoch = undefined
52
+ }
53
+ }
54
+
55
+ export function toLocation(coords: CoordinatesType | Location): Location {
56
+ if (coords instanceof Location) {
57
+ return coords
58
+ }
59
+ return Location.from(coords)
60
+ }
@@ -0,0 +1,72 @@
1
+ import {Name, UInt16, UInt32, UInt64} from '@wharfkit/antelope'
2
+ import {ServerContract} from '../contracts'
3
+ import {Ship, ShipStateInput} from './ship'
4
+ import {Warehouse, WarehouseStateInput} from './warehouse'
5
+ import {Container, ContainerStateInput} from './container'
6
+
7
+ export function makeShip(state: ShipStateInput): Ship {
8
+ const info: Record<string, unknown> = {
9
+ type: Name.from('ship'),
10
+ id: UInt64.from(state.id),
11
+ owner: Name.from(state.owner),
12
+ entity_name: state.name,
13
+ coordinates: ServerContract.Types.coordinates.from(state.coordinates),
14
+ cargomass: UInt32.from(0),
15
+ cargo: state.cargo || [],
16
+ is_idle: !state.schedule,
17
+ current_task_elapsed: UInt32.from(0),
18
+ current_task_remaining: UInt32.from(0),
19
+ pending_tasks: [],
20
+ }
21
+ if (state.hullmass !== undefined) info.hullmass = UInt32.from(state.hullmass)
22
+ if (state.capacity !== undefined) info.capacity = UInt32.from(state.capacity)
23
+ if (state.energy !== undefined) info.energy = UInt16.from(state.energy)
24
+ if (state.engines) info.engines = state.engines
25
+ if (state.generator) info.generator = state.generator
26
+ if (state.loaders) info.loaders = state.loaders
27
+ if (state.schedule) info.schedule = state.schedule
28
+ const entityInfo = ServerContract.Types.entity_info.from(info)
29
+ return new Ship(entityInfo)
30
+ }
31
+
32
+ export function makeWarehouse(state: WarehouseStateInput): Warehouse {
33
+ const info: Record<string, unknown> = {
34
+ type: Name.from('warehouse'),
35
+ id: UInt64.from(state.id),
36
+ owner: Name.from(state.owner),
37
+ entity_name: state.name,
38
+ coordinates: ServerContract.Types.coordinates.from(state.coordinates),
39
+ capacity: UInt32.from(state.capacity),
40
+ cargomass: UInt32.from(0),
41
+ cargo: state.cargo || [],
42
+ is_idle: !state.schedule,
43
+ current_task_elapsed: UInt32.from(0),
44
+ current_task_remaining: UInt32.from(0),
45
+ pending_tasks: [],
46
+ }
47
+ if (state.hullmass !== undefined) info.hullmass = UInt32.from(state.hullmass)
48
+ if (state.loaders) info.loaders = state.loaders
49
+ if (state.schedule) info.schedule = state.schedule
50
+ const entityInfo = ServerContract.Types.entity_info.from(info)
51
+ return new Warehouse(entityInfo)
52
+ }
53
+
54
+ export function makeContainer(state: ContainerStateInput): Container {
55
+ const entityInfo = ServerContract.Types.entity_info.from({
56
+ type: Name.from('container'),
57
+ id: UInt64.from(state.id),
58
+ owner: Name.from(state.owner),
59
+ entity_name: state.name,
60
+ coordinates: ServerContract.Types.coordinates.from(state.coordinates),
61
+ hullmass: UInt32.from(state.hullmass),
62
+ capacity: UInt32.from(state.capacity),
63
+ cargomass: UInt32.from(state.cargomass || 0),
64
+ cargo: [],
65
+ is_idle: !state.schedule,
66
+ current_task_elapsed: UInt32.from(0),
67
+ current_task_remaining: UInt32.from(0),
68
+ pending_tasks: [],
69
+ schedule: state.schedule,
70
+ })
71
+ return new Container(entityInfo)
72
+ }
@@ -0,0 +1,15 @@
1
+ import {Name, NameType} from '@wharfkit/antelope'
2
+ import {ServerContract} from '../contracts'
3
+
4
+ export interface PlayerStateInput {
5
+ owner: NameType
6
+ }
7
+
8
+ export class Player extends ServerContract.Types.player_row {
9
+ static fromState(state: PlayerStateInput): Player {
10
+ const playerRow = ServerContract.Types.player_row.from({
11
+ owner: Name.from(state.owner),
12
+ })
13
+ return new Player(playerRow)
14
+ }
15
+ }