# frozen_string_literal: true class SpaceTraders::Ship < SpaceTraders::Model attributes :symbol, :registration, :nav, :crew, :frame, :reactor, :engine, :cooldown, :modules, :mounts, :cargo, :fuel class Helper def initialize(ship) @ship = ship end def waypoints Waypoint.waypoints(@ship.client, system: @ship.nav["systemSymbol"]) end end attr_reader :helper def initialize(client, **params) super @helper = Helper.new(self) end def self.my_ships(client, page: 1) list = client.ships.my_ships(page: 1) list.map { new(client, **_1) } end def reload! update(**client.ships.my_ship(id: symbol)) self end def orbit! client.ships.my_ship_orbit(id: symbol) self end def refine!(material:) client.ships.my_ship_refine(id: symbol, produce: material) self end def survey! client.ships.my_ship_survey(id: symbol) self end def extract!(signature:, symbol:, deposits:, expiration:, size:) client.ships.my_ship_extract({ id: symbol }, { signature:, symbol:, deposits:, expiration:, size: }) self end def siphon! client.ships.my_ship_siphon(id: symbol) self end def jump!(waypoint:) client.ships.my_ship_jump({ id: symbol }, { waypointSymbol: waypoint }) self end def navigate!(waypoint:) client.ships.my_ship_navigate({ id: symbol }, { waypointSymbol: waypoint }) self end def warp!(waypoint:) client.ships.my_ship_warp({ id: symbol }, { waypointSymbol: waypoint }) self end def refuel! client.ships.my_ship_refuel(id: symbol) self end def sell!(cargo:, unit:) client.ships.my_ship_warp({ id: symbol }, { cargo:, unit: }) self end module Type PROBE = "SHIP_PROBE" MINING_DRONE = "SHIP_MINING_DRONE" SIPHON_DRONE = "SHIP_SIPHON_DRONE" INTERCEPTOR = "SHIP_INTERCEPTOR" LIGHT_HAULER = "SHIP_LIGHT_HAULER" COMMAND_FRIGATE = "SHIP_COMMAND_FRIGATE" EXPLORER = "SHIP_EXPLORER" HEAVY_FREIGHTER = "SHIP_HEAVY_FREIGHTER" LIGHT_SHUTTLE = "SHIP_LIGHT_SHUTTLE" ORE_HOUND = "SHIP_ORE_HOUND" REFINING_FREIGHTER = "SHIP_REFINING_FREIGHTER" SURVEYOR = "SHIP_SURVEYOR" end module Material IRON = "IRON" COPPER = "COPPER" SILVER = "SILVER" GOLD = "GOLD" ALUMINUM = "ALUMINUM" PLATINUM = "PLATINUM" URANITE = "URANITE" MERITIUM = "MERITIUM" FUEL = "FUEL" end end