Merge pull request #178 from Sakimori/indev

Indev
This commit is contained in:
Sakimori 2021-01-29 16:23:05 -05:00 committed by GitHub
commit 7384ebedbe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 84 additions and 9 deletions

View file

@ -829,7 +829,7 @@ def base_string(base):
elif base == 3:
return "third"
elif base == 4:
return "fourth"
return "None"
class weather(object):
name = "Sunny"

View file

@ -154,6 +154,7 @@ class league_structure(object):
a_home = not a_home
for i in range(0, self.constraints["inter_div_games"]): #inter-division matchups
extra_teams = []
for subleague in league.keys():
division_max = 1
divisions = []
@ -164,10 +165,7 @@ class league_structure(object):
last_div = None
if len(divisions) % 2 != 0:
if division_max % 2 != 0:
divisions.append(["OFF" for i in range(0, division_max)])
else:
last_div = divisions.pop()
last_div = divisions.pop()
divs_a = list(chain(divisions[int(len(divisions)/2):]))[0]
if last_div is not None:
@ -179,6 +177,11 @@ class league_structure(object):
divs_a.extend(last_div[:int(len(last_div)/2)])
random.shuffle(divs_b)
if len(divs_a) % 2 != 0:
extra_teams.append(divs_a.pop())
if len(divs_b) % 2 != 0:
extra_teams.append(divs_b.pop())
a_home = True
for team_a, team_b in zip(divs_a, divs_b):
if a_home:
@ -187,6 +190,11 @@ class league_structure(object):
matchups.append([team_a.name, team_b.name])
a_home = not a_home
if extra_teams != []:
if len(extra_teams) % 2 == 0:
for index in range(0, int(len(extra_teams)/2)):
matchups.append(extra_teams[index], extra_teams[index+1])
for subleague in league.keys():
for division in league[subleague].values(): #generate round-robin matchups

View file

@ -1,8 +1,8 @@
SELECT name,
SELECT name, team_name,
plate_appearances - (walks_taken + sacrifices) as atbats,
ROUND(hits*1.0 / (plate_appearances - (walks_taken + sacrifices)*1.0),3) as average,
ROUND(total_bases*1.0 / (plate_appearances - (walks_taken + sacrifices)*1.0),3) as slg,
ROUND((walks_taken + hits)*1.0/plate_appearances*1.0,3) as obp,
ROUND((walks_taken + hits)*1.0/plate_appearances*1.0,3) + ROUND(total_bases*1.0 / (plate_appearances - (walks_taken + sacrifices)*1.0),3) as ops
FROM stats WHERE plate_appearances > 50
ORDER BY ops DESC;
ORDER BY average DESC;

View file

@ -1,4 +1,4 @@
SELECT name,
SELECT name, team_name,
outs_pitched,
ROUND(runs_allowed*27.0/(outs_pitched*1.0),3) as era,
ROUND((walks_allowed+hits_allowed)*3.0/(outs_pitched*1.0),3) as whip,

View file

@ -0,0 +1,8 @@
SELECT name, team_name,
plate_appearances - (walks_taken + sacrifices) as atbats,
ROUND(hits*1.0 / (plate_appearances - (walks_taken + sacrifices)*1.0),3) as average,
ROUND(total_bases*1.0 / (plate_appearances - (walks_taken + sacrifices)*1.0),3) as slg,
ROUND((walks_taken + hits)*1.0/plate_appearances*1.0,3) as obp,
ROUND((walks_taken + hits)*1.0/plate_appearances*1.0,3) + ROUND(total_bases*1.0 / (plate_appearances - (walks_taken + sacrifices)*1.0),3) as ops
FROM stats WHERE plate_appearances > 50
ORDER BY ops DESC;

BIN
sql scripts/sql scripts.zip Normal file

Binary file not shown.

View file

