23 lines
785 B
Gleam
23 lines
785 B
Gleam
import gleam/dynamic/decode.{type Decoder}
|
|
import models/system_symbol.{type SystemSymbol}
|
|
import models/waypoint_symbol.{type WaypointSymbol}
|
|
import models/waypoint_type.{type WaypointType}
|
|
|
|
pub type ShipNavRouteWaypoint {
|
|
ShipNavRouteWaypoint(
|
|
symbol: WaypointSymbol,
|
|
type_: WaypointType,
|
|
system_symbol: SystemSymbol,
|
|
x: Int,
|
|
y: Int,
|
|
)
|
|
}
|
|
|
|
pub fn decoder() -> Decoder(ShipNavRouteWaypoint) {
|
|
use symbol <- decode.field("symbol", waypoint_symbol.decoder())
|
|
use type_ <- decode.field("type", waypoint_type.decoder())
|
|
use system_symbol <- decode.field("systemSymbol", system_symbol.decoder())
|
|
use x <- decode.field("x", decode.int)
|
|
use y <- decode.field("y", decode.int)
|
|
decode.success(ShipNavRouteWaypoint(symbol:, type_:, system_symbol:, x:, y:))
|
|
}
|