A SpaceTraders Agent
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

add systems api

Altagos 0ec9df87 a92c5b1f

+618 -60
+2 -2
build.zig.zon
··· 7 7 .hash = "known_folders-0.0.0-Fy-PJqHJAAB43zDJmOdlr3nViu69IFI9pNFt7hkHjKk4", 8 8 }, 9 9 .pretty = .{ 10 - .url = "git+https://git.sr.ht/~altagos/pretty?ref=main#aa04716ea6ccca41ebbaa5579f92d4bca6a89f11", 11 - .hash = "pretty-0.1.0--Y3D24RNAADsMIYIeuZmK4eJS1l9Iskck5EgzACPkR5e", 10 + .url = "git+https://git.sr.ht/~altagos/pretty?ref=main#0c6719d70ffd881bd85741d7c78a2528a91460da", 11 + .hash = "pretty-0.1.0--Y3D221OAAAabyuks8iUly5b0-qdnE3VD1pLRmb1NCra", 12 12 }, 13 13 .zqlite = .{ 14 14 .url = "git+https://github.com/altagos/zqlite.zig?ref=master#f95c6bc7b182a8c18d8341fba031fa6d5d2ffbd1",
+35 -1
src/main.zig
··· 7 7 const st = @import("st"); 8 8 const api = st.api; 9 9 const Client = st.http.Client; 10 + const m = st.models; 10 11 11 12 const agent = @import("agent"); 12 13 const Config = agent.config.Config; ··· 32 33 33 34 // std.log.info("Registered agent\n{f}", .{pretty(register.value)}); 34 35 36 + var af = try api.agent.own(client); 37 + defer _ = af.cancel(io) catch {}; 38 + 35 39 var fleet_f = try api.fleet.listShips(client, .{}); 36 40 defer _ = fleet_f.cancel(io) catch {}; 37 41 42 + var traits = [_]m.systems.Waypoint.Trait{ .MARKETPLACE, .INDUSTRIAL, .OCEAN }; 43 + var waypoints_f = try api.system.waypoints( 44 + client, 45 + (try m.parseSymbol("X1-TA72")).system, 46 + .{ .traits = &traits }, 47 + .{}, 48 + ); 49 + defer _ = waypoints_f.cancel(io) catch {}; 50 + 51 + const own = try af.await(io); 52 + defer own.deinit(); 53 + 38 54 const fleet = try fleet_f.await(io); 39 55 defer fleet.deinit(); 40 56 41 - std.log.info("{f}", .{pretty(fleet.value)}); 57 + const waypoints = try waypoints_f.await(io); 58 + defer waypoints.deinit(); 59 + 60 + std.log.info("Agent: {f}", .{pretty(own.value)}); 61 + std.log.info("Ships: {f}", .{pretty(fleet.value.data.?)}); 62 + std.log.info("Waypoints with {any} traits: {f}", .{ traits, pretty(waypoints.value.data.?) }); 63 + 64 + if (waypoints.value.data.?.len > 0) { 65 + var market_f = try api.system.market( 66 + client, 67 + waypoints.value.data.?[0].symbol.waypoint, 68 + ); 69 + defer _ = market_f.cancel(io) catch {}; 70 + 71 + const market = try market_f.await(io); 72 + defer market.deinit(); 73 + 74 + std.log.info("Market: {f}", .{pretty(market.value.data.?)}); 75 + } 42 76 } 43 77 44 78 pub fn main(init: std.process.Init) !void {
+135 -8
src/st/api.zig
··· 1 + const std = @import("std"); 2 + 1 3 pub const fleet = @import("fleet.zig"); 2 4 3 5 const st = @import("root.zig"); ··· 33 35 symbol: []const u8, 34 36 faction: models.factions.Symbol, 35 37 ) !Response(models.agents.Register) { 36 - return client.post( 37 - Wrapper(models.agents.Register), 38 + return client.postW( 39 + models.agents.Register, 38 40 "/register", 39 41 .{}, 40 42 .{ .symbol = symbol, .faction = faction }, ··· 43 45 } 44 46 45 47 pub fn list(client: *Client, opts: Query) !Response([]models.agents.Agent) { 46 - return client.get( 47 - Wrapper([]models.agents.Agent), 48 + return client.getW( 49 + []models.agents.Agent, 48 50 "/agents{f}", 49 51 .{opts}, 50 52 .agent, ··· 52 54 } 53 55 54 56 pub fn get(client: *Client, symbol: []const u8) !Response(models.agents.Agent) { 55 - return client.get( 56 - Wrapper(models.agents.Agent), 57 + return client.getW( 58 + models.agents.Agent, 57 59 "/agents/{s}", 58 60 .{symbol}, 59 61 .agent, ··· 61 63 } 62 64 63 65 pub fn own(client: *Client) !Response(models.agents.Agent) { 64 - return client.get( 65 - Wrapper(models.agents.Agent), 66 + return client.getW( 67 + models.agents.Agent, 66 68 "/my/agent", 67 69 .{}, 68 70 .agent, 69 71 ); 70 72 } 71 73 }; 74 + 75 + pub const system = struct { 76 + const Symbol = models.systems.Symbol; 77 + 78 + pub fn get(client: *Client, symbol: Symbol.System) !Response(models.systems.System) { 79 + return client.getW( 80 + models.systems.System, 81 + "/systems/{f}", 82 + .{symbol}, 83 + .agent, 84 + ); 85 + } 86 + 87 + pub fn list(client: *Client, opts: Query) !Response([]models.systems.System) { 88 + return client.getW( 89 + []models.systems.System, 90 + "/systems{f}", 91 + .{opts}, 92 + .agent, 93 + ); 94 + } 95 + 96 + pub fn waypoint( 97 + client: *Client, 98 + waypoint_symbol: Symbol.Waypoint, 99 + ) !Response(models.systems.Waypoint) { 100 + return client.getW( 101 + models.systems.Waypoint, 102 + "/systems/{f}/waypoints/{f}", 103 + .{ waypoint_symbol.system, waypoint_symbol }, 104 + .agent, 105 + ); 106 + } 107 + 108 + pub const WaypointsFilter = struct { 109 + type: ?models.systems.Waypoint.Type = null, 110 + traits: []models.systems.Waypoint.Trait = &.{}, 111 + 112 + pub fn format(this: @This(), writer: *std.Io.Writer) std.Io.Writer.Error!void { 113 + if (this.type) |ty| { 114 + try writer.print("&type={s}", .{@tagName(ty)}); 115 + } 116 + if (this.traits.len > 0) { 117 + for (this.traits) |trait| { 118 + try writer.print("&traits={s}", .{@tagName(trait)}); 119 + } 120 + } 121 + } 122 + }; 123 + 124 + pub fn waypoints( 125 + client: *Client, 126 + symbol: Symbol.System, 127 + filter: WaypointsFilter, 128 + opts: Query, 129 + ) !Response([]models.systems.Waypoint) { 130 + return client.getW( 131 + []models.systems.Waypoint, 132 + "/systems/{f}/waypoints{f}{f}", 133 + .{ symbol, opts, filter }, 134 + .agent, 135 + ); 136 + } 137 + 138 + pub fn construction( 139 + client: *Client, 140 + waypoint_symbol: Symbol.Waypoint, 141 + ) !Response(models.systems.Construction) { 142 + return client.getW( 143 + models.systems.Construction, 144 + "/systems/{f}/waypoints/{f}/construction", 145 + .{ waypoint_symbol.system, waypoint_symbol }, 146 + .agent, 147 + ); 148 + } 149 + 150 + pub const SupplyConstruction = struct { 151 + shipSymbol: []const u8, 152 + tradeSymbol: models.inventory.AllItems.Combined, 153 + units: u64, 154 + 155 + pub const Response = struct { 156 + construction: models.systems.ConstructionSite, 157 + cargo: models.inventory.Cargo, 158 + }; 159 + }; 160 + 161 + pub fn supplyConstruction( 162 + client: *Client, 163 + waypoint_symbol: Symbol.Waypoint, 164 + supply: SupplyConstruction, 165 + ) !Response(SupplyConstruction.Response) { 166 + return client.postW( 167 + SupplyConstruction.Response, 168 + "/systems/{f}/waypoints/{f}/supply-construction", 169 + .{ waypoint_symbol.system, waypoint_symbol }, 170 + supply, 171 + .agent, 172 + ); 173 + } 174 + 175 + pub fn market( 176 + client: *Client, 177 + waypoint_symbol: Symbol.Waypoint, 178 + ) !Response(models.systems.Market) { 179 + return client.getW( 180 + models.systems.Market, 181 + "/systems/{f}/waypoints/{f}/market", 182 + .{ waypoint_symbol.system, waypoint_symbol }, 183 + .agent, 184 + ); 185 + } 186 + 187 + pub fn shipyard( 188 + client: *Client, 189 + waypoint_symbol: Symbol.Waypoint, 190 + ) !Response(models.systems.Shipyard) { 191 + return client.getW( 192 + models.systems.Shipyard, 193 + "/systems/{f}/waypoints/{f}/shipyard", 194 + .{ waypoint_symbol.system, waypoint_symbol }, 195 + .agent, 196 + ); 197 + } 198 + };
+32
src/st/http.zig
··· 240 240 return cl.request(T, path, args, .{ .auth = auth }); 241 241 } 242 242 243 + pub fn getW( 244 + cl: *Client, 245 + comptime T: type, 246 + comptime path: []const u8, 247 + args: anytype, 248 + auth: AuthType, 249 + ) !Response(T) { 250 + return cl.get(models.Wrapper(T), path, args, auth); 251 + } 252 + 243 253 pub fn post( 244 254 cl: *Client, 245 255 comptime T: type, ··· 258 268 }); 259 269 } 260 270 271 + pub fn postW( 272 + cl: *Client, 273 + comptime T: type, 274 + comptime path: []const u8, 275 + args: anytype, 276 + body: anytype, 277 + auth: AuthType, 278 + ) !Response(T) { 279 + return cl.post(models.Wrapper(T), path, args, body, auth); 280 + } 281 + 261 282 pub fn patch( 262 283 cl: *Client, 263 284 comptime T: type, ··· 274 295 .body = .{ .buffer = buffer }, 275 296 .free_body_after_sending = true, 276 297 }); 298 + } 299 + 300 + pub fn patchW( 301 + cl: *Client, 302 + comptime T: type, 303 + comptime path: []const u8, 304 + args: anytype, 305 + body: anytype, 306 + auth: AuthType, 307 + ) !Response(T) { 308 + return cl.patch(models.Wrapper(T), path, args, body, auth); 277 309 } 278 310 279 311 pub fn request(
+19
src/st/models.zig
··· 1 1 const std = @import("std"); 2 + const prettym = @import("pretty"); 2 3 3 4 pub const accounts = @import("models/accounts.zig"); 4 5 pub const agents = @import("models/agents.zig"); 5 6 pub const contracts = @import("models/contracts.zig"); 6 7 pub const factions = @import("models/factions.zig"); 7 8 pub const ships = @import("models/ships.zig"); 9 + pub const systems = @import("models/systems.zig"); 8 10 9 11 pub const inventory = @import("models/inventory.zig"); 10 12 11 13 pub const Info = @import("models/Info.zig"); 14 + 15 + pub const parseSymbol = systems.Symbol.parseSlice; 12 16 13 17 pub fn Wrapper(comptime T: type) type { 14 18 return struct { ··· 34 38 try writer.print("?page={}&limit={}", .{ this.page, this.limit }); 35 39 } 36 40 }; 41 + 42 + pub fn SymbolWrapper(comptime T: type) type { 43 + return struct { 44 + symbol: T, 45 + 46 + pub fn pretty( 47 + this: *const @This(), 48 + comptime ctx: prettym.Context, 49 + run: *const prettym.Runtime, 50 + ) error{WriteFailed}!void { 51 + return run.pretty(ctx, this.symbol, .{ .skip_type_name = true }); 52 + } 53 + }; 54 + } 37 55 38 56 pub const Error = struct { 39 57 message: []const u8, ··· 178 196 constructionMaterialFulfilled = 4801, 179 197 shipConstructionInvalidLocationError = 4802, 180 198 unsupportedMediaTypeError = 5000, 199 + _, 181 200 };
+2 -1
src/st/models/agents.zig
··· 8 8 const Faction = st.models.factions.Faction; 9 9 const FactionSymbol = st.models.factions.Symbol; 10 10 const Ship = st.models.ships.Ship; 11 + const Symbol = st.models.systems.Symbol; 11 12 12 13 pub const Agent = struct { 13 14 symbol: []const u8, 14 - headquarters: []const u8, 15 + headquarters: Symbol, 15 16 credits: u64, 16 17 startingFaction: FactionSymbol, 17 18 shipCount: u64,
+6 -2
src/st/models/contracts.zig
··· 1 + const m = @import("../models.zig"); 2 + const factions = m.factions; 3 + const Symbol = m.systems.Symbol; 4 + 1 5 pub const Contract = struct { 2 6 id: []const u8, 3 - factionSymbol: []const u8, 7 + factionSymbol: factions.Symbol, 4 8 type: Type = .PROCUREMENT, 5 9 terms: Terms = .{}, 6 10 accepted: bool = false, ··· 27 31 28 32 pub const Deliver = struct { 29 33 tradeSymbol: []const u8, 30 - destinationSymbol: []const u8, 34 + destinationSymbol: Symbol, 31 35 unitsRequired: u64, 32 36 unitsFulfilled: u64, 33 37 };
+3 -1
src/st/models/factions.zig
··· 1 + const m = @import("../models.zig"); 2 + 1 3 pub const Symbol = enum { 2 4 COSMIC, 3 5 VOID, ··· 92 94 symbol: Symbol = .COSMIC, 93 95 name: []const u8, 94 96 description: []const u8, 95 - headquarters: []const u8, 97 + headquarters: m.systems.Symbol, 96 98 traits: []Trait = &.{}, 97 99 isRecruiting: bool = false, 98 100 };
+1 -1
src/st/models/inventory.zig
··· 10 10 symbol: AllItems.Combined, 11 11 name: []const u8, 12 12 description: []const u8, 13 - units: u64, 13 + units: u64 = 0, 14 14 }; 15 15 16 16 pub const AllItems = CombinedEnum(ItemSymbols);
+31 -43
src/st/models/ships.zig
··· 80 80 }; 81 81 82 82 pub const Nav = struct { 83 - systemSymbol: []const u8, 84 - waypointSymbol: []const u8, 83 + systemSymbol: m.systems.Symbol, 84 + waypointSymbol: m.systems.Symbol, 85 85 route: Route, 86 86 status: Status, 87 87 flightMode: FlightMode, 88 88 89 89 pub const Route = struct { 90 - destination: Waypoint, 91 - origin: Waypoint, 90 + destination: m.systems.WaypointPreview, 91 + origin: m.systems.WaypointPreview, 92 92 departureTime: []const u8, 93 93 arrival: []const u8, 94 94 }; 95 95 96 - pub const Waypoint = struct { 97 - symbol: []const u8, 98 - type: Type, 99 - systemSymbol: []const u8, 100 - x: i64, 101 - y: i64, 102 - 103 - pub const Type = enum { 104 - PLANET, 105 - GAS_GIANT, 106 - MOON, 107 - ORBITAL_STATION, 108 - JUMP_GATE, 109 - ASTEROID_FIELD, 110 - ASTEROID, 111 - ENGINEERED_ASTEROID, 112 - ASTEROID_BASE, 113 - NEBULA, 114 - DEBRIS_FIELD, 115 - GRAVITY_WELL, 116 - ARTIFICIAL_GRAVITY_WELL, 117 - FUEL_STATION, 118 - }; 119 - 120 - pub fn pretty( 121 - this: *const @This(), 122 - comptime ctx: prettym.Context, 123 - run: *const prettym.Runtime, 124 - ) error{WriteFailed}!void { 125 - run.setColor(ctx, .value); 126 - try run.write(this.symbol); 127 - run.setColor(ctx, .dim); 128 - try run.print("[{s}] ", .{@tagName(this.type)}); 129 - run.resetColor(); 130 - } 131 - }; 132 - 133 96 pub const Status = enum { 134 97 IN_TRANSIT, 135 98 IN_ORBIT, ··· 155 118 run.resetColor(); 156 119 157 120 run.setColor(ctx, .value); 158 - try this.route.origin.pretty(ctx, run); 121 + try this.route.origin.prettyInline(ctx, run); 122 + try run.pretty( 123 + ctx, 124 + this.route.origin, 125 + .{ .force_inline = true, .skip_type_name = true }, 126 + ); 159 127 run.setColor(ctx, .dim); 160 128 try run.write(" -> "); 161 129 run.resetColor(); ··· 172 140 }, 173 141 } 174 142 175 - try this.route.destination.pretty(ctx, run); 143 + try run.pretty( 144 + ctx, 145 + this.route.destination, 146 + .{ .force_inline = true, .skip_type_name = true }, 147 + ); 176 148 } 177 149 }; 178 150 ··· 261 233 crew: ?u64 = null, 262 234 slots: ?u64 = null, 263 235 }; 236 + 237 + pub const Type = enum { 238 + SHIP_PROBE, 239 + SHIP_MINING_DRONE, 240 + SHIP_SIPHON_DRONE, 241 + SHIP_INTERCEPTOR, 242 + SHIP_LIGHT_HAULER, 243 + SHIP_COMMAND_FRIGATE, 244 + SHIP_EXPLORER, 245 + SHIP_HEAVY_FREIGHTER, 246 + SHIP_LIGHT_SHUTTLE, 247 + SHIP_ORE_HOUND, 248 + SHIP_REFINING_FREIGHTER, 249 + SHIP_SURVEYOR, 250 + SHIP_BULK_FREIGHTER, 251 + };
+351
src/st/models/systems.zig
··· 1 + const std = @import("std"); 2 + const Allocator = std.mem.Allocator; 3 + const json = std.json; 4 + 5 + const prettym = @import("pretty"); 6 + 7 + const m = @import("../models.zig"); 8 + 9 + pub const Symbol = union(Symbol.Type) { 10 + sector: u8, 11 + system: Symbol.System, 12 + waypoint: Symbol.Waypoint, 13 + 14 + pub const Type = enum { sector, system, waypoint }; 15 + 16 + pub const System = struct { 17 + sector: u8, 18 + symbol: []const u8, 19 + 20 + pub fn format(this: @This(), writer: *std.Io.Writer) std.Io.Writer.Error!void { 21 + try writer.print("X{}-{s}", .{ this.sector, this.symbol }); 22 + } 23 + }; 24 + 25 + pub const Waypoint = struct { 26 + system: Symbol.System, 27 + symbol: []const u8, 28 + 29 + pub fn format(this: @This(), writer: *std.Io.Writer) std.Io.Writer.Error!void { 30 + try writer.print("{f}-{s}", .{ this.system, this.symbol }); 31 + } 32 + }; 33 + 34 + pub fn parseSlice(slice: []const u8) !Symbol { 35 + var tokens = std.mem.tokenizeScalar(u8, slice, '-'); 36 + const sector_raw = tokens.next() orelse return error.InvalidSymbol; 37 + 38 + std.debug.assert(sector_raw.len == 2); 39 + std.debug.assert(sector_raw[0] == 'X'); 40 + 41 + const sector = std.fmt.parseInt(u8, sector_raw[1..], 10) catch return error.InvalidSector; 42 + const system_raw = tokens.next(); 43 + 44 + if (system_raw) |system| { 45 + const sys = Symbol.System{ .sector = sector, .symbol = system }; 46 + if (tokens.next()) |waypoint| { 47 + return Symbol{ .waypoint = .{ 48 + .system = sys, 49 + .symbol = waypoint, 50 + } }; 51 + } 52 + return Symbol{ .system = sys }; 53 + } else { 54 + return Symbol{ .sector = sector }; 55 + } 56 + } 57 + 58 + pub fn jsonParse( 59 + allocator: Allocator, 60 + source: anytype, 61 + options: json.ParseOptions, 62 + ) json.ParseError(@TypeOf(source.*))!Symbol { 63 + const string = try json.innerParse([]const u8, allocator, source, options); 64 + return parseSlice(string) catch return error.MissingField; 65 + } 66 + 67 + pub fn format(this: @This(), writer: *std.Io.Writer) std.Io.Writer.Error!void { 68 + switch (this) { 69 + .sector => |sector| { 70 + try writer.print("X{}", .{sector}); 71 + }, 72 + inline else => |e| try writer.print("{f}", .{e}), 73 + } 74 + } 75 + 76 + pub fn pretty( 77 + this: *const @This(), 78 + comptime ctx: prettym.Context, 79 + run: *const prettym.Runtime, 80 + ) error{WriteFailed}!void { 81 + run.setColor(ctx, .value); 82 + try run.print("{f}", .{this}); 83 + run.resetColor(); 84 + } 85 + }; 86 + 87 + pub const System = struct { 88 + constellation: []const u8, 89 + symbol: Symbol, 90 + sectorSymbol: Symbol, 91 + type: Type, 92 + x: i64, 93 + y: i64, 94 + waypoints: []WaypointPreview, 95 + factions: []Faction, 96 + name: []const u8, 97 + 98 + pub const Type = enum { 99 + NEUTRON_STAR, 100 + RED_STAR, 101 + ORANGE_STAR, 102 + BLUE_STAR, 103 + YOUNG_STAR, 104 + WHITE_DWARF, 105 + BLACK_HOLE, 106 + HYPERGIANT, 107 + NEBULA, 108 + UNSTABLE, 109 + }; 110 + }; 111 + 112 + pub const Waypoint = struct { 113 + symbol: Symbol, 114 + systemSymbol: Symbol, 115 + type: Type, 116 + x: i64, 117 + y: i64, 118 + faction: Faction, 119 + traits: []m.SymbolWrapper(Trait), 120 + modifiers: []Modifier, 121 + chart: Chart, 122 + isUnderConstruction: bool, 123 + 124 + orbitals: []m.SymbolWrapper([]const u8), 125 + orbits: ?[]const u8 = null, 126 + 127 + pub fn unwrapTraits(this: *const @This(), alloc: std.mem.Allocator) ![]Trait { 128 + var buf = try alloc.alloc(Trait, this.traits.len); 129 + for (this.traits, 0..) |trait, i| { 130 + buf[i] = trait.symbol; 131 + } 132 + return buf; 133 + } 134 + 135 + pub const Type = enum { 136 + PLANET, 137 + GAS_GIANT, 138 + MOON, 139 + ORBITAL_STATION, 140 + JUMP_GATE, 141 + ASTEROID_FIELD, 142 + ASTEROID, 143 + ENGINEERED_ASTEROID, 144 + ASTEROID_BASE, 145 + NEBULA, 146 + DEBRIS_FIELD, 147 + GRAVITY_WELL, 148 + ARTIFICIAL_GRAVITY_WELL, 149 + FUEL_STATION, 150 + }; 151 + 152 + pub const Trait = enum { 153 + UNCHARTED, 154 + UNDER_CONSTRUCTION, 155 + MARKETPLACE, 156 + SHIPYARD, 157 + OUTPOST, 158 + SCATTERED_SETTLEMENTS, 159 + SPRAWLING_CITIES, 160 + MEGA_STRUCTURES, 161 + PIRATE_BASE, 162 + OVERCROWDED, 163 + HIGH_TECH, 164 + CORRUPT, 165 + BUREAUCRATIC, 166 + TRADING_HUB, 167 + INDUSTRIAL, 168 + BLACK_MARKET, 169 + RESEARCH_FACILITY, 170 + MILITARY_BASE, 171 + SURVEILLANCE_OUTPOST, 172 + EXPLORATION_OUTPOST, 173 + MINERAL_DEPOSITS, 174 + COMMON_METAL_DEPOSITS, 175 + PRECIOUS_METAL_DEPOSITS, 176 + RARE_METAL_DEPOSITS, 177 + METHANE_POOLS, 178 + ICE_CRYSTALS, 179 + EXPLOSIVE_GASES, 180 + STRONG_MAGNETOSPHERE, 181 + VIBRANT_AURORAS, 182 + SALT_FLATS, 183 + CANYONS, 184 + PERPETUAL_DAYLIGHT, 185 + PERPETUAL_OVERCAST, 186 + DRY_SEABEDS, 187 + MAGMA_SEAS, 188 + SUPERVOLCANOES, 189 + ASH_CLOUDS, 190 + VAST_RUINS, 191 + MUTATED_FLORA, 192 + TERRAFORMED, 193 + EXTREME_TEMPERATURES, 194 + EXTREME_PRESSURE, 195 + DIVERSE_LIFE, 196 + SCARCE_LIFE, 197 + FOSSILS, 198 + WEAK_GRAVITY, 199 + STRONG_GRAVITY, 200 + CRUSHING_GRAVITY, 201 + TOXIC_ATMOSPHERE, 202 + CORROSIVE_ATMOSPHERE, 203 + BREATHABLE_ATMOSPHERE, 204 + THIN_ATMOSPHERE, 205 + JOVIAN, 206 + ROCKY, 207 + VOLCANIC, 208 + FROZEN, 209 + SWAMP, 210 + BARREN, 211 + TEMPERATE, 212 + JUNGLE, 213 + OCEAN, 214 + RADIOACTIVE, 215 + MICRO_GRAVITY_ANOMALIES, 216 + DEBRIS_CLUSTER, 217 + DEEP_CRATERS, 218 + SHALLOW_CRATERS, 219 + UNSTABLE_COMPOSITION, 220 + HOLLOWED_INTERIOR, 221 + STRIPPED, 222 + }; 223 + 224 + pub const Modifier = struct { 225 + symbol: ModSymbol, 226 + name: []const u8, 227 + description: []const u8, 228 + 229 + pub const ModSymbol = enum { 230 + STRIPPED, 231 + UNSTABLE, 232 + RADIATION_LEAK, 233 + CRITICAL_LIMIT, 234 + CIVIL_UNREST, 235 + }; 236 + }; 237 + 238 + pub const Chart = struct { 239 + waypointSymbol: Symbol, 240 + submittedBy: []const u8, 241 + submittedOn: []const u8, 242 + }; 243 + }; 244 + 245 + pub const WaypointPreview = struct { 246 + symbol: Symbol, 247 + type: Waypoint.Type, 248 + x: i64, 249 + y: i64, 250 + orbitals: []m.SymbolWrapper(Symbol) = &.{}, 251 + orbits: ?Symbol = null, 252 + 253 + pub fn prettyInline( 254 + this: *const @This(), 255 + comptime ctx: prettym.Context, 256 + run: *const prettym.Runtime, 257 + ) error{WriteFailed}!void { 258 + run.setColor(ctx, .value); 259 + try run.print("{f}", .{this.symbol}); 260 + run.setColor(ctx, .dim); 261 + try run.print("[{s}]({}, {}) ", .{ @tagName(this.type), this.x, this.y }); 262 + run.resetColor(); 263 + } 264 + }; 265 + 266 + pub const ConstructionSite = struct { 267 + symbol: Symbol, 268 + isComplete: bool, 269 + materials: []Material, 270 + 271 + pub const Material = struct { 272 + tradeSymbol: m.inventory.AllItems.Combined, 273 + required: i64, 274 + fulfilled: i64, 275 + }; 276 + }; 277 + 278 + pub const Market = struct { 279 + symbol: Symbol, 280 + exports: []m.inventory.Item = &.{}, 281 + imports: []m.inventory.Item = &.{}, 282 + exchange: []m.inventory.Item = &.{}, 283 + transactions: ?[]Transaction = null, 284 + tradeGoods: ?[]TradeGood = null, 285 + 286 + pub const Transaction = struct { 287 + waypointSymbol: Symbol, 288 + shipSymbol: []const u8, 289 + tradeSymbol: []const u8, 290 + type: Type, 291 + units: u64, 292 + pricePerUnit: u64, 293 + totalPrice: u64, 294 + timestamp: []const u8, 295 + 296 + pub const Type = enum { PURCHASE, SELL }; 297 + }; 298 + 299 + pub const TradeGood = struct { 300 + symbol: m.inventory.AllItems.Combined, 301 + type: TradeGood.Type, 302 + tradeVolume: u64, 303 + supply: Supply, 304 + activity: ?Activity = null, 305 + purchasePrice: u64, 306 + sellPrice: u64, 307 + 308 + pub const Type = enum { EXPORT, IMPORT, EXCHANGE }; 309 + }; 310 + 311 + pub const Supply = enum { SCARCE, LIMITED, MODERATE, HIGH, ABUNDANT }; 312 + pub const Activity = enum { WEAK, GROWING, STRONG, RESTRICTED }; 313 + }; 314 + 315 + pub const JumpGate = struct { 316 + symbol: Symbol, 317 + connections: []Symbol, 318 + }; 319 + 320 + pub const Shipyard = struct { 321 + symbol: Symbol, 322 + shipTypes: struct { type: m.ships.Type }, 323 + transactions: []Transaction, 324 + modificationsFee: i64, 325 + 326 + pub const Transaction = struct { 327 + waypointSymbol: Symbol, 328 + shipType: m.ships.Type, 329 + price: u64, 330 + agentSymbol: []const u8, 331 + timestamp: []const u8, 332 + }; 333 + 334 + pub const Ship = struct { 335 + activity: Market.Activity, 336 + supply: Market.Supply, 337 + purchasePrice: u64, 338 + 339 + type: m.ships.Type, 340 + name: []const u8, 341 + description: []const u8, 342 + crew: m.ships.Crew, 343 + frame: m.ships.Frame, 344 + reactor: m.ships.Reactor, 345 + engine: m.ships.Engine, 346 + modules: []m.ships.Module, 347 + mounts: []m.ships.Mount, 348 + }; 349 + }; 350 + 351 + pub const Faction = m.SymbolWrapper(m.factions.Symbol);
+1 -1
src/st/root.zig
··· 4 4 5 5 test { 6 6 const testing = @import("std").testing; 7 - testing.refAllDecls(@This()); 7 + testing.refAllDecls(models); 8 8 }