def forget_handler(str, cl): parts = str.split(' ', 2) if len(parts) == 1: print 'Missing argument, try "help forget" for usage info.' return try: p = player.by_partial_name(parts[1]) except PlayerAmbiguityError as e: print 'Found two players with same partial name: {e.p_one.name} and {e.p_two.name}'.format(e=e) return if not p: print 'Couldn\'t find player with prefix', parts[1] return # TODO: Should notify player of being kicked print 'Forgetting player', p.name network.to_ready( edicomm.encode( 'USD', p.id, 'Player kicked.' ) ) player.all.remove(p)
def wp_handler(str, cl): parts = str.split(' ', 4) if len(parts) == 1: # Just wp by itself lists waypoints print 'ID\ttitle\tposition' for wp in waypoint.all: print wp.id, '\t', wp.title, '\t', wp.position elif len(parts) == 2: # wp <wpid> deletes waypoints wpid = int(parts[1]) wp = waypoint.by_id(wpid) if not wp: print 'No waypoint with id {0}'.format(wpid) return print 'Deleting waypoint {wp.id} at {wp.position} titled {wp.title}'.format(wp=wp) waypoint.all.remove(wp) network.to_ready(edicomm.encode('WPT', wpid)) elif len(parts) == 4: # wp <id> <x,y> <title> makes/moves waypoints wpid = int(parts[1]) wppos = [int(x) for x in parts[2].split(',')] wptitle = parts[3] wp = waypoint.by_id(wpid) if not wp: wp = waypoint.Waypoint(wpid, wppos, wptitle) waypoint.all.append(wp) wp.position = wppos wp.title = wptitle print 'Created/moved/named waypoint {wp.id} at {wp.position} titled {wp.title}'.format(wp=wp) network.to_ready(edicomm.encode('WPT', wpid, wppos, wptitle))