def get_scan(team: str) -> DiscordAction: def do_scan(sub): message = sub.scan.previous_scan() if message != "": return Message(message) return Message("No scan done yet!") return with_sub(team, do_scan, FAIL_REACT)
def unpower_systems(team: str, systems: List[str]) -> DiscordAction: """ Unpowers `systems` of the submarine `team` if able. """ def do_unpower(sub): result = sub.power.unpower_systems(systems) return Message(result) return with_sub(team, do_unpower, FAIL_REACT)
def teleport(subname: str, x: int, y: int) -> DiscordAction: """ Teleports team to (x,y), checking if the space is in the world. """ def do_teleport(sub): if sub.movement.set_position(x, y): return OKAY_REACT return FAIL_REACT return with_sub(subname, do_teleport, FAIL_REACT)
def move(direction: str, subname: str) -> DiscordAction: """ Records the team's direction. We then react to the message accordingly. """ def do_move(sub): # Store the move and return the correct emoji. if sub.movement.set_direction(direction): return React(direction_emoji[direction]) return FAIL_REACT return with_sub(subname, do_move, FAIL_REACT)
def get_status(team: str, loop) -> DiscordAction: def do_status(sub): status_message = sub.status_message(loop) return Message(status_message) return with_sub(team, do_status, FAIL_REACT)
def drop_item(team: str, item: str) -> DiscordAction: def drop(sub): return Message(sub.inventory.drop(item)) return with_sub(team, drop, FAIL_REACT)
def schedule_shot(x: int, y: int, team: str, damaging: bool): def do_schedule(sub): return Message(sub.weapons.prepare_shot(damaging, x, y)) return with_sub(team, do_schedule, FAIL_REACT)
def drop_crane(team: str) -> DiscordAction: def do_crane(sub): return Message(sub.inventory.drop_crane()) return with_sub(team, do_crane, FAIL_REACT)
def get_scan(team: str) -> DiscordAction: def do_scan(sub): return Message(sub.scan.previous_scan()) return with_sub(team, do_scan, FAIL_REACT)