First of all, your enum needs a name. Without the name, the enum is just a fancy way to make a series of constants. For the purposes of this answer, I'll use MyEnum
, like this:
enum MyEnum {
STRENGTH, DEXTERITY, CONSTITUTION, INTELLIGENCE, WISDOM, CHARISMA
}
Now, we can refer to the enum and ask it about its elements. In particular, we can figure out what is the value associated with a name like this:
var boost = "DEXTERITY"
print("Value of ", boost, ": ", MyEnum.get(boost))
That should print:
Value of DEXTERITY: 1
By the way, if you want to get the name from the value, you can do this:
var value = MyEnum.DEXTERITY
print("Name of ", value, ": ", MyEnum.keys()[value])
That should print:
Name of 1: DEXTERITY
What you are getting is just a regular dictionary preset with the contents of the enum. So, we can ask it about all the values:
for boost in MyEnum:
print(boost)
Which will print:
STRENGTH
DEXTERITY
CONSTITUTION
INTELLIGENCE
WISDOM
CHARISMA
And we can also ask it if it has a particular one, for example print(MyEnum.has("ENDURANCE"))
prints False
.
And yes you could edit the dictionary. It is just a dictionary you get initialized with the values of the enum.
_facing
property correctly switches between -1 and 1, but the Keys lookup always returns RIGHT (I'm guessing because the ordinals are 0 and 1). – Plagal