|
@@ -1,4 +1,8 @@
|
|
|
|
|
+from __future__ import annotations
|
|
|
|
|
+import collections
|
|
|
|
|
+import dataclasses
|
|
|
import sys
|
|
import sys
|
|
|
|
|
+import typing
|
|
|
|
|
|
|
|
import httpx
|
|
import httpx
|
|
|
|
|
|
|
@@ -8,15 +12,50 @@ def main():
|
|
|
(username,) = sys.argv[1:]
|
|
(username,) = sys.argv[1:]
|
|
|
prod = httpx.get('https://api.punoted.net/v1/production/user?username=' + username,
|
|
prod = httpx.get('https://api.punoted.net/v1/production/user?username=' + username,
|
|
|
headers={'X-Data-Token': config.punoted_api_key}).raise_for_status().json()
|
|
headers={'X-Data-Token': config.punoted_api_key}).raise_for_status().json()
|
|
|
|
|
+ ms_in_day = 24 * 60 * 60 * 1000
|
|
|
for line in prod:
|
|
for line in prod:
|
|
|
print(line['PlanetName'], f'{line["Capacity"]}×{line["Type"]}', line['Efficiency'], line['Condition'])
|
|
print(line['PlanetName'], f'{line["Capacity"]}×{line["Type"]}', line['Efficiency'], line['Condition'])
|
|
|
- for orders in line['Orders']:
|
|
|
|
|
- outputs = set()
|
|
|
|
|
- if orders['CompletedPercentage'] is not None:
|
|
|
|
|
|
|
+ production: dict[str, Production] = {}
|
|
|
|
|
+ for order in line['Orders']:
|
|
|
|
|
+ if order['CompletedPercentage'] is not None:
|
|
|
continue
|
|
continue
|
|
|
- for output in orders['Outputs']:
|
|
|
|
|
- outputs.add(output['MaterialTicker'])
|
|
|
|
|
- print('\t' + ', '.join(outputs))
|
|
|
|
|
|
|
+ for output in order['Outputs']:
|
|
|
|
|
+ production[output['ProductionLineOutputId']] = Production(
|
|
|
|
|
+ ticker=output['MaterialTicker'],
|
|
|
|
|
+ amount=output['MaterialAmount'],
|
|
|
|
|
+ duration_ms=order['DurationMs']
|
|
|
|
|
+ )
|
|
|
|
|
+ line_queued_time = sum(p.duration_ms for p in production.values())
|
|
|
|
|
+ line_outputs: dict[str, float] = collections.defaultdict(float)
|
|
|
|
|
+ for p in production.values():
|
|
|
|
|
+ amount = p.amount * ms_in_day / line_queued_time * line['Capacity']
|
|
|
|
|
+ line_outputs[p.ticker] += amount
|
|
|
|
|
+ for ticker, amount in line_outputs.items():
|
|
|
|
|
+ print(f'\t{amount}×{ticker}')
|
|
|
|
|
+
|
|
|
|
|
+@dataclasses.dataclass
|
|
|
|
|
+class Production:
|
|
|
|
|
+ ticker: str
|
|
|
|
|
+ amount: float
|
|
|
|
|
+ duration_ms: int
|
|
|
|
|
+
|
|
|
|
|
+class ProductionLine(typing.TypedDict):
|
|
|
|
|
+ PlanetName: str
|
|
|
|
|
+ Type: str
|
|
|
|
|
+ Capacity: int
|
|
|
|
|
+ Efficiency: float
|
|
|
|
|
+ Condition: float
|
|
|
|
|
+ Orders: typing.Sequence[ProductionOrder]
|
|
|
|
|
+
|
|
|
|
|
+class ProductionOrder(typing.TypedDict):
|
|
|
|
|
+ CompletedPercentage: float | None
|
|
|
|
|
+ DurationMs: int
|
|
|
|
|
+ Outputs: typing.Sequence[ProductionOutput]
|
|
|
|
|
+
|
|
|
|
|
+class ProductionOutput(typing.TypedDict):
|
|
|
|
|
+ ProductionLineOutputId: str
|
|
|
|
|
+ MaterialTicker: str
|
|
|
|
|
+ MaterialAmount: float
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
if __name__ == '__main__':
|
|
|
main()
|
|
main()
|