How to had operation with character/items on binary with concrete operations on C++?
- by Piperoman
I have the next problem.
A item can had a lot of states:
NORMAL = 0000000
DRY = 0000001
HOT = 0000010
BURNING = 0000100
WET = 0001000
COLD = 0010000
FROZEN = 0100000
POISONED= 1000000
A item can had some states at same time but not all of them
Is impossible to be dry and wet at same time.
If you COLD a WET item, it turns into FROZEN.
If you HOT a WET item, it turns into NORMAL
A item can be BURNING and POISON
Etc.
I have try to set binary flags to states, and use AND to set operation to combine different states, checking before if is possible or not to do it, or change to another status.
Exist a concrete patron to solve this problem efficiently without had a interminable switch that check every states with everynew states?
It is relative easy to check 2 different states, but if exist a third state it is not trivial to do.