forked from External/mage
Ability refactor: new code to search abilities in cards and permanents;
This commit is contained in:
parent
978118148b
commit
8af43dc13a
31 changed files with 85 additions and 47 deletions
|
|
@ -158,12 +158,12 @@ public class Commander implements CommandObject {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAbility(UUID abilityId, Game game) {
|
||||
if (this.getAbilities().containsKey(abilityId)) {
|
||||
public boolean hasAbility(Ability ability, Game game) {
|
||||
if (this.getAbilities().contains(ability)) {
|
||||
return true;
|
||||
}
|
||||
Abilities<Ability> otherAbilities = game.getState().getAllOtherAbilities(getId());
|
||||
return otherAbilities != null && otherAbilities.containsKey(abilityId);
|
||||
return otherAbilities != null && otherAbilities.contains(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -173,8 +173,8 @@ public class Emblem implements CommandObject {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAbility(UUID abilityId, Game game) {
|
||||
return abilites.containsKey(abilityId);
|
||||
public boolean hasAbility(Ability ability, Game game) {
|
||||
return getAbilities().contains(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -182,8 +182,8 @@ public class Plane implements CommandObject {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAbility(UUID abilityId, Game game) {
|
||||
return abilites.containsKey(abilityId);
|
||||
public boolean hasAbility(Ability ability, Game game) {
|
||||
return getAbilities().contains(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ class TrailOfTheMageRingsReboundEffect extends ContinuousEffectImpl {
|
|||
|
||||
private void addReboundAbility(Card card, Ability source, Game game) {
|
||||
if (filter.match(card, game)) {
|
||||
boolean found = card.getAbilities().stream().anyMatch(ability -> ability instanceof ReboundAbility);
|
||||
boolean found = card.getAbilities(game).containsClass(ReboundAbility.class);
|
||||
if (!found) {
|
||||
Ability ability = new ReboundAbility();
|
||||
game.getState().addOtherAbility(card, ability);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue