|
@@ -26,7 +26,7 @@ def main() -> None:
|
|
|
|
|
|
|
|
planets = [Planet(fio_burn) for fio_burn in get_fio_burn(args.planets)]
|
|
planets = [Planet(fio_burn) for fio_burn in get_fio_burn(args.planets)]
|
|
|
if args.include_ship:
|
|
if args.include_ship:
|
|
|
- stores: typing.Sequence[Storage] = cache.get('https://rest.fnar.net/storage/' + config.username,
|
|
|
|
|
|
|
+ stores: typing.Sequence[market.Storage] = cache.get('https://rest.fnar.net/storage/' + config.username,
|
|
|
headers={'Authorization': config.fio_api_key})
|
|
headers={'Authorization': config.fio_api_key})
|
|
|
for ship in args.include_ship:
|
|
for ship in args.include_ship:
|
|
|
ship_name, planet_name = ship.casefold().split('=')
|
|
ship_name, planet_name = ship.casefold().split('=')
|
|
@@ -64,7 +64,8 @@ def main() -> None:
|
|
|
buys: dict[str, dict[str, int]] = {}
|
|
buys: dict[str, dict[str, int]] = {}
|
|
|
iteration_weight = iteration_volume = 0
|
|
iteration_weight = iteration_volume = 0
|
|
|
for planet in planets:
|
|
for planet in planets:
|
|
|
- buy, weight_used, volume_used = planet.buy_for_target(materials, target_days)
|
|
|
|
|
|
|
+ buy = planet.buy_for_target(target_days)
|
|
|
|
|
+ weight_used, volume_used = shipping_used(materials, buy)
|
|
|
iteration_weight += weight_used
|
|
iteration_weight += weight_used
|
|
|
iteration_volume += volume_used
|
|
iteration_volume += volume_used
|
|
|
if iteration_weight > args.weight or iteration_volume > args.volume:
|
|
if iteration_weight > args.weight or iteration_volume > args.volume:
|
|
@@ -141,6 +142,13 @@ def get_fio_burn(planet_names: typing.Sequence[str]) -> typing.Iterator[FIOBurn]
|
|
|
else:
|
|
else:
|
|
|
raise ValueError(name + ' not found')
|
|
raise ValueError(name + ' not found')
|
|
|
|
|
|
|
|
|
|
+def shipping_used(materials: dict[str, Material], buy: dict[str, int]) -> tuple[float, float]:
|
|
|
|
|
+ weight = volume = 0
|
|
|
|
|
+ for ticker, amount in buy.items():
|
|
|
|
|
+ weight += amount * materials[ticker]['Weight']
|
|
|
|
|
+ volume += amount * materials[ticker]['Volume']
|
|
|
|
|
+ return weight, volume
|
|
|
|
|
+
|
|
|
def cyan(text: str) -> str:
|
|
def cyan(text: str) -> str:
|
|
|
return '\033[36m' + text + '\033[0m'
|
|
return '\033[36m' + text + '\033[0m'
|
|
|
|
|
|
|
@@ -150,7 +158,7 @@ class FIOBurn(typing.TypedDict):
|
|
|
Error: typing.Any
|
|
Error: typing.Any
|
|
|
OrderConsumption: list[Amount]
|
|
OrderConsumption: list[Amount]
|
|
|
WorkforceConsumption: list[Amount]
|
|
WorkforceConsumption: list[Amount]
|
|
|
- Inventory: list[Inventory]
|
|
|
|
|
|
|
+ Inventory: list[market.StorageItem]
|
|
|
OrderProduction: list[Amount]
|
|
OrderProduction: list[Amount]
|
|
|
|
|
|
|
|
@dataclasses.dataclass(init=False, eq=False, slots=True)
|
|
@dataclasses.dataclass(init=False, eq=False, slots=True)
|
|
@@ -173,8 +181,7 @@ class Planet:
|
|
|
c['net_consumption'] = net
|
|
c['net_consumption'] = net
|
|
|
self.net_consumption.append(c)
|
|
self.net_consumption.append(c)
|
|
|
|
|
|
|
|
- def buy_for_target(self, materials: dict[str, Material], target_days: float) -> tuple[dict[str, int], float, float]:
|
|
|
|
|
- weight_used = volume_used = 0
|
|
|
|
|
|
|
+ def buy_for_target(self, target_days: float) -> dict[str, int]:
|
|
|
buy: dict[str, int] = {}
|
|
buy: dict[str, int] = {}
|
|
|
for consumption in self.net_consumption:
|
|
for consumption in self.net_consumption:
|
|
|
ticker = consumption['MaterialTicker']
|
|
ticker = consumption['MaterialTicker']
|
|
@@ -183,24 +190,13 @@ class Planet:
|
|
|
days = avail / daily_consumption
|
|
days = avail / daily_consumption
|
|
|
if days < target_days:
|
|
if days < target_days:
|
|
|
buy[ticker] = math.ceil((target_days - days) * daily_consumption)
|
|
buy[ticker] = math.ceil((target_days - days) * daily_consumption)
|
|
|
- weight_used += buy[ticker] * materials[ticker]['Weight']
|
|
|
|
|
- volume_used += buy[ticker] * materials[ticker]['Volume']
|
|
|
|
|
- return buy, weight_used, volume_used
|
|
|
|
|
|
|
+ return buy
|
|
|
|
|
|
|
|
class Amount(typing.TypedDict):
|
|
class Amount(typing.TypedDict):
|
|
|
MaterialTicker: str
|
|
MaterialTicker: str
|
|
|
DailyAmount: float
|
|
DailyAmount: float
|
|
|
net_consumption: float
|
|
net_consumption: float
|
|
|
|
|
|
|
|
-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):
|
|
class Material(typing.TypedDict):
|
|
|
Ticker: str
|
|
Ticker: str
|
|
|
Weight: float
|
|
Weight: float
|