Update transactions.py
Fixed mil roster check in Transaction class
This commit is contained in:
parent
39b81bf10b
commit
a81e07b8cc
@ -140,8 +140,9 @@ class SBaTransaction:
|
||||
mil_wara = 0
|
||||
this_team = self.teams[team]['team']
|
||||
# team_roster = await get_players(self.current['season'], this_team['abbrev'])
|
||||
mil_team = await get_team_by_abbrev(f'{this_team["abbrev"]}MiL', season=this_team['season'])
|
||||
t_query = await db_get('players', params=[
|
||||
('season', self.current['season']), ('team_id', this_team['id'])
|
||||
('season', self.current['season']), ('team_id', mil_team['id'])
|
||||
])
|
||||
team_roster = t_query['players']
|
||||
|
||||
@ -150,7 +151,7 @@ class SBaTransaction:
|
||||
])
|
||||
# mil_roster = await get_players(self.current['season'], f'{this_team["abbrev"]}MiL')
|
||||
m_query = await db_get('players', params=[
|
||||
('season', self.current['season']), ('team_id', f'{this_team["abbrev"]}MiL')
|
||||
('season', self.current['season']), ('team_abbrev', f'{this_team["abbrev"]}MiL')
|
||||
])
|
||||
mil_roster = m_query['players']
|
||||
|
||||
@ -202,6 +203,7 @@ class SBaTransaction:
|
||||
|
||||
logging.info(f'updating rosters')
|
||||
for x in self.players:
|
||||
logging.info(f'x player: {x}')
|
||||
# If player is joining this team, add to roster and add WARa
|
||||
if self.players[x]['to'] == this_team:
|
||||
team_roster.append(self.players[x]['player'])
|
||||
@ -216,6 +218,8 @@ class SBaTransaction:
|
||||
|
||||
# If player is leaving this team next week, remove from roster and subtract WARa
|
||||
if self.players[x]['player']['team'] == this_team:
|
||||
logging.info(f'major league player')
|
||||
logging.info(f'team roster: {team_roster}')
|
||||
team_roster.remove(self.players[x]['player'])
|
||||
# 06-13: COMMENTED OUT TO RESOLVE MID-WEEK IL REPLACEMENT BEING SENT BACK DOWN
|
||||
# if self.effective_week != self.current['week']:
|
||||
@ -223,7 +227,9 @@ class SBaTransaction:
|
||||
|
||||
# If player is leaving MiL team next week, remove from roster and subtract WARa
|
||||
if self.players[x]['player']['team']['abbrev'] == f'{this_team["abbrev"]}MiL':
|
||||
logging.info(f'minor league player')
|
||||
mil_roster.remove(self.players[x]['player'])
|
||||
logging.info(f'mil roster: {mil_roster}')
|
||||
if self.effective_week != self.current['week']:
|
||||
mil_wara -= self.players[x]['player']['wara']
|
||||
|
||||
@ -1288,9 +1294,8 @@ class Transactions(commands.Cog):
|
||||
# week_start=current['week'] + 1,
|
||||
# week_end=current['week'] + 1,
|
||||
# )
|
||||
s_query = await db_get('schedules', params=[
|
||||
('season', current['season']), ('team_abbrev', team['abbrev']), ('week_start', current['week'] + 1),
|
||||
('week_end', current['week'] + 1)
|
||||
s_query = await db_get('games', params=[
|
||||
('season', current['season']), ('team1_id', team['id']), ('week', current['week'] + 1)
|
||||
])
|
||||
team_role = get_team_role(ctx, team)
|
||||
player_cog = self.bot.get_cog('Players')
|
||||
@ -1565,10 +1570,10 @@ class Transactions(commands.Cog):
|
||||
f'trade and drop players to FA, though!')
|
||||
return
|
||||
|
||||
team = await get_team_by_owner(current['season'], ctx.author.id)
|
||||
s_query = await db_get('schedules', params=[
|
||||
('season', current['season']), ('team_abbrev', team['abbrev']), ('week_start', current['week'] + 1),
|
||||
('week_end', current['week'] + 1)
|
||||
# team = await get_team_by_owner(current['season'], ctx.author.id)
|
||||
team = await get_team_by_abbrev('VA', current['season'])
|
||||
s_query = await db_get('games', params=[
|
||||
('season', current['season']), ('team1_id', team['id']), ('week', current['week'] + 1)
|
||||
])
|
||||
if s_query['count'] == 0 and current['week'] != 22:
|
||||
await ctx.send('It looks like your season is over so transactions are locked.')
|
||||
|
||||
Loading…
Reference in New Issue
Block a user