fixed some logic errors with foundation

This commit is contained in:
Sakimori 2021-07-06 03:01:44 -04:00
parent 71f1a86db1
commit 5d8dfca7f8
2 changed files with 20 additions and 15 deletions

View file

@ -7,39 +7,39 @@ class Archetype:
display_symbol = "🃏"
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"""
pass
def modify_out_type(self, outcome):
def modify_out_type(outcome):
"""if the batter would go out, do something"""
pass
def modify_hit_type(self, outcome):
def modify_hit_type(outcome):
"""if the batter would get a hit, do something"""
pass
def hold_runner(self, outcome, stats):
def hold_runner(outcome, stats):
"""affect the pitcher's ability to prevent steal attempts"""
pass
def steal_check(self, outcome, steal_roll):
def steal_check(outcome, steal_roll):
"""make a runner more or less likely to steal"""
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"""
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"""
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"""
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"""
pass

View file

@ -392,6 +392,7 @@ class game(object):
def thievery_attempts(self): #returns either false or "at-bat" outcome
thieves = []
attempts = []
outcome = {}
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+1] is None: #if there's somewhere to go
@ -404,8 +405,8 @@ class game(object):
self.weather.modify_steal_stats(stats)
if pitcher.name in self.defense_archetypes.keys():
outcome["pitcher_archetype"] = self.defense_archetypes[pitcher.name]
if self.get_pitcher().name in self.defense_archetypes.keys():
outcome["pitcher_archetype"] = self.defense_archetypes[self.get_pitcher().name]
else:
outcome["pitcher_archetype"] = archetypes.Archetype
@ -425,16 +426,14 @@ class game(object):
if len(attempts) == 0:
return False
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:
defense_team = self.teams["home"]
else:
defense_team = self.teams["away"]
outcome = {}
for baserunner, start_base in attempts:
defender = random.choice(defense_team.lineup) #excludes pitcher
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:
if player.name == "Tim Locastro":
player.randomize_stars()
if not hasattr(team_json, "archetypes"):
team_json.archetypes = {}
return team_json
return None
except AttributeError:
@ -938,6 +939,8 @@ def get_team_and_owner(name):
for player in team_json.rotation + team_json.lineup:
if player.name == "Tim Locastro":
player.randomize_stars()
if not hasattr(team_json, "archetypes"):
team_json.archetypes = {}
return (team_json, owner_id)
return (None, None)
except AttributeError:
@ -987,6 +990,8 @@ def search_team(search_term):
for player in team_json.rotation + team_json.lineup:
if player.name == "Tim Locastro":
player.randomize_stars()
if not hasattr(team_json, "archetypes"):
team_json.archetypes = {}
except AttributeError:
team_json.rotation = []
team_json.rotation.append(team_json.pitcher)