From 5e60919e01064229fa258225de220011d05b1601 Mon Sep 17 00:00:00 2001 From: Keith Solomon Date: Wed, 11 Feb 2026 22:53:42 -0600 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8feature:=20Buy=20ships=20page=20update?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buy-ships.php | 44 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/buy-ships.php b/buy-ships.php index 82a3476..c1602d3 100644 --- a/buy-ships.php +++ b/buy-ships.php @@ -23,6 +23,7 @@ $ships = array(); $shipyards = array(); $agent = array(); $currentSystemSymbol = ''; +$waypointShipMap = array(); if (! is_string( $token ) || trim( $token ) === '' ) { $envToken = getenv( 'SPACETRADERS_TOKEN' ); @@ -67,6 +68,22 @@ try { $agent = $agentResponse['data'] ?? $agentResponse; $ships = $shipsResponse['data'] ?? $shipsResponse; + foreach ( $ships as $ship ) { + $shipSymbol = (string) ( $ship['symbol'] ?? '' ); + $shipStatus = (string) ( $ship['nav']['status'] ?? '' ); + $waypointSymbol = (string) ( $ship['nav']['waypointSymbol'] ?? '' ); + + if ($shipSymbol === '' || $waypointSymbol === '' || $shipStatus === 'IN_TRANSIT' ) { + continue; + } + + if (! isset( $waypointShipMap[ $waypointSymbol ] ) ) { + $waypointShipMap[ $waypointSymbol ] = array(); + } + + $waypointShipMap[ $waypointSymbol ][] = $shipSymbol; + } + if (isset( $ships[0]['nav']['systemSymbol'] ) && is_string( $ships[0]['nav']['systemSymbol'] ) ) { $currentSystemSymbol = $ships[0]['nav']['systemSymbol']; } @@ -119,6 +136,7 @@ try { 'waypoint' => $waypoint, 'shipTypes' => array(), 'prices' => array(), + 'shipSymbols' => (array) ( $waypointShipMap[ $waypointSymbol ] ?? array() ), 'error' => '', ); @@ -127,6 +145,15 @@ try { $shipyardData = $shipyardResponse['data'] ?? array(); $record['shipTypes'] = (array) ( $shipyardData['shipTypes'] ?? array() ); + $shipsForSale = (array) ( $shipyardData['ships'] ?? array() ); + foreach ( $shipsForSale as $shipForSale ) { + $shipType = (string) ( $shipForSale['type'] ?? '' ); + $price = (int) ( $shipForSale['purchasePrice'] ?? 0 ); + if ($shipType !== '' && $price > 0 ) { + $record['prices'][ $shipType ] = $price; + } + } + $transactions = (array) ( $shipyardData['transactions'] ?? array() ); foreach ( $transactions as $transaction ) { $shipType = (string) ( $transaction['shipType'] ?? '' ); @@ -184,13 +211,6 @@ try { -

- Credits: - - | Current System: - -

-
No shipyards were found in your current system. @@ -203,6 +223,14 @@ try { Shipyard: +

+ Ships Here: + +

+

@@ -216,7 +244,7 @@ try { - + 0 ? number_format( $knownPrice ) : 'Unknown'; ?>