I'm making a "game engine" for a game that's supposed to be played entirely within the python shell, and I got to the part where I am making the system responsible for handling story flags and the general progress of the player.
Problem is though, whenever I create a normal dictionary in python, it appears to be a default dict instead.
Here is a python file that represents this problem in the clearest way:
import json
BRANCH_LIST = ["storybranch1", 'storybranch2', 'storybranch3']
NPC_VALUES = {
"NPC1": {
"Likeness": 0,
"Hate": 0,
"Trust": 0,
"Respect": 0
},
"NPC2": {
"Likeness": 0,
"Hate": 0,
"Trust": 0,
"Respect": 0
}
}
FLAGS = {
"flagA": True,
"flagB": False,
"flagC": True
}
QUEST_FLAGS = {
"quests_completed": 0,
"side-quests_completed": 0,
"quest_list": ["quest1", "quest2", "quest3"],
"individual_completion": {
"quest1_completed": False,
"quest2_completed": False
}
}
def change_flag(flag_name: str, value):
FLAGS[flag_name] = value
change_flag("asdw", True)
print(FLAGS.keys(), FLAGS.values())
The output of this program looks like this:
dict_keys(['flagA', 'flagB', 'flagC', 'asdw']) dict_values([True, False, True, True])
While the expected output is something like this:
KeyError: 'asdw'
I am working on a Linux Mint 22.2 machine with python 3.12.3
There is no virutal environment present in my project.
Any ideas why this is happening?