fixed some logic errors with foundation
This commit is contained in:
parent
71f1a86db1
commit
5d8dfca7f8
|
@ -7,39 +7,39 @@ class Archetype:
|
||||||
display_symbol = "🃏"
|
display_symbol = "🃏"
|
||||||
description= "Master of none. This archetype has no bonuses and no penalties."
|
description= "Master of none. This archetype has no bonuses and no penalties."
|
||||||
|
|
||||||
def modify_bat_rolls(self, outcome, rolls):
|
def modify_bat_rolls(outcome, rolls):
|
||||||
""""modify the rolls used in batting before using the rolled values"""
|
""""modify the rolls used in batting before using the rolled values"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def modify_out_type(self, outcome):
|
def modify_out_type(outcome):
|
||||||
"""if the batter would go out, do something"""
|
"""if the batter would go out, do something"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def modify_hit_type(self, outcome):
|
def modify_hit_type(outcome):
|
||||||
"""if the batter would get a hit, do something"""
|
"""if the batter would get a hit, do something"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def hold_runner(self, outcome, stats):
|
def hold_runner(outcome, stats):
|
||||||
"""affect the pitcher's ability to prevent steal attempts"""
|
"""affect the pitcher's ability to prevent steal attempts"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def steal_check(self, outcome, steal_roll):
|
def steal_check(outcome, steal_roll):
|
||||||
"""make a runner more or less likely to steal"""
|
"""make a runner more or less likely to steal"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def modify_steal_attempt(self, outcome, steal_success_roll):
|
def modify_steal_attempt(outcome, steal_success_roll):
|
||||||
"""affect a runner's ability to successfully steal"""
|
"""affect a runner's ability to successfully steal"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def modify_tag_up_roll(self, outcome, run_roll):
|
def modify_tag_up_roll(outcome, run_roll):
|
||||||
"""change the runner's decision to tag-up"""
|
"""change the runner's decision to tag-up"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def modify_advance_roll(self, outcome, run_roll):
|
def modify_advance_roll(outcome, run_roll):
|
||||||
"""change the runner's decision to advance on groundouts"""
|
"""change the runner's decision to advance on groundouts"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def modify_extra_running_roll(self, outcome, run_roll):
|
def modify_extra_running_roll(outcome, run_roll):
|
||||||
"""change the runner's ability to advance extra bases on base hits by a teammate"""
|
"""change the runner's ability to advance extra bases on base hits by a teammate"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
17
games.py
17
games.py
|
@ -392,6 +392,7 @@ class game(object):
|
||||||
def thievery_attempts(self): #returns either false or "at-bat" outcome
|
def thievery_attempts(self): #returns either false or "at-bat" outcome
|
||||||
thieves = []
|
thieves = []
|
||||||
attempts = []
|
attempts = []
|
||||||
|
outcome = {}
|
||||||
for base in self.bases.keys():
|
for base in self.bases.keys():
|
||||||
if self.bases[base] is not None and base != 3: #no stealing home in simsim, sorry stu
|
if self.bases[base] is not None and base != 3: #no stealing home in simsim, sorry stu
|
||||||
if self.bases[base+1] is None: #if there's somewhere to go
|
if self.bases[base+1] is None: #if there's somewhere to go
|
||||||
|
@ -404,8 +405,8 @@ class game(object):
|
||||||
|
|
||||||
self.weather.modify_steal_stats(stats)
|
self.weather.modify_steal_stats(stats)
|
||||||
|
|
||||||
if pitcher.name in self.defense_archetypes.keys():
|
if self.get_pitcher().name in self.defense_archetypes.keys():
|
||||||
outcome["pitcher_archetype"] = self.defense_archetypes[pitcher.name]
|
outcome["pitcher_archetype"] = self.defense_archetypes[self.get_pitcher().name]
|
||||||
else:
|
else:
|
||||||
outcome["pitcher_archetype"] = archetypes.Archetype
|
outcome["pitcher_archetype"] = archetypes.Archetype
|
||||||
|
|
||||||
|
@ -425,16 +426,14 @@ class game(object):
|
||||||
if len(attempts) == 0:
|
if len(attempts) == 0:
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
return (self.steals_check(attempts), 0) #effectively an at-bat outcome with no score
|
return (self.steals_check(attempts, outcome), 0) #effectively an at-bat outcome with no score
|
||||||
|
|
||||||
def steals_check(self, attempts):
|
def steals_check(self, attempts, outcome):
|
||||||
if self.top_of_inning:
|
if self.top_of_inning:
|
||||||
defense_team = self.teams["home"]
|
defense_team = self.teams["home"]
|
||||||
else:
|
else:
|
||||||
defense_team = self.teams["away"]
|
defense_team = self.teams["away"]
|
||||||
|
|
||||||
outcome = {}
|
|
||||||
|
|
||||||
for baserunner, start_base in attempts:
|
for baserunner, start_base in attempts:
|
||||||
defender = random.choice(defense_team.lineup) #excludes pitcher
|
defender = random.choice(defense_team.lineup) #excludes pitcher
|
||||||
run_stat = random_star_gen("baserunning_stars", baserunner)
|
run_stat = random_star_gen("baserunning_stars", baserunner)
|
||||||
|
@ -915,6 +914,8 @@ def get_team(name):
|
||||||
for player in team_json.rotation + team_json.lineup:
|
for player in team_json.rotation + team_json.lineup:
|
||||||
if player.name == "Tim Locastro":
|
if player.name == "Tim Locastro":
|
||||||
player.randomize_stars()
|
player.randomize_stars()
|
||||||
|
if not hasattr(team_json, "archetypes"):
|
||||||
|
team_json.archetypes = {}
|
||||||
return team_json
|
return team_json
|
||||||
return None
|
return None
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
|
@ -938,6 +939,8 @@ def get_team_and_owner(name):
|
||||||
for player in team_json.rotation + team_json.lineup:
|
for player in team_json.rotation + team_json.lineup:
|
||||||
if player.name == "Tim Locastro":
|
if player.name == "Tim Locastro":
|
||||||
player.randomize_stars()
|
player.randomize_stars()
|
||||||
|
if not hasattr(team_json, "archetypes"):
|
||||||
|
team_json.archetypes = {}
|
||||||
return (team_json, owner_id)
|
return (team_json, owner_id)
|
||||||
return (None, None)
|
return (None, None)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
|
@ -987,6 +990,8 @@ def search_team(search_term):
|
||||||
for player in team_json.rotation + team_json.lineup:
|
for player in team_json.rotation + team_json.lineup:
|
||||||
if player.name == "Tim Locastro":
|
if player.name == "Tim Locastro":
|
||||||
player.randomize_stars()
|
player.randomize_stars()
|
||||||
|
if not hasattr(team_json, "archetypes"):
|
||||||
|
team_json.archetypes = {}
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
team_json.rotation = []
|
team_json.rotation = []
|
||||||
team_json.rotation.append(team_json.pitcher)
|
team_json.rotation.append(team_json.pitcher)
|
||||||
|
|
Loading…
Reference in a new issue