Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relationship/kin thought weights | Option to save dead relationships #2476

Open
wants to merge 29 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
3cf52b3
Kin and relationship thoughts, retain death relationships
Snowstar38 Jun 10, 2024
a830bef
Merge branch 'ClanGenOfficial:development' into development
Snowstar38 Jun 10, 2024
609ddd5
Fix game setting crash
Snowstar38 Jun 10, 2024
fde35e4
Merge branch 'development' of https://github.com/Snowstar38/clangen i…
Snowstar38 Jun 10, 2024
cafa66f
Update ProfileScreen.py
Snowstar38 Jun 10, 2024
668b9e4
remove print
Snowstar38 Jun 10, 2024
0d3af92
Merge branch 'ClanGenOfficial:development' into development
Snowstar38 Jun 10, 2024
a77e2e5
Merge branch 'Clangen' into development
Snowstar38 Jun 10, 2024
a00f8a6
Merge branch 'ClanGenOfficial:development' into development
Snowstar38 Jun 15, 2024
fb5c788
Add description for new function
Snowstar38 Jun 15, 2024
583f574
Fixing dead relations
Snowstar38 Jun 16, 2024
7077ef7
Inheritance/family tree fix
Snowstar38 Jun 16, 2024
f7cdcda
Polish
Snowstar38 Jun 16, 2024
961f534
add description
Snowstar38 Jun 16, 2024
6d54c25
plurality
Snowstar38 Jun 16, 2024
8ecf4d6
Weight based rolls
Snowstar38 Jun 16, 2024
bc50b5d
Update cats.py
Snowstar38 Jun 16, 2024
c0c8f83
Update game_config.json
Snowstar38 Jun 16, 2024
92b5d33
pylint pls
Snowstar38 Jun 16, 2024
8a9a70e
surprise, I'm just dumb
Snowstar38 Jun 16, 2024
496672e
Update cats.py
Snowstar38 Jun 16, 2024
4ada0c5
consarn it
Snowstar38 Jun 16, 2024
1929beb
tidying up get_kin_groups
Snowstar38 Jun 16, 2024
7d2feaa
Fix for other_cat being self
Snowstar38 Jul 12, 2024
fda32d0
Merge branch 'ClanGenOfficial:development' into Relationship-thoughts
Snowstar38 Oct 27, 2024
8c25287
Lixxis requests :)
Snowstar38 Oct 28, 2024
6486866
self > cat
Snowstar38 Oct 28, 2024
072fd0b
Merge branch 'ClanGenOfficial:development' into Relationship-thoughts
Snowstar38 Oct 31, 2024
a36aa48
Merge branch 'ClanGenOfficial:development' into Relationship-thoughts
Snowstar38 Nov 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions resources/clansettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@
"Allow first cousins to be mates and have romantic interactions",
"Allows cats with the same grandparents but different parents to become mates.",
false
],
"dead_relations": [
"Save dead cats' relationships",
"Allow dead cats to retain their relationship information. May cause lag on large saves.",
false
]
},
"freshkill_tactics":{
Expand Down
7 changes: 6 additions & 1 deletion resources/game_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,16 @@
"chance_of_special_group": 8,
"chance_romantic_not_mate": 15,
"influence_condition_events": 20,
"relationship_thought_chance": 20,
"kin_thought_chance": 20,
"comment":[
"chance_for_neutral - how high the chance is to make the interaction of the relationship to a 'neutral' instead of negative or positive",
"chance_of_special_group - 1/chance often when a group event is happening not all cats are considered, only a special group, which is defined in group_types.json",
"chance_romantic_not_mate - the base chance of an romantic interaction with another cat, when a cat has a mate",
"influence_condition_events - how much an event with a condition can influence the relationship"
"influence_condition_events - how much an event with a condition can influence the relationship",
"relationship_thought_chance - % chance that a cat's thought will refer to a cat they have a relationship with",
"kin_thought_chance - % chance that a cat's thought will refer to a cat they are related to",
"the % for thought_chance only applies to thoughts that would have already mentioned a second cat."
]
},
"mates":{
Expand Down
364 changes: 332 additions & 32 deletions scripts/cat/cats.py

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions scripts/cat_relations/inheritance.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,17 @@ def update_inheritance(self):
# parents_siblings
self.init_parents_siblings(inter_id, inter_cat)

# cousins
self.init_cousins(inter_id, inter_cat)

# since grand kits depending on kits, ALL KITS HAVE TO BE SET FIRST!
# since grandkits depends on kits, ALL KITS HAVE TO BE SET FIRST!
# cousins depend on parents_siblings so those must be set first too
for inter_id, inter_cat in self.cat.all_cats.items():
if inter_id == self.cat.ID:
continue

# grand kits
self.init_grand_kits(inter_id, inter_cat)

# cousins
self.init_cousins(inter_id, inter_cat)

# relations to faded cats - these must occur after all non-faded
# cats have been handled, and in the following order.
Expand Down
5 changes: 4 additions & 1 deletion scripts/game_structure/game_essentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,10 @@ def save_cats(self):
inter_cat.save_history(directory + "/history")
# after saving, dump the history info
inter_cat.history = None
if not inter_cat.dead:
if not game.clan.clan_settings["dead_relations"]:
if not inter_cat.dead:
inter_cat.save_relationship_of_cat(directory + "/relationships")
else:
inter_cat.save_relationship_of_cat(directory + "/relationships")

self.safe_save(f"{get_save_dir()}/{clanname}/clan_cats.json", clan_cats)
Expand Down
4 changes: 1 addition & 3 deletions scripts/game_structure/load_cat.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,9 @@ def json_load():
# load the relationships
try:
if not cat.dead:
cat.load_relationship_of_cat()
if cat.relationships is not None and len(cat.relationships) < 1:
cat.init_all_relationships()
else:
cat.relationships = {}
cat.load_relationship_of_cat()
except Exception as e:
logger.exception(
f"There was an error loading relationships for cat #{cat}."
Expand Down
3 changes: 2 additions & 1 deletion scripts/screens/ProfileScreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -2175,8 +2175,9 @@ def update_disabled_buttons_and_text(self):
pass
elif self.open_tab == "relations":
if self.the_cat.dead:
self.see_relationships_button.disable()
self.change_adoptive_parent_button.disable()
if not game.clan.clan_settings["dead_relations"]:
self.see_relationships_button.disable()
else:
self.see_relationships_button.enable()
self.change_adoptive_parent_button.enable()
Expand Down
37 changes: 37 additions & 0 deletions scripts/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -1665,6 +1665,43 @@ def change_relationship_values(
if log_text not in rel.log:
rel.log.append(log_text)

def get_kin_groups(cat, include_dead=True):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it important at this point to already have the cat class? It would be more performant to just use the id's as long as possible and then fetch the cat, when the information from them is needed.

"""
Retrieves the kin groups (close kin, kin, and distant kin) for the cat.
:param include_dead: Whether to include dead cats in the kin groups (default: True).
:return: A tuple containing three dictionaries: close_kin, kin, and distant_kin.
- close_kin: Dictionary of close kin groups (parents, siblings, children, mates, former mates).
- kin: Dictionary of kin groups (grandparents, aunts/uncles, cousins, grandkits).
- distant_kin: Dictionary of distant kin groups.
"""
close_kin = {
"gen_parents": [cat.all_cats.get(cat_id) for cat_id in cat.get_parents()],
"gen_siblings": [cat.all_cats.get(cat_id) for cat_id in cat.get_siblings()],
"gen_children": [cat.all_cats.get(cat_id) for cat_id in cat.get_children()],
"gen_mates": [cat.all_cats.get(cat_id) for cat_id in cat.mate],
"gen_former_mates": [cat.all_cats.get(cat_id) for cat_id in cat.previous_mates]
}

kin = {
"gen_grandparents": [cat.all_cats.get(cat_id) for cat_id in cat.all_cats if cat.all_cats.get(cat_id).is_grandparent(cat)],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "get_kin_groups" function is not very performant. To improve it at least a little add the new "kin" to the inheritance class. It seems it was done but not used?

"gen_auntuncle": [cat.all_cats.get(cat_id) for cat_id in cat.all_cats if cat.is_uncle_aunt(cat.all_cats.get(cat_id))],
"gen_cousin": [cat.all_cats.get(cat_id) for cat_id in cat.all_cats if cat.is_cousin(cat.all_cats.get(cat_id))],
"gen_grandkits": [cat.all_cats.get(cat_id) for cat_id in cat.get_grandkits()]
}

distant_kin = {
"gen_distantkin": [cat.all_cats.get(cat_id) for cat_id in cat.get_distant_kin()]
}

if not include_dead:
for group in close_kin.values():
group[:] = [cat for cat in group if not cat.dead]
for group in kin.values():
group[:] = [cat for cat in group if not cat.dead]
for group in distant_kin.values():
group[:] = [cat for cat in group if not cat.dead]

return close_kin, kin, distant_kin

# ---------------------------------------------------------------------------- #
# Text Adjust #
Expand Down