def prepare_tournament_games(round_of): L.info('***** prepare tournament games for round of %d' % round_of) # 직전 라운드(16강)는 이번 라운드(8강) * 2 # 직전 라운드(16강) 결과에서 이번 라운드(8강) 대진표가 정해짐 games = get_games_round_of(round_of * 2) # 토너먼트: 직전 라운드의 경기 수 == 이번 라운드 번호 if len(games) == round_of: # 이번 라운드 경기수 = 이번 라운드(8강) / 2 for i in range(int(round_of / 2)): # 앞쪽 반을 순회하면서.. 뒤쪽 반은 역순으로... # 최고점자 vs 최저점자 p1 = games[i].winner p2 = games[-1 - i].winner g = Game(p1, p2, round_of) db.session.add(g) db.session.commit() L.info('prepare game#%d round of #%d : %s vs %s' % (g.id, round_of, p1, p2)) # 예선 풀 리그: 직전 라운드의 경기 수 == 0 else: # FIXME: .... players = get_players(round_of) # 이번 라운드 경기수 = 이번 라운드(8강) / 2 for i in range(int(round_of / 2)): # 앞쪽 반을 순회하면서.. 뒤쪽 반은 역순으로... # 최고점자 vs 최저점자 p1 = players[i].name p2 = players[-1 - i].name g = Game(p1, p2, round_of) db.session.add(g) db.session.commit() L.info('prepare game#%d round of #%d : %s vs %s' % (g.id, round_of, p1, p2))
def init_db(session): Base.metadata.create_all(engine) # skip if there are games already if session.query(Game).first(): return game = Game(name="Test Game", uuid="A97E57A2-E440-4975-A624-6F99999D64DA") questions = [Question(question="Who won the quiz?", game=game)] session.add(game) game = Game(name="new", uuid="C0CFAF27-0770-400E-A9B9-82461ED9FB6F") questions = [ Question(question="Who is good at this?", game=game), Question(question="Who read the next question?", game=game), ] session.add(game) session.commit() t = Team(name="ee22dc", team_code="111", game_id=game.id) session.commit() p = Player(color="#ee22dc", name="p1") sp = PlayerInGame(team=t, player=p, game=game) session.add(p) session.commit() session.add( GivenAnswer(answer="This is my answer", question_uuid=questions[0].uuid, player_id=p.id)) session.commit()
def act_createGame(data): user = dbi.getXbyY('User', 'sid', data['sid']) if user.gameId: raise BadFieldException('alreadyInGame') map_ = dbi.getXbyY('Map', 'id', data['mapId']) descr = None if 'gameDescription' in data: descr = data['gameDescription'] randseed = math.trunc(time.time()) if 'randseed' in data: randseed = data['randseed'] ai = data['ai'] if 'ai' in data else 0 if ai > map_.playersNum: raise BadFieldException('tooManyPlayersForMap') newGame = Game(data['gameName'], descr, map_, randseed, data['ai'] if 'ai' in\ data else None) dbi.addUnique(newGame, 'gameName') initRegions(map_, newGame) if ai < map_.playersNum: user.game = newGame user.priority = 1 user.inGame = True dbi.flush(user) if not misc.TEST_MODE: data['randseed'] = randseed dbi.updateGameHistory(user.game, data) return {'result': 'ok', 'gameId': newGame.id}
def main(): init_db("carreritas.db") users = User.select() if not users.count(): create_random_user() users = User.select() _map = Map() game = Game(users[0], _map) frame = game.map.render(game.players, game.winners) frame.save("0.png") while True: player = game.next_player() game.play_turn(player) frame = game.map.render(game.players, game.winners) frame.save(f"{game.turn}.png") if game.is_turn_finished(): if game.is_game_finished(): winners = [p for p in game.players if p.is_winner] if len(winners) > 0: print(f"Hubo mas de un ganador: {winners}") else: print(f"Ganó el jugador {winners[0]}") else: game.turn += 1
def getMatch(): game = Game() print('\nAVAILABLE MATCHES\n') game.viewGames() mID = int(input('Enter match you want to book for: ')) if game.gameVerify(mID) != 1: print('The match id you entered is invalid!\nPlease Try Again!!\n') getMatch() return mID
def prepare_full_league_games(max_player): L.info('***** prepare full league games for %d players' % max_player) players = get_players(max_player) for p1 in players: for p2 in players: if p1.name == p2.name: break g = Game(p1.name, p2.name, 0) db.session.add(g) db.session.commit() L.info('prepare game#%d full league %s vs %s' % (g.id, p1.name, p2.name))
def process_create_game(socw, msg): # create game name = msg.params['name'] game = find_game_by_name(name) if not game: game = Game() game.name = name game.players.append(socw.get_user()) db.games.append(game) # send OK msg = AppMessageFactory.ok() socw.send_message(msg)
def new(): """Start a new game. Create a new Game object, quit current game if any, start the game, and redirect to / route. """ game = Game() if current_user.has_current_game: current_user.current_player.quit() game.add_player(current_user) game.start() return redirect('/')
def create_game(teamOneId, teamTwoId): post_body = json.loads(request.data) teamOneScore = post_body.get('teamOneScore', 0) teamTwoScore = post_body.get('teamTwoScore', 0) game = Game(teamOneId=teamOneId, teamTwoId=teamTwoId, teamOneScore=teamOneScore, teamTwoScore=teamTwoScore) db.session.add(game) db.session.commit() return json.dumps({'success': True, 'data': game.serialize()}), 201
def create_game(): game_form = form.GameCreateForm() if not game_form.validate_on_submit(): return jsonify(errors=game_form.errors) name = game_form.name.data map_name = game_form.map_name.data game = Game(name=name, map_name=map_name, state=collection.get(map_name, State.sample())) db.session.add(game) db.session.commit() return fl.redirect(fl.url_for("index"))
def parse_game(data, session): """ adds an entry to the Game table """ competitions = data["gamepackageJSON"]["header"]["competitions"][0] # date of the game in datetime format date = competitions["date"] date = datetime.datetime.strptime( date, '%Y-%m-%dT%H:%MZ') - datetime.timedelta(hours=4) # the id's of the two teams playing team_0 = competitions["competitors"][0]["team"]["abbreviation"] team_1 = competitions["competitors"][1]["team"]["abbreviation"] # parse home and away teams, as well as game score if competitions["competitors"][0]["homeAway"] == "home": home, visitor = team_0, team_1 home_score = intf(competitions["competitors"][0]["score"]) visitor_score = intf(competitions["competitors"][1]["score"]) else: home, visitor = team_1, team_0 home_score = intf(competitions["competitors"][1]["score"]) visitor_score = intf(competitions["competitors"][0]["score"]) # parse winner and loser if competitions["competitors"][0]["winner"]: winner, loser = team_0, team_1 else: winner, loser = team_1, team_0 isLeague = competitions["conferenceCompetition"] g = session.query(Game).filter_by(date=date, home=home).first() if not g: g = Game(id=data["gameId"], date=date, home=home, visitor=visitor, winner=winner, loser=loser, home_score=home_score, visitor_score=visitor_score, isLeague=isLeague) session.add(g)
def conn(): if isLoggedIn(): uid = session["uid"] gm.removeTable(uid) ng = gm.hasGameWithId(uid) u = User.query.get(uid) g = Game(u) if ng == None: ng = cGame(logic.Game(), uid, u.nick) ng.game.new_game() gm.addTable(ng) db.session.add(g) db.session.commit() join_room(room) else: #Already playing (prevent multiple login) return False emit("player_connect", (uid, u.nick), room=room) emit("bupdate", printBoard(ng), room=room) emit("load_others", gm.getGames(uid))
def manageGames(): print( "\n\nWelcome To the stadium ticket booking system!\nAdmin Menu\nManage Games\n" "1. View all Games\n" "2. Add Game\n" "3. Remove Game\n" "4. Edit Game\n" "5. Reset\n" "6. Exit\n" ) choice = int(input("Enter your choice: ")) game = Game() if choice == 1: game.viewGames() elif choice == 2: gameName = input('Enter game Name: ') date = input('Enter game Date: ') time = input('Enter game Time: ') game.addGame(gameName,date,time) elif choice == 3: gID = input('Enter game ID to remove: ') try: game.removeGame(gID) except: print('\nGame not found!\n') elif choice == 4: gID = input('Enter game ID to Edit: ') game.editGame(gID) elif choice == 5: game.resetTable() elif choice == 6: return else: print('The Choice you entered is invalid!\nPlease Try Again!!\n') manageGames() manageGames()
def xml_to_database(xml_file): game_info = parse_game_file(xml_file) # Extract information for the Game table venue = game_info['venue'] home = venue["home_id"] vis = venue["vis_id"] # Check if information for this game has already been added - if it has, then exit the function if session.query(Game).filter_by(date=venue['date'], home=venue['home_id']).first(): return "ERR: Game data already documented. Aborting upload" g = Game(date=venue['date'], home=venue['home_id'], visitor=venue['vis_id'], isLeague=venue['is_league'], isPlayoff=venue['is_playoff']) session.add(g) # Extract information for Team table, adding the playing teams to the database if they don't already exist t1 = session.query(Team).filter_by(team_id=venue['home_id']).first( ) # Should only be one team with each id, so we can use first() t2 = session.query(Team).filter_by(team_id=venue['vis_id']).first() if not t1: t1 = Team(team_id=venue['home_id'], name=venue['home_name']) session.add(t1) if not t2: t2 = Team(team_id=venue['vis_id'], name=venue['vis_name']) session.add(t2) # Extract information for the TeamIn table """ TODO: Wrap everything in its own adder function, maybe put this in a file like py2db.py, which converts from the python dictionary to the database""" team1 = game_info['t1'] spec = team1['special'] stats = team1['stats'] p1_vh = True if spec['vh'] == 'H' else False plays_in_team_one = TeamIn(team=team1["id"], game=g.id, fgm=stats['fgm'], fga=stats['fga'], fgm3=stats['fgm3'], fga3=stats['fga3'], fta=stats['fta'], ftm=stats['ftm'], tp=stats['tp'], blk=stats['blk'], stl=stats['stl'], ast=stats['ast'], oreb=stats['oreb'], dreb=stats['dreb'], treb=stats['treb'], pf=stats['pf'], tf=stats['tf'], to=stats['to'], is_home=p1_vh, pts_to=spec['pts_to'], pts_paint=spec['pts_paint'], pts_ch2=spec['pts_ch2'], pts_fastb=spec['pts_fastb'], pts_bench=spec['pts_bench'], ties=spec['ties'], leads=spec['leads'], poss_count=spec['poss_count'], poss_time=spec['poss_time'], score_count=spec['score_count'], score_time=spec['score_time']) session.add(plays_in_team_one) team2 = game_info['t2'] spec = team2['special'] stats = team2['stats'] p2_vh = True if spec['vh'] == 'H' else False plays_in_team_two = TeamIn(team=team2["id"], game=g.id, fgm=stats['fgm'], fga=stats['fga'], fgm3=stats['fgm3'], fga3=stats['fga3'], fta=stats['fta'], ftm=stats['ftm'], tp=stats['tp'], blk=stats['blk'], stl=stats['stl'], ast=stats['ast'], oreb=stats['oreb'], dreb=stats['dreb'], treb=stats['treb'], pf=stats['pf'], tf=stats['tf'], to=stats['to'], is_home=p2_vh, pts_to=spec['pts_to'], pts_paint=spec['pts_paint'], pts_ch2=spec['pts_ch2'], pts_fastb=spec['pts_fastb'], pts_bench=spec['pts_bench'], ties=spec['ties'], leads=spec['leads'], poss_count=spec['poss_count'], poss_time=spec['poss_time'], score_count=spec['score_count'], score_time=spec['score_time']) session.add(plays_in_team_two) session.commit() # Put in information on total game scores if team1['special']['vh'] == 'H': # team1 is the home team g.home_score = team1['stats']['score'] g.visitor_score = team2['stats']['score'] else: g.home_score = team2['stats']['score'] g.visitor_score = team1['stats']['score'] if team1['stats']['score'] > team2['stats']['score']: g.winner = team1['id'] g.loser = team2['id'] else: g.winner = team2['id'] g.loser = team1['id'] session.add(g) session.commit() # Loop through Players and add them to the database if they don't already exist, repeat for team2 starters_team_1 = [] for player in team1['players']: name_formatted = player["checkname"].title() if player["checkname"] != "TEAM": comma = name_formatted.index(",") name_formatted = name_formatted[:comma + 1] + " " + name_formatted[comma + 1:] p = session.query(Player).filter_by(name=name_formatted.title(), team=team1["id"]).first() if not p: # If the player's not already in the database add him p = Player(name=name_formatted, team=team1["id"]) session.add(p) session.commit() # Some players don't have stats for the game - we ignore those by checking arbitrarily for the fgm stat to exist # Example: Keion Green from CENTPENN if "fgm" in player: game_stats = PlayerIn(player=p.id, game=g.id, fgm=player["fgm"], fga=player["fga"], fgm3=player["fgm3"], fga3=player["fga3"], ftm=player["ftm"], fta=player["fta"], tp=player["tp"], blk=player["blk"], stl=player["stl"], ast=player["ast"], oreb=player["oreb"], dreb=player["dreb"], treb=player["treb"], pf=player["pf"], tf=player["tf"], to=player["to"], dq=player["dq"], number=player["uni"], mins=player["min"]) session.add(game_stats) if "gs" in player: starters_team_1.append(p.id) session.commit() # Add stats for the player for the game # Now do the same thing for team2 starters_team_2 = [] for player in team2['players']: name_formatted = player["checkname"].title() if player["checkname"] != "TEAM": comma = name_formatted.index(",") name_formatted = name_formatted[:comma + 1] + " " + name_formatted[comma + 1:] p = session.query(Player).filter_by(name=name_formatted, team=team2["id"]).first() if not p: # If the player's not already in the database add him p = Player(name=name_formatted, team=team2["id"]) session.add(p) session.commit() # Some players don't have stats for the game - we ignore those by checking arbitrarily for the fgm stat to exist # Example: Keion Green from CENTPENN if "fgm" in player: game_stats = PlayerIn(player=p.id, game=g.id, fgm=player["fgm"], fga=player["fga"], fgm3=player["fgm3"], fga3=player["fga3"], ftm=player["ftm"], fta=player["fta"], tp=player["tp"], blk=player["blk"], stl=player["stl"], ast=player["ast"], oreb=player["oreb"], dreb=player["dreb"], treb=player["treb"], pf=player["pf"], tf=player["tf"], to=player["to"], dq=player["dq"], number=player["uni"], mins=player["min"]) if "gs" in player: starters_team_2.append(p.id) session.add(game_stats) session.commit() # print("TEAM ONE STARTERS", starters_team_1) # print("TEAM TWO STARTERS", starters_team_2) if team1["id"] == home: home_on_court = starters_team_1 away_on_court = starters_team_2 else: home_on_court = starters_team_2 away_on_court = starters_team_1 # Now create a dummy play that initializes the starters starters_play = Play(game_id=g.id, period=1, time="20:00", scoring_play=False, shooting_play=False, home_score=0, away_score=0, text="Starters", action="Starters", type="", h1=home_on_court[0], h2=home_on_court[1], h3=home_on_court[2], h4=home_on_court[3], h5=home_on_court[4], v1=away_on_court[0], v2=away_on_court[1], v3=away_on_court[2], v4=away_on_court[3], v5=away_on_court[4]) session.add(starters_play) session.commit() plays = game_info["plays"] last_v_score = 0 last_h_score = 0 # TODO: add a dummy play to the start of the second period for period in plays: if team1["id"] == home: home_on_court = starters_team_1 away_on_court = starters_team_2 else: home_on_court = starters_team_2 away_on_court = starters_team_1 for play in plays[period]: # print(play) name_formatted = play["checkname"].title() if play["checkname"] != "TEAM": comma = name_formatted.index(",") name_formatted = name_formatted[:comma + 1] + " " + name_formatted[ comma + 1:] player_id = session.query(Player).filter_by( name=name_formatted, team=play["team"]).first().id # Update home_on_court and away_on_court as necessary if play["action"] == "SUB": if play["type"] == "OUT": if player_id in home_on_court: home_on_court.remove(player_id) elif player_id in away_on_court: away_on_court.remove(player_id) if play["type"] == "IN": team = session.query(Player).filter_by( id=player_id).first().team # print(team) if team == home: home_on_court.append(player_id) else: away_on_court.append(player_id) # TODO: make sure this loops in order of increasing period, dicts are unpredictable if play["action"] == "GOOD": # Update the last known score after someone scores last_v_score = play["vscore"] last_h_score = play["hscore"] this_play = Play( game_id=g.id, period=period, time=play["time"], scoring_play=play["action"] == "GOOD", shooting_play=( play["type"] == "LAYUP" or play["type"] == "3PTR" or play["type"] == "JUMPER") if "type" in play else False, home_score=last_h_score, away_score=last_v_score, text="", action=play["action"], type=play["type"] if "type" in play else "", player_id=player_id, h1=home_on_court[0] if len(home_on_court) > 0 else -1, h2=home_on_court[1] if len(home_on_court) > 1 else -1, h3=home_on_court[2] if len(home_on_court) > 2 else -1, h4=home_on_court[3] if len(home_on_court) > 3 else -1, h5=home_on_court[4] if len(home_on_court) > 4 else -1, v2=away_on_court[0] if len(away_on_court) > 0 else -1, v1=away_on_court[1] if len(away_on_court) > 1 else -1, v3=away_on_court[2] if len(away_on_court) > 2 else -1, v4=away_on_court[3] if len(away_on_court) > 3 else -1, v5=away_on_court[4] if len(away_on_court) > 4 else -1) this_play.convert_time(int(this_play.period), this_play.time) session.add(this_play) session.commit()
def populate_db(d): # Players david = Player(name='david', display_name='DarthMarth', password='******') nathan = Player(name='Nathan', display_name='humcalc', password='******') elwood = Player(name='Elwood', display_name='Kalen', password='******') # Games game = Game(id_=1, num_rounds=2, players=[david, nathan, elwood]) long_game = Game(id_=2, num_rounds=4, players=[david, nathan]) unfinished_game = Game(id_=3, num_rounds=2, players=[david, elwood, nathan]) queue_game = Game(id_=4, players=[david, nathan, elwood]) reverse_game = Game(id_=5, pass_left=False, players=[david, nathan, elwood]) draw_first_game = Game(id_=6, write_first=False, players=[david, nathan, elwood]) # Pending games pending_game_1 = PendingGame(id_=1, pass_left=False, creator=david, players=[david, nathan, elwood]) pending_game_2 = PendingGame(id_=2, num_rounds=3, write_first=False, creator=elwood, players=[david, elwood]) pending_game_3 = PendingGame(id_=3, num_rounds=5, write_first=False, creator=nathan, players=[nathan, elwood]) pending_game_4 = PendingGame(id_=4, num_rounds=7, creator=david, players=[david]) invitation = Invitation(recipient=nathan, game=pending_game_2) invitation2 = Invitation(recipient=david, game=pending_game_3) invitation3 = Invitation(recipient=elwood, game=pending_game_4) # Stacks yesterday = Stack(game=game, owner=david) hungry_cat = Stack(game=long_game, owner=david) olympics = Stack(game=unfinished_game, owner=david) enders_game = Stack(game=game, owner=nathan) dediscovering = Stack(game=long_game, owner=nathan) changing_stack = Stack(game=unfinished_game, owner=nathan) eiffel_tower = Stack(game=game, owner=elwood) fire_dice = Stack(game=unfinished_game, owner=elwood) q_yesterday = Stack(game=queue_game, owner=david) q_enders_game = Stack(game=queue_game, owner=nathan) q_eiffel_tower = Stack(game=queue_game, owner=elwood) d_stack_reverse = Stack(game=reverse_game, owner=david) n_stack_reverse = Stack(game=reverse_game, owner=nathan) e_stack_reverse = Stack(game=reverse_game, owner=elwood) d_stack_drawfirst = Stack(game=draw_first_game, owner=david) n_stack_drawfirst = Stack(game=draw_first_game, owner=nathan) e_stack_drawfirst = Stack(game=draw_first_game, owner=elwood) # Game dw_11 = Writing(text="Coming soon: yesterday", stack_pos=0, stack=yesterday, author=david) dw_12 = Writing(text="Be kind, bake your VHS tapes at 400 degrees for " "20 minutes before returning", stack_pos=2, stack=enders_game, author=david) dw_13 = Writing(text="The pyramid is sad because it fell over. " "People measure it instead of helping.", stack_pos=4, stack=eiffel_tower, author=david) nw_11 = Writing(text="Ender's Game", stack_pos=0, stack=enders_game, author=nathan) nw_12 = Writing(text="The Eiffel Tower is sad that it's being subjected to a linear " "transformation that's stretching in the x direction and " "compressing in the y direction.", stack_pos=2, stack=eiffel_tower, author=nathan) nw_13 = Writing(text="Daylight Savings starts on Monday the 21st this year " "for some reason.", stack_pos=4, stack=yesterday, author=nathan) ew_11 = Writing(text="An Awful Eiffel Tower", stack_pos=0, stack=eiffel_tower, author=elwood) ew_12 = Writing(text="Passing an hour on the fourth Monday.", stack_pos=2, stack=yesterday, author=elwood) ew_13 = Writing(text="Roomba is ready to vacuum up the shocked TV person's mess", stack_pos=4, stack=enders_game, author=elwood) dd_11 = Drawing(drawing=open(os.path.join('data', 'drawings', 'dd_11.jpg'), 'rb').read(), stack_pos=1, stack=eiffel_tower, author=david) dd_12 = Drawing(drawing=open(os.path.join('data', 'drawings', 'dd_12.jpg'), 'rb').read(), stack_pos=3, stack=yesterday, author=david) dd_13 = Drawing(drawing=open(os.path.join('data', 'drawings', 'dd_13.jpg'), 'rb').read(), stack_pos=5, stack=enders_game, author=david) nd_11 = Drawing(drawing=open(os.path.join('data', 'drawings', 'nd_11.jpg'), 'rb').read(), stack_pos=1, stack=yesterday, author=nathan) nd_12 = Drawing(drawing=open(os.path.join('data', 'drawings', 'nd_12.jpg'), 'rb').read(), stack_pos=3, stack=enders_game, author=nathan) nd_13 = Drawing(drawing=open(os.path.join('data', 'drawings', 'nd_13.jpg'), 'rb').read(), stack_pos=5, stack=eiffel_tower, author=nathan) ed_11 = Drawing(drawing=open(os.path.join('data', 'drawings', 'ed_11.jpg'), 'rb').read(), stack_pos=1, stack=enders_game, author=elwood) ed_12 = Drawing(drawing=open(os.path.join('data', 'drawings', 'ed_12.jpg'), 'rb').read(), stack_pos=3, stack=eiffel_tower, author=elwood) ed_13 = Drawing(drawing=open(os.path.join('data', 'drawings', 'ed_13.jpg'), 'rb').read(), stack_pos=5, stack=yesterday, author=elwood) # Long game dw_21 = Writing(text="A cat (hungry) on a conveyor belt to Mexican Hell. " "Old mice watch.", stack_pos=0, stack=hungry_cat, author=david) dw_22 = Writing(text="Europeans waiting in line for food and communism", stack_pos=2, stack=hungry_cat, author=david) dw_23 = Writing(text="Daggers piercing balloons makes for a sunny week.", stack_pos=4, stack=hungry_cat, author=david) dw_24 = Writing(text="Recursive sunset chainsaw massacre", stack_pos=6, stack=hungry_cat, author=david) nw_21 = Writing(text="The de-discovering of America. The Europeans were afraid of the colossi.", stack_pos=0, stack=dediscovering, author=nathan) nw_22 = Writing(text="Elworld. The Elwood,themed theme park", stack_pos=2, stack=dediscovering, author=nathan) nw_23 = Writing(text="A dinosaur texting his prey.", stack_pos=4, stack=dediscovering, author=nathan) nw_24 = Writing(text="Dead puppies make new puppies", stack_pos=6, stack=dediscovering, author=nathan) dd_21 = Drawing(drawing=open(os.path.join('data', 'drawings', 'dd_21.jpg'), 'rb').read(), stack_pos=1, stack=dediscovering, author=david) dd_22 = Drawing(drawing=open(os.path.join('data', 'drawings', 'dd_22.jpg'), 'rb').read(), stack_pos=3, stack=dediscovering, author=david) dd_23 = Drawing(drawing=open(os.path.join('data', 'drawings', 'dd_23.jpg'), 'rb').read(), stack_pos=5, stack=dediscovering, author=david) dd_24 = Drawing(drawing=open(os.path.join('data', 'drawings', 'dd_24.jpg'), 'rb').read(), stack_pos=7, stack=dediscovering, author=david) nd_21 = Drawing(drawing=open(os.path.join('data', 'drawings', 'nd_21.jpg'), 'rb').read(), stack_pos=1, stack=hungry_cat, author=nathan) nd_22 = Drawing(drawing=open(os.path.join('data', 'drawings', 'nd_22.jpg'), 'rb').read(), stack_pos=3, stack=hungry_cat, author=nathan) nd_23 = Drawing(drawing=open(os.path.join('data', 'drawings', 'nd_23.jpg'), 'rb').read(), stack_pos=5, stack=hungry_cat, author=nathan) nd_24 = Drawing(drawing=open(os.path.join('data', 'drawings', 'nd_24.jpg'), 'rb').read(), stack_pos=7, stack=hungry_cat, author=nathan) # Unfinished game dw_31 = Writing(text="The Olympic hide-and-seek championships", stack_pos=0, stack=olympics, author=david) dw_32 = Writing(text="1d4, 1d6, 1d8 roasting on an open fire", stack_pos=2, stack=fire_dice, author=david) nw_31 = Writing(text="Changing the meaning of the stack in Telephone Pictionary", stack_pos=0, stack=changing_stack, author=nathan) nw_32 = Writing(text="Olympic fan waving", stack_pos=2, stack=olympics, author=nathan) ew_31 = Writing(text="Fire Dice", stack_pos=0, stack=fire_dice, author=elwood) ew_32 = Writing(text="Nerd is angry/surprised that things are collating the " "wrong way when printed", stack_pos=2, stack=changing_stack, author=elwood) dd_31 = Drawing(drawing=open(os.path.join('data', 'drawings', 'dd_31.jpg'), 'rb').read(), stack_pos=1, stack=changing_stack, author=david) dd_32 = Drawing(drawing=open(os.path.join('data', 'drawings', 'dd_32.jpg'), 'rb').read(), stack_pos=3, stack=olympics, author=david) nd_31 = Drawing(drawing=open(os.path.join('data', 'drawings', 'nd_31.jpg'), 'rb').read(), stack_pos=1, stack=fire_dice, author=nathan) nd_32 = Drawing(drawing=open(os.path.join('data', 'drawings', 'nd_32.jpg'), 'rb').read(), stack_pos=3, stack=changing_stack, author=nathan) ed_31 = Drawing(drawing=open(os.path.join('data', 'drawings', 'ed_31.jpg'), 'rb').read(), stack_pos=1, stack=olympics, author=elwood) ed_32 = Drawing(drawing=open(os.path.join('data', 'drawings', 'ed_32.jpg'), 'rb').read(), stack_pos=3, stack=fire_dice, author=elwood) # Queue game q_dw = Writing(text="Coming soon: yesterday", stack_pos=0, stack=q_yesterday, author=david) q_nw = Writing(text="Ender's Game", stack_pos=0, stack=q_enders_game, author=nathan) q_ew = Writing(text="An Awful Eiffel Tower", stack_pos=0, stack=q_eiffel_tower, author=elwood) q_nd = Drawing(drawing=open(os.path.join('data', 'drawings', 'nd_11.jpg'), 'rb').read(), stack_pos=1, stack=q_yesterday, author=nathan) # Reverse game r_dw = Writing(text="Europeans waiting in line for food and communism", stack_pos=0, stack=d_stack_reverse, author=david) r_nw = Writing(text="Elworld. The Elwood,themed theme park", stack_pos=0, stack=n_stack_reverse, author=nathan) r_ew = Writing(text="A dinosaur texting his prey.", stack_pos=0, stack=e_stack_reverse, author=elwood) # Draw first game df_ed = Drawing(drawing=open(os.path.join('data', 'drawings', 'nd_21.jpg'), 'rb').read(), stack_pos=0, stack=e_stack_drawfirst, author=elwood) with d.session_scope() as session: for ent in [david, nathan, elwood, queue_game, reverse_game, draw_first_game, pending_game_1, pending_game_2]: session.add(ent)