mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -08:00
program towards Interface rather than implementations
This commit is contained in:
parent
b04c436801
commit
ae7919cd07
100 changed files with 218 additions and 209 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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())));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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)) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ public class Sets extends HashMap<String, ExpansionSet> {
|
|||
private Set<String> customSets = new HashSet<>();
|
||||
|
||||
private Sets() {
|
||||
ArrayList<String> packages = new ArrayList<>();
|
||||
List<String> packages = new ArrayList<>();
|
||||
packages.add("mage.sets");
|
||||
for (Class c : ClassScanner.findClasses(null, packages, ExpansionSet.class)) {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ public abstract class XmlDeckImporter extends DeckImporter {
|
|||
|
||||
protected List<Node> getNodes(Document doc, String xpathExpression) throws XPathExpressionException {
|
||||
NodeList nodes = (NodeList) xpathFactory.newXPath().evaluate(xpathExpression, doc, NODESET);
|
||||
ArrayList<Node> list = new ArrayList<>();
|
||||
List<Node> list = new ArrayList<>();
|
||||
for (int i = 0; i < nodes.getLength(); i++) {
|
||||
list.add(nodes.item(i));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ public class CardInfo {
|
|||
}
|
||||
if (length > MAX_RULE_LENGTH) {
|
||||
length = 0;
|
||||
ArrayList<String> shortRules = new ArrayList<>();
|
||||
List<String> shortRules = new ArrayList<>();
|
||||
for (String rule : rulesList) {
|
||||
if (length + rule.length() + 3 <= MAX_RULE_LENGTH) {
|
||||
shortRules.add(rule);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ public class ChoiceColor extends ChoiceImpl {
|
|||
private static final List<String> colorChoices = getBaseColors();
|
||||
|
||||
public static List<String> getBaseColors() {
|
||||
ArrayList<String> arr = new ArrayList<>();
|
||||
List<String> arr = new ArrayList<>();
|
||||
arr.add("Green");
|
||||
arr.add("Blue");
|
||||
arr.add("Black");
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
package mage.filter.common;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.filter.FilterImpl;
|
||||
|
|
@ -26,14 +27,14 @@ public class FilterPlaneswalkerOrPlayer extends FilterImpl<Object> {
|
|||
public FilterPlaneswalkerOrPlayer(Set<UUID> defenders) {
|
||||
super("planeswalker or player");
|
||||
|
||||
ArrayList<Predicate<Permanent>> permanentPredicates = new ArrayList<>();
|
||||
List<Predicate<Permanent>> permanentPredicates = new ArrayList<>();
|
||||
for (UUID defenderId : defenders) {
|
||||
permanentPredicates.add(new ControllerIdPredicate(defenderId));
|
||||
}
|
||||
planeswalkerFilter = new FilterPlaneswalkerPermanent();
|
||||
planeswalkerFilter.add(Predicates.or(permanentPredicates));
|
||||
|
||||
ArrayList<Predicate<Player>> playerPredicates = new ArrayList<>();
|
||||
List<Predicate<Player>> playerPredicates = new ArrayList<>();
|
||||
for (UUID defenderId : defenders) {
|
||||
playerPredicates.add(new PlayerIdPredicate(defenderId));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@ public final class Predicates {
|
|||
}
|
||||
|
||||
static <T> List<T> defensiveCopy(Iterable<T> iterable) {
|
||||
ArrayList<T> list = new ArrayList<>();
|
||||
List<T> list = new ArrayList<>();
|
||||
for (T element : iterable) {
|
||||
list.add(checkNotNull(element));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ public interface Game extends MageItem, Serializable {
|
|||
|
||||
Map<UUID, Permanent> getPermanentsEntering();
|
||||
|
||||
Map<Zone, HashMap<UUID, MageObject>> getLKI();
|
||||
Map<Zone, Map<UUID, MageObject>> getLKI();
|
||||
|
||||
// Result must be checked for null. Possible errors search pattern: (\S*) = game.getCard.+\n(?!.+\1 != null)
|
||||
Card getCard(UUID cardId);
|
||||
|
|
|
|||
|
|
@ -89,8 +89,8 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
protected Map<UUID, Card> gameCards = new HashMap<>();
|
||||
protected Map<UUID, MeldCard> meldCards = new HashMap<>(0);
|
||||
|
||||
protected Map<Zone, HashMap<UUID, MageObject>> lki = new EnumMap<>(Zone.class);
|
||||
protected Map<Zone, HashMap<UUID, CardState>> lkiCardState = new EnumMap<>(Zone.class);
|
||||
protected Map<Zone, Map<UUID, MageObject>> lki = new EnumMap<>(Zone.class);
|
||||
protected Map<Zone, Map<UUID, CardState>> lkiCardState = new EnumMap<>(Zone.class);
|
||||
protected Map<UUID, Map<Integer, MageObject>> lkiExtended = new HashMap<>();
|
||||
// Used to check if an object was moved by the current effect in resolution (so Wrath like effect can be handled correctly)
|
||||
protected Map<Zone, Set<UUID>> shortLivingLKI = new EnumMap<>(Zone.class);
|
||||
|
|
@ -2819,7 +2819,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
if (lkiMap != null) {
|
||||
lkiMap.put(objectId, copy);
|
||||
} else {
|
||||
HashMap<UUID, MageObject> newMap = new HashMap<>();
|
||||
Map<UUID, MageObject> newMap = new HashMap<>();
|
||||
newMap.put(objectId, copy);
|
||||
lki.put(zone, newMap);
|
||||
}
|
||||
|
|
@ -2844,7 +2844,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
if (lkiMap != null) {
|
||||
lkiMap.put(objectId, getState().getCardState(objectId));
|
||||
} else {
|
||||
HashMap<UUID, CardState> newMap = new HashMap<>();
|
||||
Map<UUID, CardState> newMap = new HashMap<>();
|
||||
newMap.put(objectId, getState().getCardState(objectId).copy());
|
||||
lkiCardState.put(zone, newMap);
|
||||
}
|
||||
|
|
@ -2908,7 +2908,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Map<Zone, HashMap<UUID, MageObject>> getLKI() {
|
||||
public Map<Zone, Map<UUID, MageObject>> getLKI() {
|
||||
return lki;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -448,8 +448,7 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
}
|
||||
if (mustAttack) {
|
||||
// check which defenders the forced to attack creature can attack without paying a cost
|
||||
HashSet<UUID> defendersCostlessAttackable = new HashSet<>();
|
||||
defendersCostlessAttackable.addAll(defenders);
|
||||
Set<UUID> defendersCostlessAttackable = new HashSet<>(defenders);
|
||||
for (UUID defenderId : defenders) {
|
||||
if (game.getContinuousEffects().checkIfThereArePayCostToAttackBlockEffects(
|
||||
GameEvent.getEvent(GameEvent.EventType.DECLARE_ATTACKER,
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import mage.abilities.Ability;
|
|||
import mage.cards.Card;
|
||||
import mage.game.Game;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
|
@ -23,7 +24,7 @@ public interface Token extends MageObject {
|
|||
|
||||
UUID getLastAddedToken();
|
||||
|
||||
ArrayList<UUID> getLastAddedTokenIds();
|
||||
List<UUID> getLastAddedTokenIds();
|
||||
|
||||
void addAbility(Ability ability);
|
||||
|
||||
|
|
|
|||
|
|
@ -111,10 +111,8 @@ public abstract class TokenImpl extends MageObjectImpl implements Token {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<UUID> getLastAddedTokenIds() {
|
||||
ArrayList<UUID> ids = new ArrayList<>();
|
||||
ids.addAll(lastAddedTokenIds);
|
||||
return ids;
|
||||
public List<UUID> getLastAddedTokenIds() {
|
||||
return new ArrayList<>(lastAddedTokenIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -405,7 +405,7 @@ public abstract class TournamentImpl implements Tournament {
|
|||
}
|
||||
|
||||
public void resetBufferedCards() {
|
||||
HashSet<ExpansionSet> setsDone = new HashSet<>();
|
||||
Set<ExpansionSet> setsDone = new HashSet<>();
|
||||
for (ExpansionSet set : sets) {
|
||||
if (!setsDone.contains(set)) {
|
||||
set.removeSavedCards();
|
||||
|
|
|
|||
|
|
@ -396,17 +396,17 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
|
||||
boolean flipCoin(Ability source, Game game, boolean winnable);
|
||||
|
||||
boolean flipCoin(Ability source, Game game, boolean winnable, ArrayList<UUID> appliedEffects);
|
||||
boolean flipCoin(Ability source, Game game, boolean winnable, List<UUID> appliedEffects);
|
||||
|
||||
int rollDice(Game game, int numSides);
|
||||
|
||||
int rollDice(Game game, ArrayList<UUID> appliedEffects, int numSides);
|
||||
int rollDice(Game game, List<UUID> appliedEffects, int numSides);
|
||||
|
||||
PlanarDieRoll rollPlanarDie(Game game);
|
||||
|
||||
PlanarDieRoll rollPlanarDie(Game game, ArrayList<UUID> appliedEffects);
|
||||
PlanarDieRoll rollPlanarDie(Game game, List<UUID> appliedEffects);
|
||||
|
||||
PlanarDieRoll rollPlanarDie(Game game, ArrayList<UUID> appliedEffects, int numberChaosSides, int numberPlanarSides);
|
||||
PlanarDieRoll rollPlanarDie(Game game, List<UUID> appliedEffects, int numberChaosSides, int numberPlanarSides);
|
||||
|
||||
Card discardOne(boolean random, Ability source, Game game);
|
||||
|
||||
|
|
|
|||
|
|
@ -1784,7 +1784,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
@Override
|
||||
public void untap(Game game) {
|
||||
// create list of all "notMoreThan" effects to track which one are consumed
|
||||
HashMap<Entry<RestrictionUntapNotMoreThanEffect, Set<Ability>>, Integer> notMoreThanEffectsUsage = new HashMap<>();
|
||||
Map<Entry<RestrictionUntapNotMoreThanEffect, Set<Ability>>, Integer> notMoreThanEffectsUsage = new HashMap<>();
|
||||
for (Entry<RestrictionUntapNotMoreThanEffect, Set<Ability>> restrictionEffect
|
||||
: game.getContinuousEffects().getApplicableRestrictionUntapNotMoreThanEffects(this, game).entrySet()) {
|
||||
notMoreThanEffectsUsage.put(restrictionEffect, restrictionEffect.getKey().getNumber());
|
||||
|
|
@ -1908,6 +1908,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
|
||||
} else {
|
||||
//20091005 - 502.2
|
||||
|
||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(playerId)) {
|
||||
boolean untap = true;
|
||||
for (RestrictionEffect effect : game.getContinuousEffects().getApplicableRestrictionEffects(permanent, game).keySet()) {
|
||||
|
|
@ -2788,7 +2789,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
* for heads and false for tails
|
||||
*/
|
||||
@Override
|
||||
public boolean flipCoin(Ability source, Game game, boolean winnable, ArrayList<UUID> appliedEffects) {
|
||||
public boolean flipCoin(Ability source, Game game, boolean winnable, List<UUID> appliedEffects) {
|
||||
boolean chosen = false;
|
||||
if (winnable) {
|
||||
chosen = this.chooseUse(Outcome.Benefit, "Heads or tails?", "", "Heads", "Tails", source, game);
|
||||
|
|
@ -2843,7 +2844,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
* @return the number that the player rolled
|
||||
*/
|
||||
@Override
|
||||
public int rollDice(Game game, ArrayList<UUID> appliedEffects, int numSides) {
|
||||
public int rollDice(Game game, List<UUID> appliedEffects, int numSides) {
|
||||
int result = RandomUtil.nextInt(numSides) + 1;
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers("[Roll a die] " + getLogName() + " rolled a "
|
||||
|
|
@ -2869,7 +2870,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PlanarDieRoll rollPlanarDie(Game game, ArrayList<UUID> appliedEffects) {
|
||||
public PlanarDieRoll rollPlanarDie(Game game, List<UUID> appliedEffects) {
|
||||
return rollPlanarDie(game, appliedEffects, 2, 2);
|
||||
}
|
||||
|
||||
|
|
@ -2884,7 +2885,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
* or NilRoll
|
||||
*/
|
||||
@Override
|
||||
public PlanarDieRoll rollPlanarDie(Game game, ArrayList<UUID> appliedEffects, int numberChaosSides,
|
||||
public PlanarDieRoll rollPlanarDie(Game game, List<UUID> appliedEffects, int numberChaosSides,
|
||||
int numberPlanarSides) {
|
||||
int result = RandomUtil.nextInt(9) + 1;
|
||||
PlanarDieRoll roll = PlanarDieRoll.NIL_ROLL;
|
||||
|
|
|
|||
|
|
@ -451,9 +451,7 @@ public abstract class TargetImpl implements Target {
|
|||
|
||||
@Override
|
||||
public List<UUID> getTargets() {
|
||||
ArrayList<UUID> newList = new ArrayList<>();
|
||||
newList.addAll(targets.keySet());
|
||||
return newList;
|
||||
return new ArrayList<>(targets.keySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ public class FirstTargetPointer implements TargetPointer {
|
|||
|
||||
@Override
|
||||
public List<UUID> getTargets(Game game, Ability source) {
|
||||
ArrayList<UUID> target = new ArrayList<>();
|
||||
List<UUID> target = new ArrayList<>();
|
||||
if (!source.getTargets().isEmpty()) {
|
||||
for (UUID targetId : source.getTargets().get(0).getTargets()) {
|
||||
Card card = game.getCard(targetId);
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ public class FixedTarget implements TargetPointer {
|
|||
}
|
||||
}
|
||||
|
||||
ArrayList<UUID> list = new ArrayList<>(1);
|
||||
List<UUID> list = new ArrayList<>(1);
|
||||
list.add(targetId);
|
||||
return list;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ public class FixedTargets implements TargetPointer {
|
|||
@Override
|
||||
public List<UUID> getTargets(Game game, Ability source) {
|
||||
// check target not changed zone
|
||||
ArrayList<UUID> list = new ArrayList<>(1);
|
||||
List<UUID> list = new ArrayList<>(1);
|
||||
for (MageObjectReference mor : targets) {
|
||||
if (game.getState().getZoneChangeCounter(mor.getSourceId()) == mor.getZoneChangeCounter()) {
|
||||
list.add(mor.getSourceId());
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public class SecondTargetPointer implements TargetPointer {
|
|||
|
||||
@Override
|
||||
public List<UUID> getTargets(Game game, Ability source) {
|
||||
ArrayList<UUID> target = new ArrayList<>();
|
||||
List<UUID> target = new ArrayList<>();
|
||||
if (source.getTargets().size() > 1) {
|
||||
for (UUID targetId : source.getTargets().get(1).getTargets()) {
|
||||
Card card = game.getCard(targetId);
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ public class ThirdTargetPointer implements TargetPointer {
|
|||
|
||||
@Override
|
||||
public List<UUID> getTargets(Game game, Ability source) {
|
||||
ArrayList<UUID> target = new ArrayList<>();
|
||||
List<UUID> target = new ArrayList<>();
|
||||
if (source.getTargets().size() > 2) {
|
||||
for (UUID targetId : source.getTargets().get(2).getTargets()) {
|
||||
Card card = game.getCard(targetId);
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import java.util.*;
|
|||
public class CastFromGraveyardWatcher extends Watcher {
|
||||
|
||||
// holds which spell with witch zone change counter was cast from graveyard
|
||||
private final Map<UUID, HashSet<Integer>> spellsCastFromGraveyard = new HashMap<>();
|
||||
private final Map<UUID, Set<Integer>> spellsCastFromGraveyard = new HashMap<>();
|
||||
|
||||
public CastFromGraveyardWatcher() {
|
||||
super(WatcherScope.GAME);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue