fixed bye string sneaking into league
This commit is contained in:
parent
8d21e29fdd
commit
d141c21433
|
@ -81,7 +81,6 @@ def init_league_db(league):
|
||||||
c.execute(teams_table_check_string)
|
c.execute(teams_table_check_string)
|
||||||
|
|
||||||
for team in league.teams_in_league():
|
for team in league.teams_in_league():
|
||||||
print(team)
|
|
||||||
c.execute("INSERT INTO teams (name) VALUES (?)", (team.name,))
|
c.execute("INSERT INTO teams (name) VALUES (?)", (team.name,))
|
||||||
|
|
||||||
player_string = "INSERT INTO stats (name, team_name) VALUES (?,?)"
|
player_string = "INSERT INTO stats (name, team_name) VALUES (?,?)"
|
||||||
|
|
21
leagues.py
21
leagues.py
|
@ -1,6 +1,7 @@
|
||||||
import time, asyncio, json, jsonpickle, random, math, os
|
import time, asyncio, json, jsonpickle, random, math, os
|
||||||
import league_storage as league_db
|
import league_storage as league_db
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
|
from copy import deepcopy
|
||||||
from games import team, game
|
from games import team, game
|
||||||
from discord import Embed, Color
|
from discord import Embed, Color
|
||||||
|
|
||||||
|
@ -122,8 +123,9 @@ class league_structure(object):
|
||||||
matchups = []
|
matchups = []
|
||||||
batch_subleagues = [] #each sub-array is all teams in each subleague
|
batch_subleagues = [] #each sub-array is all teams in each subleague
|
||||||
subleague_max = 1
|
subleague_max = 1
|
||||||
for subleague in self.league.keys():
|
league = deepcopy(self.league)
|
||||||
teams = self.teams_in_subleague(subleague)
|
for subleague in league.keys():
|
||||||
|
teams = deepcopy(self.teams_in_subleague(subleague))
|
||||||
if subleague_max < len(teams):
|
if subleague_max < len(teams):
|
||||||
subleague_max = len(teams)
|
subleague_max = len(teams)
|
||||||
batch_subleagues.append(teams)
|
batch_subleagues.append(teams)
|
||||||
|
@ -152,13 +154,13 @@ class league_structure(object):
|
||||||
a_home = not a_home
|
a_home = not a_home
|
||||||
|
|
||||||
for i in range(0, self.constraints["inter_div_games"]): #inter-division matchups
|
for i in range(0, self.constraints["inter_div_games"]): #inter-division matchups
|
||||||
for subleague in self.league.keys():
|
for subleague in league.keys():
|
||||||
division_max = 1
|
division_max = 1
|
||||||
divisions = []
|
divisions = []
|
||||||
for div in self.league[subleague].keys():
|
for div in league[subleague].keys():
|
||||||
if division_max < len(self.league[subleague][div]):
|
if division_max < len(league[subleague][div]):
|
||||||
divison_max = len(self.league[subleague][div])
|
divison_max = len(league[subleague][div])
|
||||||
divisions.append(self.league[subleague][div])
|
divisions.append(deepcopy(league[subleague][div]))
|
||||||
|
|
||||||
last_div = None
|
last_div = None
|
||||||
if len(divisions) % 2 != 0:
|
if len(divisions) % 2 != 0:
|
||||||
|
@ -186,8 +188,8 @@ class league_structure(object):
|
||||||
a_home = not a_home
|
a_home = not a_home
|
||||||
|
|
||||||
|
|
||||||
for subleague in self.league.keys():
|
for subleague in league.keys():
|
||||||
for division in self.league[subleague].values(): #generate round-robin matchups
|
for division in league[subleague].values(): #generate round-robin matchups
|
||||||
if len(division) % 2 != 0:
|
if len(division) % 2 != 0:
|
||||||
division.append("OFF")
|
division.append("OFF")
|
||||||
|
|
||||||
|
@ -197,6 +199,7 @@ class league_structure(object):
|
||||||
teams_b.reverse()
|
teams_b.reverse()
|
||||||
|
|
||||||
for team_a, team_b in zip(teams_a, teams_b):
|
for team_a, team_b in zip(teams_a, teams_b):
|
||||||
|
if team_a != "OFF" and team_b != "OFF":
|
||||||
for j in range(0, self.constraints["division_games"]):
|
for j in range(0, self.constraints["division_games"]):
|
||||||
if i % 2 == 0:
|
if i % 2 == 0:
|
||||||
matchups.append([team_b.name, team_a.name])
|
matchups.append([team_b.name, team_a.name])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user