Refactor - remove duplicate AdditionalAttackPhaseEffect classes

This commit is contained in:
JOAC69 2016-09-20 22:15:19 -05:00
parent ca414417e3
commit 541c9727ff
6 changed files with 51 additions and 143 deletions

View file

@ -33,14 +33,12 @@ import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.AdditionalCombatPhaseEffect;
import mage.abilities.effects.common.UntapAllControllerEffect;
import mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.TurnPhase;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.common.FilterControlledCreaturePermanent;
@ -51,7 +49,6 @@ import mage.filter.predicate.permanent.PermanentIdPredicate;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.turn.TurnMod;
import mage.target.common.TargetCardInLibrary;
import mage.util.CardUtil;
@ -145,25 +142,3 @@ class GodoBanditWarlordAttacksTriggeredAbility extends TriggeredAbilityImpl {
}
}
class AdditionalCombatPhaseEffect extends OneShotEffect {
public AdditionalCombatPhaseEffect() {
super(Outcome.Benefit);
staticText = "After this phase, there is an additional combat phase";
}
public AdditionalCombatPhaseEffect(final AdditionalCombatPhaseEffect effect) {
super(effect);
}
@Override
public AdditionalCombatPhaseEffect copy() {
return new AdditionalCombatPhaseEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
game.getState().getTurnMods().add(new TurnMod(source.getControllerId(), TurnPhase.COMBAT, null, false));
return true;
}
}

View file

