Exemple #1
0
def add_new_teams():
    app_service = AppService()
    team_service = TeamService()
    game_data = app_service.get_current_data()
    teams_to_add = get_next_teams(str(game_data.current_year))
    for t in teams_to_add:
        team_service.create(t, 0, True)
Exemple #2
0
def button_play_clicked():
    app_service = AppService()

    r = random
    app_service.play_and_process_games_for_current_day(r)

    return get_home_page()
Exemple #3
0
def setup():
    # team_service = TeamService()
    # [team_service.create(n, 0) for n in team_name_list]
    game_rules_service = GameRulesService()
    game_rules_service.create("Season", True)
    game_rules_service.create("Playoff", False)
    app_service = AppService()
    app_service.setup_data(0, 0, True, True)
Exemple #4
0
    def get_current_standings_view():
        record_service = RecordService()
        app_service = AppService()
        current_data = app_service.get_current_data()
        records = record_service.get_by_year(current_data.current_year)
        record_service.sort_default(records)

        return StandingsCurrentViewModel(current_data, records)
Exemple #5
0
    def get_standings_history_view(year):
        record_service = RecordService()
        app_service = AppService()
        current_data = app_service.get_current_data()
        records = record_service.get_by_year(year)
        record_service.sort_default(records)
        seasons = record_service.get_all_seasons_for_dropdown()
        seasons.sort(reverse=True)

        return StandingsHistoryViewModel(current_data, year, records, seasons)
Exemple #6
0
def get_games_for_today():
    app_service = AppService()
    current_data = app_service.get_current_data()

    game_service = GameService()
    games = game_service.get_games_for_days(current_data.current_year,
                                            current_data.current_day,
                                            current_data.current_day)

    return render_template('games/pages/game_day.html',
                           current_data=current_data,
                           games=games)
Exemple #7
0
    def get_standings_team_history_view(team_id):
        record_service = RecordService()
        app_service = AppService()
        team_service = TeamService()
        team = team_service.get_by_id(team_id)
        teams = team_service.get_all()
        current_data = app_service.get_current_data()
        records = record_service.get_by_team(team_id)
        record_service.sort_by_year(records)

        return StandingsTeamHistoryViewModel(current_data, team.name, records,
                                             teams)
    def test_should_get_standings_history_view(self):
        self.setup_test()
        team_service = TeamService()
        record_service = RecordService()
        app_service = AppService()
        app_service.setup_data(35, 1, True, True)

        standings_service = StandingsService()

        for i in range(10):
            team_service.create("Team " + str(i), 5, True)

        record_service.add(team_service.get_all(), 25)
        record_service.add(team_service.get_all(), 35)
        record_service.add(team_service.get_all(), 2)

        result = standings_service.get_standings_history_view(2)
        self.assertEqual(10, len(result.records))
Exemple #9
0
def button_setup_clicked():
    app_service = AppService()
    game_rules_service = GameRulesService()
    rules = game_rules_service.get_by_name(rules_name)

    game_data = app_service.get_current_data()
    if game_data.is_year_finished:
        app_service.go_to_next_year()
        app_service.setup_year(rules, rounds, do_home_and_away)

    return get_home_page()
Exemple #10
0
def get_home_page():
    standings_service = StandingsService()
    standings_view = standings_service.get_current_standings_view()
    app_service = AppService()
    current_data = app_service.get_current_data()

    year = current_data.current_year
    day = current_data.current_day

    game_service = GameService()
    day_map = {}
    games = game_service.get_games_for_days(year, day - 10, day)

    for game in games:
        if not game.day in day_map:
            day_map[game.day] = []
        day_map[game.day].append(game)

    button_view = ButtonViewModel(current_data)
    homepage_view = HomePageViewModel(day_map, current_data, standings_view,
                                      button_view, current_data.current_day)

    return render_template("homepage.html", view=homepage_view)
Exemple #11
0
if setup:
    Database.clean_up_database(Database.get_session())
    data_setup.setup()

if add_teams:
    data_setup.add_new_teams()

team_service = TeamService()

for t in team_service.get_all():
    print(t.name + " " + str(t.skill))

game_service = GameService()
record_service = RecordService()
game_rules_service = GameRulesService()
app_service = AppService()
rules = game_rules_service.get_by_name(rules_name)

game_data = app_service.get_current_data()
if game_data.is_year_finished:
    app_service.go_to_next_year()
    app_service.setup_year(rules, rounds, do_home_and_away)

while not app_service.is_year_complete():
    game_data = app_service.get_current_data()
    # print("Playing games on day " + str(game_data.current_day))
    r = random
    app_service.play_and_process_games_for_current_day(r)
    os.system('cls')
    record_service.update_rank(game_data.current_year)
    table = record_service.get_by_year(game_data.current_year)
Exemple #12
0
from app_config import db_connection_string
from teams.data.database import Database
from teams.domain.competition_configuration import CompetitionConfiguration, TableSubCompetitionConfiguration, \
    RankingGroupConfiguration, CompetitionTeamConfiguration
from teams.services.app_service import AppService
from teams.services.configuration_service import ConfigurationService
from teams.services.game_service import GameRulesService
from teams.services.team_service import TeamService

setup = True

Database.init_db(db_connection_string)

# services
app_service = AppService()
game_rules_service = GameRulesService()
team_service = TeamService()
config_service = ConfigurationService()


def setup():
    game_rules_service.create("Season", True)
    game_rules_service.create("Playoff", False)
    app_service.setup_data(0, 0, True, True)
    setup_teams()


all_teams = ["Toronto", "Montreal", "Ottawa", "Quebec City", "Vancouver", "Calgary", "Edmonton", "Winnipeg"]
western_teams = ["Vancouver", "Calgary", "Edmonton", "Winnipeg"]
eastern_teams = ["Toronto", "Montreal", "Ottawa", "Quebec City"]