From 87dd6d1b734afa7844d3a6c59fd6177efa133e11 Mon Sep 17 00:00:00 2001 From: vonavi Date: Wed, 9 Oct 2013 12:43:50 +0300 Subject: [PATCH] Add the number of games played by each player. --- lib/lorchess/tournament_table.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/lorchess/tournament_table.rb b/lib/lorchess/tournament_table.rb index 76403cd..b5b9370 100644 --- a/lib/lorchess/tournament_table.rb +++ b/lib/lorchess/tournament_table.rb @@ -19,6 +19,7 @@ module LORChess @elo_list = [] @dim = @@db_players.length @results = Array.new(@dim) { Array.new(@dim, '') } + @player_games = [] @player_score = [] @player_place = [] @buffer = '' @@ -65,8 +66,13 @@ module LORChess score_data = [] @results.each_with_index do |row, i| + games = 0 sum = 0.0 - row.each { |score| sum += score.to_f } + row.each do |score| + games += 1 unless score == '' + sum += score.to_f + end + @player_games << games.to_s @player_score << sum.to_s score_data << {:position => i, :total => sum} end @@ -114,6 +120,7 @@ module LORChess @buffer << " " << (cell+1).to_s << "\n" end + @buffer << " Игры\n" @buffer << " Очки\n" @buffer << " Место\n" @buffer << " \n" @@ -135,6 +142,7 @@ module LORChess end end + @buffer << " " << @player_games[row] << "\n" @buffer << " " << @player_score[row] << "\n" @buffer << " " << @player_place[row] << "\n" @buffer << " \n"