import gleam/dynamic/decode.{type Decoder} import spacetraders_models/agent_symbol.{type AgentSymbol} import spacetraders_models/faction_symbol.{type FactionSymbol} import spacetraders_models/waypoint_symbol.{type WaypointSymbol} pub type PublicAgent { PublicAgent( symbol: AgentSymbol, headquarters: WaypointSymbol, credits: Int, starting_faction: FactionSymbol, ship_count: Int, ) } pub fn decoder() -> Decoder(PublicAgent) { use symbol <- decode.field("symbol", agent_symbol.decoder()) use headquarters <- decode.field("headquarters", waypoint_symbol.decoder()) use credits <- decode.field("credits", decode.int) use starting_faction <- decode.field( "startingFaction", faction_symbol.decoder(), ) use ship_count <- decode.field("shipCount", decode.int) decode.success(PublicAgent( symbol:, headquarters:, credits:, starting_faction:, ship_count:, )) }