Let's Subclass the Parent with this JSON file:
The key thing to really note here is the parent block in the JSON,
If you note from the prior section, this mint and index is the mint and index used to create the parent class. By referencing it in the JSON file here for the child class, we are telling the contract to consider this class a child. This also means that when we choose an updatePermissivenessToUse
for creation here, we're actually using a permissiveness on the parent, not the child. So that tokenHolder is actually referencing the parent token, not the child. This is a nice way to get around needing to own updateAuthority on a specific NFT if you don't have it but want to make a game with it.
To create the subclass, run the same command as before:
The resulting show_player_class
command will yield the following:
The clever among you will probably be wondering where the BasicStatTemplates
from the parent class are. If it had had BasicStatTemplates
in the childUpdatePropagationPermissivenessArray
, it would have! In this case, we didn't add it in the previous section, so this child will only have the two stats it defines for itself, but if you try this example with that minor tweak to the parent, you can see the inheritance work.
However, we did set the propagation up for BodyParts
, and this resultant class does have both a Leg and an Arm.