Exemplo n.º 1
0
 def test_status(self):
     """ Testing status functions
     status.get_round_from_db
     """
     clear_tables(self.db)
     assert(status.get_round_from_db(GAME_ID1, self.db) == -1)
     status.initialize_status(GAME_ID1, self.db, 3)
     assert(status.get_round_from_db(GAME_ID1, self.db) == 0)
     status.set_round_in_db(5, GAME_ID1, self.db)
     assert(status.get_round_from_db(GAME_ID1, self.db) == 5)
     status.initialize_status(GAME_ID1, self.db, 3)
     assert(status.get_round_from_db(GAME_ID1, self.db) == 0)
     table_str = status.create_player_rel_table(5)
     assert (len(table_str) == 74)
     table = status.get_table_from_rel_table(table_str)
     assert (len(table) == 5)
     assert (len(table[0]) == 5)
     tmp_table_str = status.get_rel_table_from_table(table)
     assert (tmp_table_str == table_str)
     tmp_table = status.get_table_from_rel_table(table_str)
     assert (tmp_table == table)
     new_table = status.update_player_rel_table(table_str, 1,2,5)
     status.set_player_rel_table_in_db(GAME_ID1, new_table, self.db)
     new_status = status.get_status_from_db(GAME_ID1, self.db)
     assert(status.get_table_from_rel_table(new_status.player_rel_table)[1][2] == '5')
Exemplo n.º 2
0
 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))