gleam-spacetraders-sdk/src/models/ship_crew.gleam
Lily Rose 64f3729d0c
Some checks are pending
test / test (push) Waiting to run
Refactoring and general tidying up
2025-06-17 19:04:29 +10:00

30 lines
737 B
Gleam

import gleam/dynamic/decode.{type Decoder}
import models/crew_rotation.{type CrewRotation}
pub type ShipCrew {
ShipCrew(
current: Int,
required: Int,
capacity: Int,
rotation: CrewRotation,
morale: Int,
wages: Int,
)
}
pub fn decoder() -> Decoder(ShipCrew) {
use current <- decode.field("current", decode.int)
use required <- decode.field("required", decode.int)
use capacity <- decode.field("capacity", decode.int)
use rotation <- decode.field("rotation", crew_rotation.decoder())
use morale <- decode.field("morale", decode.int)
use wages <- decode.field("wages", decode.int)
decode.success(ShipCrew(
current:,
required:,
capacity:,
rotation:,
morale:,
wages:,
))
}