def add_player():
    new_player1 = request.form['player1']
    new_player2 = request.form['player2']
    new_game = request.form['game_number']
    player1 = player_repository.select(new_player1)
    player2 = player_repository.select(new_player2)
    # number = game_repository.select(new_game)
    game = Game(new_game, player1, player2)
    game_repository.save(game)
    return redirect('/games')
def create_game():
    print(request.form)
    name = request.form['name']
    worker = worker_repository.select(request.form["worker_id"])
    genre = request.form['genre']
    price = request.form['price']
    buying_cost = request.form['buying_cost']
    stock = request.form['stock']
    studio = studio_repository.select(request.form["studio_id"])
    game = Game(name, worker, genre, price, buying_cost, stock, studio)
    game_repository.save(game)
    return redirect("/games")
Exemple #3
0
def create_game():
    date = request.form["date"]
    venue = request.form["venue"]
    team_1_id = request.form["team_1_id"]
    team_1 = team_repository.select(team_1_id)
    team_2_id = request.form["team_2_id"]
    team_2 = team_repository.select(team_2_id)
    team_1_score = request.form["team_1_score"]
    team_2_score = request.form["team_2_score"]
    new_game = Game(date, venue, team_1, team_2, team_1_score, team_2_score)
    game_repository.save(new_game)
    return redirect('/games')
def create_game():
    team1 = request.form['team1']
    team2 = request.form['team2']
    game_week = request.form['game_week']
    league = request.form['league']
    team = request.form['team']

    team = team_repository.select(team_id)
    league = league_repository.select(league_id)
    game = Game(team1, team2, game_week, league)
    game_repository.save(game)
    return redirect('/games')

# SHOW (result)
# GET '/games/<id>' and apply game_winner(id)
Exemple #5
0
def register_game(game: RegisterGameRequest):
    black, white = (player_repository.find_by_name(game.black_player_name),
                    player_repository.find_by_name(game.white_player_name))

    winner, loser = (white, black) if game.result == 'WHITE' else (black,
                                                                   white)

    winner.elo, loser.elo = rate_1vs1(winner.elo,
                                      loser.elo,
                                      drawn=game.result == 'DRAW')

    game = Game(white_player_id=white.id,
                white_player_name=white.name,
                white_player_elo=white.elo,
                black_player_id=black.id,
                black_player_name=black.name,
                black_player_elo=black.elo,
                result=game.result,
                time=datetime.now())

    game = game_repository.save(game)
    player_repository.update(winner)
    player_repository.update(loser)

    return game
tournament_repository.delete_all()
player_repository.delete_all()
game_repository.delete_all()

# starts adding entries
player1 = Player('Charo')
player_repository.save(player1)

player2 = Player('Neil')
player_repository.save(player2)

player3 = Player('Joe')
player_repository.save(player3)

game1 = Game(1, player1, player2)
game_repository.save(game1)

game2 = Game(2, player1, player3)
game_repository.save(game2)

game3 = Game(3, player3, player2)
game_repository.save(game3)

tournament1 = Tournament(game1, player1, player2)
tournament_repository.save(tournament1)

tournament2 = Tournament(game2, player3, player1)
tournament_repository.save(tournament2)

pdb.set_trace()
Exemple #7
0
team_repository.save(team_10)

player_1 = Player("Kieran Lamb", "Centre Back", team_1)
player_repository.save(player_1)

player_2 = Player("Aidan Lamb", "Left back", team_2)
player_repository.save(player_2)

player_3 = Player("Gwen", "Centre mid", team_1)
player_repository.save(player_3)

player_4 = Player("Stuart", "GK", team_1)
player_repository.save(player_4)

game_1 = Game("12/07/95", "Peffermill", team_1, team_2, 1, 1)
game_repository.save(game_1)

game_2 = Game("25/12/2020", "Inveralmond", team_3, team_1, 2, 0)
game_repository.save(game_2)

game_3 = Game("4/03/2008", "Glasgow Green", team_2, team_1, 2, 4)
game_repository.save(game_3)

# game_4 = Game("20/06/2012", "Aberdeen", team_2, team_3, 10, 4)
# game_repository.save(game_4)

# team_repository.games(team_1)

pdb.set_trace()

# game_4.date = "0000000"
microsoft = Studio("Microsoft")
studio_repository.save(microsoft)
bethesda = Studio("Bethesda")
studio_repository.save(bethesda)
square = Studio("Square Enix")
studio_repository.save(square)
ea = Studio("EA Games")
studio_repository.save(ea)
rockstar = Studio("Rockstar Games")
studio_repository.save(rockstar)
epic = Studio("Epic Games")
studio_repository.save(epic)

# Sony games
demons = Game("Demons Souls", worker_1, "Horror", 69.99, 60.00, 2, sony)
game_repository.save(demons)
spider = Game("Spider-Man", worker_1, "Adventure", 69.99, 60.00, 11, sony)
game_repository.save(spider)
astro = Game("Astro's Playroom", worker_1, "Fun", 69.99, 60.00, 3, sony)
game_repository.save(astro)

# Ubisoft games
assassins = Game("Assassin's Creed Valhalla", worker_2, "Action", 46.85, 50.00,
                 7, ubisoft)
game_repository.save(assassins)

# Nintendo games
zelda = Game("Breath of the Wild", worker_3, "Action/Adventure", 43.00, 40.00,
             25, nintendo)
game_repository.save(zelda)
ac = Game("Animal Crossing: New Horizons", worker_3, "Life Simulation", 39.99,
team_repository.save(team4)
# above code will create each team and save to the DB

team_repository.select_all()
# above method will display the teams

league1 = League("NFC Division 1", team1)
league_repository.save(league1)
# above will create a league and save to DB

league_repository.select_all()
# above will take all info that's gone into the league
# need to input data for the league (table) to be able to populate it with game_wins

game1 = Game(team1, team2, "game week 1", league1)
game_repository.save(game1)
game2 = Game(team3, team4, "game week 1", league1)
game_repository.save(game2)

game3 = Game(team1, team3, "game week 2", league1)
game_repository.save(game3)
game4 = Game(team2, team4, "game week 2", league1)
game_repository.save(game4)

game5 = Game(team1, team4, "game week 3", league1)
game_repository.save(game5)
game6 = Game(team3, team2, "game week 3", league1)
game_repository.save(game6)

game7 = Game(team2, team1, "game week 4", league1)
game_repository.save(game7)