Let’s say we have a game, characters in which have special abilities. All abilities share an abstract base type called AbstractAbility. Each character has a list of said base type (List), elements of which are objects of derived classes (List example = new List(){new StompAbility(), new TeleportAbility()}).
The problem is that said list needs to be changeable throught a config file, but YAML cannot deserialize AbstractClasses properly.
As of now I can bypass this issue by adding a field to AbstcractAbility class called AbilityType which contains the name of the derived class it belongs to, basically telling YAML what type it is actually trying to deserialize. However is there a way I can achieve the desirable result without having to resort to such measures?
Who am I is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.