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

@ -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);

View file

@ -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;
}

View file

@ -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,

View file

@ -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);

View file

@ -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

View file

@ -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();