Skip to content

Commit

Permalink
Merge pull request #3402 from KiraDragoness/KiraDragoness-accessories
Browse files Browse the repository at this point in the history
[ENHANCEMENT] Allow cats to have multiple accessories
  • Loading branch information
j-gynn authored Feb 7, 2025
2 parents 335db5a + daa23ec commit 0d225b0
Show file tree
Hide file tree
Showing 6 changed files with 163 additions and 92 deletions.
3 changes: 2 additions & 1 deletion resources/game_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@
"elder_modifier": 20,
"happy_trait_modifier": -30,
"grumpy_trait_modifier": 30,
"ceremony_modifier": -20
"ceremony_modifier": -20,
"multiple_acc_modifier": 50
},
"transition_related": {
"base_trans_chance": 256,
Expand Down
69 changes: 56 additions & 13 deletions scripts/cat/pelts.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,14 +304,6 @@ class Pelt:
"BULB BLUE",
"CLOVER",
"DAISY",
"CLOVER",
"DAISY",
"LILY OF THE VALLEY",
"HEATHER",
"SNAPDRAGON",
"GORSE",
"BULB WHITE",
"BULB YELLOW",
"DRY HERBS",
"DRY CATMINT",
"DRY NETTLES",
Expand Down Expand Up @@ -403,6 +395,53 @@ class Pelt:
"INDIGONYLON",
]

head_accessories = [
"MOTH WINGS",
"ROSY MOTH WINGS",
"MORPHO BUTTERFLY",
"MONARCH BUTTERFLY",
"CICADA WINGS",
"BLACK CICADA",
"MAPLE LEAF",
"HOLLY",
"BLUE BERRIES",
"FORGET ME NOTS",
"RYE STALK",
"CATTAIL",
"POPPY",
"ORANGE POPPY",
"CYAN POPPY",
"WHITE POPPY",
"PINK POPPY",
"BLUEBELLS",
"LILY OF THE VALLEY",
"SNAPDRAGON",
"NETTLE",
"HEATHER",
"GORSE",
"JUNIPER",
"RASPBERRY",
"LAVENDER",
"OAK LEAVES",
"CATMINT",
"MAPLE SEED",
"LAUREL",
"BULB WHITE",
"BULB YELLOW",
"BULB ORANGE",
"BULB PINK",
"BULB BLUE",
"DRY CATMINT",
"DRY NETTLES",
"DRY LAURELS",
]

body_accessories = [
"HERBS",
"PETALS",
"DRY HERBS"
]

tabbies = ["Tabby", "Ticked", "Mackerel", "Classic", "Sokoke", "Agouti"]
spotted = ["Speckled", "Rosette"]
plain = ["SingleColour", "TwoColour", "Smoke", "Singlestripe"]
Expand Down Expand Up @@ -652,7 +691,7 @@ def __init__(
tortiepattern: str = None,
vitiligo: str = None,
points: str = None,
accessory: str = None,
accessory: list = None,
paralyzed: bool = False,
opacity: int = 100,
scars: list = None,
Expand Down Expand Up @@ -806,6 +845,10 @@ def check_and_convert(self, convert_dict):
elif self.pattern == "MINIMAL4":
self.pattern = "MINIMALFOUR"

if isinstance(self.accessory, str):
self.accessory = [self.accessory]


def init_eyes(self, parents):
if not parents:
self.eye_colour = choice(Pelt.eye_colours)
Expand Down Expand Up @@ -1171,7 +1214,7 @@ def init_scars(self, age):

def init_accessories(self, age):
if age == "newborn":
self.accessory = None
self.accessory = []
return

acc_display_choice = random.randint(0, 80)
Expand All @@ -1181,11 +1224,11 @@ def init_accessories(self, age):
acc_display_choice = random.randint(0, 100)

if acc_display_choice == 1:
self.accessory = choice(
self.accessory = [choice(
[choice(Pelt.plant_accessories), choice(Pelt.wild_accessories)]
)
)]
else:
self.accessory = None
self.accessory = []

def init_pattern(self):
if self.name in Pelt.torties:
Expand Down
6 changes: 4 additions & 2 deletions scripts/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -1709,8 +1709,8 @@ def gain_accessories(self, cat):
if cat.dead or cat.outside:
return

# check if cat already has acc
if cat.pelt.accessory:
# check if cat already has max acc
if cat.pelt.accessory and len(cat.pelt.accessory) == 3:
self.ceremony_accessory = False
return

Expand Down Expand Up @@ -1751,6 +1751,8 @@ def gain_accessories(self, cat):
"nervous",
]:
chance += acc_chances["grumpy_trait_modifier"]
if cat.pelt.accessory and len(cat.pelt.accessory) >= 1:
chance += acc_chances["multiple_acc_modifier"]
if self.ceremony_accessory:
chance += acc_chances["ceremony_modifier"]

Expand Down
24 changes: 21 additions & 3 deletions scripts/events_module/short/handle_short_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@ def handle_event(

# give accessory
if self.chosen_event.new_accessory:
self.handle_accessories()
if self.handle_accessories() is False:
return


# change relationships before killing anyone
if self.chosen_event.relationships:
Expand Down Expand Up @@ -399,8 +401,24 @@ def handle_accessories(self, pelts=Pelt):
if acc in acc_list:
acc_list.remove(acc)

if acc_list:
self.main_cat.pelt.accessory = random.choice(acc_list)
accessory_groups = [pelts.collars, pelts.head_accessories, pelts.tail_accessories, pelts.body_accessories]
if self.main_cat.pelt.accessory:
for acc in self.main_cat.pelt.accessory:
# find which accessory group it belongs to
for i, lst in enumerate(accessory_groups):
if acc in lst:
# remove that group from possible accessories
acc_list = [a for a in acc_list if a not in accessory_groups[i]]
break

if not acc_list:
return False

if self.main_cat.pelt.accessory:
self.main_cat.pelt.accessory.append(random.choice(acc_list))
else:
self.main_cat.pelt.accessory = [random.choice(acc_list)]


def handle_transition(self):
"""
Expand Down
Loading

0 comments on commit 0d225b0

Please sign in to comment.