Skip to content

Commit

Permalink
Finally eliminate the bug with timer
Browse files Browse the repository at this point in the history
Remember spurious timer action back then? So it fix it now!
  • Loading branch information
kyrylo committed May 14, 2012
1 parent f779009 commit fcba4a2
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions lib/artaius/plugins/mixer.rb
Expand Up @@ -79,22 +79,24 @@ def add_player(m)

need_players = @limit - @game.players.size

if @timer
@timer.stop
else
@timer = Timer(PENDING_DELAY, shots: 1, start_automatically: false) do
@game = nil
Channel(m.channel.name).send I18n.mixer.game_cancelled
end
end

if ready_to_begin?
each_team { |blue, red| begin_game!(m, blue, red) }
else
@timer.start

m.reply I18n.mixer.players(show_players)
m.reply I18n.mixer.need_players(need_players)
end
end

@timer.stop if @timer

@timer ||= Timer(PENDING_DELAY, shots: 1, start_automatically: false) do
@game = nil
Channel(m.channel.name).send I18n.mixer.game_cancelled
end

@timer.start
end

match /#{I18n.mixer.m.cancel}$/,
Expand Down

0 comments on commit fcba4a2

Please sign in to comment.