예제 #1
0
파일: fiasco_test.py 프로젝트: sprek/fiasco
    def test_players_db(self):
        """ Testing player functions
        player.insert_player_into_db
        player.get_players_from_db
        player.get_player_from_db_by_name
        player.update_player_by_name
        """ 
        clear_tables(self.db)

        # test empty players
        test_players = player.get_players_from_db(GAME_ID1, self.db)
        assert (test_players == [])
        test_names = player.get_player_names_from_db(GAME_ID1, self.db)
        assert (test_names == [])

        # insert player
        test_player = player.Player (*TEST_PLAYER_VALUES1)
        player.insert_player_into_db(test_player, self.db)
        db_player = player.get_players_from_db(test_player.game_id, self.db)[0]
        assert db_player == test_player
        # get player
        db_player2 = player.get_player_from_db_by_name(db_player.name, db_player.game_id, self.db)
        assert(db_player2 == db_player)
        # update player
        cur_id = db_player.id_num
        db_player.id_num = cur_id + 1
        player.update_player_by_name(db_player, self.db)
        # get player
        new_db_player = player.get_player_from_db_by_name(
            db_player.name, db_player.game_id, self.db)
        assert(new_db_player.id_num == db_player.id_num)
예제 #2
0
파일: __init__.py 프로젝트: sprek/fiasco
 def play():
     player_names = player.get_player_names_from_db(GAME_ID, get_db())
     cur_player_name = game_control.player_name_check(request.args.get('player',''),
                                                      session['player'],
                                                      player_names)
     if cur_player_name:
         session['player'] = cur_player_name
     else:
         return render_template('select_player.html', players=player_names)
     
     if status.get_round_from_db(GAME_ID, get_db()) == -1:
         game_control.initialize_game(GAME_ID, get_db())
     cur_player = player.get_player_from_db_by_name(cur_player_name, GAME_ID, get_db())
     pd = playset.parse_playset('/Users/danielsprechman/development/projects/fiasco/playset_main_st.txt')
     return render_template('play.html',
                            player=session['player'],
                            playset_name='Main St.',
                            dice_html=view.get_dice_html(dice.get_dice_from_db(GAME_ID, get_db()).dice),
                            neighbors=[cur_player.p_left_name, cur_player.p_right_name],
                            playset_html = view.get_playset_html(pd, get_db(), cur_player_name, GAME_ID))
예제 #3
0
파일: __init__.py 프로젝트: sprek/fiasco
 def playerlist():
     player_names = player.get_player_names_from_db(GAME_ID, get_db())
     result_str = view.get_player_list_html(player_names)
     return result_str