@ -0,0 +1,9 @@
SELECT name, team_name,
outs_pitched,
ROUND(runs_allowed*27.0/(outs_pitched*1.0),3) as era,
ROUND((walks_allowed+hits_allowed)*3.0/(outs_pitched*1.0),3) as whip,
ROUND(walks_allowed*27.0/(outs_pitched*1.0),3) as bbper9,
ROUND(strikeouts_given*27.0/(outs_pitched*1.0),3) as kper9,
ROUND(strikeouts_given*1.0/walks_allowed*1.0,3) as kperbb
FROM stats WHERE outs_pitched > 150
ORDER BY kperbb ASC;

View file

@ -0,0 +1,9 @@
SELECT name, team_name,
outs_pitched,
ROUND(runs_allowed*27.0/(outs_pitched*1.0),3) as era,
ROUND((walks_allowed+hits_allowed)*3.0/(outs_pitched*1.0),3) as whip,
ROUND(walks_allowed*27.0/(outs_pitched*1.0),3) as bbper9,
ROUND(strikeouts_given*27.0/(outs_pitched*1.0),3) as kper9,
ROUND(strikeouts_given*1.0/walks_allowed*1.0,3) as kperbb
FROM stats WHERE outs_pitched > 150
ORDER BY whip ASC;

View file

@ -443,6 +443,45 @@ class RemovePlayerCommand(Command):
except IndexError:
await msg.channel.send("Three lines, remember? Command, then team, then name.")
class ReplacePlayerCommand(Command):
name = "replaceplayer"
template = """m;replaceplayer
[team name]
[player name to **remove**]
[player name to **add**]"""
description = "Replaces a player on your team. If there are multiple copies of the same player on a team this will only replace the first one. Requires team ownership and exact spelling of team name."
async def execute(self, msg, command):
try:
team_name = command.split("\n")[1].strip()
remove_name = command.split("\n")[2].strip()
add_name = command.split("\n")[3].strip()
team, owner_id = games.get_team_and_owner(team_name)
if owner_id != msg.author.id and msg.author.id not in config()["owners"]:
await msg.channel.send("You're not authorized to mess with this team. Sorry, boss.")
return
old_player, old_pos, old_list = team.find_player(remove_name)
new_player = games.player(ono.get_stats(add_name))
if old_player is None:
await msg.channel.send("We've got bad news: that player isn't on your team. The good news is that... that player isn't on your team?")
return
else:
if old_list == team.lineup:
team.delete_player(remove_name)
team.add_lineup(new_player)
team.slide_player(add_name, old_pos+1)
else:
team.delete_player(remove_name)
team.add_pitcher(new_player)
team.slide_player(add_name, old_pos+1)
await msg.channel.send(embed=build_team_embed(team))
games.update_team(team)
await msg.channel.send("Paperwork signed, stamped, copied, and faxed up to the goddess. Xie's pretty quick with this stuff.")
except IndexError:
await msg.channel.send("Four lines, remember? Command, then team, then the two names.")
class HelpCommand(Command):
name = "help"
@ -807,6 +846,7 @@ Plays a league with a given name, provided that league has been saved on the web
if league_exists(league_name):
league = leagues.load_league_file(league_name)
if "--noautopostseason" in command:
await msg.channel.send("Automatic postseason disabled.")
autoplay = int(list(league.schedule.keys())[-1]) - league.day_to_series_num(league.day) + 1
if league.historic:
@ -874,7 +914,7 @@ class LeagueWildcardCommand(Command):
class LeaguePauseCommand(Command):
name = "pauseleague"
template = "m;pauseleague [league name]"
descripton = "Tells a currently running league to stop running automatically after the current series."
description = "Tells a currently running league to stop running automatically after the current series."
async def execute(self, msg, command):
league_name = command.strip()
@ -970,6 +1010,7 @@ commands = [
MovePlayerCommand(),
AddPlayerCommand(),
RemovePlayerCommand(),
ReplacePlayerCommand(),
DeleteTeamCommand(),
ShowTeamCommand(),
ShowAllTeamsCommand(),