Skip to content

Commit

Permalink
Add compatibility method for getting maximum relationship
Browse files Browse the repository at this point in the history
  • Loading branch information
KiloOscarSix committed Jun 10, 2024
1 parent 985ecb5 commit da191cf
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion CharacterService_ren.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Iterable, Optional, Union
from typing import Any, Iterable, Optional, Union

from game.characters.npcs.svc_housing_officer_ren import SVCHousingOfficer
from renpy import store
Expand Down Expand Up @@ -70,6 +70,35 @@ def get_relationship(

return character.relationships.setdefault(target, Relationship.FRIEND)

@staticmethod
def compat_get_max_rel(
npc_vars: dict[str, Any], target_vars: dict[str, Any]
) -> "Relationship":
current_rel = Relationship.FRIEND

mc_rels = target_vars.get("relationships", {})
npc_name = npc_vars["name"]

# region MC
mc_rel = mc_rels.get(npc_name, Relationship.FRIEND)
if mc_rel.value > current_rel.value:
current_rel = mc_rel
# endregion

# region _relationship
npc_rel = npc_vars.get("_relationship", Relationship.FRIEND)
if npc_rel.value > current_rel.value:
current_rel = npc_rel
# endregion

# region relationships
npc_rel = npc_vars.get("relationship", Relationship.FRIEND)
if npc_rel.value > current_rel.value:
current_rel = npc_rel
# endregion

return current_rel

@staticmethod
def has_relationship(
character: Character,
Expand Down

0 comments on commit da191cf

Please sign in to comment.