gleam-spacetraders-sdk/src/models/scanned_system.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

32 lines
855 B
Gleam

import gleam/dynamic/decode.{type Decoder}
import models/sector_symbol.{type SectorSymbol}
import models/system_symbol.{type SystemSymbol}
import models/system_type.{type SystemType}
pub type ScannedSystem {
ScannedSystem(
symbol: SystemSymbol,
sector_symbol: SectorSymbol,
type_: SystemType,
x: Int,
y: Int,
distance: Int,
)
}
pub fn decoder() -> Decoder(ScannedSystem) {
use symbol <- decode.field("symbol", system_symbol.decoder())
use sector_symbol <- decode.field("sectorSymbol", sector_symbol.decoder())
use type_ <- decode.field("type", system_type.decoder())
use x <- decode.field("x", decode.int)
use y <- decode.field("y", decode.int)
use distance <- decode.field("distance", decode.int)
decode.success(ScannedSystem(
symbol:,
sector_symbol:,
type_:,
x:,
y:,
distance:,
))
}