- tools/simulate.py + puga/simulate.py: replica of PRUNplanner's simulator (flows and efficiency verified against screenshots), reports real new capex (planned minus built) - tools/scan.py: staffing variants, freight, HQ/experts, --planet mode, demolish-later, --min-n as a pure market-size filter, --json output - tools/history.py, tools/persistence.py: margin history and short-horizon payback checks - tools/plan_push.py: guarded delete; tools/state.py: syncs to empire/ - README with features and setup; CLAUDE.md made generic - Own-empire material (profile, state, plans, notes) moved to gitignored empire/; generic examples in plans/examples and state/company.example.yaml Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
40 lines
1.8 KiB
Python
40 lines
1.8 KiB
Python
"""Public FIO REST (rest.fnar.net). Static game data caches long; market data short."""
|
|
from .cache import get_json
|
|
|
|
BASE = "https://rest.fnar.net"
|
|
STATIC, MARKET = 24 * 3600, 15 * 60
|
|
|
|
|
|
def _g(path: str, ttl: int, refresh: bool = False):
|
|
return get_json(BASE + path, ttl, refresh=refresh)
|
|
|
|
|
|
def exchange_all(refresh=False): return _g("/exchange/all", MARKET, refresh)
|
|
def order_book(mat: str, cx: str, refresh=False):
|
|
"""Full book: BuyingOrders / SellingOrders lists (price + quantity). Short TTL."""
|
|
return _g(f"/exchange/{mat}.{cx}", 5 * 60, refresh)
|
|
def cxpc(mat: str, cx: str, refresh=False):
|
|
return _g(f"/exchange/cxpc/{mat}.{cx}", 3600, refresh)
|
|
def materials(refresh=False): return _g("/material/allmaterials", STATIC, refresh)
|
|
def recipes(refresh=False): return _g("/recipes/allrecipes", STATIC, refresh)
|
|
def buildings(refresh=False): return _g("/building/allbuildings", STATIC, refresh)
|
|
def planets_full(refresh=False): return _g("/planet/allplanets/full", STATIC, refresh)
|
|
def workforce_needs(refresh=False): return _g("/global/workforceneeds", STATIC, refresh)
|
|
def systems(refresh=False): return _g("/systemstars", STATIC, refresh)
|
|
def stations(refresh=False): return _g("/exchange/station", STATIC, refresh)
|
|
|
|
|
|
def own(path: str, ttl: int = 300, refresh: bool = False):
|
|
"""Authenticated FIO REST (own data: /sites/{user}, /storage/{user}, /production/{user}, /ship/ships/{user}...).
|
|
Auth: `Authorization: <FIO_REST_KEY>` (verified 2026-09-18). FIO_API_KEY does NOT work on rest.fnar.net."""
|
|
from . import config
|
|
key = config.get("FIO_REST_KEY")
|
|
if not key:
|
|
raise RuntimeError("FIO_REST_KEY missing in .env")
|
|
return get_json(BASE + path, ttl, headers={"Authorization": key}, refresh=refresh)
|
|
|
|
|
|
def me() -> str:
|
|
from . import config
|
|
return config.get("FIO_USERNAME", "")
|