Exemple #1
0
    def _do_execute(self, command):
        if self._room.race.is_before_race:
            return

        if len(command.args) == 1:
            igt = racetime.from_str(command.args[0])
            racer = self._room.race.get_racer(command.author)
            if igt != -1 and racer and racer.is_done_racing:
                racer.igt = igt
                asyncio.ensure_future(self._room.update_leaderboard())
Exemple #2
0
    def _do_execute(self, command):
        if self._room.is_race_admin(command.author):
            if len(command.args) == 0:
                yield from self._room.write('You must specify a winner, or `-draw`, to record a race.')
                return

            winner_name = command.args[0].lower()
            winner_int = 0
            if winner_name == self._room.match.racer_1.twitch_name.lower():
                winner_int = 1
            elif winner_name == self._room.match.racer_2.twitch_name.lower():
                winner_int = 2
            elif winner_name != '-draw':
                yield from self._room.write('I don\'t recognize the twitch name {}.'.format(winner_name))
                return

            command.args.pop(0)
            parse_seed = False
            parse_loser_time = False
            seed = 0
            racer_1_time = -1
            racer_2_time = -1
            for arg in command.args:
                if arg == '-seed':
                    parse_seed = True
                elif parse_seed:
                    try:
                        seed = int(arg)
                        parse_seed = False
                    except ValueError:
                        yield from self._room.write('Couldn\'t parse {0} as a seed.'.format(arg))
                        return
                else:
                    time = racetime.from_str(arg)
                    if time == -1:
                        yield from self._room.write('Couldn\'t parse {0} as a time.'.format(arg))
                        return
                    else:
                        if (parse_loser_time and winner_int == 2) or (not parse_loser_time and winner_int == 1):
                            racer_1_time = time
                        elif winner_int != 0:
                            racer_2_time = time
                        else:
                            yield from self._room.write('I can\'t parse racer times in races with no winner.')
                            return
                
            self._room.condordb.record_race(self._room.match, racer_1_time, racer_2_time, winner_int, seed, int(0), False, force_recorded=True)
            yield from self._room.write('Forced record of a race.')
            yield from self._room.update_leaderboard()

            if self._room.played_all_races:
                yield from self._room.record_match()
    def _do_execute(self, command):
        if self._room.is_race_admin(command.author):
            if len(command.args) == 0:
                yield from self._room.write('You must specify a winner, or `-draw`, to record a race.')
                return

            winner_name = command.args[0].lower()
            winner_int = 0
            if winner_name == self._room.match.racer_1.twitch_name.lower():
                winner_int = 1
            elif winner_name == self._room.match.racer_2.twitch_name.lower():
                winner_int = 2
            elif winner_name != '-draw':
                yield from self._room.write('I don\'t recognize the twitch name {}.'.format(winner_name))
                return

            command.args.pop(0)
            parse_seed = False
            parse_loser_time = False
            seed = 0
            racer_1_time = -1
            racer_2_time = -1
            for arg in command.args:
                if arg == '-seed':
                    parse_seed = True
                elif parse_seed:
                    try:
                        seed = int(arg)
                        parse_seed = False
                    except ValueError:
                        yield from self._room.write('Couldn\'t parse {0} as a seed.'.format(arg))
                        return
                else:
                    time = racetime.from_str(arg)
                    if time == -1:
                        yield from self._room.write('Couldn\'t parse {0} as a time.'.format(arg))
                        return
                    else:
                        if (parse_loser_time and winner_int == 2) or (not parse_loser_time and winner_int == 1):
                            racer_1_time = time
                        elif winner_int != 0:
                            racer_2_time = time
                        else:
                            yield from self._room.write('I can\'t parse racer times in races with no winner.')
                            return
                
            self._room.condordb.record_race(self._room.match, racer_1_time, racer_2_time, winner_int, seed, int(0), False, force_recorded=True)
            yield from self._room.write('Forced record of a race.')
            yield from self._room.update_leaderboard()

            if self._room.played_all_races:
                yield from self._room.record_match()
Exemple #4
0
    def parse_submission(self, daily_number, user, args):
        lv = -1
        time = -1
        ret_str = ''
        if len(args) > 0:
            if args[0] == 'death':
                if len(args) == 2:
                    lv = level.from_str(args[1])
                    if not lv == -1:
                        ret_str = 'died on {}'.format(args[1])
                else:
                    lv = 0
                    ret_str = 'died'
            else:
                time = racetime.from_str(args[0])
                if not time == -1:
                    lv = 18
                    ret_str = 'finished in {}'.format(racetime.to_str(time))

        if not lv == -1: # parse succeeded
            asyncio.ensure_future(self.submit_to_daily(daily_number, user, lv, time))
            return ret_str
        else:
            return ''