Skip to content

Commit

Permalink
Add a client command to toggle DeathLink
Browse files Browse the repository at this point in the history
  • Loading branch information
Ars-Ignis committed Jan 25, 2025
1 parent e22441c commit 7a6cc64
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion worlds/crystalis/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,22 @@
MAIN_LOOP_GAME: int = 1


def cmd_deathlink(self: "BizHawkClientCommandProcessor") -> None:
"""Toggle DeathLink on or off."""
from CommonClient import logger
if self.ctx.game != "Crystalis":
logger.warning(f"Somehow running a Crystalis command handler while playing a different game: {self.ctx.game}")
return
else:
if "DeathLink" in self.ctx.tags:
async_start(self.ctx.update_death_link(False))
logger.info("Death Link is now disabled.")
else:
async_start(self.ctx.update_death_link(True))
logger.info("Death Link is now enabled.")




class CrystalisClient(BizHawkClient):
game = "Crystalis"
Expand All @@ -52,7 +68,6 @@ class CrystalisClient(BizHawkClient):
is_dying: bool = False
last_death_link: float = time()


def __init__(self):
super().__init__()
for region in regions_data.values():
Expand Down Expand Up @@ -81,6 +96,7 @@ async def validate_rom(self, ctx: "BizHawkClientContext") -> bool:
ctx.game = self.game
ctx.items_handling = 0b111
ctx.want_slot_data = True
ctx.command_processor.commands["deathlink"] = cmd_deathlink
return True

def on_package(self, ctx: "BizHawkClientContext", cmd: str, args: dict) -> None:
Expand Down

0 comments on commit 7a6cc64

Please sign in to comment.