Esempio n. 1
0
    def set_time_limit(self,
                       time_limit: Optional[int] = None,
                       additive: bool = False) -> Optional[int]:
        advance_call = self.advance_call
        add_time = 0.0
        if advance_call is not None:
            add_time = ((advance_call.getTime() - reactor.seconds()) / 60.0)
            advance_call.cancel()
            self.advance_call = None
        time_limit = time_limit or self.default_time_limit
        if not time_limit:
            for call in self.end_calls[:]:
                call.set(None)
            return None

        if additive:
            time_limit = min(time_limit + add_time, self.default_time_limit)

        seconds = time_limit * 60
        self.advance_call = reactor.callLater(seconds, self._time_up)

        for call in self.end_calls[:]:
            call.set(seconds)

        if self.time_announce_schedule is not None:
            self.time_announce_schedule.reset()
        self.time_announce_schedule = Scheduler(self)
        for seconds in self.time_announcements:
            self.time_announce_schedule.call_end(seconds,
                                                 self._next_time_announce)

        return time_limit
Esempio n. 2
0
    def __init__(self, instigator, victim, reason):
        self.protocol = protocol = instigator.protocol
        self.instigator = instigator
        self.victim = victim
        self.reason = reason
        self.votes = {instigator: True}
        self.ended = False

        protocol.irc_say(
            S_ANNOUNCE_IRC.format(instigator=instigator.name,
                                  instigator_id=instigator.player_id,
                                  victim=victim.name,
                                  victim_id=victim.player_id,
                                  reason=self.reason))
        protocol.send_chat(S_ANNOUNCE.format(
            instigator=instigator.name,
            instigator_id=instigator.player_id,
            victim=victim.name,
            victim_id=victim.player_id),
                           sender=instigator)
        protocol.send_chat(S_REASON.format(reason=self.reason),
                           sender=instigator)
        instigator.send_chat(
            S_ANNOUNCE_SELF.format(victim=victim.name,
                                   victim_id=victim.player_id))

        schedule = Scheduler(protocol)
        schedule.call_later(self.timeout, self.end, S_RESULT_TIMED_OUT)
        schedule.loop_call(30.0, self.send_chat_update)
        self.schedule = schedule
Esempio n. 3
0
 def start(self):
     instigator = self.instigator
     protocol = self.protocol
     if instigator is None:
         protocol.send_chat('Time to vote!', irc=True)
     else:
         protocol.send_chat('* %s initiated a map vote.' % instigator.name,
                            irc=True)
     self.schedule = schedule = Scheduler(protocol)
     schedule.call_later(self.vote_time, self.timeout)
     schedule.loop_call(30.0, self.update)
     self.protocol.votemap = self
     self.update()
Esempio n. 4
0
    def __init__(self, player, time=300, reason='None'):
        if time == 0:
            player.mute = True
            player.protocol.send_chat(
                '%s was muted indefinitely (Reason: %s)' %
                (player.name, reason),
                irc=True)
            return

        schedule = Scheduler(player.protocol)
        schedule.call_later(time, self.end)
        player.mute_schedule = schedule

        player.protocol.send_chat('%s was muted for %s seconds (Reason: %s)' %
                                  (player.name, time, reason),
                                  irc=True)
        player.mute = True

        self.player = player
        self.time = time