Skip to content

Commit

Permalink
Merge pull request #3075 from bakermor/development
Browse files Browse the repository at this point in the history
[ENHANCEMENT] Change transing function to use ShortEvents
  • Loading branch information
scribblecrumb authored Dec 2, 2024
2 parents c4fd481 + 2451b56 commit 4395255
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 32 deletions.
25 changes: 25 additions & 0 deletions resources/dicts/events/misc/general.json
Original file line number Diff line number Diff line change
Expand Up @@ -4044,5 +4044,30 @@
"age": ["adolescent", "young adult", "adult", "senior adult", "senior"],
"status": ["medicine cat"]
}
},
{
"event_id": "gen_misc_transition_from_female1",
"location": ["any"],
"season": ["any"],
"sub_type": ["transition"],
"weight": 10,
"event_text": "m_c has realized that she-cat doesn't describe how {PRONOUN/m_c/subject} {VERB/m_c/feel/feels} anymore.",
"m_c": {
"age": ["young adult"],
"gender": ["female"]
},
"new_gender": ["trans male", "nonbinary"]
},
{
"event_id": "gen_misc_transition_from_male1",
"location": ["any"],
"season": ["any"],
"sub_type": ["transition"],
"weight": 10,
"event_text": "m_c has realized that tom doesn't describe how {PRONOUN/m_c/subject} {VERB/m_c/feel/feels} anymore.",
"m_c": {
"gender": ["male"]
},
"new_gender": ["trans female", "nonbinary"]
}
]
5 changes: 5 additions & 0 deletions resources/game_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,11 @@
"grumpy_trait_modifier": 30,
"ceremony_modifier": -20
},
"transition_related": {
"base_trans_chance": 256,
"adolescent_modifier": -128,
"older_modifier": 256
},
"fading": {
"age_to_fade": 202,
"opacity_at_fade": 20,
Expand Down
50 changes: 18 additions & 32 deletions scripts/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -2439,42 +2439,28 @@ def handle_outbreaks(self, cat):

def coming_out(self, cat):
"""turnin' the kitties trans..."""
# TODO: should figure out how to handle these as a ShortEvent, we don't want hardcoded text
if cat.genderalign == cat.gender:
if cat.moons < 6:
return

involved_cats = [cat.ID]
if cat.age == "adolescent":
transing_chance = random.getrandbits(8) # 2/256
elif cat.age == "young adult":
transing_chance = random.getrandbits(9) # 2/512
else:
# adult, senior adult, elder
transing_chance = random.getrandbits(10) # 2/1028
if cat.age in ["kitten", "newborn"]:
return

if transing_chance:
# transing_chance != 0, no trans kitties today... L
return
random_cat = get_random_moon_cat(Cat, main_cat=cat)

if random.getrandbits(1): # 50/50
if cat.gender == "male":
cat.genderalign = "trans female"
cat.pronouns = [cat.default_pronouns[1].copy()]
else:
cat.genderalign = "trans male"
cat.pronouns = [cat.default_pronouns[2].copy()]
else:
cat.genderalign = "nonbinary"
cat.pronouns = [cat.default_pronouns[0].copy()]
transing_chance = game.config["transition_related"]
chance = transing_chance["base_trans_chance"]
if cat.age in ["adolescent"]:
chance += transing_chance["adolescent_modifier"]
elif cat.age in ["adult", "senior adult", "senior"]:
chance += transing_chance["older_modifier"]

if cat.gender == "male":
gender = "tom"
else:
gender = "she-cat"
text = f"{cat.name} has realized that {gender} doesn't describe how they feel anymore."
game.cur_events_list.append(Single_Event(text, "misc", involved_cats))
# game.misc_events_list.append(text)
if not int(random.random() * chance):
sub_type = ["transition"]
handle_short_events.handle_event(event_type="misc",
main_cat=cat,
random_cat=random_cat,
sub_type=sub_type,
freshkill_pile=game.clan.freshkill_pile)

return

def check_and_promote_leader(self):
"""Checks if a new leader need to be promoted, and promotes them, if needed."""
Expand Down
21 changes: 21 additions & 0 deletions scripts/events_module/generate_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ def generate_short_events(event_triggered, biome):
outsider=event["outsider"] if "outsider" in event else {},
other_clan=event["other_clan"] if "other_clan" in event else {},
supplies=event["supplies"] if "supplies" in event else [],
new_gender=event["new_gender"] if "new_gender" in event else []
)
event_list.append(event)

Expand Down Expand Up @@ -397,6 +398,13 @@ def filter_possible_short_events(
if "romantic" in event.tags and not random_cat.is_potential_mate(cat):
continue

# check if already trans
if (
"transition" in event.sub_type
and cat.gender != cat.genderalign
):
continue

if event.m_c:
if cat.age not in event.m_c["age"] and "any" not in event.m_c["age"]:
continue
Expand Down Expand Up @@ -476,6 +484,15 @@ def filter_possible_short_events(
if cat.backstory not in event.m_c["backstory"]:
continue

# check gender for transition events
if event.m_c["gender"]:
if (
cat.gender not in event.m_c["gender"]
and "any" not in event.m_c["gender"]
):
continue


# check that a random_cat is available to use for r_c
if event.r_c and random_cat:
if (
Expand Down Expand Up @@ -1041,6 +1058,7 @@ def __init__(
outsider=None,
other_clan=None,
supplies=None,
new_gender=None
):
if not event_id:
print("WARNING: moon event has no event_id")
Expand Down Expand Up @@ -1074,6 +1092,8 @@ def __init__(
self.m_c["backstory"] = []
if "dies" not in self.m_c:
self.m_c["dies"] = False
if "gender" not in self.m_c:
self.m_c["gender"] = []

self.r_c = r_c if r_c else {}
if self.r_c:
Expand Down Expand Up @@ -1115,6 +1135,7 @@ def __init__(
if "changed" not in self.other_clan:
self.other_clan["changed"] = 0
self.supplies = supplies if supplies else []
self.new_gender = new_gender


class OngoingEvent:
Expand Down
23 changes: 23 additions & 0 deletions scripts/events_module/handle_short_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ def handle_event(
trust=-30,
)

# update gender
if self.chosen_event.new_gender:
self.handle_transition()

# kill cats
self.handle_death()

Expand Down Expand Up @@ -390,6 +394,25 @@ def handle_accessories(self, pelts=Pelt):
if acc_list:
self.main_cat.pelt.accessory = random.choice(acc_list)

def handle_transition(self):
"""
handles updating gender_align and pronouns
"""
possible_genders = getattr(self.chosen_event, "new_gender", [])

if possible_genders:
new_gender = random.choice(possible_genders)
self.main_cat.genderalign = new_gender

if new_gender == "nonbinary":
self.main_cat.pronouns = [self.main_cat.default_pronouns[0].copy()]
elif new_gender == "trans female":
self.main_cat.pronouns = [self.main_cat.default_pronouns[1].copy()]
elif new_gender == "trans male":
self.main_cat.pronouns = [self.main_cat.default_pronouns[2].copy()]
else:
print("No pronouns found for new_gender, keeping original pronouns.", new_gender)

def handle_death(self):
"""
handles killing/murdering cats
Expand Down

0 comments on commit 4395255

Please sign in to comment.