mirror of
https://github.com/magefree/mage.git
synced 2026-01-23 19:59:54 -08:00
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
|
|
@ -82,7 +82,7 @@ class ChaosphereEffect extends RestrictionEffect {
|
|||
if (attacker == null) {
|
||||
return true;
|
||||
}
|
||||
return attacker.hasAbility(FlyingAbility.getInstance().getId(), game);
|
||||
return attacker.hasAbility(FlyingAbility.getInstance(), game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ class CrimsonRocTriggeredAbility extends TriggeredAbilityImpl {
|
|||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
return permanent != null
|
||||
&& permanent.isCreature()
|
||||
&& !permanent.getAbilities(game).contains(FlyingAbility.getInstance());
|
||||
&& !permanent.hasAbility(FlyingAbility.getInstance(), game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ class DenseCanopyCantBlockEffect extends RestrictionEffect {
|
|||
if (attacker == null) {
|
||||
return true;
|
||||
}
|
||||
return attacker.hasAbility(FlyingAbility.getInstance().getId(), game);
|
||||
return attacker.hasAbility(FlyingAbility.getInstance(), game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -75,6 +75,6 @@ enum MomentumRumblerCondition implements Condition {
|
|||
if (permanent == null) {
|
||||
return false;
|
||||
}
|
||||
return hasAbility == permanent.getAbilities(game).containsKey(FirstStrikeAbility.getInstance().getId());
|
||||
return hasAbility == permanent.hasAbility(FirstStrikeAbility.getInstance(), game);
|
||||
}
|
||||
}
|
||||
|
|
@ -82,7 +82,7 @@ class QuartzwoodCrasherTriggeredAbility extends TriggeredAbilityImpl {
|
|||
&& ((DamagedPlayerEvent) event).isCombatDamage()) {
|
||||
Permanent creature = game.getPermanent(event.getSourceId());
|
||||
if (creature != null && creature.isControlledBy(controllerId)
|
||||
&& creature.hasAbility(TrampleAbility.getInstance().getId(), game)
|
||||
&& creature.hasAbility(TrampleAbility.getInstance(), game)
|
||||
&& !damagedPlayerIds.contains(event.getTargetId())) {
|
||||
damagedPlayerIds.add(event.getTargetId());
|
||||
this.getEffects().setTargetPointer(new FixedTarget(event.getTargetId(), game));
|
||||
|
|
@ -143,7 +143,7 @@ class QuartzwoodCrasherWatcher extends Watcher {
|
|||
return;
|
||||
}
|
||||
Permanent creature = game.getPermanent(event.getSourceId());
|
||||
if (creature == null || !creature.getAbilities(game).containsKey(TrampleAbility.getInstance().getId())) {
|
||||
if (creature == null || !creature.hasAbility(TrampleAbility.getInstance(), game)) {
|
||||
return;
|
||||
}
|
||||
damageMap
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ class ReturnFromExtinctionTarget extends TargetCardInYourGraveyard {
|
|||
return false;
|
||||
}
|
||||
for (Card card : player.getGraveyard().getCards(filter, sourceId, sourceControllerId, game)) {
|
||||
if (card.isAllCreatureTypes() || card.getAbilities(game).contains(ChangelingAbility.getInstance())) {
|
||||
if (card.isAllCreatureTypes() || card.hasAbility(ChangelingAbility.getInstance(), game)) {
|
||||
if (!subTypes.isEmpty()) {
|
||||
return true;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -80,8 +80,8 @@ class SidarKondoOfJamuraaCantBlockCreaturesSourceEffect extends RestrictionEffec
|
|||
|
||||
@Override
|
||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||
if (permanent.hasAbility(FlyingAbility.getInstance().getId(), game)
|
||||
|| permanent.hasAbility(ReachAbility.getInstance().getId(), game)) {
|
||||
if (permanent.hasAbility(FlyingAbility.getInstance(), game)
|
||||
|| permanent.hasAbility(ReachAbility.getInstance(), game)) {
|
||||
return false;
|
||||
}
|
||||
return game.getOpponents(source.getControllerId()).contains(permanent.getControllerId());
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ enum SlingbowTrapCondition implements Condition {
|
|||
for (UUID attackingCreatureId : game.getCombat().getAttackers()) {
|
||||
Permanent attackingCreature = game.getPermanent(attackingCreatureId);
|
||||
if (attackingCreature != null) {
|
||||
if (attackingCreature.getColor(game).isBlack() && attackingCreature.hasAbility(FlyingAbility.getInstance().getId(), game)) {
|
||||
if (attackingCreature.getColor(game).isBlack() && attackingCreature.hasAbility(FlyingAbility.getInstance(), game)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ public final class StormtideLeviathan extends CardImpl {
|
|||
// land abilities are intrinsic, so add them here, not in layer 6
|
||||
if (!land.hasSubtype(SubType.ISLAND, game)) {
|
||||
land.getSubtype(game).add(SubType.ISLAND);
|
||||
if (!land.getAbilities(game).contains(new BlueManaAbility())) {
|
||||
if (!land.getAbilities(game).containsClass(BlueManaAbility.class)) {
|
||||
land.addAbility(new BlueManaAbility(), source.getSourceId(), game);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ class TaigamOjutaiMasterGainReboundEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
|
||||
private void addReboundAbility(Card card, Ability source, Game game) {
|
||||
boolean found = card.getAbilities(game).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