Ability refactor: new code to search abilities in cards and permanents;

This commit is contained in:
Oleg Agafonov 2020-05-28 22:34:27 +04:00
parent 978118148b
commit 8af43dc13a
31 changed files with 85 additions and 47 deletions

View file

@ -41,9 +41,13 @@ public interface MageObject extends MageItem, Serializable {
Set<SuperType> getSuperType();
/**
* For cards: return basic abilities (without dynamic added)
* For permanents: return all abilities (dynamic ability inserts into permanent)
*/
Abilities<Ability> getAbilities();
boolean hasAbility(UUID abilityId, Game game);
boolean hasAbility(Ability ability, Game game);
ObjectColor getColor(Game game);
@ -180,9 +184,9 @@ public interface MageObject extends MageItem, Serializable {
}
if (this.isCreature() && otherCard.isCreature()) {
if (this.getAbilities().contains(ChangelingAbility.getInstance())
if (this.hasAbility(ChangelingAbility.getInstance(), game)
|| this.isAllCreatureTypes()
|| otherCard.getAbilities().contains(ChangelingAbility.getInstance())
|| otherCard.hasAbility(ChangelingAbility.getInstance(), game)
|| otherCard.isAllCreatureTypes()) {
return true;
}