Revert "Added missing fields to many copy constructors. (#8957)" (#8999)

This reverts commit 82708e4273.

Some of these (AI related result in bloated memory usage, needs more investigation).
This commit is contained in:
Alex Vasile 2022-05-25 12:57:24 -06:00 committed by GitHub
parent 2f3831599d
commit 015cdf3136
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
79 changed files with 597 additions and 811 deletions

View file

@ -23,10 +23,10 @@ public abstract class TriggeredAbilityImpl extends AbilityImpl implements Trigge
protected boolean optional;
protected boolean leavesTheBattlefieldTrigger;
private boolean triggersOnce;
private boolean doOnlyOnce;
private GameEvent triggerEvent;
private String triggerPhrase;
private boolean triggersOnce = false;
private boolean doOnlyOnce = false;
private GameEvent triggerEvent = null;
private String triggerPhrase = null;
public TriggeredAbilityImpl(Zone zone, Effect effect) {
this(zone, effect, false);
@ -55,7 +55,6 @@ public abstract class TriggeredAbilityImpl extends AbilityImpl implements Trigge
this.triggersOnce = ability.triggersOnce;
this.doOnlyOnce = ability.doOnlyOnce;
this.triggerPhrase = ability.triggerPhrase;
this.triggerEvent = ability.triggerEvent;
}
@Override

View file

@ -15,8 +15,8 @@ import mage.target.targetpointer.FixedTarget;
*/
public class BlocksAttachedTriggeredAbility extends TriggeredAbilityImpl {
private final boolean setFixedTargetPointer;
private final String attachedDescription;
private boolean setFixedTargetPointer;
private String attachedDescription;
private boolean setFixedTargetPointerToBlocked;
public BlocksAttachedTriggeredAbility(Effect effect, String attachedDescription, boolean optional) {
@ -40,7 +40,6 @@ public class BlocksAttachedTriggeredAbility extends TriggeredAbilityImpl {
super(ability);
this.setFixedTargetPointer = ability.setFixedTargetPointer;
this.attachedDescription = ability.attachedDescription;
this.setFixedTargetPointerToBlocked = ability.setFixedTargetPointerToBlocked;
}
@Override

View file

@ -16,14 +16,13 @@ import java.util.UUID;
*/
public class CyclingDiscardCost extends CostImpl {
private MageObjectReference cycledCard;
private MageObjectReference cycledCard = null;
public CyclingDiscardCost() {
}
private CyclingDiscardCost(CyclingDiscardCost cost) {
super(cost);
this.cycledCard = cost.cycledCard;
}
@Override

View file

@ -49,7 +49,6 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements M
this.add(cost.copy());
}
this.phyrexian = costs.phyrexian;
this.phyrexianPaid = costs.phyrexianPaid;
}
@Override

View file

@ -42,7 +42,9 @@ public abstract class EffectImpl implements Effect {
if (effect.values != null) {
values = new HashMap<>();
Map<String, Object> map = effect.values;
values.putAll(map);
for (Map.Entry<String, Object> entry : map.entrySet()) {
values.put(entry.getKey(), entry.getValue());
}
}
}

View file

@ -21,7 +21,6 @@ public class DontUntapInControllersNextUntapStepSourceEffect extends ContinuousR
public DontUntapInControllersNextUntapStepSourceEffect(final DontUntapInControllersNextUntapStepSourceEffect effect) {
super(effect);
this.validForTurnNum = effect.validForTurnNum;
}
@Override

View file

@ -17,6 +17,7 @@ import mage.util.CardUtil;
public class ExileCardsFromTopOfLibraryTargetEffect extends OneShotEffect {
int amount;
String targetName;
public ExileCardsFromTopOfLibraryTargetEffect(int amount) {
this(amount, null);

View file

@ -10,10 +10,9 @@ import mage.game.ExileZone;
import mage.game.Game;
import mage.players.Player;
// TODO: Remove this class? Nothing uses it.
public class ReturnCreaturesFromExileEffect extends OneShotEffect {
private final UUID exileId;
private UUID exileId;
private boolean byOwner;
public ReturnCreaturesFromExileEffect(UUID exileId, boolean byOwner, String description) {
@ -24,10 +23,9 @@ public class ReturnCreaturesFromExileEffect extends OneShotEffect {
}
private ReturnCreaturesFromExileEffect(final ReturnCreaturesFromExileEffect effect) {
public ReturnCreaturesFromExileEffect(final ReturnCreaturesFromExileEffect effect) {
super(effect);
this.exileId = effect.exileId;
this.byOwner = effect.byOwner;
}
@Override

View file

@ -29,7 +29,6 @@ public class MustBeBlockedByAllAttachedEffect extends RequirementEffect {
public MustBeBlockedByAllAttachedEffect(final MustBeBlockedByAllAttachedEffect effect) {
super(effect);
this.attachmentType = effect.attachmentType;
}
@Override

View file

@ -11,7 +11,7 @@ import mage.game.permanent.Permanent;
*/
public class BecomesCreatureIfVehicleEffect extends ContinuousEffectImpl {
private static final CardType addedType = CardType.CREATURE;
private CardType addedType = CardType.CREATURE;
public BecomesCreatureIfVehicleEffect() {
super(Duration.WhileOnBattlefield, Layer.TypeChangingEffects_4, SubLayer.NA, Outcome.Benefit);

View file

@ -22,7 +22,7 @@ public class BecomesCreatureTargetEffect extends ContinuousEffectImpl {
protected boolean addStillALandText;
protected boolean loseName;
protected boolean keepAbilities;
protected boolean removeSubtypes;
protected boolean removeSubtypes = false;
public BecomesCreatureTargetEffect(Token token, boolean loseAllAbilities, boolean stillALand, Duration duration) {
@ -58,7 +58,6 @@ public class BecomesCreatureTargetEffect extends ContinuousEffectImpl {
this.addStillALandText = effect.addStillALandText;
this.loseName = effect.loseName;
this.keepAbilities = effect.keepAbilities;
this.removeSubtypes = effect.removeSubtypes;
}
@Override

View file

@ -57,7 +57,6 @@ public class GainControlTargetEffect extends ContinuousEffectImpl {
super(effect);
this.controllingPlayerId = effect.controllingPlayerId;
this.fixedControl = effect.fixedControl;
this.firstControlChange = effect.firstControlChange;
}
@Override

View file

@ -32,7 +32,7 @@ public class AmassEffect extends OneShotEffect {
}
private final DynamicValue amassNumber;
private UUID amassedCreatureId;
private UUID amassedCreatureId = null;
public AmassEffect(int amassNumber) {
this(StaticValue.get(amassNumber));
@ -53,7 +53,6 @@ public class AmassEffect extends OneShotEffect {
private AmassEffect(final AmassEffect effect) {
super(effect);
this.amassNumber = effect.amassNumber;
this.amassedCreatureId = effect.amassedCreatureId;
}
@Override

View file

@ -39,7 +39,6 @@ public class ProtectionChosenColorAttachedEffect extends ContinuousEffectImpl {
this.protectionAbility = effect.protectionAbility.copy();
}
this.notRemoveItself = effect.notRemoveItself;
this.notRemoveControlled = effect.notRemoveControlled;
}
@Override

View file

@ -135,7 +135,7 @@ class ReturnAttackerToHandTargetCost extends CostImpl {
filter.add(UnblockedPredicate.instance);
}
private UUID defendingPlayerId;
private UUID defendingPlayerId = null;
public ReturnAttackerToHandTargetCost() {
this.addTarget(new TargetControlledPermanent(filter));
@ -144,7 +144,6 @@ class ReturnAttackerToHandTargetCost extends CostImpl {
public ReturnAttackerToHandTargetCost(ReturnAttackerToHandTargetCost cost) {
super(cost);
this.defendingPlayerId = cost.defendingPlayerId;
}
@Override
@ -153,7 +152,8 @@ class ReturnAttackerToHandTargetCost extends CostImpl {
for (UUID targetId : targets.get(0).getTargets()) {
Permanent permanent = game.getPermanent(targetId);
Player controller = game.getPlayer(controllerId);
if (permanent == null || controller == null) {
if (permanent == null
|| controller == null) {
return false;
}
defendingPlayerId = game.getCombat().getDefenderId(permanent.getId());

View file

@ -12,8 +12,8 @@ import mage.util.CardUtil;
public class VanishingUpkeepAbility extends BeginningOfUpkeepTriggeredAbility {
private final int vanishingAmount;
private final String permanentType;
private int vanishingAmount;
private String permanentType;
public VanishingUpkeepAbility(int vanishingEffect) {
super(new VanishingEffect(), TargetController.YOU, false);
@ -27,10 +27,9 @@ public class VanishingUpkeepAbility extends BeginningOfUpkeepTriggeredAbility {
this.permanentType = permanentType;
}
private VanishingUpkeepAbility(final VanishingUpkeepAbility ability) {
public VanishingUpkeepAbility(final VanishingUpkeepAbility ability) {
super(ability);
this.vanishingAmount = ability.vanishingAmount;
this.permanentType = ability.permanentType;
}
@Override
@ -64,16 +63,15 @@ class VanishingEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent p = game.getPermanent(source.getSourceId());
if (p == null) {
return false;
if (p != null) {
int amount = p.getCounters(game).getCount(CounterType.TIME);
if (amount > 0) {
p.removeCounters(CounterType.TIME.createInstance(), source, game);
game.informPlayers("Removed a time counter from " + p.getLogName() + " (" + amount + " left)");
}
return true;
}
int amount = p.getCounters(game).getCount(CounterType.TIME);
if (amount > 0) {
p.removeCounters(CounterType.TIME.createInstance(), source, game);
game.informPlayers("Removed a time counter from " + p.getLogName() + " (" + amount + " left)");
}
return true;
return false;
}
@Override

View file

@ -73,7 +73,7 @@ class AnyColorLandsProduceManaEffect extends ManaEffect {
private final FilterPermanent filter;
private final boolean onlyColors; // false if mana types can be produced (also Colorless mana), if true only colors can be produced (no Colorless mana).
private boolean inManaTypeCalculation;
private boolean inManaTypeCalculation = false;
AnyColorLandsProduceManaEffect(TargetController targetController, boolean onlyColors, FilterPermanent filter) {
super();
@ -93,7 +93,6 @@ class AnyColorLandsProduceManaEffect extends ManaEffect {
super(effect);
this.filter = effect.filter.copy();
this.onlyColors = effect.onlyColors;
this.inManaTypeCalculation = effect.inManaTypeCalculation;
}
@Override

View file

@ -57,7 +57,7 @@ class AnyColorPermanentTypesManaEffect extends ManaEffect {
private final FilterPermanent filter;
private final boolean onlyColors; // false if mana types can be produced (also Colorless mana), if true only colors can be produced (no Colorless mana).
private boolean inManaTypeCalculation;
private boolean inManaTypeCalculation = false;
public AnyColorPermanentTypesManaEffect(TargetController targetController, boolean onlyColors, FilterPermanent permanentTypes) {
super();
@ -72,7 +72,6 @@ class AnyColorPermanentTypesManaEffect extends ManaEffect {
super(effect);
this.filter = effect.filter.copy();
this.onlyColors = effect.onlyColors;
this.inManaTypeCalculation = effect.inManaTypeCalculation;
}
@Override

View file

@ -85,9 +85,9 @@ public class GameState implements Serializable, Copyable<GameState> {
private Exile exile;
private Battlefield battlefield;
private int turnNum = 1;
private int stepNum;
private UUID turnId;
private boolean extraTurn;
private int stepNum = 0;
private UUID turnId = null;
private boolean extraTurn = false;
private boolean legendaryRuleActive = true;
private boolean gameOver;
private boolean paused;
@ -105,8 +105,8 @@ public class GameState implements Serializable, Copyable<GameState> {
private int permanentOrderNumber;
private final Map<UUID, FilterCreaturePermanent> usePowerInsteadOfToughnessForDamageLethalityFilters = new HashMap<>();
private Set<MageObjectReference> commandersToStay = new HashSet<>(); // commanders that do not go back to command zone
private boolean manaBurn;
private boolean hasDayNight;
private boolean manaBurn = false;
private boolean hasDayNight = false;
private boolean isDaytime = true;
private int applyEffectsCounter; // Upcounting number of each applyEffects execution
@ -157,7 +157,6 @@ public class GameState implements Serializable, Copyable<GameState> {
this.battlefield = state.battlefield.copy();
this.turnNum = state.turnNum;
this.stepNum = state.stepNum;
this.turnId = state.turnId;
this.extraTurn = state.extraTurn;
this.legendaryRuleActive = state.legendaryRuleActive;
this.effects = state.effects.copy();
@ -200,7 +199,6 @@ public class GameState implements Serializable, Copyable<GameState> {
this.commandersToStay.addAll(state.commandersToStay);
this.hasDayNight = state.hasDayNight;
this.isDaytime = state.isDaytime;
this.manaBurn = state.manaBurn;
}
public void clearOnGameRestart() {

View file

@ -39,7 +39,6 @@ public abstract class GameTinyLeadersImpl extends GameImpl {
public GameTinyLeadersImpl(final GameTinyLeadersImpl game) {
super(game);
this.alsoHand = game.alsoHand;
this.alsoLibrary = game.alsoLibrary;
this.startingPlayerSkipsDraw = game.startingPlayerSkipsDraw;
}
@ -51,37 +50,35 @@ public abstract class GameTinyLeadersImpl extends GameImpl {
// move tiny leader to command zone
for (UUID playerId : state.getPlayerList(startingPlayerId)) {
Player player = getPlayer(playerId);
if (player == null) {
continue;
}
String commanderName = player.getMatchPlayer().getDeck().getName();
Card commander = findCommander(this, player, commanderName);
if (commander != null) {
// already exists - just move to zone (example: game restart by Karn Liberated)
commander.moveToZone(Zone.COMMAND, null, this, true);
} else {
// create new commander
commander = getCommanderCard(commanderName, player.getId());
if (player != null) {
String commanderName = player.getMatchPlayer().getDeck().getName();
Card commander = findCommander(this, player, commanderName);
if (commander != null) {
Set<Card> cards = new HashSet<>();
cards.add(commander);
this.loadCards(cards, playerId);
player.addCommanderId(commander.getId());
// already exists - just move to zone (example: game restart by Karn Liberated)
commander.moveToZone(Zone.COMMAND, null, this, true);
Ability ability = new SimpleStaticAbility(Zone.COMMAND, new InfoEffect("Commander effects"));
ability.addEffect(new CommanderReplacementEffect(commander.getId(), alsoHand, alsoLibrary, false, "Commander"));
ability.addEffect(new CommanderCostModification(commander));
// Commander rule #4 was removed Jan. 18, 2016
// ability.addEffect(new CommanderManaReplacementEffect(player.getId(), CardUtil.getColorIdentity(commander)));
CommanderInfoWatcher watcher = new CommanderInfoWatcher("Commander", commander.getId(), false);
getState().addWatcher(watcher);
watcher.addCardInfoToCommander(this);
this.getState().addAbility(ability, null);
} else {
// GameWorker.call processing errors and write it in magediag.log by defalt
// Test use case: create tiny game with random generated deck - game freezes with empty battlefield
throw new IllegalStateException("Commander card could not be created. Name: [" + player.getMatchPlayer().getDeck().getName() + ']');
// create new commander
commander = getCommanderCard(commanderName, player.getId());
if (commander != null) {
Set<Card> cards = new HashSet<>();
cards.add(commander);
this.loadCards(cards, playerId);
player.addCommanderId(commander.getId());
commander.moveToZone(Zone.COMMAND, null, this, true);
Ability ability = new SimpleStaticAbility(Zone.COMMAND, new InfoEffect("Commander effects"));
ability.addEffect(new CommanderReplacementEffect(commander.getId(), alsoHand, alsoLibrary, false, "Commander"));
ability.addEffect(new CommanderCostModification(commander));
// Commander rule #4 was removed Jan. 18, 2016
// ability.addEffect(new CommanderManaReplacementEffect(player.getId(), CardUtil.getColorIdentity(commander)));
CommanderInfoWatcher watcher = new CommanderInfoWatcher("Commander", commander.getId(), false);
getState().addWatcher(watcher);
watcher.addCardInfoToCommander(this);
this.getState().addAbility(ability, null);
} else {
// GameWorker.call processing errors and write it in magediag.log by defalt
// Test use case: create tiny game with random generated deck - game freezes with empty battlefield
throw new IllegalStateException("Commander card could not be created. Name: [" + player.getMatchPlayer().getDeck().getName() + ']');
}
}
}
}

View file

@ -73,9 +73,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
protected boolean morphed = false;
protected int classLevel = 1;
protected final Set<UUID> goadingPlayers = new HashSet<>();
// The UUID of the controller under who the permanent first entered the battelfield under.
protected UUID originalControllerId;
// The UUID of the current controller.
protected UUID controllerId;
protected UUID beforeResetControllerId;
protected int damage;
@ -131,7 +129,6 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
this.flipped = permanent.flipped;
this.originalControllerId = permanent.originalControllerId;
this.controllerId = permanent.controllerId;
this.beforeResetControllerId = permanent.controllerId;
this.damage = permanent.damage;
this.controlledFromStartOfControllerTurn = permanent.controlledFromStartOfControllerTurn;
this.turnsOnBattlefield = permanent.turnsOnBattlefield;
@ -144,9 +141,11 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
this.deathtouched = permanent.deathtouched;
this.markedLifelink = permanent.markedLifelink;
this.connectedCards.putAll(permanent.connectedCards);
for (Map.Entry<String, List<UUID>> entry : permanent.connectedCards.entrySet()) {
this.connectedCards.put(entry.getKey(), entry.getValue());
}
if (permanent.dealtDamageByThisTurn != null) {
this.dealtDamageByThisTurn = new HashSet<>(permanent.dealtDamageByThisTurn);
dealtDamageByThisTurn = new HashSet<>(permanent.dealtDamageByThisTurn);
}
if (permanent.markedDamage != null) {
markedDamage = new ArrayList<>();
@ -172,7 +171,6 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
this.bandedCards.addAll(permanent.bandedCards);
this.timesLoyaltyUsed = permanent.timesLoyaltyUsed;
this.transformCount = permanent.transformCount;
this.removedFromCombat = permanent.removedFromCombat;
this.morphed = permanent.morphed;
this.manifested = permanent.manifested;
@ -195,14 +193,6 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
abilities.setControllerId(controllerId);
}
/**
* Used to override the original controller of a permanent to be different than the player who cast the spell
* or activated the ability.
*
* E.g. Xantcha, Sleeper Agent. Who enters the battlefield directly under someone else's control.
*
* @param originalControllerId The UUID of the original controller of the permanent
*/
@Override
public void setOriginalControllerId(UUID originalControllerId) {
this.originalControllerId = originalControllerId;
@ -774,7 +764,6 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
@Override
public boolean checkControlChanged(Game game) {
// TODO Put a break point and see what's going on with controllerID, beforeResetControllerID, and originalControllerID
if (!controllerId.equals(beforeResetControllerId)) {
this.removeFromCombat(game);
this.controlledFromStartOfControllerTurn = false;
@ -915,7 +904,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
* @return
*/
private int doDamage(int damageAmount, UUID attackerId, Ability source, Game game, boolean preventable, boolean combat, boolean markDamage, List<UUID> appliedEffects) {
int damageDone;
int damageDone = 0;
if (damageAmount < 1 || !canDamage(game.getObject(attackerId), game)) {
return 0;
}
@ -1769,22 +1758,20 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
public boolean moveToZone(Zone toZone, Ability source, Game game, boolean flag, List<UUID> appliedEffects) {
Zone fromZone = game.getState().getZone(objectId);
Player controller = game.getPlayer(controllerId);
if (controller == null) {
return false;
if (controller != null) {
ZoneChangeEvent event = new ZoneChangeEvent(this, source, controllerId, fromZone, toZone, appliedEffects);
ZoneChangeInfo zoneChangeInfo;
if (toZone == Zone.LIBRARY) {
zoneChangeInfo = new ZoneChangeInfo.Library(event, flag /* put on top */);
} else {
zoneChangeInfo = new ZoneChangeInfo(event);
}
boolean successfullyMoved = ZonesHandler.moveCard(zoneChangeInfo, game, source);
//20180810 - 701.3d
detachAllAttachments(game);
return successfullyMoved;
}
ZoneChangeEvent event = new ZoneChangeEvent(this, source, controllerId, fromZone, toZone, appliedEffects);
ZoneChangeInfo zoneChangeInfo;
if (toZone == Zone.LIBRARY) {
zoneChangeInfo = new ZoneChangeInfo.Library(event, flag /* put on top */);
} else {
zoneChangeInfo = new ZoneChangeInfo(event);
}
boolean successfullyMoved = ZonesHandler.moveCard(zoneChangeInfo, game, source);
//20180810 - 701.3d
detachAllAttachments(game);
return successfullyMoved;
return false;
}
@Override

View file

@ -81,7 +81,6 @@ public abstract class TokenImpl extends MageObjectImpl implements Token {
this.expansionSetCodeChecked = token.expansionSetCodeChecked;
this.copySourceCard = token.copySourceCard; // will never be changed
this.availableImageSetCodes = token.availableImageSetCodes;
this.tokenDescriptor = token.tokenDescriptor;
}
@Override

View file

@ -30,7 +30,6 @@ public class SpellStack extends ArrayDeque<StackObject> {
for (StackObject spell : stack) {
this.addLast(spell.copy());
}
this.dateLastAdded = stack.dateLastAdded;
}
//resolve top StackObject