import gleam/dynamic/decode.{type Decoder} import spacetraders_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:, )) }