Example #1
0
def game_generate_tables(slot):
    game = db.get_game(slot)
    players = db.get_players_for_game(slot)
    generator = GameTablesGenerator(game, players)
    game_tables = generator.generate_lowest_penalty_tables()
    db.set_game_tables(slot, game_tables)

    flash("Tables generated.")
    return redirect(url_for('game', slot=slot))
Example #2
0
def game(slot):
    try:
        game = db.get_game(slot)
    except db.NotFound:
        abort(404)
    game_tables = db.get_game_tables(slot)
    return render_template(
        'game.html', game=game, game_tables=game_tables,
        player_name=player_name, len=len)
Example #3
0
 def test_get_game(self):
     db.import_games(Games([
         Game('1A', 'Game 1A', 'Author 1A', 'System 1A', 'Blurb 1A', 4, 6),
         Game('1B', 'Game 1B', 'Author 1B', 'System 1B', 'Blurb 1B', 4, 6),
     ]))
     self.assertRaises(db.NotFound, db.get_game, '9X')
     self.assertEqual(
         Game('1A', 'Game 1A', 'Author 1A', 'System 1A', 'Blurb 1A', 4, 6),
         db.get_game('1A'))
Example #4
0
def game_table_list_csv(slot):
    try:
        game = db.get_game(slot)
    except db.NotFound:
        abort(404)
    players = db.get_players_for_game(slot)
    game_tables = GameTables([game], players, {slot: db.get_game_tables(slot)})
    table_list_csv = StringIO()
    game_tables.to_list_csv(table_list_csv)
    resp = make_response(table_list_csv.getvalue())
    resp.headers['Content-Type'] = 'text/csv'
    return resp