Merge pull request #203 from Sakimori/indev
hillexed cleanup and minor bugfix
This commit is contained in:
commit
5ddee87c7f
48
README.md
48
README.md
|
@ -70,9 +70,10 @@ accepting pull requests, check the issues for to-dos.
|
||||||
- shows a paginated list of all teams available for games which can be scrolled through.
|
- shows a paginated list of all teams available for games which can be scrolled through.
|
||||||
|
|
||||||
### game commands:
|
### game commands:
|
||||||
- m;startgame --day # or -d #
|
- m;startgame --day # or -d #, -w [weather name] or --weather [weather name]
|
||||||
- starts a game with premade teams made using saveteam. provides a link to the website where you can watch the game.
|
- starts a game with premade teams made using saveteam. provides a link to the website where you can watch the game.
|
||||||
- the --day/-d is optional, if used it'll force the game to use the #th spot in each team's rotations. if this number is larger than the number of pitchers in one or both of the teams' rotations it'll wrap around. if it is not used pitchers will be chosen randomly from the teams' rotations.
|
- the --day/-d is an optional flag, if used it'll force the game to use the #th spot in each team's rotations. if this number is larger than the number of pitchers in one or both of the teams' rotations it'll wrap around. if it is not used pitchers will be chosen randomly from the teams' rotations.
|
||||||
|
- the -w/--weather is the same, if used it'll force the game to be the specified weather.
|
||||||
- use this command at the top of a list with entries separated by new lines:
|
- use this command at the top of a list with entries separated by new lines:
|
||||||
- the away team's name.
|
- the away team's name.
|
||||||
- the home team's name.
|
- the home team's name.
|
||||||
|
@ -80,25 +81,24 @@ accepting pull requests, check the issues for to-dos.
|
||||||
- this command has fuzzy search so you don't need to type the full name of the team as long as you give enough to identify the team you're looking for.
|
- this command has fuzzy search so you don't need to type the full name of the team as long as you give enough to identify the team you're looking for.
|
||||||
- m;randomgame
|
- m;randomgame
|
||||||
- starts a 9-inning game between 2 entirely random teams. embrace chaos!
|
- starts a 9-inning game between 2 entirely random teams. embrace chaos!
|
||||||
- m;starttournament --rounddelay #
|
- m;starttournament --rounddelay #, --bestof #, --finalsbestof #
|
||||||
- starts a randomly seeded tournament with the provided teams, automatically adding byes as necessary. all series have a 5 minute break between games. the current format is: best of 5 until the finals which are best of 7.
|
- starts a randomly seeded tournament with the provided teams, automatically adding byes as necessary. all series have a 5 minute break between games. the current default format is best of 5 until the finals which are best of 7 but this can be adjusted by adding the bestof and finalsbestof flags.
|
||||||
- the --rounddelay is optional, if used, # must be between 1 and 120 and it'll set the delay between rounds to be # minutes. if not included it will default to 10.
|
- the --rounddelay is optional, if used, # must be between 1 and 120 and it'll set the delay between rounds to be # minutes. if not included it will default to 10.
|
||||||
- use this command at the top of a list with entries separated by new lines:
|
- use this command at the top of a list with entries separated by new lines:
|
||||||
- the name of the tournament.
|
- the name of the tournament.
|
||||||
- the name of each participating team on its own line.
|
- the name of each participating team on its own line.
|
||||||
|
|
||||||
### draft commands
|
### obl commands:
|
||||||
- m;startdraft
|
- m;oblhelp
|
||||||
- starts a draft with an arbitrary number of participants. use this command at the top of a list with entries separated by new lines:
|
- shows the explanation for what the obl is and how to participate.
|
||||||
- for each participant's entry you need three lines:
|
- m;oblteam [team name]
|
||||||
- their discord @
|
- displays a team's rank, current OBL points, and current bounty board.
|
||||||
- their team name
|
- m;oblrival [team name] [rival team]
|
||||||
- their team slogan
|
- sets your team's obl rival, this can be changed at any time and requires ownership. your rival is purely cosmetic but will show on your team card and be marked with a special marker if they're on your list of opponents. each team needs to be on a new line below the command.
|
||||||
- post this with all three of these things for all participants and the draft will begin.
|
- m;oblwins [team name]
|
||||||
- the draft will begin once all participants have given a 👍 and will proceed in the order that participants were entered. each participant will select 12 hitters and 1 pitcher from a pool of 20 random players which will refresh automatically when it becomes small.
|
- displays a trophy case with all teams that the given team has won points off of.
|
||||||
- m;draft [name]
|
- m;oblstandings
|
||||||
- use this on your turn during a draft to pick your player.
|
- displays the 15 teams with the most obl points in this meta-season.
|
||||||
- you can also just use a 'd' instead of the full command.
|
|
||||||
|
|
||||||
### league commands
|
### league commands
|
||||||
- all of these commands are for leagues that have already been started. to start a league, click the 'create a league' button on the website and fill out the info for your league there, then use the m;claimleague command in discord to set yourself as the owner.
|
- all of these commands are for leagues that have already been started. to start a league, click the 'create a league' button on the website and fill out the info for your league there, then use the m;claimleague command in discord to set yourself as the owner.
|
||||||
|
@ -131,6 +131,20 @@ accepting pull requests, check the issues for to-dos.
|
||||||
- the currently available starts are:
|
- the currently available starts are:
|
||||||
- for batters: avg (batting average), slg (slugging percentage), obp (on-base percentage), ops (on-base plus slugging).
|
- for batters: avg (batting average), slg (slugging percentage), obp (on-base percentage), ops (on-base plus slugging).
|
||||||
- for pitchers era (earned run average), whip (walks and hits per innings pitched), kper9 (strikeouts per 9 innings), bbper9 (walks per 9 innings), kperbb (strikeout to walk ratio).
|
- for pitchers era (earned run average), whip (walks and hits per innings pitched), kper9 (strikeouts per 9 innings), bbper9 (walks per 9 innings), kperbb (strikeout to walk ratio).
|
||||||
|
|
||||||
|
### draft commands
|
||||||
|
- m;startdraft
|
||||||
|
- starts a draft with an arbitrary number of participants. use this command at the top of a list with entries separated by new lines:
|
||||||
|
- for each participant's entry you need three lines:
|
||||||
|
- their discord @
|
||||||
|
- their team name
|
||||||
|
- their team slogan
|
||||||
|
- post this with all three of these things for all participants and the draft will begin.
|
||||||
|
- the draft will begin once all participants have given a 👍 and will proceed in the order that participants were entered. each participant will select 12 hitters and 1 pitcher from a pool of 20 random players which will refresh automatically when it becomes small.
|
||||||
|
- m;draft [name]
|
||||||
|
- use this on your turn during a draft to pick your player.
|
||||||
|
- you can also just use a 'd' instead of the full command.
|
||||||
|
|
||||||
### player commands:
|
### player commands:
|
||||||
- m;showplayer [name]
|
- m;showplayer [name]
|
||||||
- displays any name's stars, there's a limit of 70 characters. that should be *plenty*. note: if you want to lookup a lot of different players you can do it on onomancer instead of spamming this command a bunch and clogging up discord: https://onomancer.sibr.dev/reflect
|
- displays any name's stars, there's a limit of 70 characters. that should be *plenty*. note: if you want to lookup a lot of different players you can do it on onomancer instead of spamming this command a bunch and clogging up discord: https://onomancer.sibr.dev/reflect
|
||||||
|
|
|
@ -320,11 +320,12 @@ def get_all_team_names():
|
||||||
conn.close()
|
conn.close()
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_filtered_teams(filter_list):
|
def get_filtered_teams(i_filter_list):
|
||||||
teams_list = get_all_team_names()
|
teams_list = get_all_team_names()
|
||||||
out_list = []
|
out_list = []
|
||||||
|
filter_list = [re.sub('[^A-Za-z0-9 %]+', '', filter_team) for filter_team in i_filter_list]
|
||||||
for team in teams_list:
|
for team in teams_list:
|
||||||
if team not in filter_list:
|
if re.sub('[^A-Za-z0-9 %]+', '', team) not in filter_list:
|
||||||
out_list.append(team)
|
out_list.append(team)
|
||||||
return out_list
|
return out_list
|
||||||
|
|
||||||
|
@ -385,9 +386,9 @@ def save_obl_results(winning_team, losing_team):
|
||||||
if re.sub('[^A-Za-z0-9 %]+', '', losing_team.name) in opponent_teams:
|
if re.sub('[^A-Za-z0-9 %]+', '', losing_team.name) in opponent_teams:
|
||||||
beaten_teams.append(losing_team.name)
|
beaten_teams.append(losing_team.name)
|
||||||
try:
|
try:
|
||||||
opponent_teams = sample(get_filtered_teams([re.sub('[^A-Za-z0-9 %]+', '', winning_team.name)]), 5)
|
opponent_teams = sample(get_filtered_teams([winning_team.name] + beaten_teams), 5)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
opponent_teams = get_filtered_teams([re.sub('[^A-Za-z0-9 %]+', '', winning_team.name)])
|
opponent_teams = get_filtered_teams([winning_team.name] + beaten_teams)
|
||||||
obl_points += 1
|
obl_points += 1
|
||||||
|
|
||||||
c.execute("UPDATE one_big_league SET teams_beaten_list = ?, current_opponent_pool = ?, obl_points = ? WHERE team_name = ?", (list_to_newline_string(beaten_teams), list_to_newline_string(opponent_teams), obl_points, winning_team.name))
|
c.execute("UPDATE one_big_league SET teams_beaten_list = ?, current_opponent_pool = ?, obl_points = ? WHERE team_name = ?", (list_to_newline_string(beaten_teams), list_to_newline_string(opponent_teams), obl_points, winning_team.name))
|
||||||
|
|
19
games.py
19
games.py
|
@ -50,7 +50,8 @@ class player(object):
|
||||||
"rbis" : 0,
|
"rbis" : 0,
|
||||||
"strikeouts_taken" : 0
|
"strikeouts_taken" : 0
|
||||||
}
|
}
|
||||||
|
self.stat_name = self.name
|
||||||
|
|
||||||
def star_string(self, key):
|
def star_string(self, key):
|
||||||
str_out = ""
|
str_out = ""
|
||||||
starstring = str(self.stlats[key])
|
starstring = str(self.stlats[key])
|
||||||
|
@ -670,11 +671,11 @@ class game(object):
|
||||||
def get_stats(self):
|
def get_stats(self):
|
||||||
players = []
|
players = []
|
||||||
for this_player in self.teams["away"].lineup:
|
for this_player in self.teams["away"].lineup:
|
||||||
players.append((this_player.name, this_player.game_stats))
|
players.append((this_player.stat_name, this_player.game_stats))
|
||||||
for this_player in self.teams["home"].lineup:
|
for this_player in self.teams["home"].lineup:
|
||||||
players.append((this_player.name, this_player.game_stats))
|
players.append((this_player.stat_name, this_player.game_stats))
|
||||||
players.append((self.teams["home"].pitcher.name, self.teams["home"].pitcher.game_stats))
|
players.append((self.teams["home"].pitcher.stat_name, self.teams["home"].pitcher.game_stats))
|
||||||
players.append((self.teams["away"].pitcher.name, self.teams["away"].pitcher.game_stats))
|
players.append((self.teams["away"].pitcher.stat_name, self.teams["away"].pitcher.game_stats))
|
||||||
return players
|
return players
|
||||||
|
|
||||||
def get_team_specific_stats(self):
|
def get_team_specific_stats(self):
|
||||||
|
@ -683,11 +684,11 @@ class game(object):
|
||||||
self.teams["home"].name : []
|
self.teams["home"].name : []
|
||||||
}
|
}
|
||||||
for this_player in self.teams["away"].lineup:
|
for this_player in self.teams["away"].lineup:
|
||||||
players[self.teams["away"].name].append((this_player.name, this_player.game_stats))
|
players[self.teams["away"].name].append((this_player.stat_name, this_player.game_stats))
|
||||||
for this_player in self.teams["home"].lineup:
|
for this_player in self.teams["home"].lineup:
|
||||||
players[self.teams["home"].name].append((this_player.name, this_player.game_stats))
|
players[self.teams["home"].name].append((this_player.stat_name, this_player.game_stats))
|
||||||
players[self.teams["home"].name].append((self.teams["home"].pitcher.name, self.teams["home"].pitcher.game_stats))
|
players[self.teams["home"].name].append((self.teams["home"].pitcher.stat_name, self.teams["home"].pitcher.game_stats))
|
||||||
players[self.teams["away"].name].append((self.teams["away"].pitcher.name, self.teams["away"].pitcher.game_stats))
|
players[self.teams["away"].name].append((self.teams["away"].pitcher.stat_name, self.teams["away"].pitcher.game_stats))
|
||||||
return players
|
return players
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -186,6 +186,8 @@ def update_loop():
|
||||||
|
|
||||||
if "weather_message" in this_game.last_update[0].keys():
|
if "weather_message" in this_game.last_update[0].keys():
|
||||||
state["update_emoji"] = this_game.weather.emoji
|
state["update_emoji"] = this_game.weather.emoji
|
||||||
|
else:
|
||||||
|
state["update_emoji"] = "🏏"
|
||||||
|
|
||||||
if "steals" in this_game.last_update[0].keys():
|
if "steals" in this_game.last_update[0].keys():
|
||||||
updatestring = ""
|
updatestring = ""
|
||||||
|
@ -211,7 +213,7 @@ def update_loop():
|
||||||
if this_game.last_update[1] > 0:
|
if this_game.last_update[1] > 0:
|
||||||
updatestring += f"{this_game.last_update[1]} runs scored!"
|
updatestring += f"{this_game.last_update[1]} runs scored!"
|
||||||
|
|
||||||
state["update_emoji"] = "🏏"
|
|
||||||
state["update_text"] = updatestring
|
state["update_text"] = updatestring
|
||||||
|
|
||||||
this_game.weather.modify_atbat_message(this_game, state)
|
this_game.weather.modify_atbat_message(this_game, state)
|
||||||
|
|
|
@ -1241,7 +1241,7 @@ class OBLExplainCommand(Command):
|
||||||
async def execute(self, msg, command):
|
async def execute(self, msg, command):
|
||||||
await msg.channel.send("""The One Big League, or OBL, is an asynchronous league that includes every team in the simsim's database. To participate, just use the m;oblteam command with your team of choice. **No signup is required!** This will give you a list of five opponents; playing against one of them and winning nets you a point, and will refresh the list with five new opponents. **Losing results in no penalty!** Each meta-season will last for a few weeks, after which the leaderboards are reset to start the race again!
|
await msg.channel.send("""The One Big League, or OBL, is an asynchronous league that includes every team in the simsim's database. To participate, just use the m;oblteam command with your team of choice. **No signup is required!** This will give you a list of five opponents; playing against one of them and winning nets you a point, and will refresh the list with five new opponents. **Losing results in no penalty!** Each meta-season will last for a few weeks, after which the leaderboards are reset to start the race again!
|
||||||
|
|
||||||
Look out for the people wrestling emoji, which indicates the potential for a :people_wrestling:Wrassle Match:people_wrestling:, where both teams are on each others' lists and both have the opportunity to score a point. Team rankings and points can also be viewed in the oblteam command, and the overall OBL leaderboard can be checked with the m;oblstandings command. Best of luck!!
|
Look out for the people wrestling emoji, which indicates the potential for a :people_wrestling:Wrassle Match:people_wrestling:, where both teams are on each others' lists and both have the opportunity to score a point. Team rankings and points can also be viewed in the m;oblteam command, and the overall OBL leaderboard can be checked with the m;oblstandings command. Best of luck!!
|
||||||
""")
|
""")
|
||||||
|
|
||||||
class OBLLeaderboardCommand(Command):
|
class OBLLeaderboardCommand(Command):
|
||||||
|
@ -1319,11 +1319,11 @@ class OBLSetRivalCommand(Command):
|
||||||
elif owner_id != msg.author.id and msg.author.id not in config()["owners"]:
|
elif 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.")
|
await msg.channel.send("You're not authorized to mess with this team. Sorry, boss.")
|
||||||
return
|
return
|
||||||
#try:
|
try:
|
||||||
db.set_obl_rival(team, team_r)
|
db.set_obl_rival(team, team_r)
|
||||||
await msg.channel.send("One pair of mortal enemies, coming right up. Unless you're more of the 'enemies to lovers' type. We can manage that too, don't worry.")
|
await msg.channel.send("One pair of mortal enemies, coming right up. Unless you're more of the 'enemies to lovers' type. We can manage that too, don't worry.")
|
||||||
#except:
|
except:
|
||||||
#await msg.channel.send("Hm. We don't think that team has tried to do anything in the One Big League yet, so you'll have to wait for consent. Get them to check their bounty board.")
|
await msg.channel.send("Hm. We don't think that team has tried to do anything in the One Big League yet, so you'll have to wait for consent. Get them to check their bounty board.")
|
||||||
|
|
||||||
class OBLConqueredCommand(Command):
|
class OBLConqueredCommand(Command):
|
||||||
name = "oblwins"
|
name = "oblwins"
|
||||||
|
|
11
weather.py
11
weather.py
|
@ -44,7 +44,7 @@ class Supernova(Weather):
|
||||||
self.emoji = "🌟"
|
self.emoji = "🌟"
|
||||||
|
|
||||||
def modify_atbat_stats(self, roll):
|
def modify_atbat_stats(self, roll):
|
||||||
roll["pitch_stat"] *= 0.9
|
roll["pitch_stat"] *= 0.8
|
||||||
|
|
||||||
class Midnight(Weather):
|
class Midnight(Weather):
|
||||||
def __init__(self, game):
|
def __init__(self, game):
|
||||||
|
@ -73,6 +73,7 @@ class SlightTailwind(Weather):
|
||||||
result.clear()
|
result.clear()
|
||||||
result.update({
|
result.update({
|
||||||
"text": f"{game.get_batter()} would have gone out, but they took a mulligan!",
|
"text": f"{game.get_batter()} would have gone out, but they took a mulligan!",
|
||||||
|
"mulligan": True,
|
||||||
"text_only": True,
|
"text_only": True,
|
||||||
"weather_message": True,
|
"weather_message": True,
|
||||||
})
|
})
|
||||||
|
@ -229,13 +230,15 @@ class Breezy(Weather):
|
||||||
def __init__(self, game):
|
def __init__(self, game):
|
||||||
self.name = "Breezy"
|
self.name = "Breezy"
|
||||||
self.emoji = "🎐"
|
self.emoji = "🎐"
|
||||||
self.activation_chance = 0.05
|
self.activation_chance = 0.08
|
||||||
|
|
||||||
def activate(self, game, result):
|
def activate(self, game, result):
|
||||||
if random.random() < self.activation_chance:
|
if random.random() < self.activation_chance:
|
||||||
teamtype = random.choice(["away","home"])
|
teamtype = random.choice(["away","home"])
|
||||||
team = game.teams[teamtype]
|
team = game.teams[teamtype]
|
||||||
player = random.choice(team.lineup)
|
player = random.choice(team.lineup)
|
||||||
|
player.stlats["batting_stars"] = player.stlats["pitching_stars"]
|
||||||
|
player.stlats["pitching_stars"] = player.stlats["baserunning_stars"]
|
||||||
old_player_name = player.name
|
old_player_name = player.name
|
||||||
if ' ' in player.name:
|
if ' ' in player.name:
|
||||||
names = player.name.split(" ")
|
names = player.name.split(" ")
|
||||||
|
@ -245,10 +248,10 @@ class Breezy(Weather):
|
||||||
names[-1] = first_first_letter + names[-1][1:]
|
names[-1] = first_first_letter + names[-1][1:]
|
||||||
player.name = ' '.join(names)
|
player.name = ' '.join(names)
|
||||||
else:
|
else:
|
||||||
#name is one word, so turn 'bartholemew' into 'martholebew'
|
#name is one word, so turn 'bartholemew' into 'martholemeb'
|
||||||
first_letter = player.name[0]
|
first_letter = player.name[0]
|
||||||
last_letter = player.name[-1]
|
last_letter = player.name[-1]
|
||||||
player.name = last_letter + player.name[1:-1] + last_letter
|
player.name = last_letter + player.name[1:-1] + first_letter
|
||||||
|
|
||||||
book_adjectives = ["action-packed", "historical", "mystery", "thriller", "horror", "sci-fi", "fantasy", "spooky","romantic"]
|
book_adjectives = ["action-packed", "historical", "mystery", "thriller", "horror", "sci-fi", "fantasy", "spooky","romantic"]
|
||||||
book_types = ["novel", "novella", "poem", "anthology", "fan fiction", "autobiography"]
|
book_types = ["novel", "novella", "poem", "anthology", "fan fiction", "autobiography"]
|
||||||
|
|
Loading…
Reference in a new issue