program towards Interface rather than implementations

This commit is contained in:
Ingmar Goudt 2020-02-10 10:39:56 +01:00
parent b04c436801
commit ae7919cd07
100 changed files with 218 additions and 209 deletions

View file

@ -2,6 +2,7 @@
package mage.abilities.common;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.ActivatedAbilityImpl;
@ -120,7 +121,7 @@ class LicidContinuousEffect extends ContinuousEffectImpl {
licid.getSubtype(game).add(SubType.AURA);
break;
case AbilityAddingRemovingEffects_6:
ArrayList<Ability> toRemove = new ArrayList<>();
List<Ability> toRemove = new ArrayList<>();
for (Ability ability : licid.getAbilities(game)) {
for (Effect effect : ability.getEffects()) {
if (effect instanceof LicidEffect) {

View file

@ -705,7 +705,7 @@ public class ContinuousEffects implements Serializable {
Cards cardsToReveal = new CardsImpl();
do {
FilterCard filter = new FilterCard("a card to splice");
ArrayList<Predicate<MageObject>> idPredicates = new ArrayList<>();
List<Predicate<MageObject>> idPredicates = new ArrayList<>();
for (Ability ability : spliceAbilities) {
idPredicates.add(new CardIdPredicate((ability.getSourceId())));
}

View file

@ -29,7 +29,7 @@ public class CreateTokenEffect extends OneShotEffect {
private boolean tapped;
private boolean attacking;
private UUID lastAddedTokenId;
private ArrayList<UUID> lastAddedTokenIds = new ArrayList<>();
private List<UUID> lastAddedTokenIds = new ArrayList<>();
public CreateTokenEffect(Token token) {
this(token, StaticValue.get(1));

View file

@ -3,6 +3,7 @@
package mage.abilities.effects.common;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
@ -32,7 +33,7 @@ public class ExileGraveyardAllTargetPlayerEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source));
if (targetPlayer != null) {
ArrayList<UUID> graveyard = new ArrayList<>(targetPlayer.getGraveyard());
List<UUID> graveyard = new ArrayList<>(targetPlayer.getGraveyard());
for (UUID cardId : graveyard) {
game.getCard(cardId).moveToZone(Zone.EXILED, cardId, game, false);
}

View file

@ -12,10 +12,7 @@ import mage.filter.FilterPermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Locale;
import java.util.UUID;
import java.util.*;
/**
* @author Loki
@ -101,7 +98,7 @@ public class GainAbilityAllEffect extends ContinuousEffectImpl {
}
}
// still as long as the prev. permanent is known to the LKI (e.g. Mikaeus, the Unhallowed) so gained dies triggered ability will trigger
HashMap<UUID, MageObject> LKIBattlefield = game.getLKI().get(Zone.BATTLEFIELD);
Map<UUID, MageObject> LKIBattlefield = game.getLKI().get(Zone.BATTLEFIELD);
if (LKIBattlefield != null) {
for (MageObject mageObject : LKIBattlefield.values()) {
Permanent perm = (Permanent) mageObject;

View file

@ -13,6 +13,7 @@ import mage.game.permanent.Permanent;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.UUID;
/**
@ -104,7 +105,7 @@ public class GainAbilityControlledEffect extends ContinuousEffectImpl {
}
}
// still as long as the prev. permanent is known to the LKI (e.g. Mikaeus, the Unhallowed) so gained dies triggered ability will trigger
HashMap<UUID, MageObject> LKIBattlefield = game.getLKI().get(Zone.BATTLEFIELD);
Map<UUID, MageObject> LKIBattlefield = game.getLKI().get(Zone.BATTLEFIELD);
if (LKIBattlefield != null) {
for (MageObject mageObject : LKIBattlefield.values()) {
Permanent perm = (Permanent) mageObject;

View file

@ -2,6 +2,7 @@ package mage.abilities.effects.common.continuous;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.UUID;
import mage.MageObject;
import mage.MageObjectReference;
@ -104,7 +105,7 @@ public class LoseAbilityAllEffect extends ContinuousEffectImpl {
}
}
// still as long as the prev. permanent is known to the LKI (e.g. Mikaeus, the Unhallowed) so gained dies triggered ability will trigger
HashMap<UUID, MageObject> LKIBattlefield = game.getLKI().get(Zone.BATTLEFIELD);
Map<UUID, MageObject> LKIBattlefield = game.getLKI().get(Zone.BATTLEFIELD);
if (LKIBattlefield != null) {
for (MageObject mageObject : LKIBattlefield.values()) {
Permanent perm = (Permanent) mageObject;

View file

@ -2,6 +2,7 @@
package mage.abilities.effects.common.continuous;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.Mode;
@ -45,7 +46,7 @@ public class PlayWithHandRevealedEffect extends ContinuousEffectImpl {
affectedPlayers = game.getOpponents(source.getControllerId());
break;
case YOU:
ArrayList<UUID> tmp = new ArrayList<>();
List<UUID> tmp = new ArrayList<>();
tmp.add(source.getControllerId());
affectedPlayers = tmp;
break;

View file

@ -1,6 +1,7 @@
package mage.abilities.effects.common.counter;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.UUID;
import mage.abilities.Ability;
@ -79,7 +80,7 @@ public class AddCountersSourceEffect extends OneShotEffect {
countersToAdd--;
}
newCounter.add(countersToAdd);
ArrayList<UUID> appliedEffects = (ArrayList<UUID>) this.getValue("appliedEffects");
List<UUID> appliedEffects = (ArrayList<UUID>) this.getValue("appliedEffects");
card.addCounters(newCounter, source, game, appliedEffects);
if (informPlayers && !game.isSimulation()) {
Player player = game.getPlayer(source.getControllerId());
@ -107,7 +108,7 @@ public class AddCountersSourceEffect extends OneShotEffect {
}
newCounter.add(countersToAdd);
int before = permanent.getCounters(game).getCount(newCounter.getName());
ArrayList<UUID> appliedEffects = (ArrayList<UUID>) this.getValue("appliedEffects");
List<UUID> appliedEffects = (ArrayList<UUID>) this.getValue("appliedEffects");
permanent.addCounters(newCounter, source, game, appliedEffects); // if used from a replacement effect, the basic event determines if an effect was already applied to an event
if (informPlayers && !game.isSimulation()) {
int amountAdded = permanent.getCounters(game).getCount(newCounter.getName()) - before;

View file

@ -18,6 +18,7 @@ import mage.target.common.TargetDiscard;
import mage.util.CardUtil;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public class DiscardEachPlayerEffect extends OneShotEffect {
@ -60,7 +61,7 @@ public class DiscardEachPlayerEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
// Store for each player the cards to discard, that's important because all discard shall happen at the same time
HashMap<UUID, Cards> cardsToDiscard = new HashMap<>();
Map<UUID, Cards> cardsToDiscard = new HashMap<>();
if (controller != null) {
// choose cards to discard
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {

View file

@ -37,7 +37,7 @@ public class AddConditionalManaOfTwoDifferentColorsEffect extends ManaEffect {
@Override
public List<Mana> getNetMana(Game game, Ability source) {
ArrayList<Mana> netMana = new ArrayList<>();
List<Mana> netMana = new ArrayList<>();
netMana.add(Mana.AnyMana(2));
return netMana;
}

View file

@ -44,7 +44,7 @@ public class AddManaAnyColorAttachedControllerEffect extends ManaEffect {
@Override
public List<Mana> getNetMana(Game game, Ability source) {
ArrayList<Mana> netMana = new ArrayList<>();
List<Mana> netMana = new ArrayList<>();
netMana.add(Mana.AnyMana(1));
return netMana;
}

View file

@ -65,7 +65,7 @@ public class AddManaInAnyCombinationEffect extends ManaEffect {
@Override
public List<Mana> getNetMana(Game game, Ability source) {
ArrayList<Mana> netMana = new ArrayList<>();
List<Mana> netMana = new ArrayList<>();
int amountOfManaLeft = amount.calculate(game, source, this);
if (amountOfManaLeft > 0) {
netMana.add(Mana.AnyMana(amountOfManaLeft));

View file

@ -37,7 +37,7 @@ public class AddManaOfAnyTypeProducedEffect extends ManaEffect {
@Override
public List<Mana> getNetMana(Game game, Ability source) {
ArrayList<Mana> netMana = new ArrayList<>();
List<Mana> netMana = new ArrayList<>();
Mana types = (Mana) this.getValue("mana"); // TODO: will not work until TriggeredManaAbility fix (see TriggeredManaAbilityMustGivesExtraManaOptions test)
if (types != null) {
netMana.add(types.copy());

View file

@ -24,7 +24,7 @@ public class AddManaOfTwoDifferentColorsEffect extends ManaEffect {
@Override
public List<Mana> getNetMana(Game game, Ability source) {
ArrayList<Mana> netMana = new ArrayList<>();
List<Mana> netMana = new ArrayList<>();
netMana.add(Mana.AnyMana(2));
return netMana;
}

View file

@ -60,7 +60,7 @@ public class AddManaToManaPoolTargetControllerEffect extends ManaEffect {
@Override
public List<Mana> getNetMana(Game game, Ability source) {
ArrayList<Mana> netMana = new ArrayList<>();
List<Mana> netMana = new ArrayList<>();
netMana.add(mana.copy());
return netMana;
}

View file

@ -3,6 +3,7 @@ package mage.abilities.hint;
import java.awt.*;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* @author JayDi85
@ -46,7 +47,7 @@ public class HintUtils {
public static void appendHints(List<String> destList, List<String> newHints) {
// append only unique hints
HashSet<String> used = new HashSet<>();
Set<String> used = new HashSet<>();
for (String s : newHints) {
if (!used.contains(s)) {
destList.add(s);

View file

@ -1,6 +1,7 @@
package mage.abilities.keyword;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldAbility;
@ -73,7 +74,7 @@ class BloodthirstEffect extends OneShotEffect {
if (watcher != null && watcher.conditionMet()) {
Permanent permanent = game.getPermanentEntering(source.getSourceId());
if (permanent != null) {
ArrayList<UUID> appliedEffects = (ArrayList<UUID>) this.getValue("appliedEffects"); // the basic event is the EntersBattlefieldEvent, so use already applied replacement effects from that event
List<UUID> appliedEffects = (ArrayList<UUID>) this.getValue("appliedEffects"); // the basic event is the EntersBattlefieldEvent, so use already applied replacement effects from that event
permanent.addCounters(CounterType.P1P1.createInstance(amount), source, game, appliedEffects);
}
return true;

View file

@ -3,6 +3,7 @@ package mage.abilities.keyword;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
@ -74,7 +75,7 @@ public class ChampionAbility extends StaticAbility {
this.subtypes = subtypes;
StringBuilder sb = new StringBuilder("another ");
ArrayList<Predicate<MageObject>> subtypesPredicates = new ArrayList<>();
List<Predicate<MageObject>> subtypesPredicates = new ArrayList<>();
if (!subtypes.isEmpty()) {
int i = 0;
for (SubType subtype : this.subtypes) {

View file

@ -1,6 +1,7 @@
package mage.abilities.keyword;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.StaticAbility;
@ -160,7 +161,7 @@ class ModularDistributeCounterEffect extends OneShotEffect {
if (sourcePermanent != null && targetArtifact != null && player != null) {
int numberOfCounters = sourcePermanent.getCounters(game).getCount(CounterType.P1P1);
if (numberOfCounters > 0) {
ArrayList<UUID> appliedEffects = (ArrayList<UUID>) this.getValue("appliedEffects"); // the basic event is the EntersBattlefieldEvent, so use already applied replacement effects from that event
List<UUID> appliedEffects = (ArrayList<UUID>) this.getValue("appliedEffects"); // the basic event is the EntersBattlefieldEvent, so use already applied replacement effects from that event
targetArtifact.addCounters(CounterType.P1P1.createInstance(numberOfCounters), source, game, appliedEffects);
}
return true;

View file

@ -10,6 +10,7 @@ import mage.constants.Zone;
import mage.game.Game;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
@ -56,7 +57,7 @@ public class SpectacleAbility extends SpellAbility {
@SuppressWarnings("unchecked")
public boolean activate(Game game, boolean noMana) {
if (super.activate(game, noMana)) {
ArrayList<Integer> spectacleActivations = (ArrayList) game.getState().getValue(SPECTACLE_ACTIVATION_VALUE_KEY + getSourceId());
List<Integer> spectacleActivations = (ArrayList) game.getState().getValue(SPECTACLE_ACTIVATION_VALUE_KEY + getSourceId());
if (spectacleActivations == null) {
spectacleActivations = new ArrayList<>(); // zoneChangeCounter
game.getState().setValue(SPECTACLE_ACTIVATION_VALUE_KEY + getSourceId(), spectacleActivations);

View file

@ -2,6 +2,7 @@
package mage.abilities.keyword;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldAbility;
@ -71,14 +72,12 @@ class SunburstEffect extends OneShotEffect {
} else {
counter = CounterType.CHARGE.createInstance(amount.calculate(game, source, this));
}
if (counter != null) {
ArrayList<UUID> appliedEffects = (ArrayList<UUID>) this.getValue("appliedEffects"); // the basic event is the EntersBattlefieldEvent, so use already applied replacement effects from that event
permanent.addCounters(counter, source, game, appliedEffects);
if (!game.isSimulation()) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
game.informPlayers(player.getLogName() + " puts " + counter.getCount() + ' ' + counter.getName() + " counter on " + permanent.getName());
}
List<UUID> appliedEffects = (ArrayList<UUID>) this.getValue("appliedEffects"); // the basic event is the EntersBattlefieldEvent, so use already applied replacement effects from that event
permanent.addCounters(counter, source, game, appliedEffects);
if (!game.isSimulation()) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
game.informPlayers(player.getLogName() + " puts " + counter.getCount() + ' ' + counter.getName() + " counter on " + permanent.getName());
}
}
}

View file

@ -10,6 +10,7 @@ import mage.players.Player;
import mage.watchers.common.CastSpellLastTurnWatcher;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
@ -66,7 +67,7 @@ public class SurgeAbility extends SpellAbility {
@SuppressWarnings("unchecked")
public boolean activate(Game game, boolean noMana) {
if (super.activate(game, noMana)) {
ArrayList<Integer> surgeActivations = (ArrayList) game.getState().getValue(SURGE_ACTIVATION_VALUE_KEY + getSourceId());
List<Integer> surgeActivations = (ArrayList) game.getState().getValue(SURGE_ACTIVATION_VALUE_KEY + getSourceId());
if (surgeActivations == null) {
surgeActivations = new ArrayList<>(); // zoneChangeCounter
game.getState().setValue(SURGE_ACTIVATION_VALUE_KEY + getSourceId(), surgeActivations);

View file

@ -70,7 +70,7 @@ public abstract class ActivatedManaAbilityImpl extends ActivatedAbilityImpl impl
@Override
public List<Mana> getNetMana(Game game) {
if (netMana.isEmpty()) {
ArrayList<Mana> dynamicNetMana = new ArrayList<>();
List<Mana> dynamicNetMana = new ArrayList<>();
for (Effect effect : getEffects()) {
if (effect instanceof ManaEffect) {
List<Mana> effectNetMana = ((ManaEffect) effect).getNetMana(game, this);
@ -81,7 +81,7 @@ public abstract class ActivatedManaAbilityImpl extends ActivatedAbilityImpl impl
}
return dynamicNetMana;
}
ArrayList<Mana> netManaCopy = new ArrayList<>();
List<Mana> netManaCopy = new ArrayList<>();
for (Mana mana : netMana) {
netManaCopy.add(mana.copy());
}

View file

@ -45,7 +45,7 @@ public abstract class TriggeredManaAbility extends TriggeredAbilityImpl implemen
@Override
public List<Mana> getNetMana(Game game) {
if (game != null) {
ArrayList<Mana> newNetMana = new ArrayList<>();
List<Mana> newNetMana = new ArrayList<>();
for (Effect effect : getEffects()) {
if (effect instanceof ManaEffect) {
newNetMana.addAll(((ManaEffect) effect).getNetMana(game, this));