Skip to content

Commit

Permalink
Merge pull request #10 from DRincs-Productions/9-add-a-function-to-lo…
Browse files Browse the repository at this point in the history
…ok-up-the-character-in-a-dictionary

Update utility.py
  • Loading branch information
BlackRam-oss committed Jan 13, 2024
2 parents bc03b9e + 9e7fde8 commit c2b2e72
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions pythonpackages/renpy_utility/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,38 @@ def all_characters(store) -> list[character.ADVCharacter]:
if isinstance(item, character.ADVCharacter):
my_list.append(item)
return my_list


def get_value_by_character_key(character: character.ADVCharacter, dict: dict):
if character in dict:
return dict[character]
else:
for key, value in dict.items():
if str(character) == str(key):
dict[character] = value
del dict[key]
return value
return None


def set_value_by_character_key(character: character.ADVCharacter, dict: dict, value):
if character in dict:
dict[character] = value
else:
for key in dict.keys():
if str(character) == str(key):
dict[character] = value
del dict[key]
return
dict[character] = value


def del_value_by_character_key(character: character.ADVCharacter, dict: dict):
if character in dict:
del dict[character]
else:
for key in dict.keys():
if str(character) == str(key):
del dict[key]
return
return

0 comments on commit c2b2e72

Please sign in to comment.