Smart hit assignation and chain monitoring
This commit is contained in:
@@ -5,9 +5,8 @@ from config import TORN_API_KEY
|
||||
from .ffscouter import fetch_batch_stats
|
||||
from .server_state import STATE
|
||||
|
||||
# -----------------------------
|
||||
|
||||
# Tasks
|
||||
# -----------------------------
|
||||
friendly_status_task = None
|
||||
enemy_status_task = None
|
||||
|
||||
@@ -15,9 +14,8 @@ enemy_status_task = None
|
||||
friendly_lock = asyncio.Lock()
|
||||
enemy_lock = asyncio.Lock()
|
||||
|
||||
# -----------------------------
|
||||
|
||||
# Populate faction (memory only)
|
||||
# -----------------------------
|
||||
async def populate_faction(faction_id: int, kind: str):
|
||||
"""
|
||||
Fetch members + FFScouter estimates once and store in STATE.
|
||||
@@ -64,9 +62,8 @@ async def populate_faction(faction_id: int, kind: str):
|
||||
|
||||
return True
|
||||
|
||||
# -----------------------------
|
||||
|
||||
# Status refresh loop
|
||||
# -----------------------------
|
||||
async def refresh_status_loop(faction_id: int, kind: str, lock: asyncio.Lock, interval: int):
|
||||
"""
|
||||
Periodically refresh member statuses in STATE.
|
||||
@@ -95,10 +92,11 @@ async def refresh_status_loop(faction_id: int, kind: str, lock: asyncio.Lock, in
|
||||
|
||||
await asyncio.sleep(interval)
|
||||
|
||||
# -----------------------------
|
||||
|
||||
# Public API helpers
|
||||
# -----------------------------
|
||||
async def populate_friendly(faction_id: int):
|
||||
# Store friendly faction ID for chain monitoring
|
||||
STATE.friendly_faction_id = faction_id
|
||||
return await populate_faction(faction_id, "friendly")
|
||||
|
||||
async def populate_enemy(faction_id: int):
|
||||
|
||||
Reference in New Issue
Block a user