Symmetric difference set operation
heinezen opened this issue · comments
Christoph Heine commented
Symmetric difference, disjunctive union, XOR - or whatever you call it - is a set operation where the resulting set is composed of elements which are present in either set, but not in both. The corresponding python operator is ^=
.
This operation would lower the required patches for "replacement" changes such as the replacement of a move ability.
Without XOR (2 patches):
PatchRemove<SomeUnit>(..):
abilities -= {OldMove}
PatchAdd<SomeUnit>(..):
abilities += {NewMove}
With XOR (1 patch):
PatchXOR<SomeUnit>(..)
# OldMove will be removed because it is in both sets
abilities ^= {OldMove, NewMove}
Jonas Jelten commented
We can add it, but I would be careful because if an unforseen mod already adds an ability you want to add know, the ^=
will remove it then even though you intended to add it.