def invisible(connection, player = None): protocol = connection.protocol if player is not None: player = get_player(protocol, player) elif connection in protocol.players: player = connection else: raise ValueError() if not player.invisible and player.spy: # disable spy before going invisible result = toggle_spy(connection, player.name) if result: connection.send_chat(result) commands.invisible(connection, player.name)
def toggle_spy(connection, player = None): protocol = connection.protocol if player is not None: player = get_player(protocol, player) elif connection in protocol.players: player = connection else: raise ValueError() player.spy = spy = not player.spy player.killing = not spy if spy and player.invisible: # spy and invisibility don't get along nicely, the latter doesn't know # about the multiteaming when sending out create_player packets result = commands.invisible(connection, player.name) if result: connection.send_chat(result) if player.world_object and not player.world_object.dead: team = player.team.other if player.spy else player.team fill_create_player(player, team) protocol.send_contained(create_player, team = team, sender = player, save = True) other_message = S_SPY if spy else S_NO_SPY other_message = other_message.format(player = player.name) protocol.irc_say('* ' + other_message) self_message = S_SPY_SELF if spy else S_NO_SPY_SELF if connection is player: return self_message elif connection in protocol.players: player.send_chat(self_message) return other_message