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

@ -524,8 +524,8 @@ public class Spell extends StackObjImpl implements Card {
}
@Override
public boolean hasAbility(UUID abilityId, Game game) {
return card.hasAbility(abilityId, game);
public boolean hasAbility(Ability ability, Game game) {
return card.hasAbility(ability, game);
}
@Override

View file

@ -178,7 +178,7 @@ public class StackAbility extends StackObjImpl implements Ability {
}
@Override
public boolean hasAbility(UUID abilityId, Game game) {
public boolean hasAbility(Ability ability, Game game) {
return false;
}
@ -672,4 +672,17 @@ public class StackAbility extends StackObjImpl implements Ability {
public Outcome getCustomOutcome() {
return this.ability.getCustomOutcome();
}
@Override
public boolean isSameInstance(Ability ability) {
// same instance (by mtg rules) = same object, ID or class+text (you can't check class only cause it can be different by params/text)
if (ability == null) {
return false;
}
return (this == ability)
|| (this.getId().equals(ability.getId()))
|| (this.getOriginalId().equals(ability.getOriginalId()))
|| (this.getClass() == ability.getClass() && this.getRule().equals(ability.getRule()));
}
}