Ejemplo n.º 1
0
def set_name_and_team(re_match, group_name, game, sample):
    if group_name in re_match.groupdict() and re_match.group(
            group_name) is not None:
        player = re_match.group(group_name)
        sample.set_arg(group_name, f'[[{player}]]')
        if sample.get_arg(f'{group_name}Team') is None:
            try:
                playerObj = Player.find_by_name(player)
                playerId = playerObj.id
                historicalPlayerObj = Player.load_by_gameday(
                    playerId, game.season, game.day)
                if historicalPlayerObj is not None:
                    teamId = historicalPlayerObj.team_id
                    teamObj = Team.load(teamId)
                    print(
                        f'{player}: Found historical team data: {teamObj.full_name}'
                    )
                    sample.set_arg(f'{group_name}Team',
                                   f'[[{teamObj.full_name}]]')
                elif playerObj.team_id is not None:
                    teamObj = Team.load(playerObj.team_id)
                    print(
                        f'{player}: Falling back to current team: {teamObj.full_name}'
                    )
                    sample.set_arg(
                        f'{group_name}Team',
                        f'maybe? [[{playerObj.league_team.full_name}]]')
                else:
                    print(f'Tried but failed to look up {player}')
                    sample.set_arg(f'{group_name}Team', 'Unknown')
            except:
                print(f'Failed to look up {player}')
                sample.set_arg(f'{group_name}Team', 'Unknown')
Ejemplo n.º 2
0
def _get_or_generate_player(name):
    try:
        p = Player.find_by_name(name)
        player = p.json()
        player['current_vibe'] = p.get_vibe(_current_day())
        player['batting_stars'] = p.batting_stars
        player['pitching_stars'] = p.pitching_stars
        player['baserunning_stars'] = p.baserunning_stars
        player['defense_stars'] = p.defense_stars
        player['soulscream'] = p.soulscream
        player['blood'] = p.blood
        player['coffee'] = p.coffee
    except (AttributeError, KeyError, json.decoder.JSONDecodeError):
        player = _make_player_json(name)
    return player
Ejemplo n.º 3
0
 def test_find_by_name_bad_name(self):
     bad_player = Player.find_by_name("Test Playerson")
     assert bad_player is None
Ejemplo n.º 4
0
 def test_find_by_name(self):
     player = Player.find_by_name("August Mina")
     assert isinstance(player, Player)
Ejemplo n.º 5
0
 def test_long_soulscream_extralong(self):
     """Test very long soulscreams"""
     test_player = Player.find_by_name("Chorby Soul")
     test_value = test_player.get_soulscream(collapse=False)
     assert isinstance(test_value, str)
     assert test_value[-9:] == "undefined"
Ejemplo n.º 6
0
 def test_long_soulscream(self):
     """Test very long soulscreams"""
     test_player = Player.find_by_name("Chorby Soul")
     test_value = test_player.soulscream
     assert isinstance(test_value, str)
     assert test_value[-22:] in f"... (CONT. FOR {test_player.soul-300} SOUL)"