Exemple #1
0
 def __start_competition(self):
     calendar = service.getCalendar(self.get_teams(),
                                    self.get_competition().tworound)
     for i, team in enumerate(calendar):
         match = model.getMatchProvider().get_new(
             team[0].id,
             team[1].id,
             comment='match number {}'.format(i + 1))
         dao.getMatch().insert(match)
     self.set_competition_begin(True)
Exemple #2
0
 def __after_changed_property_competition_begin(self, compet_start):
     self.pushButton_deleteplayer.setEnabled(not compet_start)
     self.pushButton_deleteteam.setEnabled(not compet_start)
     self.actionStart.setEnabled(not compet_start)
     if compet_start:
         self.progressBar_competitionlevel.setMaximum(
             len(dao.getMatch().getAll(self.get_competition())))
         self.tableWidget_competitionresult.setRowCount(
             len(self.get_teams()))
         match = dao.getMatch().getNextMatch(self.get_competition())
         self.set_current_match(match)
Exemple #3
0
 def __event_load_competition(self, p_index):
     # loading existing competition
     compet = dao.getCompetition().getById(p_index)
     self.set_competition(compet)
     if dao.getMatch().getAll(self.get_competition()) is not None:
         print('la competition a déjà commencé')
         self.set_competition_begin(True)
Exemple #4
0
 def __event_tab_selection_changed(self, index):
     self.__clear_listwidget(self.listWidget_matchslist)
     if index == 1:
         matchs = dao.getMatch().getMatchPlayed(self.get_competition())
         if matchs is not None:
             self.progressBar_competitionlevel.setValue(len(matchs))
         teams = dao.getTeam().getAll(self.get_competition())
         monClassement = Classement(teams)
         if matchs is not None:
             for match in matchs:
                 team_dom = dao.getTeam().getById(match.idteam_home)
                 team_ext = dao.getTeam().getById(match.idteam_outside)
                 score_dom = 0
                 score_ext = 0
                 goals = dao.getGoals().getByMatch(match)
                 if goals is not None:
                     for goal in goals:
                         if goal.idequipe == team_dom.id:
                             score_dom += 1
                         else:
                             score_ext += 1
                     monClassement.add_score(team_dom, score_dom, score_ext,
                                             team_ext)
                     self.listWidget_matchslist.addItem(
                         '{} {} - {} {}'.format(team_dom.name, score_dom,
                                                score_ext, team_ext.name))
         self.__update_result(monClassement)
Exemple #5
0
 def __event_bt_after_save_match(self):
     match = self.get_current_match()
     match.isplayed = True
     dao.getMatch().update(match)
     nextmatch = dao.getMatch().getNextMatch(self.get_competition())
     self.set_current_match(nextmatch)
Exemple #6
0
 def __update_result_after_match_finished(self):
     self.progressBar_competitionlevel.setValue(
         dao.getMatch().getMatchPlayed(self.get_competition()))
     matchs = dao.getMatch().getAll()
Exemple #7
0
            self.teams[oteam2][0] += 1
        self.teams[oteam1][3] += score1
        self.teams[oteam1][4] += score2
        self.teams[oteam2][3] += score2
        self.teams[oteam2][4] += score1


model = ModelFactory()
dao = DaoFactory()
service = ServiceProvider()
ch = dao.getCompetition().getById(1)
teams = dao.getTeam().getAll(ch)
monClassement = Classement(teams)
monClassement.show()

matchs = dao.getMatch().getMatchPlayed(ch)
for match in matchs:
    team_dom = dao.getTeam().getById(match.idteam_home)
    team_ext = dao.getTeam().getById(match.idteam_outside)
    score_dom = 0
    score_ext = 0
    goals = dao.getGoals().getByMatch(match)
    for goal in goals:
        if goal.idequipe == team_dom.id:
            score_dom += 1
        else:
            score_ext += 1
    monClassement.set_result(team_dom, score_dom, score_ext, team_ext)
    print('{} {} - {} {}'.format(team_dom.name, score_dom, score_ext,
                                 team_ext.name))
monClassement.show()
Exemple #8
0
 def saveCalendar(cls, calendar):
     for i, t in enumerate(calendar):
         match = model.getMatchProvider().get_new(comment='match number {}'.format(i + 1))
         dao.getMatch().insert(match, t[0], t[1])