Update card_creation.py
Calculate slash line once card creation is complete
This commit is contained in:
parent
47d7a7cad4
commit
b40409e844
@ -127,6 +127,21 @@ class BattingCardRatingsModel(pydantic.BaseModel):
|
||||
self.groundout_a, self.groundout_b, self.groundout_c
|
||||
]))
|
||||
|
||||
def update_slash_lines(self):
|
||||
self.avg = Decimal(
|
||||
(self.homerun + self.bp_homerun / 2 + self.triple + self.double_three +
|
||||
self.double_two + self.double_pull + self.single_two + self.single_one +
|
||||
self.single_center + self.bp_single / 2) / Decimal(108)
|
||||
)
|
||||
|
||||
self.obp = Decimal(((self.hbp + self.walk) / 108) + self.avg)
|
||||
|
||||
self.slg = Decimal(
|
||||
(self.homerun * 4 + self.bp_homerun * 2 + self.triple * 3 + self.double_three * 2 +
|
||||
self.double_two * 2 + self.double_pull * 2 + self.single_two + self.single_one +
|
||||
self.single_center + self.bp_single / 2) / 108
|
||||
)
|
||||
|
||||
|
||||
class PitchingCardRatingsModel(pydantic.BaseModel):
|
||||
pitchingcard: int
|
||||
@ -171,6 +186,20 @@ class PitchingCardRatingsModel(pydantic.BaseModel):
|
||||
self.xcheck_cf, self.xcheck_rf
|
||||
]))
|
||||
|
||||
def update_slash_lines(self):
|
||||
self.avg = Decimal(
|
||||
(self.homerun + self.bp_homerun / 2 + self.triple + self.double_three +
|
||||
self.double_two + self.double_cf + self.single_two + self.single_one +
|
||||
self.single_center + self.bp_single / 2) / Decimal(108)
|
||||
)
|
||||
|
||||
self.obp = Decimal(((self.hbp + self.walk) / 108) + self.avg)
|
||||
|
||||
self.slg = Decimal(
|
||||
(self.homerun * 4 + self.bp_homerun * 2 + self.triple * 3 + self.double_three * 2 +
|
||||
self.double_two * 2 + self.double_cf * 2 + self.single_two + self.single_one +
|
||||
self.single_center + self.bp_single / 2) / 108)
|
||||
|
||||
|
||||
class CardResult(pydantic.BaseModel):
|
||||
result_one: str = None
|
||||
@ -2036,6 +2065,7 @@ def get_batter_card_data(player, batting_card, ratings_vl, ratings_vr, positions
|
||||
|
||||
full_log(new_ratings, card)
|
||||
|
||||
new_ratings.update_slash_lines()
|
||||
new_battingratings.append(new_ratings)
|
||||
|
||||
vl_output = vl.card_output()
|
||||
@ -2901,6 +2931,7 @@ def get_pitcher_card_data(player, pitching_card, ratings_vl, ratings_vr, positio
|
||||
full_log(new_ratings, card)
|
||||
|
||||
card.add_fatigue()
|
||||
new_ratings.update_slash_lines()
|
||||
new_pitchingratings.append(new_ratings)
|
||||
|
||||
vl_output = vl.card_output()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user