def createGame(sid, gameName, playersCount, mapName, factionName, totalCost): user = dbi().get_user(sid) if playersCount < 2: raise BadGame('Number of players must be 2 or more') if playersCount > MAX_PLAYERS: raise BadGame('Too many players') check_len(gameName, MAX_NAME_LENGTH, 'Too long game name', BadGame) check_emptiness(gameName, 'Empty game name', BadGame) if dbi().query(Player)\ .join(Game)\ .filter(Player.user_id == user.id)\ .filter(Player.is_creator == True)\ .filter(Game.state != 'finished')\ .count(): raise AlreadyInGame('User is already playing') if dbi().query(Game)\ .filter_by(name=gameName)\ .filter(Game.state != 'finished')\ .count(): raise AlreadyExists('Game with the such name already exists') if totalCost < MIN_TOTAL_COST: raise BadGame( 'totalCost must be greater than or equal to {0}'.format( MIN_TOTAL_COST)) map_id = dbi().get_map(mapName).id faction_id = dbi().get_faction(factionName).id game = Game(gameName, playersCount, map_id, faction_id, totalCost) dbi().add(game) player = Player(user.id, game.id) player.is_creator = True dbi().add(player) return response_ok()
def create(): diff_dict = {'F': 25, 'M': 50, 'D': 100} player_id = session.get('player') if player_id: player = get_player(player_id) if player: return redirect(url_for('mode')) else: session.pop('player', None) form = request.form if not form.get('name'): return render_template('create.html') else: nickname = form.get('name') diff = form.get('options') player = Player(nickname=nickname, diff=diff) player.created = datetime.now() player.save() #save之后自动生成player.id flash('Welcome, {}'.format(player.nickname)) session['player'] = unicode(player.id) session['diff'] = diff_dict[diff] if session["diff"] == 25: session["difficulte"] = "Easy" elif session["diff"] == 50: session["difficulte"] = "Normal" else: session["difficulte"] = "Hard" session['count'], session['score'] = 1, 0 session['bonus'] = 0 #session['malus'] = 0 return redirect(url_for('mode'))
def create_player(): post_body = json.loads(request.data) name = post_body.get('name', "") player = Player(name=name) db.session.add(player) db.session.commit() return json.dumps({'success': True, 'data': player.serialize()}), 201
def the_best_scores(): players_F = Player.objects(diff='F').order_by('-score').limit(10) top_10_F = [[x.nickname, x.score] for x in players_F] players_M = Player.objects(diff='M').order_by('-score').limit(10) top_10_M = [[x.nickname, x.score] for x in players_M] players_D = Player.objects(diff='D').order_by('-score').limit(10) top_10_D = [[x.nickname, x.score] for x in players_D] return render_template('the_best_scores.html', top_10_F=top_10_F, top_10_M=top_10_M, top_10_D=top_10_D)
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 handle(self, gameId): player = Player.byUser(self.user) if player is None: self.response.out.write("") return game = Game.byId(gameId) out = [player.email for player in game.players] self.response.out.write(json.dumps(out))
def handle(self, gameId): player = Player.byUser(self.user) if player is None: self.response.out.write("") return game = Game.byId(gameId) msg = self.request.get('msg') game.broadcast({ "sender": player.username, "message":msg})
def parse_players(data, session): """ Adds new players to the Players table and one entry per player to the Playerstats table """ game_id = data["gameId"] players = data["gamepackageJSON"]["boxscore"]["players"] # for each of the two teams for team in players: team_id = team["team"]["abbreviation"] # for every player on that team for athlete in team["statistics"][0]["athletes"]: athlete_id = intf(athlete["athlete"]["id"]) athlete_name = athlete["athlete"]["displayName"] position = athlete["athlete"]["position"]["displayName"] jersey_num = intf(athlete["athlete"]["jersey"]) # only add player if they are not yet in db, and they played in the game p = session.query(Player).filter_by(id=athlete_id).first() if (not p) and (not athlete["didNotPlay"]): p = Player(id=athlete_id, name=athlete_name, position=position, team=team_id) session.add(p) # if they played in the game, add their game stats if not athlete["didNotPlay"]: # s represents the parsed stats s = parse_stats(athlete["stats"]) player_stats = PlayerIn(game=game_id, player=athlete_id, number=jersey_num, mins=s["mins"], fgm=s["fgm"], fga=s["fga"], fgm3=s["fgm3"], fga3=s["fga3"], ftm=s["ftm"], fta=s["fta"], tp=s["tp"], blk=s["blk"], stl=s["stl"], ast=s["ast"], oreb=s["oreb"], dreb=s["dreb"], treb=s["treb"], pf=s["pf"], to=s["to"]) session.add(player_stats)
def handle(self, gameId): print "PlayJoin %s" % gameId game = Game.byId(gameId) if game is None: self.response.out.write("Invalid game") return player = Player.byUser(self.user) # Player joining this game fresh if player is None: player = Player.joinGame(self.user, game) # Player was in another game, leave it. if player.game.gameId != game.gameId: player.leaveGame() player = Player.joinGame(self.user, game) render(self, 'play.html', { 'me': player.user, 'token': player.token, 'game_key': player.game })
def mode(): player_id = session.get('player', None) if player_id is None: return redirect(url_for('create')) else: player = get_player(player_id) if player is None: session.pop('player', None) return redirect(url_for('create')) #post执行的部分 #redirect默认是get方法 if request.method == 'POST': m = request.form.get('optionsMode') if m == "Square": session['mode'] = "carre" return redirect(url_for('carre')) elif m == "50:50": session['mode'] = "duo" return redirect(url_for('duo')) else: session['mode'] = "cache" return redirect(url_for('cache')) # session['count'] = 1 # session['score'] = 1 #get方法的执行部分 if session['count'] == 11: score = session['score'] session.pop('count') session.pop('score') session.pop('player') players = Player.objects(diff=player.diff).order_by('-score').limit(10) top_10 = [[x.nickname, x.score] for x in players] return render_template('end.html', score=score, top_10=top_10) film1, film2, option_list, session['name'] = main_func(session['diff']) #print(session['name']) cover1 = game.get_cover(film1) cover2 = game.get_cover(film2) session['film_1'] = film1['title'] session['film_2'] = film2['title'] session['option_a'] = option_list[0] session['option_b'] = option_list[1] session['option_c'] = option_list[2] session['option_d'] = option_list[3] session['cover1'] = cover1 session['cover2'] = cover2 return render_template('select_mode.html')
def refresh_stats(): tid = request.form['tid'] stats = sbteamdata.get_team_data(tid) team = Team.query.filter_by(teamid=tid).order_by(Team.season.desc()).all() players = Player.query.filter_by(teamid=tid, season=stats.season).all() pitchers = Pitcher.query.filter_by(teamid=tid, season=stats.season).all() for entry in team: if entry.season == int(stats.season): db.session.delete(entry) db.session.commit() new_entry = Team(datetime.now(), stats.season, tid, stats.name, stats.stars, stats.stadium, stats.pl, stats.pl_position, stats.trained, stats.games, stats.ab, stats.hits, stats.avg, stats.singles, stats.doubles, stats.triples, stats.hr, stats.rbi, stats.so, stats.era, stats.slg, stats.wins, stats.losses, stats.pct, stats.rs, stats.ra) db.session.add(new_entry) if players: for player in players: db.session.delete(player) db.session.commit() for player in stats.players: new_entry = Player(stats.season, tid, player.id, player.name, player.position, player.games, player.ab, player.hits, player.avg, player.singles, player.doubles, player.triples, player.hr, player.rbi, player.so, player.era, player.slg) db.session.add(new_entry) if pitchers: for player in pitchers: db.session.delete(player) db.session.commit() for player in stats.pitchers: new_entry = Pitcher(stats.season, tid, player.id, player.name, player.games, player.so, player.era) db.session.add(new_entry) db.session.commit() return redirect('/stats/{0}'.format(tid))
async def init(player, session, *, uuid=None): # Update session-id uuid = register_uuid(player, uuid) player.player_uuid = uuid p = session.query(Player).filter_by(uuid=uuid).first() if p is None: p = Player(uuid=uuid, name="", color="") session.add(p) payload = { "player_uuid": str(p.uuid), "player_name": p.name, "player_color": p.color, } message = {"msg_type": "player_id", "payload": payload} await player.send(message)
def create_test_players(max_player): for i in range(max_player): db.session.add(Player('p%d' % i, 'test%d' % i)) db.session.commit()
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 stats(tid): current_season = sbteamdata.get_current_season() seasons = Team.query.filter_by(teamid=tid).order_by( Team.season.desc()).all() team = Team.query.filter_by(teamid=tid, season=current_season).first() if team and (team.time - datetime.now()).total_seconds() > -3600: players = Player.query.filter_by(teamid=tid, season=current_season).all() pitchers = Pitcher.query.filter_by(teamid=tid, season=current_season).all() updated = team.time.strftime('Updated on %B %d at %I:%M %p') else: stats = sbteamdata.get_team_data(tid) team = Team.query.filter_by(teamid=tid).order_by( Team.season.desc()).all() players = Player.query.filter_by(teamid=tid, season=stats.season).all() pitchers = Pitcher.query.filter_by(teamid=tid, season=stats.season).all() for entry in team: if entry.season == int(stats.season): db.session.delete(entry) db.session.commit() new_entry = Team(datetime.now(), stats.season, tid, stats.name, stats.stars, stats.stadium, stats.pl, stats.pl_position, stats.trained, stats.games, stats.ab, stats.hits, stats.avg, stats.singles, stats.doubles, stats.triples, stats.hr, stats.rbi, stats.so, stats.era, stats.slg, stats.wins, stats.losses, stats.pct, stats.rs, stats.ra) db.session.add(new_entry) if players: for player in players: db.session.delete(player) db.session.commit() for player in stats.players: new_entry = Player(stats.season, tid, player.id, player.name, player.position, player.games, player.ab, player.hits, player.avg, player.singles, player.doubles, player.triples, player.hr, player.rbi, player.so, player.era, player.slg) db.session.add(new_entry) if pitchers: for player in pitchers: db.session.delete(player) db.session.commit() for player in stats.pitchers: new_entry = Pitcher(stats.season, tid, player.id, player.name, player.games, player.so, player.era) db.session.add(new_entry) db.session.commit() team = Team.query.filter_by(teamid=tid, season=current_season).first() players = Player.query.filter_by(teamid=tid, season=current_season).all() pitchers = Pitcher.query.filter_by(teamid=tid, season=current_season).all() updated = team.time.strftime('Updated on %B %d at %I:%M %p') return render_template('stats.html', updated=updated, seasons=seasons, team=team, players=players, pitchers=pitchers)
def create_player_record(self, player_parser, import_date): attributes = player_parser.find_all("td") player = Player() player.id = int(attributes[0].string) player.timestamp = import_date player.position = attributes[1].string player.name = attributes[2].string player.team = attributes[3].string player.org = attributes[4].string player.league = attributes[5].string player.level = attributes[6].string player.dob = datetime.datetime.strptime(attributes[7].string, "%m/%d/%Y") player.age = attributes[8].string player.height = self._convert_height(attributes[9].string) player.weight = int(attributes[10].string.split(" ")[0]) player.bats = attributes[11].string player.throws = attributes[12].string player.overall = float(attributes[13].string.split(" ")[0]) player.potential = float(attributes[14].string.split(" ")[0]) player.leader = attributes[15].string player.loyalty = attributes[16].string player.adaptability = attributes[17].string player.greed = attributes[18].string player.workethic = attributes[19].string player.intelligence = attributes[20].string player.personality = attributes[21].string player.injury = attributes[22].string player.competition = attributes[23].string player.hscol = attributes[24].string player.salary = int(self._convert_unknown(attributes[25].string)) player.yearsleft = int(self._convert_unknown(attributes[26].string)) player.contractvalue = int(self._convert_unknown( attributes[27].string)) player.totalyears = int(self._convert_unknown(attributes[28].string)) player.majorleagueyears = int(attributes[29].string) player.majorleaguedays = int(attributes[30].string) player.proyears = int(attributes[31].string) player.draftleague = attributes[32].string player.draftteam = attributes[33].string player.draftyear = int(attributes[34].string) if "S" in attributes[35].string: player.draftround = int(attributes[35].string.replace("S", "")) player.draftsupplimental = 1 else: player.draftround = int(attributes[35].string) player.draftsupplimental = 0 player.draftpick = int(attributes[36].string) player.overallpick = int(attributes[37].string) player.discoveryyear = int(attributes[38].string) player.discoveryteam = attributes[39].string return player
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)