def run(self, args, conn): g = game.from_name_or_number(args[0], conn) if g: if conn.user not in g.observers | g.players: conn.write(_('You are not observing game %d.\n') % g.number) else: self._do_whisper(g, args[1], conn)
def run(self, args, conn): if args[0] in ['/l', '/b', '/s', '/S', '/w', '/z', '/B', '/L', '/x']: conn.write('TODO: observe flag\n') return g = game.from_name_or_number(args[0], conn) if g: if g in conn.user.session.observed: conn.write(_('You are already observing game %d.\n' % g.number)) elif conn.user in g.players: conn.write(_('You cannot observe yourself.\n')) else: assert(conn.user not in g.observers) g.observe(conn.user)
def run(self, args, conn): if args[0] in ['/l', '/b', '/s', '/S', '/w', '/z', '/B', '/L', '/x']: conn.write('TODO: observe flag\n') return g = game.from_name_or_number(args[0], conn) if g: if g in conn.user.session.observed: conn.write(_('You are already observing game %d.\n' % g.number)) elif conn.user in g.players: conn.write(_('You cannot observe yourself.\n')) else: assert (conn.user not in g.observers) g.observe(conn.user)
def _game_param(self, param, conn): """ Find a game from a command argument, currently being played, examined, or observed, prioritized in that order. """ if param is not None: g = game.from_name_or_number(param, conn) else: if conn.user.session.game: g = conn.user.session.game elif conn.user.session.observed: g = conn.user.session.observed.primary() else: conn.write(_("You are not playing, examining, or observing a game.\n")) g = None return g
def run(self, args, conn): if args[0] is not None: g = game.from_name_or_number(args[0], conn) if g: if g in conn.user.session.observed: g.unobserve(conn.user) else: conn.write(_('You are not observing game %d.\n') % g.number) else: if not conn.user.session.observed: conn.write(_('You are not observing any games.\n')) else: for g in conn.user.session.observed.copy(): g.unobserve(conn.user) assert(not conn.user.session.observed)
def run(self, args, conn): if not conn.user.has_title('TD'): conn.write(_('Only TD programs are allowed to use this command.\n')) return u2 = find_user.online_by_prefix_for_user(args[0], conn) if not u2: return g = game.from_name_or_number(args[1], conn) if g: if u2 in g.observers or u2 in g.players: # TODO: how to print error message to TD? pass else: g.observe(u2)
def run(self, args, conn): if args[0] is not None: g = game.from_name_or_number(args[0], conn) if g: if g in conn.user.session.observed: g.unobserve(conn.user) else: conn.write( _('You are not observing game %d.\n') % g.number) else: if not conn.user.session.observed: conn.write(_('You are not observing any games.\n')) else: for g in conn.user.session.observed.copy(): g.unobserve(conn.user) assert (not conn.user.session.observed)
def run(self, args, conn): if not conn.user.has_title('TD'): conn.write(_('Only TD programs are allowed to use this command.\n')) return u2 = user.find_by_prefix_for_user(args[0], conn, online_only=True) if not u2: return g = game.from_name_or_number(args[1], conn) if g: if u2 in g.observers or u2 in g.players: # TODO: how to print error message to TD? pass else: g.observe(u2)
def run(self, args, conn): count = 0 if args[0] is not None: g = game.from_name_or_number(args[0], conn) if g: if g.allobservers(conn): count = 1 else: conn.write(_('No one is observing game %d.\n') % g.number) else: for g in game.games.itervalues(): if g.allobservers(conn): count += 1 if count > 0: conn.write(ngettext( ' %(count)d game displayed (of %(total)d in progress).\n', ' %(count)d games displayed (of %(total)d in progress).\n', count) % {'count': count, 'total': len(game.games)})
def run(self, args, conn): if args[0] is None: if not conn.user.session.observed: conn.write(_('You are not observing any games.\n')) else: conn.write('TODO: primary no param\n') else: g = game.from_name_or_number(args[0], conn) if g: if g in conn.user.session.observed: if g == conn.user.session.observed.primary(): conn.write(_('Game %d is already your primary game.\n') % g.number) else: conn.user.session.observed.make_primary(g) conn.write(_('Game %d is now your primary game.\n') % g.number) else: conn.write('You are not observing game %d.\n' % g.number)
def run(self, args, conn): if args[0] is None: if not conn.user.session.observed: conn.write(_('You are not observing any games.\n')) else: conn.write('TODO: primary no param\n') else: g = game.from_name_or_number(args[0], conn) if g: if g in conn.user.session.observed: if g == conn.user.session.observed.primary(): conn.write( _('Game %d is already your primary game.\n') % g.number) else: conn.user.session.observed.make_primary(g) conn.write( _('Game %d is now your primary game.\n') % g.number) else: conn.write('You are not observing game %d.\n' % g.number)
def run(self, args, conn): if args[0] in [ '*', '/l', '/b', '/s', '/S', '/w', '/z', '/B', '/L', '/x' ]: if args[0] == '*': args[0] = '/b' g = game.find_best_by_char_type(args[0][1], conn.user) if g: g.observe(conn.user) else: conn.write(_('No suitable star games are in progress.\n')) return g = game.from_name_or_number(args[0], conn) if g: if g in conn.user.session.observed: conn.write(_('You are already observing game %d.\n' % g.number)) elif conn.user in g.players: conn.write(_('You cannot observe yourself.\n')) else: assert (conn.user not in g.observers) g.observe(conn.user)
def run(self, args, conn): count = 0 if args[0] is not None: g = game.from_name_or_number(args[0], conn) if g: if g.allobservers(conn): count = 1 else: conn.write(_('No one is observing game %d.\n') % g.number) else: for g in global_.games.itervalues(): if g.allobservers(conn): count += 1 if count > 0: conn.write( ngettext( ' %(count)d game displayed (of %(total)d in progress).\n', ' %(count)d games displayed (of %(total)d in progress).\n', count) % { 'count': count, 'total': len(global_.games) })