def __event_bt_addplayer(self, checked): dialog = AddPlayerWindow(self) result = dialog.exec() if result: team = self.get_current_team() if dialog.get_lname() != "": player = model.getPlayerProvider().get_new( team.id, dialog.get_lname(), dialog.get_fname()) else: player = model.getPlayerProvider().get_randomplayer(team.id) dao.getPlayer().insert(player) self.__refresh_tab1() self.set_current_team(team)
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)
def __event_create_competition(self): # create competition with user's name name, bt = QInputDialog.getText(None, 'New competition', "Enter your competition's name:", text='choose') if bt: c = model.getCompetitionProvider().get_standard_competition(name) dao.getCompetition().insert(c) self.set_competition(c)
def __event_bt_addteam(self, checked): message = 'please can you input the name of the team?' text, yespressed = QInputDialog.getText(None, "Add team", message, QLineEdit.Normal, "") if yespressed and text is not None: o = model.getTeamProvider().get_new(self.get_competition().id, text) dao.getTeam().insert(o) self.__refresh_tab1() self.set_current_team(o)
def __event_bt_after_goals(self): match = self.get_current_match() oteamdom = dao.getTeam().getById(match.idteam_home) playersdom = dao.getPlayer().getByTeam(oteamdom) oteamvis = dao.getTeam().getById(match.idteam_outside) playersext = dao.getPlayer().getByTeam(oteamvis) dialog = GoalWindow(self, oteamdom, playersdom, oteamvis, playersext) btpressed = dialog.exec() if btpressed: oteam, oscorer, oass = dialog.get_datas() but = model.getGoalsProvider().get_new( oscorer.id if oscorer is not None else None, match.id, oteam.id, oass.id if oass is not None else None) dao.getGoals().insert(but) self.__update_view_after_goals(oteam, oscorer, oass)
from datetime import datetime from model.dao.daofactory import DaoFactory as dao from model.provider.modelfactory import ModelFactory as model from service.service_provider import ServiceProvider as service o = len(dao.getCompetition().getAll()) if o == 0: chp = model.getCompetitionProvider().get_standard_competition( "ma competition") dao.getCompetition().insert(chp) team1 = model.getTeamProvider().get_new("Liverpool") dao.getTeam().insert(team1, chp) team2 = model.getTeamProvider().get_new("Chelsea") dao.getTeam().insert(team2, chp) team3 = model.getTeamProvider().get_new("Arsenal") dao.getTeam().insert(team3, chp) team4 = model.getTeamProvider().get_new("Manchester") dao.getTeam().insert(team4, chp) pl1 = model.getPlayerProvider().get_randomplayer() pl2 = model.getPlayerProvider().get_randomplayer() dao.getPlayer().insert(pl1, team1, team1.name) dao.getPlayer().insert(pl2, team1, team1.name) pl3 = model.getPlayerProvider().get_randomplayer() pl4 = model.getPlayerProvider().get_randomplayer() dao.getPlayer().insert(pl3, team2, team2.name) dao.getPlayer().insert(pl4, team2, team2.name) pl5 = model.getPlayerProvider().get_randomplayer() pl6 = model.getPlayerProvider().get_randomplayer() dao.getPlayer().insert(pl5, team3, team3.name) dao.getPlayer().insert(pl6, team3, team3.name)
if score1 == score2: self.teams[oteam1][1] += 1 self.teams[oteam2][1] += 1 elif score1 > score2: self.teams[oteam1][0] += 1 self.teams[oteam2][2] += 1 else: self.teams[oteam1][2] += 1 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:
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])