*** quiz.rb.orig 2006-07-23 21:10:45.000000000 +0200 --- quiz.rb 2006-07-23 21:57:54.000000000 +0200 *************** class QuizPlugin < Plugin *** 203,224 **** # Updates the per-channel rank table, which is kept for performance reasons # def calculate_ranks( m, q, nick ) if q.registry.has_key?( nick ) stats = q.registry[nick] # Find player in table i = 0 q.rank_table.each_index do |i| ! break if nick == q.rank_table[i][0] end ! old_rank = i ! q.rank_table.delete_at( i ) # Insert player at new position inserted = false q.rank_table.each_index do |i| ! if stats.score >= q.rank_table[i][1].score q.rank_table[i,0] = [[nick, stats]] inserted = true break --- 203,236 ---- # Updates the per-channel rank table, which is kept for performance reasons # def calculate_ranks( m, q, nick ) + debug "before resort:" + debug q.rank_table.inspect + if q.registry.has_key?( nick ) stats = q.registry[nick] # Find player in table + found_player = false i = 0 q.rank_table.each_index do |i| ! if nick == q.rank_table[i][0] ! found_player = true ! break ! end end ! # Remove player from old position ! if found_player ! old_rank = i ! q.rank_table.delete_at( i ) ! else ! old_rank = nil ! end # Insert player at new position inserted = false q.rank_table.each_index do |i| ! if stats.score > q.rank_table[i][1].score q.rank_table[i,0] = [[nick, stats]] inserted = true break *************** class QuizPlugin < Plugin *** 231,244 **** i += 1 end ! if i < old_rank m.reply "#{nick} ascends to rank #{i + 1}. Congratulations :)" ! elsif i > old_rank m.reply "#{nick} slides down to rank #{i + 1}. So Sorry! NOT. :p" end else q.rank_table << [[nick, PlayerStats.new( 1 )]] end debug q.rank_table.inspect end --- 243,259 ---- i += 1 end ! unless old_rank.nil? ! if i < old_rank m.reply "#{nick} ascends to rank #{i + 1}. Congratulations :)" ! elsif i > old_rank m.reply "#{nick} slides down to rank #{i + 1}. So Sorry! NOT. :p" + end end else q.rank_table << [[nick, PlayerStats.new( 1 )]] end + debug "after resort:" debug q.rank_table.inspect end