def strikeout(self): self.outs += 1 if self.batting_team == constants.AWAY_TEAM: self.box_score.away_lineup.get(self.diamond.atbat.player.name)["K"] += 1 self.box_score.away_lineup.get(self.diamond.atbat.player.name)["AB"] += 1 self.box_score.home_pitchers.get(self.home_active_pitcher.name)["K"] += 1 self.box_score.home_pitchers.get(self.home_active_pitcher.name)["IP"] = \ util.add_innings(self.box_score.home_pitchers.get(self.home_active_pitcher.name)["IP"],0.1) else: self.box_score.home_lineup.get(self.diamond.atbat.player.name)["K"] += 1 self.box_score.home_lineup.get(self.diamond.atbat.player.name)["AB"] += 1 self.box_score.away_pitchers.get(self.away_active_pitcher.name)["K"] += 1 self.box_score.away_pitchers.get(self.away_active_pitcher.name)["IP"] = \ util.add_innings(self.box_score.away_pitchers.get(self.away_active_pitcher.name)["IP"],0.1)
def ground_ball(self, result): if result[constants.RESULT_HIT_TYPE] == constants.ACTION_SINGLE: runs = self.diamond.single() if self.batting_team == constants.AWAY_TEAM: for player in runs: self.box_score.away_lineup.get(player.name)["R"] += 1 self.box_score.away_lineup.get(self.diamond.first.player.name)["RBI"] += 1 self.box_score.home_pitchers.get(self.home_active_pitcher.name)["ER"] += 1 self.away_runs += 1 self.box_score.away_lineup.get(self.diamond.first.player.name)["AB"] += 1 self.box_score.away_lineup.get(self.diamond.first.player.name)["S"] += 1 self.box_score.home_pitchers.get(self.home_active_pitcher.name)["H"] += 1 else: for player in runs: self.box_score.home_lineup.get(player.name)["R"] += 1 self.box_score.home_lineup.get(self.diamond.first.player.name)["RBI"] += 1 self.box_score.away_pitchers.get(self.away_active_pitcher.name)["ER"] += 1 self.home_runs += 1 self.box_score.home_lineup.get(self.diamond.first.player.name)["AB"] += 1 self.box_score.home_lineup.get(self.diamond.first.player.name)["S"] += 1 self.box_score.away_pitchers.get(self.away_active_pitcher.name)["H"] += 1 elif result[constants.RESULT_HIT_TYPE] == constants.ACTION_DOUBLE: runs = self.diamond.double() if self.batting_team == constants.AWAY_TEAM: for player in runs: self.box_score.away_lineup.get(player.name)["R"] += 1 self.box_score.away_lineup.get(self.diamond.second.player.name)["RBI"] += 1 self.box_score.home_pitchers.get(self.home_active_pitcher.name)["ER"] += 1 self.away_runs += 1 self.box_score.away_lineup.get(self.diamond.second.player.name)["AB"] += 1 self.box_score.away_lineup.get(self.diamond.second.player.name)["D"] += 1 self.box_score.home_pitchers.get(self.home_active_pitcher.name)["H"] += 1 else: for player in runs: self.box_score.home_lineup.get(player.name)["R"] += 1 self.box_score.home_lineup.get(self.diamond.second.player.name)["RBI"] += 1 self.box_score.away_pitchers.get(self.away_active_pitcher.name)["ER"] += 1 self.home_runs += 1 self.box_score.home_lineup.get(self.diamond.second.player.name)["AB"] += 1 self.box_score.home_lineup.get(self.diamond.second.player.name)["D"] += 1 self.box_score.away_pitchers.get(self.away_active_pitcher.name)["H"] += 1 elif result[constants.RESULT_HIT_TYPE] == constants.ACTION_TRIPLE: runs = self.diamond.triple() if self.batting_team == constants.AWAY_TEAM: for player in runs: self.box_score.away_lineup.get(player.name)["R"] += 1 self.box_score.away_lineup.get(self.diamond.third.player.name)["RBI"] += 1 self.box_score.home_pitchers.get(self.home_active_pitcher.name)["ER"] += 1 self.away_runs += 1 self.box_score.away_lineup.get(self.diamond.third.player.name)["AB"] += 1 self.box_score.away_lineup.get(self.diamond.third.player.name)["T"] += 1 self.box_score.home_pitchers.get(self.home_active_pitcher.name)["H"] += 1 else: for player in runs: self.box_score.home_lineup.get(player.name)["R"] += 1 self.box_score.home_lineup.get(self.diamond.third.player.name)["RBI"] += 1 self.box_score.away_pitchers.get(self.away_active_pitcher.name)["ER"] += 1 self.home_runs += 1 self.box_score.home_lineup.get(self.diamond.third.player.name)["AB"] += 1 self.box_score.home_lineup.get(self.diamond.third.player.name)["T"] += 1 self.box_score.away_pitchers.get(self.away_active_pitcher.name)["H"] += 1 elif result[constants.RESULT_HIT_TYPE] == constants.ACTION_HOMERUN: runs = self.diamond.homerun() if self.batting_team == constants.AWAY_TEAM: for player in runs: self.box_score.away_lineup.get(player.name)["R"] += 1 self.box_score.away_lineup.get(runs[len(runs)-1].name)["RBI"] += 1 self.box_score.home_pitchers.get(self.home_active_pitcher.name)["ER"] += 1 self.away_runs += 1 self.box_score.away_lineup.get(runs[len(runs)-1].name)["AB"] += 1 self.box_score.away_lineup.get(runs[len(runs)-1].name)["HR"] += 1 self.box_score.home_pitchers.get(self.home_active_pitcher.name)["H"] += 1 else: for player in runs: self.box_score.home_lineup.get(player.name)["R"] += 1 self.box_score.home_lineup.get(runs[len(runs)-1].name)["RBI"] += 1 self.box_score.away_pitchers.get(self.away_active_pitcher.name)["ER"] += 1 self.home_runs += 1 self.box_score.home_lineup.get(runs[len(runs)-1].name)["AB"] += 1 self.box_score.home_lineup.get(runs[len(runs)-1].name)["HR"] += 1 self.box_score.away_pitchers.get(self.away_active_pitcher.name)["H"] += 1 elif result[constants.RESULT_OUT_OR_ERROR] == constants.ACTION_ERROR: runs = self.diamond.error() if self.batting_team == constants.AWAY_TEAM: for player in runs: self.box_score.away_lineup.get(player.name)["R"] += 1 self.away_runs += 1 self.box_score.away_lineup.get(self.diamond.first.player.name)["AB"] += 1 else: for player in runs: self.box_score.home_lineup.get(player.name)["R"] += 1 self.home_runs += 1 self.box_score.home_lineup.get(self.diamond.first.player.name)["AB"] += 1 else: self.outs += 1 if self.batting_team == constants.AWAY_TEAM: self.box_score.away_lineup.get(self.diamond.atbat.player.name)["AB"] += 1 self.box_score.home_pitchers.get(self.home_active_pitcher.name)["IP"] = \ util.add_innings(self.box_score.home_pitchers.get(self.home_active_pitcher.name)["IP"],0.1) else: self.box_score.home_lineup.get(self.diamond.atbat.player.name)["AB"] += 1 self.box_score.away_pitchers.get(self.away_active_pitcher.name)["IP"] = \ util.add_innings(self.box_score.away_pitchers.get(self.away_active_pitcher.name)["IP"],0.1)