gleam-spacetraders-models/src/spacetraders_models/construction.gleam
Lily Rose fab4c9df5d
Some checks are pending
test / test (push) Waiting to run
Initial commit
2025-07-08 23:03:42 +10:00

21 lines
670 B
Gleam

import gleam/dynamic/decode.{type Decoder}
import spacetraders_models/construction_material.{type ConstructionMaterial}
import spacetraders_models/waypoint_symbol.{type WaypointSymbol}
pub type Construction {
Construction(
symbol: WaypointSymbol,
materials: List(ConstructionMaterial),
is_complete: Bool,
)
}
pub fn decoder() -> Decoder(Construction) {
use symbol <- decode.field("symbol", waypoint_symbol.decoder())
use materials <- decode.field(
"materials",
decode.list(construction_material.decoder()),
)
use is_complete <- decode.field("isComplete", decode.bool)
decode.success(Construction(symbol:, materials:, is_complete:))
}