moved duration to class attributes

This commit is contained in:
Sakimori 2021-03-07 13:14:52 -05:00
parent 2e74bac6fe
commit 24195e9a2f

View file

@ -4,6 +4,7 @@ from gametext import appearance_outcomes, base_string
class Weather: class Weather:
name = "Sunny" name = "Sunny"
emoji = "🌞" emoji = "🌞"
duration_range = [3,5]
def __init__(self, game): def __init__(self, game):
pass pass
@ -11,6 +12,9 @@ class Weather:
def __str__(self): def __str__(self):
return f"{self.emoji} {self.name}" return f"{self.emoji} {self.name}"
def set_duration(self):
pass
def modify_atbat_stats(self, player_rolls): def modify_atbat_stats(self, player_rolls):
# Activates before batting # Activates before batting
pass pass
@ -48,9 +52,7 @@ class Weather:
class Supernova(Weather): class Supernova(Weather):
name = "Supernova" name = "Supernova"
emoji = "🌟" emoji = "🌟"
duration_range = [1,2]
def __init__(self, game):
self.duration = random.randint(1,2)
def modify_atbat_stats(self, roll): def modify_atbat_stats(self, roll):
roll["pitch_stat"] *= 0.8 roll["pitch_stat"] *= 0.8
@ -58,11 +60,7 @@ class Supernova(Weather):
class Midnight(Weather): class Midnight(Weather):
name = "Midnight" name = "Midnight"
emoji = "🕶" emoji = "🕶"
duration_range = [1,1]
def __init__(self, game):
self.name = "Midnight"
self.emoji = "🕶"
self.duration = 1
def modify_steal_stats(self, roll): def modify_steal_stats(self, roll):
roll["run_stars"] *= 2 roll["run_stars"] *= 2
@ -70,11 +68,7 @@ class Midnight(Weather):
class SlightTailwind(Weather): class SlightTailwind(Weather):
name = "Slight Tailwind" name = "Slight Tailwind"
emoji = "🏌️‍♀️" emoji = "🏌️‍♀️"
duration_range = [2,4]
def __init__(self, game):
self.name = "Slight Tailwind"
self.emoji = "🏌️‍♀️"
self.duration = random.randint(2,4)
def activate(self, game, result): def activate(self, game, result):
@ -92,11 +86,7 @@ class SlightTailwind(Weather):
class Starlight(Weather): class Starlight(Weather):
name = "Starlight" name = "Starlight"
emoji = "🌃" emoji = "🌃"
duration_range = [2,2]
def __init__(self, game):
self.name = "Starlight"
self.emoji = "🌃"
self.duration = 2
def activate(self, game, result): def activate(self, game, result):
@ -128,12 +118,9 @@ class Starlight(Weather):
class Blizzard(Weather): class Blizzard(Weather):
name = "Blizzard" name = "Blizzard"
emoji = "" emoji = ""
duration_range = [3,6]
def __init__(self, game): def __init__(self, game):
self.name = "Blizzard"
self.emoji = ""
self.duration = random.randint(3,6)
self.counter_away = random.randint(0,len(game.teams['away'].lineup)-1) self.counter_away = random.randint(0,len(game.teams['away'].lineup)-1)
self.counter_home = random.randint(0,len(game.teams['home'].lineup)-1) self.counter_home = random.randint(0,len(game.teams['home'].lineup)-1)
@ -178,9 +165,7 @@ class Blizzard(Weather):
class Twilight(Weather): class Twilight(Weather):
name = "Twilight" name = "Twilight"
emoji = "👻" emoji = "👻"
duration_range = [2,3]
def __init__(self,game):
self.duration = random.randint(2,3)
def modify_atbat_roll(self, outcome, roll, defender): def modify_atbat_roll(self, outcome, roll, defender):
error_line = - (math.log(defender.stlats["defense_stars"] + 1)/50) + 1 error_line = - (math.log(defender.stlats["defense_stars"] + 1)/50) + 1
@ -201,9 +186,7 @@ class Twilight(Weather):
class ThinnedVeil(Weather): class ThinnedVeil(Weather):
name = "Thinned Veil" name = "Thinned Veil"
emoji = "🌌" emoji = "🌌"
duration_range = [2,4]
def __init__(self,game):
self.duration = random.randint(2,4)
def activate(self, game, result): def activate(self, game, result):
if result["ishit"]: if result["ishit"]:
@ -218,12 +201,9 @@ class ThinnedVeil(Weather):
class HeatWave(Weather): class HeatWave(Weather):
name = "Heat Wave" name = "Heat Wave"
emoji = "🌄" emoji = "🌄"
duration_range = [3,6]
def __init__(self,game): def __init__(self,game):
self.name = "Heat Wave"
self.emoji = "🌄"
self.duration = random.randint(3,6)
self.counter_away = random.randint(2,4) self.counter_away = random.randint(2,4)
self.counter_home = random.randint(2,4) self.counter_home = random.randint(2,4)
@ -264,9 +244,7 @@ class HeatWave(Weather):
class Drizzle(Weather): class Drizzle(Weather):
name = "Drizzle" name = "Drizzle"
emoji = "🌧" emoji = "🌧"
duration_range = [2,3]
def __init__(self,game):
self.duration = random.randint(2,3)
def on_flip_inning(self, game): def on_flip_inning(self, game):
if game.top_of_inning: if game.top_of_inning:
@ -291,9 +269,9 @@ class Drizzle(Weather):
class Breezy(Weather): class Breezy(Weather):
name = "Breezy" name = "Breezy"
emoji = "🎐" emoji = "🎐"
duration_range = [1,4]
def __init__(self, game): def __init__(self, game):
self.duration = random.randint(1,4)
self.activation_chance = 0.08 self.activation_chance = 0.08
def activate(self, game, result): def activate(self, game, result):
@ -335,9 +313,9 @@ class Breezy(Weather):
class MeteorShower(Weather): class MeteorShower(Weather):
name = "Meteor Shower" name = "Meteor Shower"
emoji = "🌠" emoji = "🌠"
duration_range = [3,6]
def __init__(self, game): def __init__(self, game):
self.duration = random.randint(3,6)
self.activation_chance = 0.13 self.activation_chance = 0.13
def activate(self, game, result): def activate(self, game, result):
@ -362,10 +340,9 @@ class MeteorShower(Weather):
class Hurricane(Weather): class Hurricane(Weather):
name = "Hurricane" name = "Hurricane"
emoji = "🌀" emoji = "🌀"
duration_range = [1,1]
def __init__(self, game): def __init__(self, game):
self.duration = 1
self.swaplength = random.randint(2,4) self.swaplength = random.randint(2,4)
self.swapped = False self.swapped = False
@ -385,10 +362,9 @@ class Hurricane(Weather):
class Tornado(Weather): class Tornado(Weather):
name = "Tornado" name = "Tornado"
emoji = "🌪" emoji = "🌪"
duration_range = [1,2]
def __init__(self, game): def __init__(self, game):
self.duration = random.randint(1,2)
self.activation_chance = 0.33 self.activation_chance = 0.33
self.counter = 0 self.counter = 0
@ -419,12 +395,12 @@ class Tornado(Weather):
class Downpour(Weather): class Downpour(Weather):
name = "Torrential Downpour" name = "Torrential Downpour"
emoji = '' emoji = ''
duration_range = [1,1]
def __init__(self, game): def __init__(self, game):
self.target = game.max_innings self.target = game.max_innings
self.name = f"Torrential Downpour: {roman.roman_convert(str(self.target))}" self.name = f"Torrential Downpour: {roman.roman_convert(str(self.target))}"
self.emoji = '' self.emoji = ''
self.duration = 1
def on_flip_inning(self, game): def on_flip_inning(self, game):
@ -499,6 +475,9 @@ class WeatherChains():
options, weight = WeatherChains.dictionary[weather_type] options, weight = WeatherChains.dictionary[weather_type]
return random.choices(options, weights = weight)[0] return random.choices(options, weights = weight)[0]
def starting_weather():
return random.choice(WeatherChains.light + WeatherChains.magic)
def debug_weathers(): def debug_weathers():
names = ["a.txt", "b.txt", "c.txt"] names = ["a.txt", "b.txt", "c.txt"]
for name in names: for name in names: