mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 12:11:33 -06:00
LttP: Implement DeathLink
This commit is contained in:
@@ -58,7 +58,6 @@ class FactorioContext(CommonContext):
|
||||
self.rcon_client = None
|
||||
self.awaiting_bridge = False
|
||||
self.write_data_path = None
|
||||
self.last_death_link: float = time.time() # last send/received death link on AP layer
|
||||
self.death_link_tick: int = 0 # last send death link on Factorio layer
|
||||
self.factorio_json_text_parser = FactorioJSONtoTextParser(self)
|
||||
|
||||
@@ -102,6 +101,10 @@ class FactorioContext(CommonContext):
|
||||
self.rcon_client.send_command(f"/ap-print [font=default-large-bold]Archipelago:[/font] "
|
||||
f"{text}")
|
||||
|
||||
def on_deathlink(self, data: dict):
|
||||
if self.rcon_client:
|
||||
self.rcon_client.send_command(f"/ap-deathlink {data['source']}")
|
||||
|
||||
def on_package(self, cmd: str, args: dict):
|
||||
if cmd in {"Connected", "RoomUpdate"}:
|
||||
# catch up sync anything that is already cleared.
|
||||
@@ -109,12 +112,6 @@ class FactorioContext(CommonContext):
|
||||
self.rcon_client.send_commands({item_name: f'/ap-get-technology ap-{item_name}-\t-1' for
|
||||
item_name in args["checked_locations"]})
|
||||
|
||||
elif cmd == "Bounced":
|
||||
if self.rcon_client:
|
||||
tags = args.get("tags", [])
|
||||
if "DeathLink" in tags and self.last_death_link != args["data"]["time"]:
|
||||
self.rcon_client.send_command(f"/ap-deathlink {args['data']['source']}")
|
||||
|
||||
|
||||
async def game_watcher(ctx: FactorioContext):
|
||||
bridge_logger = logging.getLogger("FactorioWatcher")
|
||||
@@ -150,14 +147,8 @@ async def game_watcher(ctx: FactorioContext):
|
||||
death_link_tick = data.get("death_link_tick", 0)
|
||||
if death_link_tick != ctx.death_link_tick:
|
||||
ctx.death_link_tick = death_link_tick
|
||||
ctx.last_death_link = time.time()
|
||||
await ctx.send_msgs([{
|
||||
"cmd": "Bounce", "tags": ["DeathLink"],
|
||||
"data": {
|
||||
"time": ctx.last_death_link,
|
||||
"source": ctx.player_names[ctx.slot]
|
||||
}
|
||||
}])
|
||||
await ctx.send_death()
|
||||
|
||||
await asyncio.sleep(0.1)
|
||||
|
||||
except Exception as e:
|
||||
|
Reference in New Issue
Block a user