#!/usr/bin/env python3 """List this account's OPEN CONTD contract offers (the NPC logistics-officer pool shown in APEX's CONTD panel - usually 3 at a time, only one acceptable) with payment, materials received/supplied, freight legs the player must personally fly, and net (see puga/contd.py's docstring for exactly which condition types are costs vs rewards vs the player's own job). Judging the actual best deal is NOT this tool's job for anything it flags as unpriced (EXPLORATION, REPAIR_SHIP, etc.) or for a freight leg's real fuel cost (flagged with weight/volume, price via puga.shipping yourself) - it reports the breakdown, the caller reasons about context. puga contd puga contd --cx AI1 """ import argparse, sys from pathlib import Path sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) from puga import config, contd def main(): ap = argparse.ArgumentParser() ap.add_argument("--cx", default=config.DEFAULT_CX) a = ap.parse_args() contracts = contd.open_contracts() if not contracts: print("no OPEN contract offers right now") return for c in contracts: r = contd.evaluate(c, a.cx) print(f"\n{r['id']} partner={r['partner']} deadline {r['deadline_days']:.1f}d" + (" +reputation" if r["reputation"] else "")) print(f" payment: {r['payment']:,.2f} AIC") for rew in r["rewards"]: print(f" receives: {rew['ticker']} x{rew['qty']:g} @ {rew['address']} market value {rew['value']:,.0f}") for cost in r["costs"]: flag = " SHORT: book can't fill this qty" if cost["short"] else "" print(f" must supply: {cost['ticker']} x{cost['qty']:g} @ {cost['address']} buy-fresh cost {cost['value']:,.0f}{flag}") for ltype, addr, wgt, vol in r["freight_legs"]: print(f" YOUR FREIGHT LEG: {ltype} @ {addr} {wgt:g}t / {vol:g}m3 - price via puga.shipping, not included in net") for ftype, addr in r["flags"]: print(f" UNPRICED CONDITION: {ftype}" + (f" @ {addr}" if addr else "") + " - context-dependent, judge separately") print(f" reward value: {r['reward_value']:,.0f} cost value: {r['cost_value']:,.0f} -> net (payment + reward - cost): {r['net']:,.0f}") priceable = [c for c in contracts if not contd.evaluate(c, a.cx)["flags"]] if len(priceable) == len(contracts): best = max(contracts, key=lambda c: contd.evaluate(c, a.cx)["net"]) print(f"\nby payment+reward net alone, best priced: {best['ContractLocalId']}" " - unpriced/flagged conditions (freight legs, exploration, etc.) still need judgment") if __name__ == "__main__": main()