Skip to content

Commit

Permalink
refactor: improved ContinuousRuleModifying effects:
Browse files Browse the repository at this point in the history
* removed unused apply methods;
* added miss overrides of checksEventType (related to wrong event usage, see 5f2edde).
  • Loading branch information
JayDi85 committed Sep 22, 2023
1 parent 5f2edde commit a9152e8
Show file tree
Hide file tree
Showing 176 changed files with 271 additions and 1,016 deletions.
11 changes: 6 additions & 5 deletions Mage.Sets/src/mage/cards/a/Abeyance.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ public AbeyanceEffect copy() {
return new AbeyanceEffect(this);
}

@Override
public boolean apply(Game game, Ability source) {
return true;
}

@Override
public String getInfoMessage(Ability source, GameEvent event, Game game) {
MageObject mageObject = game.getObject(source);
Expand All @@ -76,6 +71,12 @@ public String getInfoMessage(Ability source, GameEvent event, Game game) {
return null;
}

@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.CAST_SPELL
|| event.getType() == GameEvent.EventType.ACTIVATE_ABILITY;
}

@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (source.getFirstTarget() != null
Expand Down
5 changes: 0 additions & 5 deletions Mage.Sets/src/mage/cards/a/AetherStorm.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,6 @@ private AetherStormReplacementEffect(final AetherStormReplacementEffect effect)
super(effect);
}

@Override
public boolean apply(Game game, Ability source) {
return true;
}

