Skip to content

Turn CardTrait Changes and Keyword Changes into Interfaces/records #9532

@Hanmac

Description

@Hanmac

Similar to CardType changes in #9375

Especially the stuff with updateBasicLandAbilities should be moved into CardState.

for (int i = 0; i < MagicColor.WUBRG.length; i++ ) {
byte c = MagicColor.WUBRG[i];
if (type.hasSubtype(MagicColor.Constant.BASIC_LANDS.get(i))) {
SpellAbility sa = basicLandAbilities[i];
// no Ability for this type yet, make a new one
if (sa == null) {
sa = CardFactory.buildBasicLandAbility(state, c);
basicLandAbilities[i] = sa;
}
list.add(sa);
}
}
}

And the two places that check for hasRemoveIntrinsic, should be handled by a different kind of extra class (second implementation of the new Interface)

public Iterable<CardTraitChanges> getChangedCardTraitsList(CardState state) {
List<SpellAbility> landManaAbilities = Lists.newArrayList();
this.updateBasicLandAbilities(landManaAbilities, state);
return Iterables.concat(
changedCardTraitsByText.values(), // Layer 3
ImmutableList.of(new CardTraitChanges(landManaAbilities, null, null, null, null, hasRemoveIntrinsic(), false)), // Layer 4
changedCardTraits.values() // Layer 6
);
}

I don't know yet if i want to move the implementation of the changes into the new classes/records like i did with the CardType changes:

for (final CardTraitChanges ck : getChangedCardTraitsList(state)) {
if (ck.isRemoveNonMana()) {
// List only has nonMana
if (null == mana) {
list.removeIf(Predicate.not(SpellAbility::isManaAbility));
} else if (false == mana) {
list.clear();
}
} else if (ck.isRemoveAll()) {
list.clear();
}
list.removeAll(ck.getRemovedAbilities());
for (SpellAbility sa : ck.getAbilities()) {
if (mana == null || mana == sa.isManaAbility()) {
list.add(sa);
}
}
}

for (final CardTraitChanges ck : getChangedCardTraitsList(state)) {
if (ck.isRemoveAll()) {
list.clear();
}
list.addAll(ck.getStaticAbilities());
}

for (final CardTraitChanges ck : getChangedCardTraitsList(state)) {
if (ck.isRemoveAll()) {
list.clear();
}
list.addAll(ck.getTriggers());
}

for (final CardTraitChanges ck : getChangedCardTraitsList(state)) {
if (ck.isRemoveAll()) {
list.clear();
}
list.addAll(ck.getReplacements());
}

If possible, i want KeywordChanges/KeywordCollection to inherit the CardTraitChanges Interface, because Keywords have Card Traits inside.

Metadata

Metadata

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions