From d1a3bac9dca624d16f55ebf453e67adabf91f4a3 Mon Sep 17 00:00:00 2001 From: vonavi Date: Sat, 5 Oct 2013 12:18:01 +0300 Subject: [PATCH 1/9] Keep the results of the vacancy player. --- lib/lorchess/tournament_table.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/lorchess/tournament_table.rb b/lib/lorchess/tournament_table.rb index 0b277cd..583b4bf 100644 --- a/lib/lorchess/tournament_table.rb +++ b/lib/lorchess/tournament_table.rb @@ -38,11 +38,7 @@ module LORChess index = @player_pos['Kasparov'] if index @players[index] = 'отсутствует' - @elo_list[index] = '' - for cell in 0..(@dim-1) - @results[index][cell] = '' - end - @player_score[index] = '' + @elo_list[index] = '—' end end From a70be59b56c45cd77cdf397510877ddc3185461d Mon Sep 17 00:00:00 2001 From: vonavi Date: Sat, 5 Oct 2013 12:20:38 +0300 Subject: [PATCH 2/9] Assign elo 1200 for the vacancy player. --- lib/lorchess/tournament_table.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/lorchess/tournament_table.rb b/lib/lorchess/tournament_table.rb index 583b4bf..62cf2fd 100644 --- a/lib/lorchess/tournament_table.rb +++ b/lib/lorchess/tournament_table.rb @@ -38,7 +38,7 @@ module LORChess index = @player_pos['Kasparov'] if index @players[index] = 'отсутствует' - @elo_list[index] = '—' + @elo_list[index] = '1200' end end From cb8f8f8614fea6a1d975604a1dc6205d4e6155fd Mon Sep 17 00:00:00 2001 From: vonavi Date: Sat, 5 Oct 2013 18:42:00 +0300 Subject: [PATCH 3/9] Fix the result of game Magian - Nedis. --- autumn2013/tour_04/tour_info | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autumn2013/tour_04/tour_info b/autumn2013/tour_04/tour_info index 05c233c..e5495ed 100644 --- a/autumn2013/tour_04/tour_info +++ b/autumn2013/tour_04/tour_info @@ -4,7 +4,7 @@ Время проведения: 15.09.2013 - 22.09.2013 22.09.2013 — redgremlin 1:0 Kasparov -22.09.2013 — Magian 0:1 Nedis +22.09.2013 — Magian 1:0 Nedis 21.09.2013 — Genuine 0:1 iVS LongLiveUbuntu vs darkenshvein 17.09.2013 — raven_cler 0:1 HunOL From 5ae407f691ecaa72d9c10f34f69705b51444dae2 Mon Sep 17 00:00:00 2001 From: vonavi Date: Sat, 5 Oct 2013 18:42:23 +0300 Subject: [PATCH 4/9] Update game results. --- autumn2013/results.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autumn2013/results.yml b/autumn2013/results.yml index 1fc6ed3..be60fbe 100644 --- a/autumn2013/results.yml +++ b/autumn2013/results.yml @@ -164,7 +164,7 @@ - date: 22.09.2013 white: Magian black: Nedis - result: '0:1' + result: '1:0' - date: 21.09.2013 white: Genuine From 0797a62246d4376e2e5c0448e81d2e1d5480c3cc Mon Sep 17 00:00:00 2001 From: vonavi Date: Sat, 5 Oct 2013 20:32:33 +0300 Subject: [PATCH 5/9] Stylize the tournament table. --- lib/lorchess/tournament_table.rb | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/lib/lorchess/tournament_table.rb b/lib/lorchess/tournament_table.rb index 62cf2fd..3b24031 100644 --- a/lib/lorchess/tournament_table.rb +++ b/lib/lorchess/tournament_table.rb @@ -33,6 +33,7 @@ module LORChess fill calculate + stylize_table # Clean the vacancy place index = @player_pos['Kasparov'] @@ -63,11 +64,33 @@ module LORChess @results.each do |row| sum = 0.0 row.each { |score| sum += score.to_f } - sum = sum.to_i if sum == sum.to_i # remove the fractional part if possible @player_score << sum.to_s end end + def stylize_table + for row in 0..(@dim-1) + for cell in 0..(@dim-1) + @results[row][cell] = stylize_score @results[row][cell] + end + + @player_score[row] = stylize_score @player_score[row] + end + end + + # Replace the fractional part `0.5' by ½ + def stylize_score score + frac = score.split '.' + return '' if frac[0].nil? + unless frac[0] == '0' + score = frac[0] + score += '½' if frac[1] == '5' + else + score = (frac[1] == '5') ? '½' : '0' + end + score + end + def to_html @buffer << "\n" From 402a57f82828fbe7766f4c32ffc0bf88732b0321 Mon Sep 17 00:00:00 2001 From: vonavi Date: Sat, 5 Oct 2013 21:03:46 +0300 Subject: [PATCH 6/9] Add the player's number in the caption of tournament table. --- lib/lorchess/tournament_table.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/lorchess/tournament_table.rb b/lib/lorchess/tournament_table.rb index 3b24031..2ebe9a2 100644 --- a/lib/lorchess/tournament_table.rb +++ b/lib/lorchess/tournament_table.rb @@ -97,7 +97,7 @@ module LORChess @buffer << " \n" @buffer << " \n" - @buffer << " \n" + @buffer << " \n" @buffer << " \n" @buffer << " \n" From 667d106b27f266c1d9f7c7e205004a667c5cc00d Mon Sep 17 00:00:00 2001 From: vonavi Date: Sat, 5 Oct 2013 23:11:07 +0300 Subject: [PATCH 7/9] Add player's places in the tournament table. --- lib/lorchess/tournament_table.rb | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/lorchess/tournament_table.rb b/lib/lorchess/tournament_table.rb index 2ebe9a2..625480f 100644 --- a/lib/lorchess/tournament_table.rb +++ b/lib/lorchess/tournament_table.rb @@ -20,6 +20,7 @@ module LORChess @dim = @@db_players.length @results = Array.new(@dim) { Array.new(@dim, '') } @player_score = [] + @player_place = [] @buffer = '' @@db_players.each do |player| @@ -61,11 +62,19 @@ module LORChess end def calculate - @results.each do |row| + score_data = [] + + @results.each_with_index do |row, i| sum = 0.0 row.each { |score| sum += score.to_f } @player_score << sum.to_s + score_data << [i, sum] end + + # Sort players in correspondence with the decrease of place + score_data.sort! { |x,y| y[1] <=> x[1] } + + score_data.each_with_index { |data,i| @player_place[data[0]] = (i+1).to_s } end def stylize_table @@ -120,14 +129,14 @@ module LORChess for cell in 0..(@dim-1) unless cell == row - @buffer << " \n" + @buffer << " \n" else - @buffer << " \n" + @buffer << " \n" end end @buffer << " \n" - @buffer << " \n" + @buffer << " \n" @buffer << " \n" end From b99fcdd160ee6fb46497a4f5db944d5d3dcf796d Mon Sep 17 00:00:00 2001 From: vonavi Date: Sat, 5 Oct 2013 23:30:54 +0300 Subject: [PATCH 8/9] Modify the HTML class of cells in the tournament table. --- lib/lorchess/tournament_table.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/lorchess/tournament_table.rb b/lib/lorchess/tournament_table.rb index 625480f..8d6425b 100644 --- a/lib/lorchess/tournament_table.rb +++ b/lib/lorchess/tournament_table.rb @@ -122,10 +122,10 @@ module LORChess for row in 0..(@dim-1) - @buffer << " \n" - @buffer << " \n" - @buffer << " \n" - @buffer << " \n" + @buffer << " \n" + @buffer << " \n" + @buffer << " \n" + @buffer << " \n" for cell in 0..(@dim-1) unless cell == row @@ -135,8 +135,8 @@ module LORChess end end - @buffer << " \n" - @buffer << " \n" + @buffer << " \n" + @buffer << " \n" @buffer << " \n" end From b9c0da19d1902e103ef3ec22c2b006af4fd4fd59 Mon Sep 17 00:00:00 2001 From: vonavi Date: Sun, 6 Oct 2013 01:47:40 +0300 Subject: [PATCH 9/9] Slight changes in 'tournament_table.rb'. --- lib/lorchess/tournament_table.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/lorchess/tournament_table.rb b/lib/lorchess/tournament_table.rb index 8d6425b..76403cd 100644 --- a/lib/lorchess/tournament_table.rb +++ b/lib/lorchess/tournament_table.rb @@ -68,13 +68,13 @@ module LORChess sum = 0.0 row.each { |score| sum += score.to_f } @player_score << sum.to_s - score_data << [i, sum] + score_data << {:position => i, :total => sum} end - # Sort players in correspondence with the decrease of place - score_data.sort! { |x,y| y[1] <=> x[1] } + # Sort players in the reverse order to total score + score_data.sort! { |x,y| y[:total] <=> x[:total] } - score_data.each_with_index { |data,i| @player_place[data[0]] = (i+1).to_s } + score_data.each_with_index { |data,i| @player_place[data[:position]] = (i+1).to_s } end def stylize_table
LOR Chess : Осень-2013\n" @buffer << "
Участникelo*" << @results[row][cell] << "" << @results[row][cell] << "" << @player_score[row] << "" << @player_place[row] << "
" << (row+1).to_s << "" << @players[row] << "" << @elo_list[row] << "
" << (row+1).to_s << "" << @players[row] << "" << @elo_list[row] << "" << @player_score[row] << "" << @player_place[row] << "" << @player_score[row] << "" << @player_place[row] << "