|
|
@@ -15,6 +15,7 @@ class Args(tap.Tap):
|
|
|
planets: tuple[str, ...]
|
|
|
weight: float
|
|
|
volume: float
|
|
|
+ include_ship: tuple[str, ...] = ()
|
|
|
|
|
|
def configure(self) -> None:
|
|
|
self.add_argument('planets', nargs='+', metavar='planet') # take planets as positional args instead of flag
|
|
|
@@ -23,6 +24,20 @@ def main() -> None:
|
|
|
args = Args().parse_args()
|
|
|
|
|
|
planets = [Planet(fio_burn) for fio_burn in get_fio_burn(args.planets)]
|
|
|
+ if args.include_ship:
|
|
|
+ stores: typing.Sequence[Storage] = cache.get('https://rest.fnar.net/storage/' + config.username,
|
|
|
+ headers={'Authorization': config.fio_api_key})
|
|
|
+ for ship in args.include_ship:
|
|
|
+ ship_name, planet_name = ship.casefold().split('=')
|
|
|
+ for store in stores:
|
|
|
+ if store['Type'] == 'SHIP_STORE' and store['Name'].casefold() == ship_name:
|
|
|
+ break
|
|
|
+ else:
|
|
|
+ raise Exception(f'ship storage {ship_name} not found')
|
|
|
+ (planet,) = (p for p in planets if p.name.casefold() == planet_name)
|
|
|
+ for item in store['StorageItems']:
|
|
|
+ planet.inventory[item['MaterialTicker']] = planet.inventory.get(item['MaterialTicker'], 0) + item['MaterialAmount']
|
|
|
+
|
|
|
raw_materials: typing.Sequence[Material] = cache.get('https://rest.fnar.net/material/allmaterials')
|
|
|
materials = {mat['Ticker']: mat for mat in raw_materials}
|
|
|
|
|
|
@@ -173,6 +188,11 @@ class Inventory(typing.TypedDict):
|
|
|
MaterialTicker: str
|
|
|
MaterialAmount: int
|
|
|
|
|
|
+class Storage(typing.TypedDict):
|
|
|
+ Name: str
|
|
|
+ StorageItems: list[Inventory]
|
|
|
+ Type: typing.Literal['STORE'] | typing.Literal['WAREHOUSE_STORE'] | typing.Literal['FTL_FUEL_STORE'] | typing.Literal['STL_FUEL_STORE'] | typing.Literal['SHIP_STORE']
|
|
|
+
|
|
|
class Material(typing.TypedDict):
|
|
|
Ticker: str
|
|
|
Weight: float
|