@ -27,12 +27,10 @@
*/
package mage.sets.darksteel;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.common.CastOnlyDuringPhaseStepSourceAbility;
import mage.abilities.condition.common.MyTurnCondition;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.AdditionalCombatPhaseEffect;
import mage.abilities.effects.common.UntapAllControllerEffect;
import mage.abilities.effects.common.continuous.GainAbilityControlledEffect;
import mage.abilities.keyword.DoubleStrikeAbility;
@ -40,13 +38,12 @@ import mage.abilities.keyword.EntwineAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.TurnPhase;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.turn.TurnMod;
import java.util.UUID;
/**
*
@ -68,7 +65,7 @@ public class SavageBeating extends CardImpl {
// or untap all creatures you control and after this phase, there is an additional combat phase.
Mode mode = new Mode();
mode.getEffects().add(new UntapAllControllerEffect(new FilterControlledCreaturePermanent(), "untap all creatures you control"));
mode.getEffects().add(new AdditionalCombatPhaseEffect());
mode.getEffects().add(new AdditionalCombatPhaseEffect("and after this phase, there is an additional combat phase"));
this.getSpellAbility().getModes().addMode(mode);
// Entwine {1}{R}
@ -84,26 +81,3 @@ public class SavageBeating extends CardImpl {
return new SavageBeating(this);
}
}
class AdditionalCombatPhaseEffect extends OneShotEffect {
AdditionalCombatPhaseEffect() {
super(Outcome.Benefit);
staticText = "and after this phase, there is an additional combat phase";
}
AdditionalCombatPhaseEffect(final AdditionalCombatPhaseEffect effect) {
super(effect);
}
@Override
public AdditionalCombatPhaseEffect copy() {
return new AdditionalCombatPhaseEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
game.getState().getTurnMods().add(new TurnMod(source.getControllerId(), TurnPhase.COMBAT, null, false));
return true;
}
}

View file

@ -27,12 +27,11 @@
*/
package mage.sets.gatecrash;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.AdditionalCombatPhaseEffect;
import mage.abilities.effects.common.UntapAllControllerEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.HasteAbility;
@ -40,15 +39,14 @@ import mage.abilities.keyword.VigilanceAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.TurnPhase;
import mage.constants.Zone;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.turn.TurnMod;
import java.util.UUID;
/**
*
@ -156,26 +154,3 @@ class AureliaAttacksTriggeredAbility extends TriggeredAbilityImpl {
return new AureliaAttacksTriggeredAbility(this);
}
}
class AdditionalCombatPhaseEffect extends OneShotEffect {
public AdditionalCombatPhaseEffect() {
super(Outcome.Benefit);
staticText = "After this phase, there is an additional combat phase";
}
public AdditionalCombatPhaseEffect(final AdditionalCombatPhaseEffect effect) {
super(effect);
}
@Override
public AdditionalCombatPhaseEffect copy() {
return new AdditionalCombatPhaseEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
game.getState().getTurnMods().add(new TurnMod(source.getControllerId(), TurnPhase.COMBAT, null, false));
return true;
}
}

View file

@ -27,21 +27,18 @@
*/
package mage.sets.onslaught;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.ActivateAsSorceryActivatedAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.AddCombatAndMainPhaseEffect;
import mage.abilities.effects.common.UntapAllControllerEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.TurnPhase;
import mage.constants.Zone;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.game.Game;
import mage.game.turn.TurnMod;
import java.util.UUID;
/**
*
@ -56,7 +53,7 @@ public class AggravatedAssault extends CardImpl {
// {3}{R}{R}: Untap all creatures you control. After this main phase, there is an additional combat phase followed by an additional main phase. Activate this ability only any time you could cast a sorcery.
Ability ability = new ActivateAsSorceryActivatedAbility(Zone.BATTLEFIELD, new UntapAllControllerEffect(new FilterControlledCreaturePermanent(), "Untap all creatures you control"), new ManaCostsImpl<>("{3}{R}{R}"));
ability.addEffect(new AdditionalCombatPhaseEffect());
ability.addEffect(new AddCombatAndMainPhaseEffect());
this.addAbility(ability);
}
@ -69,27 +66,3 @@ public class AggravatedAssault extends CardImpl {
return new AggravatedAssault(this);
}
}
class AdditionalCombatPhaseEffect extends OneShotEffect {
AdditionalCombatPhaseEffect() {
super(Outcome.Benefit);
staticText = "After this main phase, there is an additional combat phase followed by an additional main phase";
}
AdditionalCombatPhaseEffect(final AdditionalCombatPhaseEffect effect) {
super(effect);
}
@Override
public AdditionalCombatPhaseEffect copy() {
return new AdditionalCombatPhaseEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
game.getState().getTurnMods().add(new TurnMod(source.getControllerId(), TurnPhase.POSTCOMBAT_MAIN, null, false));
game.getState().getTurnMods().add(new TurnMod(source.getControllerId(), TurnPhase.COMBAT, null, false));
return true;
}
}

View file

@ -27,29 +27,27 @@
*/
package mage.sets.vintagemasters;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.AdditionalCombatPhaseEffect;
import mage.abilities.effects.common.UntapAllControllerEffect;
import mage.abilities.keyword.DethroneAbility;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.TurnPhase;
import mage.constants.Zone;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.turn.TurnMod;
import mage.players.Player;
import mage.util.CardUtil;
import java.util.UUID;
/**
*
* @author LevelX2
@ -153,26 +151,3 @@ class ScourgeOfTheThroneAttacksTriggeredAbility extends TriggeredAbilityImpl {
return new ScourgeOfTheThroneAttacksTriggeredAbility(this);
}
}
class AdditionalCombatPhaseEffect extends OneShotEffect {
public AdditionalCombatPhaseEffect() {
super(Outcome.Benefit);
staticText = "After this phase, there is an additional combat phase";
}
public AdditionalCombatPhaseEffect(final AdditionalCombatPhaseEffect effect) {
super(effect);
}
@Override
public AdditionalCombatPhaseEffect copy() {
return new AdditionalCombatPhaseEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
game.getState().getTurnMods().add(new TurnMod(source.getControllerId(), TurnPhase.COMBAT, null, false));
return true;
}
}

View file

@ -0,0 +1,36 @@
package mage.abilities.effects.common;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.constants.Outcome;
import mage.constants.TurnPhase;
import mage.game.Game;
import mage.game.turn.TurnMod;
public class AdditionalCombatPhaseEffect extends OneShotEffect {
public AdditionalCombatPhaseEffect() {
super(Outcome.Benefit);
staticText = "After this phase, there is an additional combat phase";
}
public AdditionalCombatPhaseEffect(String staticText) {
this();
this.staticText = staticText;
}
public AdditionalCombatPhaseEffect(final AdditionalCombatPhaseEffect effect) {
super(effect);
}
@Override
public AdditionalCombatPhaseEffect copy() {
return new AdditionalCombatPhaseEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
game.getState().getTurnMods().add(new TurnMod(source.getControllerId(), TurnPhase.COMBAT, null, false));
return true;
}
}