mirror of
https://github.com/correl/mage.git
synced 2024-11-15 11:09:30 +00:00
commit
eb5b1771e6
118 changed files with 194 additions and 336 deletions
|
@ -2608,7 +2608,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
|
||||
tabsPanel.addTab("Controls", tabControls);
|
||||
|
||||
saveButton.setLabel("Save");
|
||||
saveButton.setText("Save");
|
||||
saveButton.setMaximumSize(new java.awt.Dimension(100, 30));
|
||||
saveButton.setMinimumSize(new java.awt.Dimension(100, 30));
|
||||
saveButton.setPreferredSize(new java.awt.Dimension(100, 30));
|
||||
|
@ -2619,7 +2619,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
}
|
||||
});
|
||||
|
||||
exitButton.setLabel("Exit");
|
||||
exitButton.setText("Exit");
|
||||
exitButton.setMaximumSize(new java.awt.Dimension(100, 30));
|
||||
exitButton.setMinimumSize(new java.awt.Dimension(100, 30));
|
||||
exitButton.setPreferredSize(new java.awt.Dimension(100, 30));
|
||||
|
|
|
@ -168,7 +168,7 @@ public class ConsoleFrame extends javax.swing.JFrame implements MageClient {
|
|||
btnSendMessage.setEnabled(false);
|
||||
btnSendMessage.setFocusable(false);
|
||||
btnSendMessage.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
|
||||
btnSendMessage.setLabel("Send Message");
|
||||
btnSendMessage.setText("Send Message");
|
||||
btnSendMessage.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
|
||||
btnSendMessage.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
|
|
|
@ -276,7 +276,7 @@ public class ConsolePanel extends javax.swing.JPanel {
|
|||
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 340, Short.MAX_VALUE)
|
||||
);
|
||||
|
||||
btnRemoveTable.setLabel("Remove Table");
|
||||
btnRemoveTable.setText("Remove Table");
|
||||
btnRemoveTable.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
btnRemoveTableActionPerformed(evt);
|
||||
|
|
|
@ -206,26 +206,20 @@ public class ConditionalMana extends Mana implements Serializable {
|
|||
break;
|
||||
case BLUE:
|
||||
blue += amount;
|
||||
;
|
||||
break;
|
||||
case GREEN:
|
||||
green += amount;
|
||||
;
|
||||
break;
|
||||
case RED:
|
||||
red += amount;
|
||||
;
|
||||
break;
|
||||
case WHITE:
|
||||
white += amount;
|
||||
;
|
||||
break;
|
||||
case COLORLESS:
|
||||
colorless += amount;
|
||||
;
|
||||
case GENERIC:
|
||||
generic += amount;
|
||||
;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ import mage.util.Copyable;
|
|||
|
||||
public class MageInt implements Serializable, Copyable<MageInt> {
|
||||
|
||||
public static MageInt EmptyMageInt = new MageInt(Integer.MIN_VALUE, "") {
|
||||
public static final MageInt EmptyMageInt = new MageInt(Integer.MIN_VALUE, "") {
|
||||
|
||||
private static final String exceptionMessage = "MageInt.EmptyMageInt can't be modified.";
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ public interface Card extends MageObject {
|
|||
|
||||
void setOwnerId(UUID ownerId);
|
||||
|
||||
public Abilities<Ability> getAbilities(Game game);
|
||||
Abilities<Ability> getAbilities(Game game);
|
||||
|
||||
void setSpellAbility(SpellAbility ability);
|
||||
|
||||
|
|
|
@ -462,9 +462,9 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
|||
}
|
||||
break;
|
||||
case COMMAND:
|
||||
lkiObject = (Commander) game.getObject(objectId);
|
||||
lkiObject = game.getObject(objectId);
|
||||
if (lkiObject != null) {
|
||||
removed = game.getState().getCommand().remove((Commander) game.getObject(objectId));
|
||||
removed = game.getState().getCommand().remove(game.getObject(objectId));
|
||||
}
|
||||
break;
|
||||
case OUTSIDE:
|
||||
|
|
|
@ -30,7 +30,6 @@ package mage.cards;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -65,6 +65,7 @@ public class Sets extends HashMap<String, ExpansionSet> {
|
|||
try {
|
||||
addSet((ExpansionSet) c.getMethod("getInstance").invoke(null));
|
||||
} catch (Exception ex) {
|
||||
logger.error(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -142,10 +143,9 @@ public class Sets extends HashMap<String, ExpansionSet> {
|
|||
}
|
||||
|
||||
public static void saveDeck(String file, DeckCardLists deck) throws FileNotFoundException {
|
||||
PrintWriter out = new PrintWriter(file);
|
||||
Map<String, DeckCardInfo> deckCards = new HashMap<>();
|
||||
Map<String, DeckCardInfo> sideboard = new HashMap<>();
|
||||
try {
|
||||
try (PrintWriter out = new PrintWriter(file)) {
|
||||
if (deck.getName() != null && deck.getName().length() > 0) {
|
||||
out.println("NAME:" + deck.getName());
|
||||
}
|
||||
|
@ -169,10 +169,10 @@ public class Sets extends HashMap<String, ExpansionSet> {
|
|||
}
|
||||
|
||||
// Write out all of the cards
|
||||
for (Map.Entry<String, DeckCardInfo> entry : deckCards.entrySet()) {
|
||||
for (Entry<String, DeckCardInfo> entry : deckCards.entrySet()) {
|
||||
out.printf("%d [%s:%s] %s%n", entry.getValue().getQuantity(), entry.getValue().getSetCode(), entry.getValue().getCardNum(), entry.getValue().getCardName());
|
||||
}
|
||||
for (Map.Entry<String, DeckCardInfo> entry : sideboard.entrySet()) {
|
||||
for (Entry<String, DeckCardInfo> entry : sideboard.entrySet()) {
|
||||
out.printf("SB: %d [%s:%s] %s%n", entry.getValue().getQuantity(), entry.getValue().getSetCode(), entry.getValue().getCardNum(), entry.getValue().getCardName());
|
||||
}
|
||||
|
||||
|
@ -183,8 +183,6 @@ public class Sets extends HashMap<String, ExpansionSet> {
|
|||
out.print("LAYOUT SIDEBOARD:");
|
||||
writeCardLayout(out, deck.getSideboardLayout());
|
||||
out.print("\n");
|
||||
} finally {
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,6 @@ import mage.abilities.AbilitiesImpl;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.SpellAbilityType;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
|
|
|
@ -8,7 +8,6 @@ package mage.cards;
|
|||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.SpellAbilityType;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
|
|
|
@ -32,7 +32,6 @@ import java.util.UUID;
|
|||
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.abilities.mana.ActivatedManaAbilityImpl;
|
||||
import mage.cards.CardImpl;
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ public class DeckCardInfo implements Serializable {
|
|||
}
|
||||
|
||||
public String getCardKey() {
|
||||
return new StringBuilder(setCode).append(cardNum).toString();
|
||||
return setCode + cardNum;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -53,8 +53,7 @@ public abstract class DeckImporter {
|
|||
lineCount = 0;
|
||||
sbMessage.setLength(0);
|
||||
try {
|
||||
Scanner scanner = new Scanner(f);
|
||||
try {
|
||||
try (Scanner scanner = new Scanner(f)) {
|
||||
while (scanner.hasNextLine()) {
|
||||
String line = scanner.nextLine().trim();
|
||||
lineCount++;
|
||||
|
@ -63,13 +62,9 @@ public abstract class DeckImporter {
|
|||
if (sbMessage.length() > 0) {
|
||||
logger.fatal(sbMessage);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
} catch (Exception ex) {
|
||||
logger.fatal(null, ex);
|
||||
}
|
||||
finally {
|
||||
scanner.close();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.fatal(null, ex);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
package mage.cards.decks.importer;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import mage.cards.decks.DeckCardInfo;
|
||||
import mage.cards.decks.DeckCardLists;
|
||||
import mage.cards.repository.CardCriteria;
|
||||
|
@ -69,8 +69,7 @@ public class MWSDeckImporter extends DeckImporter {
|
|||
CardCriteria criteria = new CardCriteria();
|
||||
criteria.name(lineName);
|
||||
criteria.setCodes(setCode);
|
||||
List<CardInfo> cards = null;
|
||||
cards = CardRepository.instance.findCards(criteria);
|
||||
List<CardInfo> cards = CardRepository.instance.findCards(criteria);
|
||||
if (!cards.isEmpty()) {
|
||||
cardInfo = cards.get(RandomUtil.nextInt(cards.size()));
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ public enum ExpansionRepository {
|
|||
|
||||
private Dao<ExpansionInfo, Object> expansionDao;
|
||||
|
||||
private ExpansionRepository() {
|
||||
ExpansionRepository() {
|
||||
File file = new File("db");
|
||||
if (!file.exists()) {
|
||||
file.mkdirs();
|
||||
|
@ -57,6 +57,7 @@ public enum ExpansionRepository {
|
|||
try {
|
||||
expansionDao.create(expansion);
|
||||
} catch (SQLException ex) {
|
||||
logger.error(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,6 +84,7 @@ public enum ExpansionRepository {
|
|||
List<ExpansionInfo> expansions = expansionDao.query(qb.prepare());
|
||||
sets = expansions.toArray(new ExpansionInfo[0]);
|
||||
} catch (SQLException ex) {
|
||||
logger.error(ex);
|
||||
}
|
||||
return sets;
|
||||
}
|
||||
|
@ -95,6 +97,7 @@ public enum ExpansionRepository {
|
|||
qb.where().eq("basicLands", new SelectArg(true));
|
||||
sets = expansionDao.query(qb.prepare());
|
||||
} catch (SQLException ex) {
|
||||
logger.error(ex);
|
||||
}
|
||||
return sets;
|
||||
}
|
||||
|
@ -106,6 +109,7 @@ public enum ExpansionRepository {
|
|||
qb.where().eq("blockName", new SelectArg(blockName));
|
||||
return expansionDao.query(qb.prepare());
|
||||
} catch (SQLException ex) {
|
||||
logger.error(ex);
|
||||
}
|
||||
return sets;
|
||||
}
|
||||
|
@ -120,6 +124,7 @@ public enum ExpansionRepository {
|
|||
set = expansions.get(0);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
logger.error(ex);
|
||||
}
|
||||
return set;
|
||||
}
|
||||
|
@ -134,6 +139,7 @@ public enum ExpansionRepository {
|
|||
set = expansions.get(0);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
logger.error(ex);
|
||||
}
|
||||
return set;
|
||||
}
|
||||
|
@ -144,6 +150,7 @@ public enum ExpansionRepository {
|
|||
qb.orderBy("releaseDate", true);
|
||||
return expansionDao.query(qb.prepare());
|
||||
} catch (SQLException ex) {
|
||||
logger.error(ex);
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
@ -159,6 +166,7 @@ public enum ExpansionRepository {
|
|||
}
|
||||
return setNames;
|
||||
} catch (SQLException ex) {
|
||||
logger.error(ex);
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ import java.util.Set;
|
|||
public class ChoiceImpl implements Choice, Serializable {
|
||||
|
||||
protected boolean chosen;
|
||||
protected boolean required;
|
||||
protected final boolean required;
|
||||
protected String choice;
|
||||
protected String choiceKey;
|
||||
protected Set<String> choices = new LinkedHashSet<>();
|
||||
|
|
|
@ -48,5 +48,5 @@ public enum DependencyType {
|
|||
BecomePlains,
|
||||
BecomeSwamp,
|
||||
EnchantmentAddingRemoving,
|
||||
LooseDefenderEffect;
|
||||
LooseDefenderEffect
|
||||
}
|
||||
|
|
|
@ -24,4 +24,4 @@ public enum ManaType {
|
|||
public String toString() {
|
||||
return text;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -19,8 +19,8 @@ public enum MatchTimeLimit {
|
|||
MIN__90(5400, "90 Minutes"),
|
||||
MIN_120(7200, "120 Minutes");
|
||||
|
||||
private int matchSeconds;
|
||||
private String name;
|
||||
private final int matchSeconds;
|
||||
private final String name;
|
||||
|
||||
MatchTimeLimit(int matchSeconds, String name) {
|
||||
this.matchSeconds = matchSeconds;
|
||||
|
|
|
@ -9,7 +9,7 @@ public enum RangeOfInfluence {
|
|||
TWO(2),
|
||||
ALL(0);
|
||||
|
||||
private int range;
|
||||
private final int range;
|
||||
|
||||
RangeOfInfluence(int range) {
|
||||
this.range = range;
|
||||
|
|
|
@ -33,5 +33,5 @@ package mage.constants;
|
|||
*/
|
||||
public enum SetTargetPointer {
|
||||
|
||||
NONE, PLAYER, SPELL, CARD, PERMANENT, ATTACHED_TO_CONTROLLER;
|
||||
NONE, PLAYER, SPELL, CARD, PERMANENT, ATTACHED_TO_CONTROLLER
|
||||
}
|
||||
|
|
|
@ -34,8 +34,8 @@ package mage.counters;
|
|||
*/
|
||||
public class BoostCounter extends Counter {
|
||||
|
||||
protected int power;
|
||||
protected int toughness;
|
||||
protected final int power;
|
||||
protected final int toughness;
|
||||
|
||||
public BoostCounter(int power, int toughness) {
|
||||
this(power, toughness, 1);
|
||||
|
|
|
@ -158,10 +158,7 @@ public class Counter implements Serializable {
|
|||
|
||||
Counter counter = (Counter) o;
|
||||
|
||||
if (count != counter.count) {
|
||||
return false;
|
||||
}
|
||||
return !(name != null ? !name.equals(counter.name) : counter.name != null);
|
||||
return count == counter.count && !(name != null ? !name.equals(counter.name) : counter.name != null);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@ public enum CounterType {
|
|||
|
||||
private final String name;
|
||||
|
||||
private CounterType(String name) {
|
||||
CounterType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ public abstract class Designation implements MageObject {
|
|||
|
||||
private static List emptyList = new ArrayList();
|
||||
private static ObjectColor emptyColor = new ObjectColor();
|
||||
private static ManaCosts emptyCost = new ManaCostsImpl();
|
||||
private static ManaCosts<ManaCost> emptyCost = new ManaCostsImpl();
|
||||
|
||||
private String name;
|
||||
private UUID id;
|
||||
|
|
|
@ -41,7 +41,7 @@ import mage.game.permanent.Permanent;
|
|||
*/
|
||||
public class FilterControlledCreatureInPlay extends FilterImpl<Object> implements FilterInPlay<Object> {
|
||||
|
||||
protected FilterCreaturePermanent creatureFilter;
|
||||
protected final FilterCreaturePermanent creatureFilter;
|
||||
|
||||
public FilterControlledCreatureInPlay() {
|
||||
this("creature");
|
||||
|
|
|
@ -43,7 +43,7 @@ import mage.players.Player;
|
|||
public class FilterCreatureOrPlayer extends FilterImpl<MageItem> implements FilterInPlay<MageItem> {
|
||||
|
||||
protected FilterCreaturePermanent creatureFilter;
|
||||
protected FilterPlayer playerFilter;
|
||||
protected final FilterPlayer playerFilter;
|
||||
|
||||
public FilterCreatureOrPlayer() {
|
||||
this("creature or player");
|
||||
|
|
|
@ -42,8 +42,8 @@ import mage.players.Player;
|
|||
*/
|
||||
public class FilterPermanentOrPlayer extends FilterImpl<MageItem> implements FilterInPlay<MageItem> {
|
||||
|
||||
protected FilterPermanent permanentFilter;
|
||||
protected FilterPlayer playerFilter;
|
||||
protected final FilterPermanent permanentFilter;
|
||||
protected final FilterPlayer playerFilter;
|
||||
|
||||
public FilterPermanentOrPlayer() {
|
||||
this("player or permanent");
|
||||
|
|
|
@ -46,8 +46,8 @@ import mage.players.Player;
|
|||
*/
|
||||
public class FilterPlaneswalkerOrPlayer extends FilterImpl<Object> {
|
||||
|
||||
protected FilterPlaneswalkerPermanent planeswalkerFilter;
|
||||
protected FilterPlayer playerFilter;
|
||||
protected final FilterPlaneswalkerPermanent planeswalkerFilter;
|
||||
protected final FilterPlayer playerFilter;
|
||||
|
||||
public FilterPlaneswalkerOrPlayer(Set<UUID> defenders) {
|
||||
super("planeswalker or player");
|
||||
|
|
|
@ -36,8 +36,8 @@ import java.util.UUID;
|
|||
*/
|
||||
public class ObjectPlayer<T> {
|
||||
|
||||
protected T object;
|
||||
protected UUID playerId;
|
||||
protected final T object;
|
||||
protected final UUID playerId;
|
||||
|
||||
public ObjectPlayer(T object, UUID playerId) {
|
||||
this.object = object;
|
||||
|
|
|
@ -36,7 +36,7 @@ import java.util.UUID;
|
|||
*/
|
||||
public class ObjectSourcePlayer<T> extends ObjectPlayer<T> {
|
||||
|
||||
protected UUID sourceId;
|
||||
protected final UUID sourceId;
|
||||
|
||||
public ObjectSourcePlayer(T object, UUID sourceId, UUID playerId) {
|
||||
super(object, playerId);
|
||||
|
|
|
@ -168,8 +168,8 @@ public final class Predicates {
|
|||
|
||||
@Override
|
||||
public boolean apply(T t, Game game) {
|
||||
for (int i = 0; i < components.size(); i++) {
|
||||
if (!components.get(i).apply(t, game)) {
|
||||
for (Predicate<? super T> component : components) {
|
||||
if (!component.apply(t, game)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -196,8 +196,8 @@ public final class Predicates {
|
|||
|
||||
@Override
|
||||
public boolean apply(T t, Game game) {
|
||||
for (int i = 0; i < components.size(); i++) {
|
||||
if (components.get(i).apply(t, game)) {
|
||||
for (Predicate<? super T> component : components) {
|
||||
if (component.apply(t, game)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -244,8 +244,8 @@ public final class Predicates {
|
|||
|
||||
private static String commaJoin(List components) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < components.size(); i++) {
|
||||
sb.append(components.get(i).toString());
|
||||
for (Object component : components) {
|
||||
sb.append(component.toString());
|
||||
}
|
||||
sb.deleteCharAt(sb.length() - 1);
|
||||
return sb.toString();
|
||||
|
|
|
@ -38,7 +38,7 @@ import mage.game.Game;
|
|||
*/
|
||||
public class FromSetPredicate<T extends MageItem> implements Predicate<T> {
|
||||
|
||||
protected Set<UUID> set;
|
||||
protected final Set<UUID> set;
|
||||
|
||||
public FromSetPredicate(Set<UUID> set) {
|
||||
this.set = set;
|
||||
|
|
|
@ -39,7 +39,7 @@ import mage.game.permanent.Permanent;
|
|||
*/
|
||||
public class AttachedToPredicate implements Predicate<Permanent> {
|
||||
|
||||
private FilterPermanent filter;
|
||||
private final FilterPermanent filter;
|
||||
|
||||
public AttachedToPredicate(FilterPermanent filter) {
|
||||
this.filter = filter;
|
||||
|
|
|
@ -41,7 +41,7 @@ import mage.game.permanent.Permanent;
|
|||
public class ControllerControlsIslandPredicate implements Predicate<Permanent> {
|
||||
|
||||
public static final FilterLandPermanent filter = new FilterLandPermanent("Island");
|
||||
{
|
||||
static {
|
||||
filter.add(new SubtypePredicate("Island"));
|
||||
}
|
||||
|
||||
|
|
|
@ -51,6 +51,6 @@ public class PermanentIdPredicate implements Predicate<Permanent> {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new StringBuilder("PermanentId(").append(permanentId).append(")").toString() ;
|
||||
return "PermanentId(" + permanentId + ")";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ public interface Game extends MageItem, Serializable {
|
|||
|
||||
void setZone(UUID objectId, Zone zone);
|
||||
|
||||
void addPlayer(Player player, Deck deck) throws GameException;
|
||||
void addPlayer(Player player, Deck deck);
|
||||
|
||||
Player getPlayer(UUID playerId);
|
||||
|
||||
|
@ -437,7 +437,7 @@ public interface Game extends MageItem, Serializable {
|
|||
// controlling the behaviour of replacement effects while permanents entering the battlefield
|
||||
void setScopeRelevant(boolean scopeRelevant);
|
||||
|
||||
public boolean getScopeRelevant();
|
||||
boolean getScopeRelevant();
|
||||
|
||||
// players' timers
|
||||
void initTimer(UUID playerId);
|
||||
|
|
|
@ -335,7 +335,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void addPlayer(Player player, Deck deck) throws GameException {
|
||||
public void addPlayer(Player player, Deck deck) {
|
||||
player.useDeck(deck, this);
|
||||
state.addPlayer(player);
|
||||
}
|
||||
|
@ -1937,7 +1937,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
Player controller = this.getPlayer(planeswalker.getControllerId());
|
||||
if (controller != null) {
|
||||
Target targetPlaneswalkerToKeep = new TargetPermanent(filterPlaneswalker);
|
||||
targetPlaneswalkerToKeep.setTargetName(new StringBuilder(planeswalker.getName()).append(" to keep?").toString());
|
||||
targetPlaneswalkerToKeep.setTargetName(planeswalker.getName() + " to keep?");
|
||||
controller.chooseTarget(Outcome.Benefit, targetPlaneswalkerToKeep, null, this);
|
||||
for (Permanent dupPlaneswalker : this.getBattlefield().getActivePermanents(filterPlaneswalker, planeswalker.getControllerId(), this)) {
|
||||
if (!targetPlaneswalkerToKeep.getTargets().contains(dupPlaneswalker.getId())) {
|
||||
|
@ -2345,12 +2345,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
}
|
||||
// Then, if that player controlled any objects on the stack not represented by cards, those objects cease to exist.
|
||||
this.getState().getContinuousEffects().removeInactiveEffects(this);
|
||||
for (Iterator<StackObject> it = getStack().iterator(); it.hasNext();) {
|
||||
StackObject object = it.next();
|
||||
if (object.getControllerId().equals(playerId)) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
getStack().removeIf(object -> object.getControllerId().equals(playerId));
|
||||
// Then, if there are any objects still controlled by that player, those objects are exiled.
|
||||
applyEffects(); // to remove control from effects removed meanwhile
|
||||
List<Permanent> permanents = this.getBattlefield().getAllActivePermanents(playerId);
|
||||
|
@ -2594,10 +2589,10 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
if (object instanceof Permanent) {
|
||||
Map<Integer, MageObject> lkiExtendedMap = lkiExtended.get(objectId);
|
||||
if (lkiExtendedMap != null) {
|
||||
lkiExtendedMap.put(((Permanent) object).getZoneChangeCounter(this), copy);
|
||||
lkiExtendedMap.put(object.getZoneChangeCounter(this), copy);
|
||||
} else {
|
||||
lkiExtendedMap = new HashMap<>();
|
||||
lkiExtendedMap.put(((Permanent) object).getZoneChangeCounter(this), copy);
|
||||
lkiExtendedMap.put(object.getZoneChangeCounter(this), copy);
|
||||
lkiExtended.put(objectId, lkiExtendedMap);
|
||||
}
|
||||
}
|
||||
|
@ -2689,7 +2684,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
permanent.entersBattlefield(permanent.getId(), this, Zone.OUTSIDE, false);
|
||||
getBattlefield().addPermanent(permanent);
|
||||
getPermanentsEntering().remove(permanent.getId());
|
||||
((PermanentImpl) permanent).removeSummoningSickness();
|
||||
permanent.removeSummoningSickness();
|
||||
if (card.isTapped()) {
|
||||
permanent.setTapped(true);
|
||||
}
|
||||
|
|
|
@ -64,9 +64,8 @@ public class Table implements Serializable {
|
|||
private TableRecorder recorder;
|
||||
|
||||
public interface TableRecorder {
|
||||
|
||||
void record(Table table);
|
||||
};
|
||||
}
|
||||
|
||||
protected TableEventSource tableEventSource = new TableEventSource();
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package mage.game;
|
||||
|
||||
import mage.cards.MeldCard;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.stack.Spell;
|
||||
|
||||
|
|
|
@ -52,11 +52,7 @@ public class ZonesHandler {
|
|||
}
|
||||
}
|
||||
}
|
||||
for (Iterator<ZoneChangeInfo> itr = zoneChangeInfos.iterator(); itr.hasNext();) {
|
||||
if (!maybeRemoveFromSourceZone(itr.next(), game)) {
|
||||
itr.remove();
|
||||
}
|
||||
}
|
||||
zoneChangeInfos.removeIf(zoneChangeInfo -> !maybeRemoveFromSourceZone(zoneChangeInfo, game));
|
||||
for (ZoneChangeInfo zoneChangeInfo : zoneChangeInfos) {
|
||||
placeInDestinationZone(zoneChangeInfo, game);
|
||||
if (game.getPhase() != null) { // moving cards to zones before game started does not need events
|
||||
|
|
|
@ -983,7 +983,7 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
for (Ability ability : entry.getValue()) {
|
||||
if (!effect.canBlockCheckAfter(ability, game)) {
|
||||
if (controller.isHuman()) {
|
||||
game.informPlayer(controller, new StringBuilder(blockingCreature.getLogName()).append(" can't block this way.").toString());
|
||||
game.informPlayer(controller, blockingCreature.getLogName() + " can't block this way.");
|
||||
return false;
|
||||
} else {
|
||||
// remove blocking creatures for AI
|
||||
|
@ -1003,7 +1003,7 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
for (Ability ability : entry.getValue()) {
|
||||
if (!effect.canBeBlockedCheckAfter(attackingCreature, ability, game)) {
|
||||
if (controller.isHuman()) {
|
||||
game.informPlayer(controller, new StringBuilder(attackingCreature.getLogName()).append(" can't be blocked this way.").toString());
|
||||
game.informPlayer(controller, attackingCreature.getLogName() + " can't be blocked this way.");
|
||||
return false;
|
||||
} else {
|
||||
// remove blocking creatures for AI
|
||||
|
@ -1030,7 +1030,7 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
switch (game.getAttackOption()) {
|
||||
case LEFT:
|
||||
players = game.getState().getPlayerList(attackingPlayerId);
|
||||
while (true && attackingPlayer.isInGame()) {
|
||||
while (attackingPlayer.isInGame()) {
|
||||
Player opponent = players.getNext(game);
|
||||
if (attackingPlayer.hasOpponent(opponent.getId(), game)) {
|
||||
addDefender(opponent.getId(), game);
|
||||
|
@ -1040,7 +1040,7 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
break;
|
||||
case RIGHT:
|
||||
players = game.getState().getPlayerList(attackingPlayerId);
|
||||
while (true && attackingPlayer.isInGame()) {
|
||||
while (attackingPlayer.isInGame()) {
|
||||
Player opponent = players.getPrevious(game);
|
||||
if (attackingPlayer.hasOpponent(opponent.getId(), game)) {
|
||||
addDefender(opponent.getId(), game);
|
||||
|
|
|
@ -457,7 +457,7 @@ public class CombatGroup implements Serializable, Copyable<CombatGroup> {
|
|||
Player player = game.getPlayer(playerId);
|
||||
List<UUID> blockerList = new ArrayList<>(blockers);
|
||||
blockerOrder.clear();
|
||||
while (true && player.canRespond()) {
|
||||
while (player.canRespond()) {
|
||||
if (blockerList.size() == 1) {
|
||||
blockerOrder.add(blockerList.get(0));
|
||||
break;
|
||||
|
|
|
@ -29,7 +29,7 @@ package mage.game.draft;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import mage.cards.Card;
|
||||
import mage.cards.repository.CardCriteria;
|
||||
import mage.cards.repository.CardInfo;
|
||||
|
|
|
@ -302,7 +302,7 @@ public class GameEvent implements Serializable {
|
|||
COMBAT_DAMAGE_APPLIED,
|
||||
SELECTED_ATTACKER, SELECTED_BLOCKER,
|
||||
//custom events
|
||||
CUSTOM_EVENT;
|
||||
CUSTOM_EVENT
|
||||
}
|
||||
|
||||
private GameEvent(EventType type, UUID customEventType,
|
||||
|
|
|
@ -62,7 +62,7 @@ public interface Match {
|
|||
|
||||
void submitDeck(UUID playerId, Deck deck);
|
||||
void updateDeck(UUID playerId, Deck deck);
|
||||
void startMatch() throws GameException;
|
||||
void startMatch();
|
||||
void startGame() throws GameException;
|
||||
void sideboard();
|
||||
void endGame();
|
||||
|
|
|
@ -31,7 +31,6 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.game.Game;
|
||||
|
@ -121,7 +120,7 @@ public abstract class MatchImpl implements Match {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void startMatch() throws GameException {
|
||||
public void startMatch() {
|
||||
this.startTime = new Date();
|
||||
}
|
||||
|
||||
|
|
|
@ -174,7 +174,7 @@ public interface Permanent extends Card, Controllable {
|
|||
|
||||
boolean canLoyaltyBeUsed(Game game);
|
||||
|
||||
public void resetControl();
|
||||
void resetControl();
|
||||
|
||||
boolean changeControllerId(UUID controllerId, Game game);
|
||||
|
||||
|
|
|
@ -981,7 +981,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
moveToZone(Zone.GRAVEYARD, sourceId, game, false);
|
||||
Player player = game.getPlayer(getControllerId());
|
||||
if (player != null && !game.isSimulation()) {
|
||||
game.informPlayers(new StringBuilder(player.getLogName()).append(" sacrificed ").append(this.getLogName()).toString());
|
||||
game.informPlayers(player.getLogName() + " sacrificed " + this.getLogName());
|
||||
}
|
||||
game.fireEvent(GameEvent.getEvent(EventType.SACRIFICED_PERMANENT, objectId, sourceId, controllerId));
|
||||
return true;
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
package mage.game.permanent.token;
|
||||
|
||||
import java.util.Random;
|
||||
import mage.constants.CardType;
|
||||
import mage.MageInt;
|
||||
import mage.util.RandomUtil;
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
package mage.game.permanent.token;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.DiesTriggeredAbility;
|
||||
|
@ -44,7 +46,7 @@ public class DevilToken extends Token {
|
|||
|
||||
public DevilToken() {
|
||||
super("Devil", "1/1 red Devil creature with \"When this creature dies, it deals 1 damage to target creature or player.\"");
|
||||
availableImageSetCodes.addAll(Arrays.asList("SOI"));
|
||||
availableImageSetCodes.addAll(Collections.singletonList("SOI"));
|
||||
cardType.add(CardType.CREATURE);
|
||||
subtype.add("Devil");
|
||||
color.setRed(true);
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
package mage.game.permanent.token;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.constants.CardType;
|
||||
|
||||
|
@ -39,7 +41,7 @@ public class DroidToken extends Token {
|
|||
|
||||
public DroidToken() {
|
||||
super("Droid", "1/1 colorless Droid creature token");
|
||||
availableImageSetCodes.addAll(Arrays.asList("SWS"));
|
||||
availableImageSetCodes.addAll(Collections.singletonList("SWS"));
|
||||
|
||||
cardType.add(CardType.CREATURE);
|
||||
cardType.add(CardType.ARTIFACT);
|
||||
|
|
|
@ -29,6 +29,7 @@ package mage.game.permanent.token;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import mage.MageInt;
|
||||
import mage.constants.CardType;
|
||||
|
@ -42,7 +43,7 @@ public class EldraziHorrorToken extends Token {
|
|||
final static private List<String> tokenImageSets = new ArrayList<>();
|
||||
|
||||
static {
|
||||
tokenImageSets.addAll(Arrays.asList("EMN"));
|
||||
tokenImageSets.addAll(Collections.singletonList("EMN"));
|
||||
}
|
||||
|
||||
public EldraziHorrorToken() {
|
||||
|
|
|
@ -30,7 +30,7 @@ package mage.game.permanent.token;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.Mana;
|
||||
import mage.abilities.costs.common.SacrificeSourceCost;
|
||||
|
|
|
@ -30,7 +30,7 @@ package mage.game.permanent.token;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.Mana;
|
||||
import mage.abilities.costs.common.SacrificeSourceCost;
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
package mage.game.permanent.token;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
import mage.constants.CardType;
|
||||
|
||||
/**
|
||||
|
@ -38,7 +40,7 @@ public class EwokToken extends Token {
|
|||
|
||||
public EwokToken() {
|
||||
super("Ewok", "1/1 green Ewok creature tokens", 1, 1);
|
||||
availableImageSetCodes.addAll(Arrays.asList("SWS"));
|
||||
availableImageSetCodes.addAll(Collections.singletonList("SWS"));
|
||||
|
||||
cardType.add(CardType.CREATURE);
|
||||
subtype.add("Ewok");
|
||||
|
|
|
@ -29,6 +29,7 @@ package mage.game.permanent.token;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import mage.MageInt;
|
||||
import mage.constants.CardType;
|
||||
|
@ -42,7 +43,7 @@ public class PrismToken extends Token {
|
|||
final static private List<String> tokenImageSets = new ArrayList<>();
|
||||
|
||||
static {
|
||||
tokenImageSets.addAll(Arrays.asList("VIS"));
|
||||
tokenImageSets.addAll(Collections.singletonList("VIS"));
|
||||
}
|
||||
|
||||
public PrismToken() {
|
||||
|
|
|
@ -29,6 +29,7 @@ package mage.game.permanent.token;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import mage.MageInt;
|
||||
import mage.constants.CardType;
|
||||
|
@ -43,7 +44,7 @@ public class ServoToken extends Token {
|
|||
final static private List<String> tokenImageSets = new ArrayList<>();
|
||||
|
||||
static {
|
||||
tokenImageSets.addAll(Arrays.asList("KLD"));
|
||||
tokenImageSets.addAll(Collections.singletonList("KLD"));
|
||||
}
|
||||
|
||||
public ServoToken() {
|
||||
|
|
|
@ -29,6 +29,7 @@ package mage.game.permanent.token;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import mage.MageInt;
|
||||
import mage.constants.CardType;
|
||||
|
@ -42,7 +43,7 @@ public class SquirrelToken extends Token {
|
|||
final static private List<String> tokenImageSets = new ArrayList<>();
|
||||
|
||||
static {
|
||||
tokenImageSets.addAll(Arrays.asList("CNS"));
|
||||
tokenImageSets.addAll(Collections.singletonList("CNS"));
|
||||
}
|
||||
|
||||
public SquirrelToken() {
|
||||
|
|
|
@ -30,6 +30,7 @@ package mage.game.permanent.token;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import mage.MageInt;
|
||||
import mage.constants.CardType;
|
||||
|
@ -43,7 +44,7 @@ public class ThrullToken extends Token {
|
|||
final static private List<String> tokenImageSets = new ArrayList<>();
|
||||
|
||||
static {
|
||||
tokenImageSets.addAll(Arrays.asList("MM2"));
|
||||
tokenImageSets.addAll(Collections.singletonList("MM2"));
|
||||
}
|
||||
|
||||
public ThrullToken() {
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
package mage.game.permanent.token;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.constants.CardType;
|
||||
|
||||
|
@ -39,7 +41,7 @@ public class TrooperToken extends Token {
|
|||
|
||||
public TrooperToken() {
|
||||
super("Trooper", "1/1 white Trooper creature token");
|
||||
availableImageSetCodes.addAll(Arrays.asList("SWS"));
|
||||
availableImageSetCodes.addAll(Collections.singletonList("SWS"));
|
||||
|
||||
cardType.add(CardType.CREATURE);
|
||||
subtype.add("Trooper");
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
package mage.game.permanent.token;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Random;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.constants.CardType;
|
||||
import mage.util.RandomUtil;
|
||||
|
|
|
@ -30,7 +30,7 @@ package mage.game.permanent.token;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.constants.CardType;
|
||||
import mage.util.RandomUtil;
|
||||
|
|
|
@ -35,7 +35,6 @@ import java.util.HashSet;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import mage.cards.ExpansionSet;
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
package mage.game.tournament;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import mage.constants.MultiplayerAttackOption;
|
||||
|
|
|
@ -49,7 +49,7 @@ public abstract class Step implements Serializable {
|
|||
protected StepPart stepPart;
|
||||
|
||||
public enum StepPart {
|
||||
PRE, PRIORITY, POST;
|
||||
PRE, PRIORITY, POST
|
||||
}
|
||||
|
||||
public abstract Step copy();
|
||||
|
|
|
@ -52,7 +52,7 @@ public class TurnMods extends ArrayList<TurnMod> {
|
|||
ListIterator<TurnMod> it = this.listIterator(this.size());
|
||||
while (it.hasPrevious()) {
|
||||
TurnMod turnMod = it.previous();
|
||||
if (turnMod.isExtraTurn() == true && turnMod.getPlayerId().equals(playerId)) {
|
||||
if (turnMod.isExtraTurn() && turnMod.getPlayerId().equals(playerId)) {
|
||||
it.remove();
|
||||
return turnMod.getId();
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ public class TurnMods extends ArrayList<TurnMod> {
|
|||
ListIterator<TurnMod> it = this.listIterator(this.size());
|
||||
while (it.hasPrevious()) {
|
||||
TurnMod turnMod = it.previous();
|
||||
if (turnMod.isExtraTurn() == true) {
|
||||
if (turnMod.isExtraTurn()) {
|
||||
it.remove();
|
||||
return turnMod;
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ public class TurnMods extends ArrayList<TurnMod> {
|
|||
ListIterator<TurnMod> it = this.listIterator(this.size());
|
||||
while (it.hasPrevious()) {
|
||||
TurnMod turnMod = it.previous();
|
||||
if (turnMod.isSkipTurn() == true && turnMod.getPlayerId().equals(playerId)) {
|
||||
if (turnMod.isSkipTurn() && turnMod.getPlayerId().equals(playerId)) {
|
||||
it.remove();
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ public class Library implements Serializable {
|
|||
public void shuffle() {
|
||||
UUID[] shuffled = library.toArray(new UUID[0]);
|
||||
for (int n = shuffled.length - 1; n > 0; n--) {
|
||||
int r = RandomUtil.nextInt(n);;
|
||||
int r = RandomUtil.nextInt(n);
|
||||
UUID temp = shuffled[n];
|
||||
shuffled[n] = shuffled[r];
|
||||
shuffled[r] = temp;
|
||||
|
|
|
@ -303,23 +303,18 @@ public class ManaPoolItem implements Serializable {
|
|||
break;
|
||||
case BLUE:
|
||||
blue += amount;
|
||||
;
|
||||
break;
|
||||
case GREEN:
|
||||
green += amount;
|
||||
;
|
||||
break;
|
||||
case RED:
|
||||
red += amount;
|
||||
;
|
||||
break;
|
||||
case WHITE:
|
||||
white += amount;
|
||||
;
|
||||
break;
|
||||
case COLORLESS:
|
||||
colorless += amount;
|
||||
;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -141,7 +141,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
|
||||
private static final Logger logger = Logger.getLogger(PlayerImpl.class);
|
||||
|
||||
private static SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss.SSS");
|
||||
private static final SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss.SSS");
|
||||
|
||||
/**
|
||||
* Used to cancel waiting requests send to the player
|
||||
|
@ -987,7 +987,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
} else {
|
||||
result = cast(card.getSpellAbility(), game, noMana);
|
||||
}
|
||||
if (result == false) {
|
||||
if (!result) {
|
||||
game.informPlayer(this, "You can't play " + card.getIdName() + ".");
|
||||
}
|
||||
return result;
|
||||
|
@ -2026,7 +2026,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
quit = true;
|
||||
idleTimeout = true;
|
||||
this.concede(game);
|
||||
game.informPlayers(new StringBuilder(getLogName()).append(" was idle for too long, losing the Match.").toString());
|
||||
game.informPlayers(getLogName() + " was idle for too long, losing the Match.");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2241,11 +2241,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
|
||||
@Override
|
||||
public boolean hasWon() {
|
||||
if (!this.loses) {
|
||||
return this.wins;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return !this.loses && this.wins;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2364,20 +2360,14 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
public List<Permanent> getAvailableAttackers(UUID defenderId, Game game) {
|
||||
FilterCreatureForCombat filter = new FilterCreatureForCombat();
|
||||
List<Permanent> attackers = game.getBattlefield().getAllActivePermanents(filter, playerId, game);
|
||||
for (Iterator<Permanent> i = attackers.iterator(); i.hasNext();) {
|
||||
Permanent entry = i.next();
|
||||
if (!entry.canAttack(defenderId, game)) {
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
attackers.removeIf(entry -> !entry.canAttack(defenderId, game));
|
||||
return attackers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Permanent> getAvailableBlockers(Game game) {
|
||||
FilterCreatureForCombatBlock blockFilter = new FilterCreatureForCombatBlock();
|
||||
List<Permanent> blockers = game.getBattlefield().getAllActivePermanents(blockFilter, playerId, game);
|
||||
return blockers;
|
||||
return game.getBattlefield().getAllActivePermanents(blockFilter, playerId, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2766,8 +2756,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
// activated abilities from stack objects
|
||||
for (StackObject stackObject : game.getState().getStack()) {
|
||||
for (ActivatedAbility ability : stackObject.getAbilities().getActivatedAbilities(Zone.STACK)) {
|
||||
if (ability instanceof ActivatedAbility
|
||||
&& canPlay(ability, availableMana, game.getObject(ability.getSourceId()), game)) {
|
||||
if (ability != null && canPlay(ability, availableMana, game.getObject(ability.getSourceId()), game)) {
|
||||
playableActivated.put(ability.toString(), ability);
|
||||
}
|
||||
|
||||
|
@ -2776,9 +2765,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
// activated abilities from objects in the command zone (emblems or commanders)
|
||||
for (CommandObject commandObject : game.getState().getCommand()) {
|
||||
for (ActivatedAbility ability : commandObject.getAbilities().getActivatedAbilities(Zone.COMMAND)) {
|
||||
if (ability.getControllerId().equals(getId())
|
||||
&& ability instanceof ActivatedAbility
|
||||
&& canPlay(ability, availableMana, game.getObject(ability.getSourceId()), game)) {
|
||||
if (ability.getControllerId().equals(getId()) && canPlay(ability, availableMana, game.getObject(ability.getSourceId()), game)) {
|
||||
playableActivated.put(ability.toString(), ability);
|
||||
}
|
||||
|
||||
|
|
|
@ -192,7 +192,7 @@ public class UserData implements Serializable {
|
|||
}
|
||||
|
||||
public String getHistory() {
|
||||
if (UserGroup.COMPUTER.equals(this.groupId)) {
|
||||
if (UserGroup.COMPUTER.equals(this.groupId)) { // Why we are checking UserGroup and integer equality??
|
||||
return "";
|
||||
}
|
||||
// todo: add preference to hide rating?
|
||||
|
|
|
@ -35,8 +35,8 @@ import java.io.Serializable;
|
|||
*/
|
||||
|
||||
public class UserSkipPrioritySteps implements Serializable {
|
||||
SkipPrioritySteps yourTurn;
|
||||
SkipPrioritySteps opponentTurn;
|
||||
final SkipPrioritySteps yourTurn;
|
||||
final SkipPrioritySteps opponentTurn;
|
||||
|
||||
boolean stopOnDeclareAttackersDuringSkipAction;
|
||||
boolean stopOnDeclareBlockerIfNoneAvailable;
|
||||
|
|
|
@ -76,10 +76,7 @@ public abstract class TargetAmount extends TargetImpl {
|
|||
|
||||
@Override
|
||||
public boolean doneChosing() {
|
||||
if (amountWasSet == false) {
|
||||
return false;
|
||||
}
|
||||
return remainingAmount == 0;
|
||||
return amountWasSet && remainingAmount == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -44,7 +44,7 @@ import mage.players.Player;
|
|||
*/
|
||||
public class TargetCard extends TargetObject {
|
||||
|
||||
protected FilterCard filter;
|
||||
protected final FilterCard filter;
|
||||
|
||||
protected TargetCard(Zone zone) {
|
||||
this(1, 1, zone, new FilterCard());
|
||||
|
@ -214,10 +214,7 @@ public class TargetCard extends TargetObject {
|
|||
|
||||
public boolean canTarget(UUID id, Cards cards, Game game) {
|
||||
Card card = cards.get(id, game);
|
||||
if (card != null) {
|
||||
return filter.match(card, game);
|
||||
}
|
||||
return false;
|
||||
return card != null && filter.match(card, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -34,7 +34,6 @@ import java.util.Iterator;
|
|||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
|
@ -55,8 +54,8 @@ import mage.util.RandomUtil;
|
|||
*/
|
||||
public abstract class TargetImpl implements Target {
|
||||
|
||||
protected Map<UUID, Integer> targets = new LinkedHashMap<>();
|
||||
protected Map<UUID, Integer> zoneChangeCounters = new HashMap<>();
|
||||
protected final Map<UUID, Integer> targets = new LinkedHashMap<>();
|
||||
protected final Map<UUID, Integer> zoneChangeCounters = new HashMap<>();
|
||||
|
||||
protected String targetName;
|
||||
protected Zone zone;
|
||||
|
@ -199,18 +198,12 @@ public abstract class TargetImpl implements Target {
|
|||
if (getMaxNumberOfTargets() == 0 && getNumberOfTargets() == 0) {
|
||||
return true;
|
||||
}
|
||||
if (getMaxNumberOfTargets() != 0 && targets.size() == getMaxNumberOfTargets()) {
|
||||
return true;
|
||||
}
|
||||
return chosen;
|
||||
return getMaxNumberOfTargets() != 0 && targets.size() == getMaxNumberOfTargets() || chosen;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doneChosing() {
|
||||
if (getMaxNumberOfTargets() == 0) {
|
||||
return false;
|
||||
}
|
||||
return targets.size() == getMaxNumberOfTargets();
|
||||
return getMaxNumberOfTargets() != 0 && targets.size() == getMaxNumberOfTargets();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -78,10 +78,7 @@ public abstract class TargetObject extends TargetImpl {
|
|||
@Override
|
||||
public boolean canTarget(UUID id, Game game) {
|
||||
MageObject object = game.getObject(id);
|
||||
if (object != null && game.getState().getZone(id).match(zone)) {
|
||||
return getFilter().match(object, game);
|
||||
}
|
||||
return false;
|
||||
return object != null && game.getState().getZone(id).match(zone) && getFilter().match(object, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -101,10 +101,7 @@ public class TargetPermanent extends TargetObject {
|
|||
|
||||
public boolean canTarget(UUID controllerId, UUID id, UUID sourceId, Game game, boolean flag) {
|
||||
Permanent permanent = game.getPermanent(id);
|
||||
if (permanent != null) {
|
||||
return filter.match(permanent, sourceId, controllerId, game);
|
||||
}
|
||||
return false;
|
||||
return permanent != null && filter.match(permanent, sourceId, controllerId, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -42,7 +42,7 @@ import mage.players.Player;
|
|||
*/
|
||||
public class TargetPlayer extends TargetImpl {
|
||||
|
||||
protected FilterPlayer filter;
|
||||
protected final FilterPlayer filter;
|
||||
|
||||
public TargetPlayer() {
|
||||
this(1, 1, false);
|
||||
|
@ -169,10 +169,7 @@ public class TargetPlayer extends TargetImpl {
|
|||
@Override
|
||||
public boolean canTarget(UUID id, Game game) {
|
||||
Player player = game.getPlayer(id);
|
||||
if (player != null) {
|
||||
return filter.match(player, game);
|
||||
}
|
||||
return false;
|
||||
return player != null && filter.match(player, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -47,7 +47,7 @@ import mage.players.Player;
|
|||
*/
|
||||
public class TargetSource extends TargetObject {
|
||||
|
||||
protected FilterObject filter;
|
||||
protected final FilterObject filter;
|
||||
|
||||
public TargetSource() {
|
||||
this(1, 1, new FilterObject("source of your choice"));
|
||||
|
|
|
@ -43,7 +43,7 @@ import mage.game.stack.StackObject;
|
|||
*/
|
||||
public class TargetSpell extends TargetObject {
|
||||
|
||||
protected FilterSpell filter;
|
||||
protected final FilterSpell filter;
|
||||
|
||||
public TargetSpell() {
|
||||
this(1, 1, new FilterSpell());
|
||||
|
@ -82,10 +82,7 @@ public class TargetSpell extends TargetObject {
|
|||
return false;
|
||||
}
|
||||
Spell spell = game.getStack().getSpell(id);
|
||||
if (spell != null) {
|
||||
return filter.match(spell, source.getSourceId(), source.getControllerId(), game);
|
||||
}
|
||||
return false;
|
||||
return spell != null && filter.match(spell, source.getSourceId(), source.getControllerId(), game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -44,7 +44,7 @@ import java.util.UUID;
|
|||
*/
|
||||
public class TargetStackObject extends TargetObject {
|
||||
|
||||
protected FilterStackObject filter;
|
||||
protected final FilterStackObject filter;
|
||||
|
||||
public TargetStackObject() {
|
||||
this(1, 1, new FilterStackObject());
|
||||
|
@ -79,10 +79,7 @@ public class TargetStackObject extends TargetObject {
|
|||
@Override
|
||||
public boolean canTarget(UUID id, Ability source, Game game) {
|
||||
StackObject stackObject = game.getStack().getStackObject(id);
|
||||
if (stackObject != null) {
|
||||
return filter.match(stackObject, source.getSourceId(), source.getControllerId(), game);
|
||||
}
|
||||
return false;
|
||||
return stackObject != null && filter.match(stackObject, source.getSourceId(), source.getControllerId(), game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -45,8 +45,8 @@ import mage.target.TargetCard;
|
|||
*/
|
||||
public class TargetCardInExile extends TargetCard {
|
||||
|
||||
private UUID zoneId;
|
||||
private boolean allExileZones;
|
||||
private final UUID zoneId;
|
||||
private final boolean allExileZones;
|
||||
|
||||
public TargetCardInExile(FilterCard filter) {
|
||||
this(1, 1, filter, null);
|
||||
|
@ -68,11 +68,7 @@ public class TargetCardInExile extends TargetCard {
|
|||
public TargetCardInExile(int minNumTargets, int maxNumTargets, FilterCard filter, UUID zoneId, boolean allExileZones) {
|
||||
super(minNumTargets, maxNumTargets, Zone.EXILED, filter);
|
||||
this.zoneId = zoneId;
|
||||
if (zoneId == null) {
|
||||
this.allExileZones = true;
|
||||
} else {
|
||||
this.allExileZones = allExileZones;
|
||||
}
|
||||
this.allExileZones = zoneId == null || allExileZones;
|
||||
}
|
||||
|
||||
public TargetCardInExile(final TargetCardInExile target) {
|
||||
|
|
|
@ -65,10 +65,7 @@ public class TargetCardInGraveyard extends TargetCard {
|
|||
@Override
|
||||
public boolean canTarget(UUID id, Ability source, Game game) {
|
||||
Card card = game.getCard(id);
|
||||
if (card != null && game.getState().getZone(card.getId()) == Zone.GRAVEYARD) {
|
||||
return filter.match(card, game);
|
||||
}
|
||||
return false;
|
||||
return card != null && game.getState().getZone(card.getId()) == Zone.GRAVEYARD && filter.match(card, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -89,10 +89,7 @@ public class TargetCardInGraveyardOrBattlefield extends TargetCard {
|
|||
return filter.match(permanent, game);
|
||||
}
|
||||
Card card = game.getCard(id);
|
||||
if (card != null && game.getState().getZone(card.getId()) == Zone.GRAVEYARD) {
|
||||
return filter.match(card, game);
|
||||
}
|
||||
return false;
|
||||
return card != null && game.getState().getZone(card.getId()) == Zone.GRAVEYARD && filter.match(card, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -69,10 +69,7 @@ public class TargetCardInHand extends TargetCard {
|
|||
@Override
|
||||
public boolean canTarget(UUID playerId, UUID id, Ability source, Game game) {
|
||||
Card card = game.getPlayer(playerId).getHand().get(id, game);
|
||||
if (card != null) {
|
||||
return filter.match(card, source.getSourceId(), playerId, game);
|
||||
}
|
||||
return false;
|
||||
return card != null && filter.match(card, source.getSourceId(), playerId, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -92,7 +92,7 @@ public class TargetCardInLibrary extends TargetCard {
|
|||
} else {
|
||||
cards = new ArrayList<>(targetPlayer.getLibrary().getTopCards(game, librarySearchLimit));
|
||||
}
|
||||
Collections.sort(cards, new CardNameComparator());
|
||||
cards.sort(new CardNameComparator());
|
||||
Cards cardsId = new CardsImpl();
|
||||
for (Card card : cards) {
|
||||
cardsId.add(card);
|
||||
|
@ -111,10 +111,7 @@ public class TargetCardInLibrary extends TargetCard {
|
|||
@Override
|
||||
public boolean canTarget(UUID id, Ability source, Game game) {
|
||||
Card card = game.getPlayer(source.getControllerId()).getLibrary().getCard(id, game);
|
||||
if (card != null) {
|
||||
return filter.match(card, game);
|
||||
}
|
||||
return false;
|
||||
return card != null && filter.match(card, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -14,7 +14,7 @@ import mage.players.Player;
|
|||
|
||||
public class TargetCardInOpponentsGraveyard extends TargetCard {
|
||||
|
||||
protected boolean allFromOneOpponent;
|
||||
protected final boolean allFromOneOpponent;
|
||||
|
||||
public TargetCardInOpponentsGraveyard(FilterCard filter) {
|
||||
this(1, 1, filter, false);
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
*/
|
||||
public class TargetCreatureOrPlaneswalkerAmount extends TargetAmount {
|
||||
|
||||
protected FilterCreatureOrPlaneswalkerPermanent filter;
|
||||
protected final FilterCreatureOrPlaneswalkerPermanent filter;
|
||||
|
||||
public TargetCreatureOrPlaneswalkerAmount(int amount) {
|
||||
// 107.1c If a rule or ability instructs a player to choose “any number,” that player may choose
|
||||
|
@ -85,10 +85,7 @@
|
|||
@Override
|
||||
public boolean canTarget(UUID objectId, Game game) {
|
||||
Permanent permanent = game.getPermanent(objectId);
|
||||
if (permanent != null) {
|
||||
return filter.match(permanent, game);
|
||||
}
|
||||
return false;
|
||||
return permanent != null && filter.match(permanent, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -90,10 +90,7 @@ public class TargetCreatureOrPlayer extends TargetImpl {
|
|||
return filter.match(permanent, game);
|
||||
}
|
||||
Player player = game.getPlayer(id);
|
||||
if (player != null) {
|
||||
return filter.match(player, game);
|
||||
}
|
||||
return false;
|
||||
return player != null && filter.match(player, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -119,10 +116,7 @@ public class TargetCreatureOrPlayer extends TargetImpl {
|
|||
if (permanent != null) {
|
||||
return filter.match(permanent, game);
|
||||
}
|
||||
if (player != null) {
|
||||
return filter.match(player, game);
|
||||
}
|
||||
return false;
|
||||
return player != null && filter.match(player, game);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -49,7 +49,7 @@ import mage.target.TargetAmount;
|
|||
*/
|
||||
public class TargetCreatureOrPlayerAmount extends TargetAmount {
|
||||
|
||||
protected FilterCreatureOrPlayer filter;
|
||||
protected final FilterCreatureOrPlayer filter;
|
||||
|
||||
public TargetCreatureOrPlayerAmount(int amount) {
|
||||
// 107.1c If a rule or ability instructs a player to choose “any number,” that player may choose
|
||||
|
@ -84,10 +84,7 @@ public class TargetCreatureOrPlayerAmount extends TargetAmount {
|
|||
return filter.match(permanent, game);
|
||||
}
|
||||
Player player = game.getPlayer(objectId);
|
||||
if (player != null) {
|
||||
return filter.match(player, game);
|
||||
}
|
||||
return false;
|
||||
return player != null && filter.match(player, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -108,10 +105,7 @@ public class TargetCreatureOrPlayerAmount extends TargetAmount {
|
|||
if (permanent != null) {
|
||||
return filter.match(permanent, game);
|
||||
}
|
||||
if (player != null) {
|
||||
return filter.match(player, game);
|
||||
}
|
||||
return false;
|
||||
return player != null && filter.match(player, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -49,7 +49,7 @@ import java.util.UUID;
|
|||
*/
|
||||
public class TargetCreaturePermanentAmount extends TargetAmount {
|
||||
|
||||
protected FilterCreaturePermanent filter;
|
||||
protected final FilterCreaturePermanent filter;
|
||||
|
||||
public TargetCreaturePermanentAmount(int amount) {
|
||||
this(amount, new FilterCreaturePermanent());
|
||||
|
@ -83,10 +83,7 @@ public class TargetCreaturePermanentAmount extends TargetAmount {
|
|||
@Override
|
||||
public boolean canTarget(UUID id, Game game) {
|
||||
Permanent permanent = game.getPermanent(id);
|
||||
if (permanent != null) {
|
||||
return filter.match(permanent, game);
|
||||
}
|
||||
return false;
|
||||
return permanent != null && filter.match(permanent, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -139,7 +136,7 @@ public class TargetCreaturePermanentAmount extends TargetAmount {
|
|||
|
||||
@Override
|
||||
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
Set<UUID> possibleTargets = new HashSet<UUID>();
|
||||
Set<UUID> possibleTargets = new HashSet<>();
|
||||
MageObject targetSource = game.getObject(sourceId);
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(), sourceControllerId, game)) {
|
||||
if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(permanent, sourceId, sourceControllerId, game)) {
|
||||
|
@ -151,7 +148,7 @@ public class TargetCreaturePermanentAmount extends TargetAmount {
|
|||
|
||||
@Override
|
||||
public Set<UUID> possibleTargets(UUID sourceControllerId, Game game) {
|
||||
Set<UUID> possibleTargets = new HashSet<UUID>();
|
||||
Set<UUID> possibleTargets = new HashSet<>();
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(), sourceControllerId, game)) {
|
||||
if (filter.match(permanent, null, sourceControllerId, game)) {
|
||||
possibleTargets.add(permanent.getId());
|
||||
|
|
|
@ -49,8 +49,8 @@ import java.util.UUID;
|
|||
*/
|
||||
public class TargetDefender extends TargetImpl {
|
||||
|
||||
protected FilterPlaneswalkerOrPlayer filter;
|
||||
protected UUID attackerId;
|
||||
protected final FilterPlaneswalkerOrPlayer filter;
|
||||
protected final UUID attackerId;
|
||||
|
||||
public TargetDefender(Set<UUID> defenders, UUID attackerId) {
|
||||
this(1, 1, defenders, attackerId);
|
||||
|
@ -187,10 +187,7 @@ public class TargetDefender extends TargetImpl {
|
|||
return filter.match(player, game);
|
||||
}
|
||||
Permanent permanent = game.getPermanent(id);
|
||||
if (permanent != null) {
|
||||
return filter.match(permanent, game);
|
||||
}
|
||||
return false;
|
||||
return permanent != null && filter.match(permanent, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -44,7 +44,7 @@ import mage.filter.predicate.other.OwnerIdPredicate;
|
|||
*/
|
||||
public class TargetDiscard extends TargetCard {
|
||||
|
||||
private UUID playerId;
|
||||
private final UUID playerId;
|
||||
|
||||
public TargetDiscard(UUID playerId) {
|
||||
this(1, 1, new FilterCard(), playerId);
|
||||
|
@ -73,10 +73,7 @@ public class TargetDiscard extends TargetCard {
|
|||
@Override
|
||||
public boolean canTarget(UUID id, Ability source, Game game) {
|
||||
Card card = game.getPlayer(playerId).getHand().get(id, game);
|
||||
if (card != null) {
|
||||
return filter.match(card, source.getControllerId(), game);
|
||||
}
|
||||
return false;
|
||||
return card != null && filter.match(card, source.getControllerId(), game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -40,10 +40,7 @@ public class TargetOpponentsChoicePermanent extends TargetPermanent {
|
|||
|
||||
@Override
|
||||
public boolean canTarget(UUID controllerId, UUID id, UUID sourceId, Game game, boolean flag) {
|
||||
if (opponentId != null) {
|
||||
return super.canTarget(opponentId, id, sourceId, game, flag);
|
||||
}
|
||||
return false;
|
||||
return opponentId != null && super.canTarget(opponentId, id, sourceId, game, flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -97,10 +97,7 @@ public class TargetPermanentOrPlayer extends TargetImpl {
|
|||
return filter.match(permanent, game);
|
||||
}
|
||||
Player player = game.getPlayer(id);
|
||||
if (player != null) {
|
||||
return filter.match(player, game);
|
||||
}
|
||||
return false;
|
||||
return player != null && filter.match(player, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -118,7 +115,7 @@ public class TargetPermanentOrPlayer extends TargetImpl {
|
|||
if (permanent != null) {
|
||||
if (!isNotTarget()) {
|
||||
if (!permanent.canBeTargetedBy(game.getObject(source.getId()), source.getControllerId(), game) ||
|
||||
!permanent.canBeTargetedBy(game.getObject(source.getSourceId()), source.getControllerId(), game)) {
|
||||
!permanent.canBeTargetedBy(game.getObject(source.getSourceId()), source.getControllerId(), game)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -137,10 +134,7 @@ public class TargetPermanentOrPlayer extends TargetImpl {
|
|||
if (permanent != null) {
|
||||
return filter.match(permanent, game);
|
||||
}
|
||||
if (player != null) {
|
||||
return filter.match(player, game);
|
||||
}
|
||||
return false;
|
||||
return player != null && filter.match(player, game);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -43,7 +43,7 @@ import mage.filter.predicate.permanent.CounterPredicate;
|
|||
*/
|
||||
public class TargetPermanentOrPlayerWithCounter extends TargetPermanentOrPlayer {
|
||||
|
||||
protected FilterPermanentOrPlayerWithCounter filter;
|
||||
protected final FilterPermanentOrPlayerWithCounter filter;
|
||||
|
||||
public TargetPermanentOrPlayerWithCounter() {
|
||||
this(1, 1);
|
||||
|
|
|
@ -48,7 +48,7 @@ import mage.target.TargetImpl;
|
|||
*/
|
||||
public class TargetPermanentOrSuspendedCard extends TargetImpl {
|
||||
|
||||
protected FilterPermanentOrSuspendedCard filter;
|
||||
protected final FilterPermanentOrSuspendedCard filter;
|
||||
|
||||
public TargetPermanentOrSuspendedCard() {
|
||||
this(new FilterPermanentOrSuspendedCard(), false);
|
||||
|
@ -118,10 +118,7 @@ public class TargetPermanentOrSuspendedCard extends TargetImpl {
|
|||
return filter.match(permanent, game);
|
||||
}
|
||||
Card card = game.getExile().getCard(id, game);
|
||||
if (card != null) {
|
||||
return filter.match(card, game);
|
||||
}
|
||||
return false;
|
||||
return card != null && filter.match(card, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -137,10 +134,7 @@ public class TargetPermanentOrSuspendedCard extends TargetImpl {
|
|||
}
|
||||
}
|
||||
Card card = game.getExile().getCard(id, game);
|
||||
if (card != null) {
|
||||
return filter.match(card, game);
|
||||
}
|
||||
return false;
|
||||
return card != null && filter.match(card, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -105,10 +105,7 @@ public class TargetSpellOrPermanent extends TargetImpl {
|
|||
return filter.match(permanent, game);
|
||||
}
|
||||
Spell spell = game.getStack().getSpell(id);
|
||||
if (spell != null) {
|
||||
return filter.match(spell, game);
|
||||
}
|
||||
return false;
|
||||
return spell != null && filter.match(spell, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -124,11 +121,8 @@ public class TargetSpellOrPermanent extends TargetImpl {
|
|||
}
|
||||
}
|
||||
Spell spell = game.getStack().getSpell(id);
|
||||
if (spell != null
|
||||
&& !source.getSourceId().equals(id)) { // 114.4. A spell or ability on the stack is an illegal target for itself.
|
||||
return filter.match(spell, game);
|
||||
}
|
||||
return false;
|
||||
// 114.4. A spell or ability on the stack is an illegal target for itself.
|
||||
return spell != null && !source.getSourceId().equals(id) && filter.match(spell, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -11,7 +11,7 @@ import mage.game.Game;
|
|||
|
||||
public class SecondTargetPointer implements TargetPointer {
|
||||
|
||||
private Map<UUID, Integer> zoneChangeCounter = new HashMap<UUID, Integer>();
|
||||
private Map<UUID, Integer> zoneChangeCounter = new HashMap<>();
|
||||
|
||||
public static SecondTargetPointer getInstance() {
|
||||
return new SecondTargetPointer();
|
||||
|
@ -41,7 +41,7 @@ public class SecondTargetPointer implements TargetPointer {
|
|||
|
||||
@Override
|
||||
public List<UUID> getTargets(Game game, Ability source) {
|
||||
ArrayList<UUID> target = new ArrayList<UUID>();
|
||||
ArrayList<UUID> target = new ArrayList<>();
|
||||
if (source.getTargets().size() > 1) {
|
||||
for (UUID targetId : source.getTargets().get(1).getTargets()) {
|
||||
Card card = game.getCard(targetId);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue