implemented the initial selection of archetypes
This commit is contained in:
parent
5d8dfca7f8
commit
4e8d88b3e3
|
@ -7,6 +7,10 @@ class Archetype:
|
|||
display_symbol = "🃏"
|
||||
description = "Master of none. This archetype has no bonuses and no penalties."
|
||||
|
||||
def modify_player_stats(player):
|
||||
"""This is called once at the start of every game"""
|
||||
pass
|
||||
|
||||
def modify_bat_rolls(outcome, rolls):
|
||||
""""modify the rolls used in batting before using the rolled values"""
|
||||
pass
|
||||
|
@ -43,13 +47,87 @@ class Archetype:
|
|||
"""change the runner's ability to advance extra bases on base hits by a teammate"""
|
||||
pass
|
||||
|
||||
class ThreeTrueOutcomes(Archetype):
|
||||
name = "pure power"
|
||||
display_name = "Three True Outcomes"
|
||||
description = "There are three outcomes in baseball that do not involve the batter running to first. Strikeouts, walks, and home runs. You'll get lots of these."
|
||||
|
||||
def modify_out_type(outcome): #if the batter flies out or grounds out, change 60% to a strikeout
|
||||
if outcome["outcome"] in [appearance_outcomes.groundout, appearance_outcomes.flyout] and random.random() > 0.4:
|
||||
outcome["outcome"] = appearance_outcomes.strikeoutswinging
|
||||
|
||||
def modify_hit_type(outcome): #if the batter gets a double, 50% chance for home run instead. Singles become strikeouts or home runs often.
|
||||
roll = random.random()
|
||||
if outcome["outcome"] in [appearance_outcomes.double, appearance_outcomes.triple] or roll > 0.8:
|
||||
outcome["outcome"] = appearance_outcomes.homerun
|
||||
elif outcome["outcome"] == appearance_outcomes.single and roll < 0.4:
|
||||
outcome["ishit"] = False
|
||||
outcome["outcome"] = appearance_outcomes.strikeoutswinging
|
||||
|
||||
class ContactHitter(Archetype):
|
||||
name = "contact"
|
||||
display_name = "Contact Specialist"
|
||||
description = "Some folks know how to get on base. Other folks learn from them. Unfortunately, these techniques make power more difficult to find."
|
||||
|
||||
def modify_bat_rolls(outcome, rolls): #if it's not a hit *and* not a walk, maybe get a hit anyway. Always reduce power.
|
||||
rolls["hitnum"] = rolls["hitnum"] * 0.75
|
||||
if rolls["pb_system_stat"] <= 0 and rolls["hitnum"] < 4 and random.random() > 0.8:
|
||||
rolls["pb_system_stat"] = 0.5
|
||||
rolls["hitnum"] = rolls["hitnum"] * 0.5
|
||||
|
||||
class Sprinter(Archetype):
|
||||
name = "speed"
|
||||
display_name = "Sprinter"
|
||||
description = "Speed can make up for a lack of strength in a lot of ways. Baserunning and defensive ability increase, at the expense of home run power."
|
||||
|
||||
def modify_player_stats(player):
|
||||
player.stlats["baserunning_stars"] = player.stlats["baserunning_stars"] + 2
|
||||
player.stlats["defense_stars"] = player.stlats["defense_stars"] + 2
|
||||
|
||||
def modify_bat_rolls(outcome, rolls): #reduce power
|
||||
rolls["hitnum"] = rolls["hitnum"] * 0.8
|
||||
|
||||
class Stuff(Archetype):
|
||||
name = "velocity"
|
||||
display_name = "They've Got the Stuff"
|
||||
description = "'Stuff' is one of the ways to talk about how fast a pitcher can throw the ball. This player has *got the stuff,* but it's hard to aim when you're throwing that fast. Watch for outs and walks to increse."
|
||||
|
||||
def modify_bat_rolls(outcome, rolls):
|
||||
if random.random() > 0.9:
|
||||
rolls["pb_system_stat"] = -1
|
||||
|
||||
if rolls["pb_system_stat"] <= 0:
|
||||
if rolls["hitnum"] > 3: #expand the Walk Zone
|
||||
rolls["hitnum"] = 4.5
|
||||
elif rolls["hitnum"] < 0: #expand the Strikeout Zone
|
||||
rolls["hitnum"] = -2
|
||||
|
||||
class Control(Archetype):
|
||||
name = "control"
|
||||
display_name = "Puppetmaster"
|
||||
description = "A pitcher with control knows how to 'pull the string' on a pitch well after it's been thrown. Batters are going to be swinging out of their shoes, but you're going to get more contact than usual. Weak contact, but still."
|
||||
|
||||
def modify_bat_rolls(outcome, rolls):
|
||||
if random.random() > 0.75:
|
||||
rolls["hitnum"] = rolls["hitnum"] * 0.5
|
||||
else:
|
||||
rolls["hitnum"] = rolls["hitnum"] * 0.9
|
||||
|
||||
if random.random() < 0.1:
|
||||
rolls["pb_system_stat"] = 1
|
||||
|
||||
def all_archetypes():
|
||||
return [
|
||||
Archetype
|
||||
Archetype,
|
||||
ThreeTrueOutcomes,
|
||||
ContactHitter,
|
||||
Sprinter,
|
||||
Stuff,
|
||||
Control
|
||||
]
|
||||
|
||||
def search_archetypes(text):
|
||||
for archetype in all_archetypes():
|
||||
if archetype.name == text or archetype.display_name == text:
|
||||
if archetype.name == text or archetype.display_name.lower() == text.lower():
|
||||
return archetype
|
||||
return None
|
7
games.py
7
games.py
|
@ -254,6 +254,11 @@ class game(object):
|
|||
self.voice = None
|
||||
self.current_batter = None
|
||||
|
||||
for this_team in [team1, team2]:
|
||||
for this_player in this_team.lineup + this_team.rotation:
|
||||
if this_player.name in this_team.archetypes.keys():
|
||||
this_team.archetypes[this_player.name].modify_player_stats(this_player)
|
||||
|
||||
def occupied_bases(self):
|
||||
occ_dic = {}
|
||||
for base in self.bases.keys():
|
||||
|
@ -367,7 +372,7 @@ class game(object):
|
|||
outcome["outcome"] = appearance_outcomes.fielderschoice
|
||||
outcome["defender"] = ""
|
||||
|
||||
if 2.5 <= roll["hitnum"] and self.outs < 2: #well hit flyouts can lead to sacrifice flies/advanced runners
|
||||
if outcome["outcome"] not in [appearance_outcomes.strikeoutlooking, appearance_outcomes.strikeoutswinging] and 2.5 <= roll["hitnum"] and self.outs < 2: #well hit flyouts can lead to sacrifice flies/advanced runners
|
||||
if self.bases[2] is not None or self.bases[3] is not None:
|
||||
outcome["advance"] = True
|
||||
else:
|
||||
|
|
|
@ -274,7 +274,7 @@ class AssignArchetypeCommand(Command):
|
|||
raise CommandError("We can't find that team.")
|
||||
|
||||
team, ownerid = games.get_team_and_owner(team.name)
|
||||
if ownerid != msg.author.id and user.id not in config()["owners"]:
|
||||
if ownerid != msg.author.id and msg.author.id not in config()["owners"]:
|
||||
raise CommandError("That team ain't yours, and we're not about to help you cheat.")
|
||||
|
||||
player = team.find_player(player_name)[0]
|
||||
|
|
Loading…
Reference in a new issue