diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/models/match.rb | 10 | ||||
-rw-r--r-- | app/views/tournaments/standings.html.erb | 4 |
2 files changed, 12 insertions, 2 deletions
diff --git a/app/models/match.rb b/app/models/match.rb index c2df6e0..d4c0ce5 100644 --- a/app/models/match.rb +++ b/app/models/match.rb @@ -5,6 +5,16 @@ class Match < ActiveRecord::Base belongs_to :winner, class_name: "Team" + def setup() + end + + def finished? + ok = true + tournament_stage.scoring_method.stats_needed.each do |stat| + ok &= statistics.where(match: self, name: stat).nil? + ok + end + def win?(player) winner.players.include? player end diff --git a/app/views/tournaments/standings.html.erb b/app/views/tournaments/standings.html.erb index b8739de..a04e132 100644 --- a/app/views/tournaments/standings.html.erb +++ b/app/views/tournaments/standings.html.erb @@ -1,7 +1,7 @@ -<% playerscores = @tournament.players.collect {|player| player => @tournament.statistics.getStatistic(player.matches.last, player, :score) } %> +<% playerscores = @tournament.players.collect {|player| player => @tournament.statistics.where(match: player.matches.last, user: player, name: :score) } %> <% teams = tournament_stage.matches.collect { |match| match.teams.collect { |team| team.id => team.players.collect -{ |player| player.user_name => @tournament.statistics.getStatistic(player.matches.last, player, :score } } } %> +{ |player| player.user_name => @tournament.statistics.where(match: player.matches.last, user: player, name: :score } } } %> <table> <tr> |