|
|
|
@ -1,5 +1,5 @@ |
|
|
|
from django.db import models |
|
|
|
from django.db import models |
|
|
|
from . import Match, TeamRegistration, PlayerRegistration |
|
|
|
from . import Match, TeamRegistration, PlayerRegistration, FederalMatchCategory |
|
|
|
import uuid |
|
|
|
import uuid |
|
|
|
|
|
|
|
|
|
|
|
class TeamScore(models.Model): |
|
|
|
class TeamScore(models.Model): |
|
|
|
@ -44,6 +44,18 @@ class TeamScore(models.Model): |
|
|
|
else: |
|
|
|
else: |
|
|
|
return [] |
|
|
|
return [] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def estimated_number_of_games(self): |
|
|
|
|
|
|
|
scores = self.scores() |
|
|
|
|
|
|
|
format = FederalMatchCategory.NINE_GAMES_DECISIVE_POINT |
|
|
|
|
|
|
|
games = 0.0 |
|
|
|
|
|
|
|
if self.match.format: |
|
|
|
|
|
|
|
format = self.match.format |
|
|
|
|
|
|
|
if FederalMatchCategory.last_set_is_tie_break(format) and len(scores) == FederalMatchCategory.max_number_of_sets(format): |
|
|
|
|
|
|
|
points = scores.pop() |
|
|
|
|
|
|
|
games += points / 7 # we take 7 points in average for a game |
|
|
|
|
|
|
|
games += sum(scores) |
|
|
|
|
|
|
|
return games |
|
|
|
|
|
|
|
|
|
|
|
def number_of_games(self): |
|
|
|
def number_of_games(self): |
|
|
|
scores = self.scores() |
|
|
|
scores = self.scores() |
|
|
|
return sum(scores) |
|
|
|
return sum(scores) |
|
|
|
|