@Override
public AetherStormReplacementEffect copy() {
return new AetherStormReplacementEffect(this);
Expand Down
5 changes: 0 additions & 5 deletions Mage.Sets/src/mage/cards/a/AggressiveMining.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@ private AggressiveMiningEffect(final AggressiveMiningEffect effect) {
public AggressiveMiningEffect copy() {
return new AggressiveMiningEffect(this);
}

@Override
public boolean apply(Game game, Ability source) {
return true;
}

@Override
public boolean checksEventType(GameEvent event, Game game) {
Expand Down
5 changes: 0 additions & 5 deletions Mage.Sets/src/mage/cards/a/AngelicArbiter.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,6 @@ public AngelicArbiterEffect2 copy() {
return new AngelicArbiterEffect2(this);
}

@Override
public boolean apply(Game game, Ability source) {
return true;
}

@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.CAST_SPELL;
Expand Down
5 changes: 0 additions & 5 deletions Mage.Sets/src/mage/cards/a/AshesOfTheAbhorrent.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@ public AshesOfTheAbhorrentEffect copy() {
return new AshesOfTheAbhorrentEffect(this);
}

@Override
public boolean apply(Game game, Ability source) {
return true;
}

@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.CAST_SPELL
Expand Down
5 changes: 0 additions & 5 deletions Mage.Sets/src/mage/cards/a/AshiokDreamRender.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,6 @@ public AshiokDreamRenderEffect copy() {
return new AshiokDreamRenderEffect(this);
}

@Override
public boolean apply(Game game, Ability source) {
return true;
}

@Override
public String getInfoMessage(Ability source, GameEvent event, Game game) {
MageObject mageObject = game.getObject(source);
Expand Down
5 changes: 0 additions & 5 deletions Mage.Sets/src/mage/cards/a/AshioksErasure.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,6 @@ public boolean applies(GameEvent event, Ability source, Game game) {
return false;
}

@Override
public boolean apply(Game game, Ability source) {
return false;
}

@Override
public AshioksErasureReplacementEffect copy() {
return new AshioksErasureReplacementEffect(this);
Expand Down
25 changes: 10 additions & 15 deletions Mage.Sets/src/mage/cards/a/AssaultSuit.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

package mage.cards.a;

import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
Expand All @@ -25,14 +24,15 @@
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;

import java.util.UUID;

/**
*
* @author LevelX2
*/
public final class AssaultSuit extends CardImpl {

public AssaultSuit(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{4}");
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{4}");
this.subtype.add(SubType.EQUIPMENT);

// Equipped creature gets +2/+2, has haste, can't attack you or a planeswalker you control, and can't be sacrificed.
Expand Down Expand Up @@ -65,7 +65,7 @@ public AssaultSuit copy() {
}
}

class AssaultSuitCantBeSacrificed extends ContinuousRuleModifyingEffectImpl {
class AssaultSuitCantBeSacrificed extends ContinuousRuleModifyingEffectImpl {

public AssaultSuitCantBeSacrificed() {
super(Duration.WhileOnBattlefield, Outcome.Detriment, true, false);
Expand All @@ -82,24 +82,19 @@ public AssaultSuitCantBeSacrificed copy() {
}

@Override
public boolean apply(Game game, Ability source) {
return true;
public String getInfoMessage(Ability source, GameEvent event, Game game) {
return "This creature can't be sacrificed.";
}

@Override
public String getInfoMessage(Ability source, GameEvent event, Game game) {
return "This creature can't be sacrificed.";
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.SACRIFICE_PERMANENT;
}

@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == GameEvent.EventType.SACRIFICE_PERMANENT) {
Permanent equipment = game.getPermanent(source.getSourceId());
if (equipment != null) {
return equipment.isAttachedTo(event.getTargetId());
}
}
return false;
Permanent equipment = game.getPermanent(source.getSourceId());
return equipment != null && equipment.isAttachedTo(event.getTargetId());
}
}

Expand Down
5 changes: 0 additions & 5 deletions Mage.Sets/src/mage/cards/a/AureliasFury.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,6 @@ public AureliasFuryCantCastEffect copy() {
return new AureliasFuryCantCastEffect(this);
}

@Override
public boolean apply(Game game, Ability source) {
return true;
}

@Override
public String getInfoMessage(Ability source, GameEvent event, Game game) {
MageObject mageObject = game.getObject(source);
Expand Down
10 changes: 5 additions & 5 deletions Mage.Sets/src/mage/cards/a/AzorTheLawbringer.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,6 @@ public AzorTheLawbringerCantCastEffect copy() {
return new AzorTheLawbringerCantCastEffect(this);
}

@Override
public boolean apply(Game game, Ability source) {
return true;
}

@Override
public String getInfoMessage(Ability source, GameEvent event, Game game) {
MageObject mageObject = game.getObject(source);
Expand All @@ -120,6 +115,11 @@ public String getInfoMessage(Ability source, GameEvent event, Game game) {
return null;
}

@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.CAST_SPELL;
}

@Override
public boolean applies(GameEvent event, Ability source, Game game) {
UUID opponentId = getTargetPointer().getFirst(game, source);
Expand Down
6 changes: 2 additions & 4 deletions Mage.Sets/src/mage/cards/b/Banefire.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,12 @@ public BanefireCantCounterEffect copy() {
}

@Override
public boolean apply(Game game, Ability source) {
return true;
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.COUNTER;
}

@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() != GameEvent.EventType.COUNTER) { return false; }

Card card = game.getCard(source.getSourceId());
if (card == null) { return false; }

Expand Down
5 changes: 0 additions & 5 deletions Mage.Sets/src/mage/cards/b/BartelRuneaxe.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,6 @@ public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.TARGET;
}

@Override
public boolean apply(Game game, Ability source) {
return true;
}

@Override
public String getInfoMessage(Ability source, GameEvent event, Game game) {
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
Expand Down
5 changes: 0 additions & 5 deletions Mage.Sets/src/mage/cards/b/BasandraBattleSeraph.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,6 @@ public BasandraBattleSeraphEffect copy() {
return new BasandraBattleSeraphEffect(this);
}

@Override
public boolean apply(Game game, Ability source) {
return true;
}

@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.CAST_SPELL;
Expand Down
12 changes: 6 additions & 6 deletions Mage.Sets/src/mage/cards/b/Berserk.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,20 @@ private BerserkReplacementEffect(final BerserkReplacementEffect effect) {
super(effect);
}

@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.CAST_SPELL;
}

@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == GameEvent.EventType.CAST_SPELL && event.getSourceId().equals(source.getSourceId())) {
if (event.getSourceId().equals(source.getSourceId())) {
CombatDamageStepStartedWatcher watcher = game.getState().getWatcher(CombatDamageStepStartedWatcher.class);
return watcher == null || watcher.conditionMet();
}
return false;
}

@Override
public boolean apply(Game game, Ability source) {
return true;
}

@Override
public BerserkReplacementEffect copy() {
return new BerserkReplacementEffect(this);
Expand Down
5 changes: 0 additions & 5 deletions Mage.Sets/src/mage/cards/b/BlindingBeam.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,6 @@ public BlindingBeamEffect2 copy() {
return new BlindingBeamEffect2(this);
}

@Override
public boolean apply(Game game, Ability source) {
return false;
}

@Override
public boolean isInactive(Ability source, Game game) {
// the PRE step part is directly after the UNTAP events for permanents
Expand Down
5 changes: 0 additions & 5 deletions Mage.Sets/src/mage/cards/b/BloodFrenzy.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,4 @@ public boolean applies(GameEvent event, Ability source, Game game) {
}
return false;
}

@Override
public boolean apply(Game game, Ability source) {
return true;
}
}
5 changes: 0 additions & 5 deletions Mage.Sets/src/mage/cards/b/BoseijuWhoSheltersAll.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,6 @@ public BoseijuWhoSheltersAllCantCounterEffect copy() {
return new BoseijuWhoSheltersAllCantCounterEffect(this);
}

@Override
public boolean apply(Game game, Ability source) {
return true;
}

@Override
public String getInfoMessage(Ability source, GameEvent event, Game game) {
MageObject sourceObject = game.getObject(source);
Expand Down
5 changes: 0 additions & 5 deletions Mage.Sets/src/mage/cards/b/BoundDetermined.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,6 @@ public DeterminedEffect copy() {
return new DeterminedEffect(this);
}

@Override
public boolean apply(Game game, Ability source) {
return true;
}

@Override
public String getInfoMessage(Ability source, GameEvent event, Game game) {
MageObject sourceObject = game.getObject(source);
Expand Down
5 changes: 0 additions & 5 deletions Mage.Sets/src/mage/cards/b/BrandOfIllOmen.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,6 @@ private BrandOfIllOmenEffect(final BrandOfIllOmenEffect effect) {
super(effect);
}

@Override
public boolean apply(Game game, Ability source) {
return true;
}

@Override
public BrandOfIllOmenEffect copy() {
return new BrandOfIllOmenEffect(this);
Expand Down
5 changes: 0 additions & 5 deletions Mage.Sets/src/mage/cards/b/BriselaVoiceOfNightmares.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@ public BriselaVoiceOfNightmaresCantCastEffect copy() {
return new BriselaVoiceOfNightmaresCantCastEffect(this);
}

@Override
public boolean apply(Game game, Ability source) {
return true;
}

@Override
public String getInfoMessage(Ability source, GameEvent event, Game game) {
MageObject mageObject = game.getObject(source);
Expand Down
5 changes: 0 additions & 5 deletions Mage.Sets/src/mage/cards/c/CavernOfSouls.java
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,6 @@ public CavernOfSoulsCantCounterEffect copy() {
return new CavernOfSoulsCantCounterEffect(this);
}

@Override
public boolean apply(Game game, Ability source) {
return true;
}

@Override
public String getInfoMessage(Ability source, GameEvent event, Game game) {
MageObject sourceObject = game.getObject(source);
Expand Down
8 changes: 6 additions & 2 deletions Mage.Sets/src/mage/cards/c/CircuDimirLobotomist.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,14 @@ public String getInfoMessage(Ability source, GameEvent event, Game game) {
return "You can't cast this spell because a card with the same name is exiled by " + CardUtil.getSourceName(game, source) + '.';
}

@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.CAST_SPELL;
}

@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() != GameEvent.EventType.CAST_SPELL
|| !game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
if (!game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
return false;
}
MageObject object = game.getObject(event.getSourceId());
Expand Down
5 changes: 0 additions & 5 deletions Mage.Sets/src/mage/cards/c/CityInABottle.java
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,6 @@ private CityInABottleCantPlayEffect(final CityInABottleCantPlayEffect effect) {
super(effect);
}

@Override
public boolean apply(Game game, Ability source) {
return true;
}

@Override
public CityInABottleCantPlayEffect copy() {
return new CityInABottleCantPlayEffect(this);
Expand Down
5 changes: 3 additions & 2 deletions Mage.Sets/src/mage/cards/c/CloudsteelKirin.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ public CloudsteelKirinEffect copy() {
}

@Override
public boolean apply(Game game, Ability source) {
return true;
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.WINS
|| event.getType() == GameEvent.EventType.LOSES;
}

@Override
Expand Down

0 comments on commit a9152e8

Please sign in to comment.