From 0ec9df872b187de5b0e0e2bd5ac80775821e222b Mon Sep 17 00:00:00 2001 From: Altagos Date: Mon, 16 Feb 2026 13:58:58 +0100 Subject: [PATCH] add systems api --- build.zig.zon | 4 +- src/main.zig | 36 +++- src/st/api.zig | 143 ++++++++++++++- src/st/http.zig | 32 ++++ src/st/models.zig | 19 ++ src/st/models/agents.zig | 3 +- src/st/models/contracts.zig | 8 +- src/st/models/factions.zig | 4 +- src/st/models/inventory.zig | 2 +- src/st/models/ships.zig | 74 ++++---- src/st/models/systems.zig | 351 ++++++++++++++++++++++++++++++++++++ src/st/root.zig | 2 +- 12 files changed, 618 insertions(+), 60 deletions(-) create mode 100644 src/st/models/systems.zig diff --git a/build.zig.zon b/build.zig.zon index ef5554a..31c1ba5 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -7,8 +7,8 @@ .hash = "known_folders-0.0.0-Fy-PJqHJAAB43zDJmOdlr3nViu69IFI9pNFt7hkHjKk4", }, .pretty = .{ - .url = "git+https://git.sr.ht/~altagos/pretty?ref=main#aa04716ea6ccca41ebbaa5579f92d4bca6a89f11", - .hash = "pretty-0.1.0--Y3D24RNAADsMIYIeuZmK4eJS1l9Iskck5EgzACPkR5e", + .url = "git+https://git.sr.ht/~altagos/pretty?ref=main#0c6719d70ffd881bd85741d7c78a2528a91460da", + .hash = "pretty-0.1.0--Y3D221OAAAabyuks8iUly5b0-qdnE3VD1pLRmb1NCra", }, .zqlite = .{ .url = "git+https://github.com/altagos/zqlite.zig?ref=master#f95c6bc7b182a8c18d8341fba031fa6d5d2ffbd1", diff --git a/src/main.zig b/src/main.zig index bb3b40a..d7de10d 100644 --- a/src/main.zig +++ b/src/main.zig @@ -7,6 +7,7 @@ const meta = @import("meta"); const st = @import("st"); const api = st.api; const Client = st.http.Client; +const m = st.models; const agent = @import("agent"); const Config = agent.config.Config; @@ -32,13 +33,46 @@ fn juicyMain( // std.log.info("Registered agent\n{f}", .{pretty(register.value)}); + var af = try api.agent.own(client); + defer _ = af.cancel(io) catch {}; + var fleet_f = try api.fleet.listShips(client, .{}); defer _ = fleet_f.cancel(io) catch {}; + var traits = [_]m.systems.Waypoint.Trait{ .MARKETPLACE, .INDUSTRIAL, .OCEAN }; + var waypoints_f = try api.system.waypoints( + client, + (try m.parseSymbol("X1-TA72")).system, + .{ .traits = &traits }, + .{}, + ); + defer _ = waypoints_f.cancel(io) catch {}; + + const own = try af.await(io); + defer own.deinit(); + const fleet = try fleet_f.await(io); defer fleet.deinit(); - std.log.info("{f}", .{pretty(fleet.value)}); + const waypoints = try waypoints_f.await(io); + defer waypoints.deinit(); + + std.log.info("Agent: {f}", .{pretty(own.value)}); + std.log.info("Ships: {f}", .{pretty(fleet.value.data.?)}); + std.log.info("Waypoints with {any} traits: {f}", .{ traits, pretty(waypoints.value.data.?) }); + + if (waypoints.value.data.?.len > 0) { + var market_f = try api.system.market( + client, + waypoints.value.data.?[0].symbol.waypoint, + ); + defer _ = market_f.cancel(io) catch {}; + + const market = try market_f.await(io); + defer market.deinit(); + + std.log.info("Market: {f}", .{pretty(market.value.data.?)}); + } } pub fn main(init: std.process.Init) !void { diff --git a/src/st/api.zig b/src/st/api.zig index 40c9922..c73f3d5 100644 --- a/src/st/api.zig +++ b/src/st/api.zig @@ -1,3 +1,5 @@ +const std = @import("std"); + pub const fleet = @import("fleet.zig"); const st = @import("root.zig"); @@ -33,8 +35,8 @@ pub const agent = struct { symbol: []const u8, faction: models.factions.Symbol, ) !Response(models.agents.Register) { - return client.post( - Wrapper(models.agents.Register), + return client.postW( + models.agents.Register, "/register", .{}, .{ .symbol = symbol, .faction = faction }, @@ -43,8 +45,8 @@ pub const agent = struct { } pub fn list(client: *Client, opts: Query) !Response([]models.agents.Agent) { - return client.get( - Wrapper([]models.agents.Agent), + return client.getW( + []models.agents.Agent, "/agents{f}", .{opts}, .agent, @@ -52,8 +54,8 @@ pub const agent = struct { } pub fn get(client: *Client, symbol: []const u8) !Response(models.agents.Agent) { - return client.get( - Wrapper(models.agents.Agent), + return client.getW( + models.agents.Agent, "/agents/{s}", .{symbol}, .agent, @@ -61,11 +63,136 @@ pub const agent = struct { } pub fn own(client: *Client) !Response(models.agents.Agent) { - return client.get( - Wrapper(models.agents.Agent), + return client.getW( + models.agents.Agent, "/my/agent", .{}, .agent, ); } }; + +pub const system = struct { + const Symbol = models.systems.Symbol; + + pub fn get(client: *Client, symbol: Symbol.System) !Response(models.systems.System) { + return client.getW( + models.systems.System, + "/systems/{f}", + .{symbol}, + .agent, + ); + } + + pub fn list(client: *Client, opts: Query) !Response([]models.systems.System) { + return client.getW( + []models.systems.System, + "/systems{f}", + .{opts}, + .agent, + ); + } + + pub fn waypoint( + client: *Client, + waypoint_symbol: Symbol.Waypoint, + ) !Response(models.systems.Waypoint) { + return client.getW( + models.systems.Waypoint, + "/systems/{f}/waypoints/{f}", + .{ waypoint_symbol.system, waypoint_symbol }, + .agent, + ); + } + + pub const WaypointsFilter = struct { + type: ?models.systems.Waypoint.Type = null, + traits: []models.systems.Waypoint.Trait = &.{}, + + pub fn format(this: @This(), writer: *std.Io.Writer) std.Io.Writer.Error!void { + if (this.type) |ty| { + try writer.print("&type={s}", .{@tagName(ty)}); + } + if (this.traits.len > 0) { + for (this.traits) |trait| { + try writer.print("&traits={s}", .{@tagName(trait)}); + } + } + } + }; + + pub fn waypoints( + client: *Client, + symbol: Symbol.System, + filter: WaypointsFilter, + opts: Query, + ) !Response([]models.systems.Waypoint) { + return client.getW( + []models.systems.Waypoint, + "/systems/{f}/waypoints{f}{f}", + .{ symbol, opts, filter }, + .agent, + ); + } + + pub fn construction( + client: *Client, + waypoint_symbol: Symbol.Waypoint, + ) !Response(models.systems.Construction) { + return client.getW( + models.systems.Construction, + "/systems/{f}/waypoints/{f}/construction", + .{ waypoint_symbol.system, waypoint_symbol }, + .agent, + ); + } + + pub const SupplyConstruction = struct { + shipSymbol: []const u8, + tradeSymbol: models.inventory.AllItems.Combined, + units: u64, + + pub const Response = struct { + construction: models.systems.ConstructionSite, + cargo: models.inventory.Cargo, + }; + }; + + pub fn supplyConstruction( + client: *Client, + waypoint_symbol: Symbol.Waypoint, + supply: SupplyConstruction, + ) !Response(SupplyConstruction.Response) { + return client.postW( + SupplyConstruction.Response, + "/systems/{f}/waypoints/{f}/supply-construction", + .{ waypoint_symbol.system, waypoint_symbol }, + supply, + .agent, + ); + } + + pub fn market( + client: *Client, + waypoint_symbol: Symbol.Waypoint, + ) !Response(models.systems.Market) { + return client.getW( + models.systems.Market, + "/systems/{f}/waypoints/{f}/market", + .{ waypoint_symbol.system, waypoint_symbol }, + .agent, + ); + } + + pub fn shipyard( + client: *Client, + waypoint_symbol: Symbol.Waypoint, + ) !Response(models.systems.Shipyard) { + return client.getW( + models.systems.Shipyard, + "/systems/{f}/waypoints/{f}/shipyard", + .{ waypoint_symbol.system, waypoint_symbol }, + .agent, + ); + } +}; diff --git a/src/st/http.zig b/src/st/http.zig index ad819c2..dae6e1d 100644 --- a/src/st/http.zig +++ b/src/st/http.zig @@ -240,6 +240,16 @@ pub const Client = struct { return cl.request(T, path, args, .{ .auth = auth }); } + pub fn getW( + cl: *Client, + comptime T: type, + comptime path: []const u8, + args: anytype, + auth: AuthType, + ) !Response(T) { + return cl.get(models.Wrapper(T), path, args, auth); + } + pub fn post( cl: *Client, comptime T: type, @@ -258,6 +268,17 @@ pub const Client = struct { }); } + pub fn postW( + cl: *Client, + comptime T: type, + comptime path: []const u8, + args: anytype, + body: anytype, + auth: AuthType, + ) !Response(T) { + return cl.post(models.Wrapper(T), path, args, body, auth); + } + pub fn patch( cl: *Client, comptime T: type, @@ -276,6 +297,17 @@ pub const Client = struct { }); } + pub fn patchW( + cl: *Client, + comptime T: type, + comptime path: []const u8, + args: anytype, + body: anytype, + auth: AuthType, + ) !Response(T) { + return cl.patch(models.Wrapper(T), path, args, body, auth); + } + pub fn request( client: *Client, comptime T: type, diff --git a/src/st/models.zig b/src/st/models.zig index 87998c7..31c65e8 100644 --- a/src/st/models.zig +++ b/src/st/models.zig @@ -1,15 +1,19 @@ const std = @import("std"); +const prettym = @import("pretty"); pub const accounts = @import("models/accounts.zig"); pub const agents = @import("models/agents.zig"); pub const contracts = @import("models/contracts.zig"); pub const factions = @import("models/factions.zig"); pub const ships = @import("models/ships.zig"); +pub const systems = @import("models/systems.zig"); pub const inventory = @import("models/inventory.zig"); pub const Info = @import("models/Info.zig"); +pub const parseSymbol = systems.Symbol.parseSlice; + pub fn Wrapper(comptime T: type) type { return struct { data: ?T = null, @@ -35,6 +39,20 @@ pub const Query = struct { } }; +pub fn SymbolWrapper(comptime T: type) type { + return struct { + symbol: T, + + pub fn pretty( + this: *const @This(), + comptime ctx: prettym.Context, + run: *const prettym.Runtime, + ) error{WriteFailed}!void { + return run.pretty(ctx, this.symbol, .{ .skip_type_name = true }); + } + }; +} + pub const Error = struct { message: []const u8, code: ErrorCode, @@ -178,4 +196,5 @@ pub const ErrorCode = enum(u16) { constructionMaterialFulfilled = 4801, shipConstructionInvalidLocationError = 4802, unsupportedMediaTypeError = 5000, + _, }; diff --git a/src/st/models/agents.zig b/src/st/models/agents.zig index bd7212d..5882d80 100644 --- a/src/st/models/agents.zig +++ b/src/st/models/agents.zig @@ -8,10 +8,11 @@ const Contract = st.models.contracts.Contract; const Faction = st.models.factions.Faction; const FactionSymbol = st.models.factions.Symbol; const Ship = st.models.ships.Ship; +const Symbol = st.models.systems.Symbol; pub const Agent = struct { symbol: []const u8, - headquarters: []const u8, + headquarters: Symbol, credits: u64, startingFaction: FactionSymbol, shipCount: u64, diff --git a/src/st/models/contracts.zig b/src/st/models/contracts.zig index d1ba274..40991c6 100644 --- a/src/st/models/contracts.zig +++ b/src/st/models/contracts.zig @@ -1,6 +1,10 @@ +const m = @import("../models.zig"); +const factions = m.factions; +const Symbol = m.systems.Symbol; + pub const Contract = struct { id: []const u8, - factionSymbol: []const u8, + factionSymbol: factions.Symbol, type: Type = .PROCUREMENT, terms: Terms = .{}, accepted: bool = false, @@ -27,7 +31,7 @@ pub const Payment = struct { pub const Deliver = struct { tradeSymbol: []const u8, - destinationSymbol: []const u8, + destinationSymbol: Symbol, unitsRequired: u64, unitsFulfilled: u64, }; diff --git a/src/st/models/factions.zig b/src/st/models/factions.zig index 81f02d2..fff79b6 100644 --- a/src/st/models/factions.zig +++ b/src/st/models/factions.zig @@ -1,3 +1,5 @@ +const m = @import("../models.zig"); + pub const Symbol = enum { COSMIC, VOID, @@ -92,7 +94,7 @@ pub const Faction = struct { symbol: Symbol = .COSMIC, name: []const u8, description: []const u8, - headquarters: []const u8, + headquarters: m.systems.Symbol, traits: []Trait = &.{}, isRecruiting: bool = false, }; diff --git a/src/st/models/inventory.zig b/src/st/models/inventory.zig index 0f8dc81..f79071c 100644 --- a/src/st/models/inventory.zig +++ b/src/st/models/inventory.zig @@ -10,7 +10,7 @@ pub const Item = struct { symbol: AllItems.Combined, name: []const u8, description: []const u8, - units: u64, + units: u64 = 0, }; pub const AllItems = CombinedEnum(ItemSymbols); diff --git a/src/st/models/ships.zig b/src/st/models/ships.zig index 1c7cedb..1b5fe47 100644 --- a/src/st/models/ships.zig +++ b/src/st/models/ships.zig @@ -80,56 +80,19 @@ pub const Role = enum { }; pub const Nav = struct { - systemSymbol: []const u8, - waypointSymbol: []const u8, + systemSymbol: m.systems.Symbol, + waypointSymbol: m.systems.Symbol, route: Route, status: Status, flightMode: FlightMode, pub const Route = struct { - destination: Waypoint, - origin: Waypoint, + destination: m.systems.WaypointPreview, + origin: m.systems.WaypointPreview, departureTime: []const u8, arrival: []const u8, }; - pub const Waypoint = struct { - symbol: []const u8, - type: Type, - systemSymbol: []const u8, - x: i64, - y: i64, - - pub const Type = enum { - PLANET, - GAS_GIANT, - MOON, - ORBITAL_STATION, - JUMP_GATE, - ASTEROID_FIELD, - ASTEROID, - ENGINEERED_ASTEROID, - ASTEROID_BASE, - NEBULA, - DEBRIS_FIELD, - GRAVITY_WELL, - ARTIFICIAL_GRAVITY_WELL, - FUEL_STATION, - }; - - pub fn pretty( - this: *const @This(), - comptime ctx: prettym.Context, - run: *const prettym.Runtime, - ) error{WriteFailed}!void { - run.setColor(ctx, .value); - try run.write(this.symbol); - run.setColor(ctx, .dim); - try run.print("[{s}] ", .{@tagName(this.type)}); - run.resetColor(); - } - }; - pub const Status = enum { IN_TRANSIT, IN_ORBIT, @@ -155,7 +118,12 @@ pub const Nav = struct { run.resetColor(); run.setColor(ctx, .value); - try this.route.origin.pretty(ctx, run); + try this.route.origin.prettyInline(ctx, run); + try run.pretty( + ctx, + this.route.origin, + .{ .force_inline = true, .skip_type_name = true }, + ); run.setColor(ctx, .dim); try run.write(" -> "); run.resetColor(); @@ -172,7 +140,11 @@ pub const Nav = struct { }, } - try this.route.destination.pretty(ctx, run); + try run.pretty( + ctx, + this.route.destination, + .{ .force_inline = true, .skip_type_name = true }, + ); } }; @@ -261,3 +233,19 @@ pub const Requirements = struct { crew: ?u64 = null, slots: ?u64 = null, }; + +pub const Type = enum { + SHIP_PROBE, + SHIP_MINING_DRONE, + SHIP_SIPHON_DRONE, + SHIP_INTERCEPTOR, + SHIP_LIGHT_HAULER, + SHIP_COMMAND_FRIGATE, + SHIP_EXPLORER, + SHIP_HEAVY_FREIGHTER, + SHIP_LIGHT_SHUTTLE, + SHIP_ORE_HOUND, + SHIP_REFINING_FREIGHTER, + SHIP_SURVEYOR, + SHIP_BULK_FREIGHTER, +}; diff --git a/src/st/models/systems.zig b/src/st/models/systems.zig new file mode 100644 index 0000000..981670f --- /dev/null +++ b/src/st/models/systems.zig @@ -0,0 +1,351 @@ +const std = @import("std"); +const Allocator = std.mem.Allocator; +const json = std.json; + +const prettym = @import("pretty"); + +const m = @import("../models.zig"); + +pub const Symbol = union(Symbol.Type) { + sector: u8, + system: Symbol.System, + waypoint: Symbol.Waypoint, + + pub const Type = enum { sector, system, waypoint }; + + pub const System = struct { + sector: u8, + symbol: []const u8, + + pub fn format(this: @This(), writer: *std.Io.Writer) std.Io.Writer.Error!void { + try writer.print("X{}-{s}", .{ this.sector, this.symbol }); + } + }; + + pub const Waypoint = struct { + system: Symbol.System, + symbol: []const u8, + + pub fn format(this: @This(), writer: *std.Io.Writer) std.Io.Writer.Error!void { + try writer.print("{f}-{s}", .{ this.system, this.symbol }); + } + }; + + pub fn parseSlice(slice: []const u8) !Symbol { + var tokens = std.mem.tokenizeScalar(u8, slice, '-'); + const sector_raw = tokens.next() orelse return error.InvalidSymbol; + + std.debug.assert(sector_raw.len == 2); + std.debug.assert(sector_raw[0] == 'X'); + + const sector = std.fmt.parseInt(u8, sector_raw[1..], 10) catch return error.InvalidSector; + const system_raw = tokens.next(); + + if (system_raw) |system| { + const sys = Symbol.System{ .sector = sector, .symbol = system }; + if (tokens.next()) |waypoint| { + return Symbol{ .waypoint = .{ + .system = sys, + .symbol = waypoint, + } }; + } + return Symbol{ .system = sys }; + } else { + return Symbol{ .sector = sector }; + } + } + + pub fn jsonParse( + allocator: Allocator, + source: anytype, + options: json.ParseOptions, + ) json.ParseError(@TypeOf(source.*))!Symbol { + const string = try json.innerParse([]const u8, allocator, source, options); + return parseSlice(string) catch return error.MissingField; + } + + pub fn format(this: @This(), writer: *std.Io.Writer) std.Io.Writer.Error!void { + switch (this) { + .sector => |sector| { + try writer.print("X{}", .{sector}); + }, + inline else => |e| try writer.print("{f}", .{e}), + } + } + + pub fn pretty( + this: *const @This(), + comptime ctx: prettym.Context, + run: *const prettym.Runtime, + ) error{WriteFailed}!void { + run.setColor(ctx, .value); + try run.print("{f}", .{this}); + run.resetColor(); + } +}; + +pub const System = struct { + constellation: []const u8, + symbol: Symbol, + sectorSymbol: Symbol, + type: Type, + x: i64, + y: i64, + waypoints: []WaypointPreview, + factions: []Faction, + name: []const u8, + + pub const Type = enum { + NEUTRON_STAR, + RED_STAR, + ORANGE_STAR, + BLUE_STAR, + YOUNG_STAR, + WHITE_DWARF, + BLACK_HOLE, + HYPERGIANT, + NEBULA, + UNSTABLE, + }; +}; + +pub const Waypoint = struct { + symbol: Symbol, + systemSymbol: Symbol, + type: Type, + x: i64, + y: i64, + faction: Faction, + traits: []m.SymbolWrapper(Trait), + modifiers: []Modifier, + chart: Chart, + isUnderConstruction: bool, + + orbitals: []m.SymbolWrapper([]const u8), + orbits: ?[]const u8 = null, + + pub fn unwrapTraits(this: *const @This(), alloc: std.mem.Allocator) ![]Trait { + var buf = try alloc.alloc(Trait, this.traits.len); + for (this.traits, 0..) |trait, i| { + buf[i] = trait.symbol; + } + return buf; + } + + pub const Type = enum { + PLANET, + GAS_GIANT, + MOON, + ORBITAL_STATION, + JUMP_GATE, + ASTEROID_FIELD, + ASTEROID, + ENGINEERED_ASTEROID, + ASTEROID_BASE, + NEBULA, + DEBRIS_FIELD, + GRAVITY_WELL, + ARTIFICIAL_GRAVITY_WELL, + FUEL_STATION, + }; + + pub const Trait = enum { + UNCHARTED, + UNDER_CONSTRUCTION, + MARKETPLACE, + SHIPYARD, + OUTPOST, + SCATTERED_SETTLEMENTS, + SPRAWLING_CITIES, + MEGA_STRUCTURES, + PIRATE_BASE, + OVERCROWDED, + HIGH_TECH, + CORRUPT, + BUREAUCRATIC, + TRADING_HUB, + INDUSTRIAL, + BLACK_MARKET, + RESEARCH_FACILITY, + MILITARY_BASE, + SURVEILLANCE_OUTPOST, + EXPLORATION_OUTPOST, + MINERAL_DEPOSITS, + COMMON_METAL_DEPOSITS, + PRECIOUS_METAL_DEPOSITS, + RARE_METAL_DEPOSITS, + METHANE_POOLS, + ICE_CRYSTALS, + EXPLOSIVE_GASES, + STRONG_MAGNETOSPHERE, + VIBRANT_AURORAS, + SALT_FLATS, + CANYONS, + PERPETUAL_DAYLIGHT, + PERPETUAL_OVERCAST, + DRY_SEABEDS, + MAGMA_SEAS, + SUPERVOLCANOES, + ASH_CLOUDS, + VAST_RUINS, + MUTATED_FLORA, + TERRAFORMED, + EXTREME_TEMPERATURES, + EXTREME_PRESSURE, + DIVERSE_LIFE, + SCARCE_LIFE, + FOSSILS, + WEAK_GRAVITY, + STRONG_GRAVITY, + CRUSHING_GRAVITY, + TOXIC_ATMOSPHERE, + CORROSIVE_ATMOSPHERE, + BREATHABLE_ATMOSPHERE, + THIN_ATMOSPHERE, + JOVIAN, + ROCKY, + VOLCANIC, + FROZEN, + SWAMP, + BARREN, + TEMPERATE, + JUNGLE, + OCEAN, + RADIOACTIVE, + MICRO_GRAVITY_ANOMALIES, + DEBRIS_CLUSTER, + DEEP_CRATERS, + SHALLOW_CRATERS, + UNSTABLE_COMPOSITION, + HOLLOWED_INTERIOR, + STRIPPED, + }; + + pub const Modifier = struct { + symbol: ModSymbol, + name: []const u8, + description: []const u8, + + pub const ModSymbol = enum { + STRIPPED, + UNSTABLE, + RADIATION_LEAK, + CRITICAL_LIMIT, + CIVIL_UNREST, + }; + }; + + pub const Chart = struct { + waypointSymbol: Symbol, + submittedBy: []const u8, + submittedOn: []const u8, + }; +}; + +pub const WaypointPreview = struct { + symbol: Symbol, + type: Waypoint.Type, + x: i64, + y: i64, + orbitals: []m.SymbolWrapper(Symbol) = &.{}, + orbits: ?Symbol = null, + + pub fn prettyInline( + this: *const @This(), + comptime ctx: prettym.Context, + run: *const prettym.Runtime, + ) error{WriteFailed}!void { + run.setColor(ctx, .value); + try run.print("{f}", .{this.symbol}); + run.setColor(ctx, .dim); + try run.print("[{s}]({}, {}) ", .{ @tagName(this.type), this.x, this.y }); + run.resetColor(); + } +}; + +pub const ConstructionSite = struct { + symbol: Symbol, + isComplete: bool, + materials: []Material, + + pub const Material = struct { + tradeSymbol: m.inventory.AllItems.Combined, + required: i64, + fulfilled: i64, + }; +}; + +pub const Market = struct { + symbol: Symbol, + exports: []m.inventory.Item = &.{}, + imports: []m.inventory.Item = &.{}, + exchange: []m.inventory.Item = &.{}, + transactions: ?[]Transaction = null, + tradeGoods: ?[]TradeGood = null, + + pub const Transaction = struct { + waypointSymbol: Symbol, + shipSymbol: []const u8, + tradeSymbol: []const u8, + type: Type, + units: u64, + pricePerUnit: u64, + totalPrice: u64, + timestamp: []const u8, + + pub const Type = enum { PURCHASE, SELL }; + }; + + pub const TradeGood = struct { + symbol: m.inventory.AllItems.Combined, + type: TradeGood.Type, + tradeVolume: u64, + supply: Supply, + activity: ?Activity = null, + purchasePrice: u64, + sellPrice: u64, + + pub const Type = enum { EXPORT, IMPORT, EXCHANGE }; + }; + + pub const Supply = enum { SCARCE, LIMITED, MODERATE, HIGH, ABUNDANT }; + pub const Activity = enum { WEAK, GROWING, STRONG, RESTRICTED }; +}; + +pub const JumpGate = struct { + symbol: Symbol, + connections: []Symbol, +}; + +pub const Shipyard = struct { + symbol: Symbol, + shipTypes: struct { type: m.ships.Type }, + transactions: []Transaction, + modificationsFee: i64, + + pub const Transaction = struct { + waypointSymbol: Symbol, + shipType: m.ships.Type, + price: u64, + agentSymbol: []const u8, + timestamp: []const u8, + }; + + pub const Ship = struct { + activity: Market.Activity, + supply: Market.Supply, + purchasePrice: u64, + + type: m.ships.Type, + name: []const u8, + description: []const u8, + crew: m.ships.Crew, + frame: m.ships.Frame, + reactor: m.ships.Reactor, + engine: m.ships.Engine, + modules: []m.ships.Module, + mounts: []m.ships.Mount, + }; +}; + +pub const Faction = m.SymbolWrapper(m.factions.Symbol); diff --git a/src/st/root.zig b/src/st/root.zig index 9adcb90..db51053 100644 --- a/src/st/root.zig +++ b/src/st/root.zig @@ -4,5 +4,5 @@ pub const models = @import("models.zig"); test { const testing = @import("std").testing; - testing.refAllDecls(@This()); + testing.refAllDecls(models); } -- 2.51.2