Exemple #1
0
def get_player_game_result(gamedict_res, player):
    """
    Tested
    Accepts a results game dictionary, and a list of players
    This should only be used if you know that the player was scheduled
    to play in this particular game
    """
    win = [1,0,0,0] ; place = [0,1,0,0] ; show = [0,0,1,0] ; lose = [0,0,0,1]
    #print gamedict_res['PLACER']
    if ut.two_lists_equal(gamedict_res['WINNER'], player):
        return win
    elif ut.two_lists_equal(gamedict_res['PLACER'], player):
        return place
    elif ut.two_lists_equal(gamedict_res['SHOWER'], player):
        return show
    else:
        return lose
Exemple #2
0
def get_player_starting_position(sch_game, player):
    """
    Accepts a scheduled game dictionary and a player list
    if the player has a starting position in the game, returns
    the starting position, if not returns None
    sch_game = {'ma-01-01-1998_sch_Milford_1': {'POS-1': ['Ara'], 'POS-2': ['Douglas'], 'POS-3': ['Liam'], 'POS-4': ['Tino'], 'S/D': 'Doubles', 'POS-6': ['Aitor'], 'POS-7': ['Zarandona','Ara'], 'POS-8': ['Eggy'], 'GAME': 1, 'DATE': '01/01/1998', 'POS-5': ['Aja'], 'POS-6-ID': [52], 'POS-SUB': ['Altuna'], 'POINTS': 7, 'DAY': 'Thursday', 'GAME-COUNT': 15, 'POS-4-ID': [17], 'POS-8-ID': [2], 'POS-SUB-ID': [15], 'POS-3-ID': [9], 'POS-7-ID': [38], 'FRONTON': 'Milford', 'POS-5-ID': [13], 'ABSOLUTE-DATE': 35795, 'POS-2-ID': [42], 'POS-1-ID': [4]}}
    player = ['Ara', 'Zarandona']
    expected = 7
    res = get_player_starting_position(sch_game, player)
    assert_equal(expected, res)
    """
    num = None
    for k,v in sch_game.items():
#        print k,v
#        for k1,v1 in v.items():
#            print k1,v1
        if isinstance(v, list) and isinstance(v[0], basestring):
            if ut.two_lists_equal(player, v):
                if isinstance(k, int):
                    num = k
                    return num
                    break
    else:
        return None