Refactor: replaced sourceId by source and introduced source param in some methods;

This commit is contained in:
Oleg Agafonov 2020-12-12 20:23:19 +04:00
parent 2bb472607b
commit db239a1055
3205 changed files with 7080 additions and 6795 deletions

View file

@ -59,8 +59,6 @@ public class AuraReplacementEffect extends ReplacementEffectImpl {
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Zone fromZone = ((ZoneChangeEvent) event).getFromZone();
Card card = game.getCard(event.getTargetId());
UUID sourceId = event.getSourceId();
UUID controllerId = event.getPlayerId();
if (card == null) {
return false;
}
@ -95,7 +93,7 @@ public class AuraReplacementEffect extends ReplacementEffectImpl {
}
UUID targetId = null;
MageObject sourceObject = game.getObject(sourceId);
MageObject sourceObject = game.getObject(event.getSourceId());
boolean enchantCardInGraveyard = false;
if (sourceObject instanceof StackAbility) {
StackAbility stackAbility = (StackAbility) sourceObject;
@ -157,25 +155,25 @@ public class AuraReplacementEffect extends ReplacementEffectImpl {
if (targetCard != null || targetPermanent != null || targetPlayer != null) {
if (firstCardFace != null) {
// transforming card. remove first face (original card) from old zone
firstCardFace.removeFromZone(game, fromZone, sourceId);
firstCardFace.removeFromZone(game, fromZone, source);
} else {
card.removeFromZone(game, fromZone, sourceId);
card.removeFromZone(game, fromZone, source);
}
PermanentCard permanent = new PermanentCard(card, (controllingPlayer == null ? card.getOwnerId() : controllingPlayer.getId()), game);
ZoneChangeEvent zoneChangeEvent = new ZoneChangeEvent(permanent, controllerId, fromZone, Zone.BATTLEFIELD);
ZoneChangeEvent zoneChangeEvent = new ZoneChangeEvent(permanent, event.getPlayerId(), fromZone, Zone.BATTLEFIELD);
permanent.updateZoneChangeCounter(game, zoneChangeEvent);
game.addPermanent(permanent, 0);
card.setZone(Zone.BATTLEFIELD, game);
if (permanent.entersBattlefield(event.getSourceId(), game, fromZone, true)) {
if (permanent.entersBattlefield(source, game, fromZone, true)) {
String attachToName = null;
if (targetCard != null) {
permanent.attachTo(targetCard.getId(), game);
permanent.attachTo(targetCard.getId(), source, game);
attachToName = targetCard.getLogName();
} else if (targetPermanent != null) {
targetPermanent.addAttachment(permanent.getId(), game);
targetPermanent.addAttachment(permanent.getId(), source, game);
attachToName = targetPermanent.getLogName();
} else if (targetPlayer != null) {
targetPlayer.addAttachment(permanent.getId(), game);
targetPlayer.addAttachment(permanent.getId(), source, game);
attachToName = targetPlayer.getLogName();
}
game.applyEffects();

View file

@ -419,7 +419,7 @@ public class ContinuousEffects implements Serializable {
return true;
}
MageObject object;
if (event.getType() == EventType.ZONE_CHANGE
if (event.getType() == GameEvent.EventType.ZONE_CHANGE
&& ((ZoneChangeEvent) event).getFromZone() == Zone.BATTLEFIELD
&& event.getTargetId().equals(ability.getSourceId())) {
object = ((ZoneChangeEvent) event).getTarget();

View file

@ -107,25 +107,23 @@ public class EntersBattlefieldEffect extends ReplacementEffectImpl {
return false;
}
}
Spell spell = game.getStack().getSpell(event.getSourceId());
if (spell == null) {
Spell entersBySpell = game.getStack().getSpell(event.getSourceId());
if (entersBySpell == null) {
StackObject stackObject = (StackObject) game.getLastKnownInformation(event.getSourceId(), Zone.STACK);
if (stackObject instanceof Spell) {
spell = (Spell) stackObject;
entersBySpell = (Spell) stackObject;
}
}
for (Effect effect : baseEffects) {
// if (source.activate(game, false)) { // Why is this needed????
if (effect instanceof ContinuousEffect) {
game.addEffect((ContinuousEffect) effect, source);
} else {
if (spell != null) {
effect.setValue(SOURCE_CAST_SPELL_ABILITY, spell.getSpellAbility());
if (entersBySpell != null) {
effect.setValue(SOURCE_CAST_SPELL_ABILITY, entersBySpell.getSpellAbility());
}
effect.setValue("appliedEffects", event.getAppliedEffects());
effect.apply(game, source);
}
// }
}
return false;
}

View file

@ -82,9 +82,9 @@ public abstract class PayCostToAttackBlockEffectImpl extends ReplacementEffectIm
case ATTACK:
return event.getType() == GameEvent.EventType.DECLARE_ATTACKER;
case BLOCK:
return event.getType() == EventType.DECLARE_BLOCKER;
return event.getType() == GameEvent.EventType.DECLARE_BLOCKER;
case ATTACK_AND_BLOCK:
return event.getType() == GameEvent.EventType.DECLARE_ATTACKER || event.getType() == EventType.DECLARE_BLOCKER;
return event.getType() == GameEvent.EventType.DECLARE_ATTACKER || event.getType() == GameEvent.EventType.DECLARE_BLOCKER;
}
return false;
}
@ -106,16 +106,16 @@ public abstract class PayCostToAttackBlockEffectImpl extends ReplacementEffectIm
Player player = game.getPlayer(event.getPlayerId());
if (player != null) {
String chooseText;
if (event.getType() == EventType.DECLARE_ATTACKER) {
if (event.getType() == GameEvent.EventType.DECLARE_ATTACKER) {
chooseText = "Pay " + attackBlockManaTax.getText() + " to attack?";
} else {
chooseText = "Pay " + attackBlockManaTax.getText() + " to block?";
}
attackBlockManaTax.clearPaid();
if (attackBlockManaTax.canPay(source, source.getSourceId(), player.getId(), game)
if (attackBlockManaTax.canPay(source, source, player.getId(), game)
&& player.chooseUse(Outcome.Neutral, chooseText, source, game)) {
if (attackBlockManaTax instanceof ManaCostsImpl) {
if (attackBlockManaTax.payOrRollback(source, game, source.getSourceId(), event.getPlayerId())) {
if (attackBlockManaTax.payOrRollback(source, game, source, event.getPlayerId())) {
return false;
}
}
@ -129,10 +129,10 @@ public abstract class PayCostToAttackBlockEffectImpl extends ReplacementEffectIm
Player player = game.getPlayer(event.getPlayerId());
if (player != null) {
attackBlockOtherTax.clearPaid();
if (attackBlockOtherTax.canPay(source, source.getSourceId(), event.getPlayerId(), game)
if (attackBlockOtherTax.canPay(source, source, event.getPlayerId(), game)
&& player.chooseUse(Outcome.Neutral,
attackBlockOtherTax.getText() + " to " + (event.getType() == EventType.DECLARE_ATTACKER ? "attack?" : "block?"), source, game)) {
if (attackBlockOtherTax.pay(source, game, source.getSourceId(), event.getPlayerId(), false, null)) {
attackBlockOtherTax.getText() + " to " + (event.getType() == GameEvent.EventType.DECLARE_ATTACKER ? "attack?" : "block?"), source, game)) {
if (attackBlockOtherTax.pay(source, game, source, event.getPlayerId(), false, null)) {
return false;
}
}

View file

@ -59,7 +59,7 @@ public class PhantomPreventionEffect extends PreventionEffectImpl {
if(removeCounter && permanent.getCounters(game).containsKey(CounterType.P1P1)) {
StringBuilder sb = new StringBuilder(permanent.getName()).append(": ");
permanent.removeCounters(CounterType.P1P1.createInstance(), game);
permanent.removeCounters(CounterType.P1P1.createInstance(), source, game);
sb.append("Removed a +1/+1 counter ");
game.informPlayers(sb.toString());
}

View file

@ -40,7 +40,7 @@ public class PlaneswalkerRedirectionEffect extends RedirectionEffect {
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.DAMAGE_PLAYER;
return event.getType() == GameEvent.EventType.DAMAGE_PLAYER;
}
@Override

View file

@ -51,7 +51,7 @@ public class PreventDamageAndRemoveCountersEffect extends PreventionEffectImpl {
if (!thatMany) {
damage = 1;
}
permanent.removeCounters(CounterType.P1P1.createInstance(damage), game); //MTG ruling (this) loses counters even if the damage isn't prevented
permanent.removeCounters(CounterType.P1P1.createInstance(damage), source, game); //MTG ruling (this) loses counters even if the damage isn't prevented
return false;
}

View file

@ -88,12 +88,12 @@ public abstract class RedirectionEffect extends ReplacementEffectImpl {
}
Permanent permanent = game.getPermanent(redirectTarget.getFirstTarget());
if (permanent != null) {
permanent.damage(damageToRedirect, event.getSourceId(), game, damageEvent.isCombatDamage(), damageEvent.isPreventable(), event.getAppliedEffects());
permanent.damage(damageToRedirect, event.getSourceId(), source, game, damageEvent.isCombatDamage(), damageEvent.isPreventable(), event.getAppliedEffects());
game.informPlayers(sourceLogName + "Redirected " + damageToRedirect + " damage" + getRedirectedFromText(event, game) + " to " + permanent.getLogName());
} else {
Player player = game.getPlayer(redirectTarget.getFirstTarget());
if (player != null) {
player.damage(damageToRedirect, event.getSourceId(), game, damageEvent.isCombatDamage(), damageEvent.isPreventable(), event.getAppliedEffects());
player.damage(damageToRedirect, event.getSourceId(), source, game, damageEvent.isCombatDamage(), damageEvent.isPreventable(), event.getAppliedEffects());
game.informPlayers(sourceLogName + "Redirected " + damageToRedirect + " damage" + getRedirectedFromText(event, game) + " to " + player.getLogName());
}
}

View file

@ -43,16 +43,16 @@ public class AttachEffect extends OneShotEffect {
|| zcc == source.getSourceObjectZoneChangeCounter() + 2) {
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (permanent != null) {
return permanent.addAttachment(source.getSourceId(), game);
return permanent.addAttachment(source.getSourceId(), source, game);
} else {
Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
if (player != null) {
return player.addAttachment(source.getSourceId(), game);
return player.addAttachment(source.getSourceId(), source, game);
}
if (!source.getTargets().isEmpty() && source.getTargets().get(0) instanceof TargetCard) { // e.g. Spellweaver Volute
Card card = game.getCard(getTargetPointer().getFirst(game, source));
if (card != null) {
return card.addAttachment(source.getSourceId(), game);
return card.addAttachment(source.getSourceId(), source, game);
}
}
}

View file

@ -92,7 +92,7 @@ public class BalanceEffect extends OneShotEffect {
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null && cardsToDiscard.get(playerId) != null) {
player.discard(cardsToDiscard.get(playerId), source, game);
player.discard(cardsToDiscard.get(playerId), false, source, game);
}
}
@ -145,7 +145,7 @@ public class BalanceEffect extends OneShotEffect {
for (Permanent permanent : permanentsToSacrifice) {
if (permanent != null) {
permanent.sacrifice(source.getSourceId(), game);
permanent.sacrifice(source, game);
}
}
}

View file

@ -52,17 +52,14 @@ public class BecomeBlockedTargetEffect extends OneShotEffect {
if (alreadyBlocked) {
continue;
}
game.fireEvent(GameEvent.getEvent(
GameEvent.EventType.CREATURE_BLOCKED, permanent.getId(),
source.getSourceId(), null
));
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.CREATURE_BLOCKED, permanent.getId(), source, null));
morSet.add(new MageObjectReference(permanent, game));
}
String key = UUID.randomUUID().toString();
game.getState().setValue("becameBlocked_" + key, morSet);
game.fireEvent(GameEvent.getEvent(
GameEvent.EventType.BATCH_BLOCK_NONCOMBAT,
source.getSourceId(), source.getSourceId(),
source.getSourceId(), source,
source.getControllerId(), key, 0)
);
return true;

View file

@ -29,7 +29,7 @@ public class BrainstormEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
player.drawCards(3, source.getSourceId(), game);
player.drawCards(3, source, game);
putOnLibrary(player, source, game);
putOnLibrary(player, source, game);
return true;
@ -43,7 +43,7 @@ public class BrainstormEffect extends OneShotEffect {
player.chooseTarget(Outcome.ReturnToHand, target, source, game);
Card card = player.getHand().get(target.getFirstTarget(), game);
if (card != null) {
return player.moveCardToLibraryWithInfo(card, source.getSourceId(), game, Zone.HAND, true, false);
return player.moveCardToLibraryWithInfo(card, source, game, Zone.HAND, true, false);
}
}
return false;

View file

@ -55,7 +55,7 @@ public class CantBeCounteredControlledEffect extends ContinuousRuleModifyingEffe
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.COUNTER;
return event.getType() == GameEvent.EventType.COUNTER;
}
@Override

View file

@ -50,7 +50,7 @@ public class CantBeCounteredSourceEffect extends ContinuousRuleModifyingEffectIm
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.COUNTER;
return event.getType() == GameEvent.EventType.COUNTER;
}
@Override

View file

@ -37,7 +37,7 @@ public class CantBeRegeneratedSourceEffect extends ContinuousRuleModifyingEffect
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.REGENERATE;
return event.getType() == GameEvent.EventType.REGENERATE;
}
@Override

View file

@ -36,7 +36,7 @@ public class CantBeRegeneratedTargetEffect extends ContinuousRuleModifyingEffect
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.REGENERATE;
return event.getType() == GameEvent.EventType.REGENERATE;
}
@Override

View file

@ -58,7 +58,7 @@ public class CantBeTargetedAllEffect extends ContinuousRuleModifyingEffectImpl {
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.TARGET;
return event.getType() == GameEvent.EventType.TARGET;
}
@Override

View file

@ -52,7 +52,7 @@ public class CantBeTargetedAttachedEffect extends ContinuousRuleModifyingEffectI
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.TARGET;
return event.getType() == GameEvent.EventType.TARGET;
}
@Override

View file

@ -44,7 +44,7 @@ public class CantBeTargetedSourceEffect extends ContinuousRuleModifyingEffectImp
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.TARGET;
return event.getType() == GameEvent.EventType.TARGET;
}
@Override

View file

@ -52,7 +52,7 @@ public class CantBeTargetedTargetEffect extends ContinuousRuleModifyingEffectImp
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.TARGET;
return event.getType() == GameEvent.EventType.TARGET;
}
@Override

View file

@ -65,7 +65,7 @@ public class CipherEffect extends OneShotEffect {
if (controller != null) {
TargetControlledCreaturePermanent target = new TargetControlledCreaturePermanent();
target.setNotTarget(true);
if (target.canChoose(source.getControllerId(), game)
if (target.canChoose(source.getSourceId(), source.getControllerId(), game)
&& controller.chooseUse(outcome, "Cipher this spell to a creature?", source, game)) {
controller.chooseTarget(outcome, target, source, game);
Card sourceCard = game.getCard(source.getSourceId());

View file

@ -86,7 +86,7 @@ public class ClashEffect extends OneShotEffect implements MageSingleton {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller != null && sourceObject != null
&& !game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.CLASH, controller.getId(), controller.getId()))) {
&& !game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.CLASH, controller.getId(), source, controller.getId()))) {
// choose opponent
Target target = new TargetOpponent(true);
target.setTargetName("an opponent to clash with");
@ -152,10 +152,10 @@ public class ClashEffect extends OneShotEffect implements MageSingleton {
} while (nextPlayer != null && !nextPlayer.getId().equals(game.getActivePlayerId()));
// put the cards back to library
if (cardController != null) {
controller.moveCardToLibraryWithInfo(cardController, source.getSourceId(), game, Zone.LIBRARY, topController, true);
controller.moveCardToLibraryWithInfo(cardController, source, game, Zone.LIBRARY, topController, true);
}
if (cardOpponent != null) {
opponent.moveCardToLibraryWithInfo(cardOpponent, source.getSourceId(), game, Zone.LIBRARY, topOpponent, true);
opponent.moveCardToLibraryWithInfo(cardOpponent, source, game, Zone.LIBRARY, topOpponent, true);
}
// fire CLASHED event with info about who won
String winner = "draw";
@ -165,7 +165,7 @@ public class ClashEffect extends OneShotEffect implements MageSingleton {
if (cmcOpponent > cmcController) {
winner = "opponent";
}
GameEvent gameEvent = new GameEvent(EventType.CLASHED, opponent.getId(), source.getSourceId(), controller.getId());
GameEvent gameEvent = new GameEvent(GameEvent.EventType.CLASHED, opponent.getId(), source, controller.getId());
gameEvent.setData(winner);
game.fireEvent(gameEvent);

View file

@ -156,9 +156,9 @@ public class CopyPermanentEffect extends OneShotEffect {
Permanent targetPermanent = game.getPermanent(targetId);
Player targetPlayer = game.getPlayer(targetId);
if (targetPermanent != null) {
targetPermanent.addAttachment(sourcePermanent.getId(), game);
targetPermanent.addAttachment(sourcePermanent.getId(), source, game);
} else if (targetPlayer != null) {
targetPlayer.addAttachment(sourcePermanent.getId(), game);
targetPlayer.addAttachment(sourcePermanent.getId(), source, game);
} else {
return false;
}

View file

@ -10,6 +10,7 @@ import mage.filter.FilterImpl;
import mage.filter.FilterInPlay;
import mage.filter.predicate.mageobject.FromSetPredicate;
import mage.game.Game;
import mage.game.events.CopiedStackObjectEvent;
import mage.game.events.GameEvent;
import mage.game.stack.Spell;
import mage.players.Player;
@ -164,8 +165,7 @@ public abstract class CopySpellForEachItCouldTargetEffect<T extends MageItem> ex
Spell chosenCopy = targetCopyMap.get(chosenId);
if (chosenCopy != null) {
game.getStack().push(chosenCopy);
game.fireEvent(new GameEvent(GameEvent.EventType.COPIED_STACKOBJECT,
chosenCopy.getId(), spell.getId(), source.getControllerId()));
game.fireEvent(new CopiedStackObjectEvent(spell, chosenCopy, source.getControllerId()));
toDelete.add(chosenId);
madeACopy = true;
}

View file

@ -53,7 +53,7 @@ public class CounterTargetAndSearchGraveyardHandLibraryEffect extends SearchTarg
cardName = targetObject.getName();
}
searchPlayerId = stackObject.getControllerId();
result = game.getStack().counter(objectId, source.getSourceId(), game);
result = game.getStack().counter(objectId, source, game);
}
}
// 5/1/2008: If the targeted spell can't be countered (it's Vexing Shusher, for example),

View file

@ -31,7 +31,7 @@ public class CounterTargetEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
boolean countered = false;
for (UUID targetId : getTargetPointer().getTargets(game, source)) {
if (game.getStack().counter(targetId, source.getSourceId(), game)) {
if (game.getStack().counter(targetId, source, game)) {
countered = true;
}
}

View file

@ -49,7 +49,7 @@ public class CounterTargetWithReplacementEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
return game.getStack().counter(targetPointer.getFirst(game, source), source.getSourceId(), game, targetZone, false, zoneDetail);
return game.getStack().counter(targetPointer.getFirst(game, source), source, game, targetZone, false, zoneDetail);
}
return false;
}

View file

@ -68,9 +68,10 @@ public class CounterUnlessPaysEffect extends OneShotEffect {
}
costToPay.clearPaid();
if (!(player.chooseUse(Outcome.Benefit, message, source, game) && costToPay.pay(source, game, spell.getSourceId(), spell.getControllerId(), false, null))) {
if (!(player.chooseUse(Outcome.Benefit, message, source, game)
&& costToPay.pay(source, game, source, spell.getControllerId(), false, null))) {
game.informPlayers(player.getLogName() + " chooses not to pay " + costValueMessage + " to prevent the counter effect");
return game.getStack().counter(spell.getId(), source.getSourceId(), game);
return game.getStack().counter(spell.getId(), source, game);
}
game.informPlayers(player.getLogName() + " chooses to pay " + costValueMessage + " to prevent the counter effect");
return true;

View file

@ -211,7 +211,7 @@ public class CreateTokenCopyTargetEffect extends OneShotEffect {
}
additionalAbilities.stream().forEach(token::addAbility);
token.putOntoBattlefield(number, game, source.getSourceId(), playerId == null ? source.getControllerId() : playerId, tapped, attacking, attackedPlayer);
token.putOntoBattlefield(number, game, source, playerId == null ? source.getControllerId() : playerId, tapped, attacking, attackedPlayer);
for (UUID tokenId : token.getLastAddedTokenIds()) { // by cards like Doubling Season multiple tokens can be added to the battlefield
Permanent tokenPermanent = game.getPermanent(tokenId);
if (tokenPermanent != null) {

View file

@ -74,7 +74,7 @@ public class CreateTokenEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
int value = amount.calculate(game, source, this);
token.putOntoBattlefield(value, game, source.getSourceId(), source.getControllerId(), tapped, attacking);
token.putOntoBattlefield(value, game, source, source.getControllerId(), tapped, attacking);
this.lastAddedTokenId = token.getLastAddedToken();
this.lastAddedTokenIds = token.getLastAddedTokenIds();

View file

@ -57,7 +57,7 @@ public class CreateTokenTargetEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
int value = amount.calculate(game, source, this);
if (value > 0) {
return token.putOntoBattlefield(value, game, source.getSourceId(), targetPointer.getFirst(game, source), tapped, attacking);
return token.putOntoBattlefield(value, game, source, targetPointer.getFirst(game, source), tapped, attacking);
}
return true;
}

View file

@ -43,7 +43,7 @@ public class DamageAllControlledTargetEffect extends OneShotEffect {
return false;
}
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, player.getId(), game)) {
permanent.damage(amount, source.getSourceId(), game, false, true);
permanent.damage(amount, source.getSourceId(), source, game, false, true);
}
return true;
}

View file

@ -56,7 +56,7 @@ public class DamageAllEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
List<Permanent> permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game);
for (Permanent permanent : permanents) {
permanent.damage(amount.calculate(game, source, this), source.getSourceId(), game, false, true);
permanent.damage(amount.calculate(game, source, this), source.getSourceId(), source, game, false, true);
}
return true;
}

View file

@ -55,7 +55,7 @@ public class DamageAttachedControllerEffect extends OneShotEffect {
}
Player player = game.getPlayer(enchanted.getControllerId());
if (player != null) {
player.damage(amount.calculate(game, source, this), source.getSourceId(), game);
player.damage(amount.calculate(game, source, this), source.getSourceId(), source, game);
return true;
}
return false;

View file

@ -62,7 +62,7 @@ public class DamageAttachedEffect extends OneShotEffect {
if(enchanted == null) {
return false;
}
enchanted.damage(amount.calculate(game, source, this), source.getSourceId(), game, false, true);
enchanted.damage(amount.calculate(game, source, this), source.getSourceId(), source, game, false, true);
return true;
}

View file

@ -72,7 +72,7 @@ public class DamageControllerEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
player.damage(amount.calculate(game, source, this), source.getSourceId(), game, false, preventable);
player.damage(amount.calculate(game, source, this), source.getSourceId(), source, game, false, preventable);
return true;
}
return false;

View file

@ -41,9 +41,9 @@ public class DamageEachOtherEffect extends OneShotEffect {
if (sourceCreature != null && targetCreature != null
&& sourceCreature.isCreature()
&& targetCreature.isCreature()) {
targetCreature.damage(sourceCreature.getPower().getValue(), sourceCreature.getId(), game, false, true);
targetCreature.damage(sourceCreature.getPower().getValue(), sourceCreature.getId(), source, game, false, true);
if (sourceOnBattlefield) {
sourceCreature.damage(targetCreature.getPower().getValue(), targetCreature.getId(), game, false, true);
sourceCreature.damage(targetCreature.getPower().getValue(), targetCreature.getId(), source, game, false, true);
}
return true;
}

View file

@ -77,12 +77,12 @@ public class DamageEverythingEffect extends OneShotEffect {
int damage = amount.calculate(game, source, this);
List<Permanent> permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game);
for (Permanent permanent : permanents) {
permanent.damage(damage, damageSource == null ? source.getSourceId() : damageSource, game, false, true);
permanent.damage(damage, damageSource == null ? source.getSourceId() : damageSource, source, game, false, true);
}
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
player.damage(damage, damageSource == null ? source.getSourceId() : damageSource, game);
player.damage(damage, damageSource == null ? source.getSourceId() : damageSource, source, game);
}
}
return true;

View file

@ -61,13 +61,13 @@ public class DamageMultiEffect extends OneShotEffect {
for (UUID target : multiTarget.getTargets()) {
Permanent permanent = game.getPermanent(target);
if (permanent != null) {
if (permanent.damage(multiTarget.getTargetAmount(target), source.getSourceId(), game, false, true) > 0) {
if (permanent.damage(multiTarget.getTargetAmount(target), source.getSourceId(), source, game, false, true) > 0) {
damagedSet.add(new MageObjectReference(permanent, game));
}
} else {
Player player = game.getPlayer(target);
if (player != null) {
player.damage(multiTarget.getTargetAmount(target), source.getSourceId(), game);
player.damage(multiTarget.getTargetAmount(target), source.getSourceId(), source, game);
}
}
}

View file

@ -60,7 +60,7 @@ public class DamagePlayersEffect extends OneShotEffect {
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
player.damage(amount.calculate(game, source, this), source.getSourceId(), game);
player.damage(amount.calculate(game, source, this), source.getSourceId(), source, game);
}
}
break;
@ -68,7 +68,7 @@ public class DamagePlayersEffect extends OneShotEffect {
for (UUID playerId : game.getOpponents(source.getControllerId())) {
Player player = game.getPlayer(playerId);
if (player != null) {
player.damage(amount.calculate(game, source, this), source.getSourceId(), game);
player.damage(amount.calculate(game, source, this), source.getSourceId(), source, game);
}
}
break;

View file

@ -35,7 +35,7 @@ public class DamageSelfEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
permanent.damage(amount, source.getSourceId(), game, false, true);
permanent.damage(amount, source.getSourceId(), source, game, false, true);
return true;
}
return false;

View file

@ -53,7 +53,7 @@ public class DamageTargetControllerEffect extends OneShotEffect {
if (permanent != null) {
Player targetController = game.getPlayer(permanent.getControllerId());
if (targetController != null) {
targetController.damage(amount.calculate(game, source, this), source.getSourceId(), game, false, preventable);
targetController.damage(amount.calculate(game, source, this), source.getSourceId(), source, game, false, preventable);
}
return true;
}

View file

@ -119,11 +119,11 @@ public class DamageTargetEffect extends OneShotEffect {
for (UUID targetId : target.getTargets()) {
Permanent permanent = game.getPermanent(targetId);
if (permanent != null) {
permanent.damage(amount.calculate(game, source, this), source.getSourceId(), game, false, preventable);
permanent.damage(amount.calculate(game, source, this), source.getSourceId(), source, game, false, preventable);
}
Player player = game.getPlayer(targetId);
if (player != null) {
player.damage(amount.calculate(game, source, this), source.getSourceId(), game, false, preventable);
player.damage(amount.calculate(game, source, this), source.getSourceId(), source, game, false, preventable);
}
}
}
@ -132,11 +132,11 @@ public class DamageTargetEffect extends OneShotEffect {
for (UUID targetId : this.getTargetPointer().getTargets(game, source)) {
Permanent permanent = game.getPermanent(targetId);
if (permanent != null) {
permanent.damage(amount.calculate(game, source, this), source.getSourceId(), game, false, preventable);
permanent.damage(amount.calculate(game, source, this), source.getSourceId(), source, game, false, preventable);
} else {
Player player = game.getPlayer(targetId);
if (player != null) {
player.damage(amount.calculate(game, source, this), source.getSourceId(), game, false, preventable);
player.damage(amount.calculate(game, source, this), source.getSourceId(), source, game, false, preventable);
}
}
}

View file

@ -40,10 +40,10 @@ public class DamageWithPowerFromOneToAnotherTargetEffect extends OneShotEffect {
Player anotherPlayer = game.getPlayer(source.getTargets().get(1).getFirstTarget());
if (myPermanent != null && anotherPermanent != null) {
anotherPermanent.damage(myPermanent.getPower().getValue(), myPermanent.getId(), game, false, true);
anotherPermanent.damage(myPermanent.getPower().getValue(), myPermanent.getId(), source, game, false, true);
return true;
} else if (myPermanent != null && anotherPlayer != null) {
anotherPlayer.damage(myPermanent.getPower().getValue(), myPermanent.getId(), game);
anotherPlayer.damage(myPermanent.getPower().getValue(), myPermanent.getId(), source, game);
return true;
}
return false;

View file

@ -40,10 +40,10 @@ public class DamageWithPowerFromSourceToAnotherTargetEffect extends OneShotEffec
Player anotherPlayer = game.getPlayer(source.getTargets().get(0).getFirstTarget());
if (myPermanent != null && anotherPermanent != null) {
anotherPermanent.damage(myPermanent.getPower().getValue(), myPermanent.getId(), game, false, true);
anotherPermanent.damage(myPermanent.getPower().getValue(), myPermanent.getId(), source, game, false, true);
return true;
} else if (myPermanent != null && anotherPlayer != null) {
anotherPlayer.damage(myPermanent.getPower().getValue(), myPermanent.getId(), game);
anotherPlayer.damage(myPermanent.getPower().getValue(), myPermanent.getId(), source, game);
return true;
}
return false;

View file

@ -41,7 +41,7 @@ public class DestroyAllAttachedEquipmentEffect extends OneShotEffect {
for (UUID attachmentId : attachments) {
Permanent attachment = game.getPermanent(attachmentId);
if (attachment != null && attachment.hasSubtype(SubType.EQUIPMENT, game)) {
attachment.destroy(source.getSourceId(), game, false);
attachment.destroy(source, game, false);
}
}
}

View file

@ -36,7 +36,7 @@ public class DestroyAllControlledTargetEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
for (Permanent permanent: game.getBattlefield().getAllActivePermanents(filter, source.getFirstTarget(), game)) {
permanent.destroy(source.getSourceId(), game, false);
permanent.destroy(source, game, false);
}
return true;
}

View file

@ -45,7 +45,7 @@ public class DestroyAllEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
permanent.destroy(source.getSourceId(), game, noRegen);
permanent.destroy(source, game, noRegen);
}
return true;
}

View file

@ -42,7 +42,7 @@ public class DestroyAllNamedPermanentsEffect extends OneShotEffect {
filter.add(new NamePredicate(targetPermanent.getName()));
}
for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
perm.destroy(source.getSourceId(), game, false);
perm.destroy(source, game, false);
}
return true;
}

View file

@ -44,7 +44,7 @@ public class DestroyAttachedToEffect extends OneShotEffect {
if (attachment != null && attachment.getAttachedTo() != null) {
Permanent attachedTo = game.getPermanent(attachment.getAttachedTo());
if (attachedTo != null) {
return attachedTo.destroy(source.getSourceId(), game, noRegen);
return attachedTo.destroy(source, game, noRegen);
}
}
return false;

View file

@ -42,7 +42,7 @@ public class DestroyEquippedEffect extends OneShotEffect {
permanent = game.getPermanent(equipment.getAttachedTo());
}
if (permanent != null) {
return permanent.destroy(source.getSourceId(), game, false);
return permanent.destroy(source, game, false);
}
}
return false;

View file

@ -44,7 +44,7 @@ public class DestroyMultiTargetEffect extends OneShotEffect {
for (UUID permanentId: target.getTargets()) {
Permanent permanent = game.getPermanent(permanentId);
if (permanent != null) {
permanent.destroy(source.getSourceId(), game, noRegen);
permanent.destroy(source, game, noRegen);
affectedTargets++;
}
}

View file

@ -41,7 +41,7 @@ public class DestroySourceEffect extends OneShotEffect {
if (permanent != null
&& permanent.isPhasedIn()
&& !permanent.isPhasedOutIndirectly()) {
permanent.destroy(source.getSourceId(), game, noRegen);
permanent.destroy(source, game, noRegen);
return true;
}
return false;

View file

@ -67,7 +67,7 @@ public class DestroyTargetEffect extends OneShotEffect {
if (permanent != null
&& permanent.isPhasedIn()
&& !permanent.isPhasedOutIndirectly()) {
permanent.destroy(source.getSourceId(), game, noRegen);
permanent.destroy(source, game, noRegen);
affectedTargets++;
}
}
@ -78,7 +78,7 @@ public class DestroyTargetEffect extends OneShotEffect {
if (permanent != null
&& permanent.isPhasedIn()
&& !permanent.isPhasedOutIndirectly()) {
permanent.destroy(source.getSourceId(), game, noRegen);
permanent.destroy(source, game, noRegen);
affectedTargets++;
}
}

View file

@ -91,7 +91,7 @@ public class DevourEffect extends ReplacementEffectImpl {
int devouredCreatures = 0;
for (UUID targetId : target.getTargets()) {
Permanent targetCreature = game.getPermanent(targetId);
if (targetCreature != null && targetCreature.sacrifice(source.getSourceId(), game)) {
if (targetCreature != null && targetCreature.sacrifice(source, game)) {
cardSubtypes.add(targetCreature.getSubtype(game));
devouredCreatures++;
}

View file

@ -36,7 +36,7 @@ public class DiscardOntoBattlefieldEffect extends ReplacementEffectImpl {
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.ZONE_CHANGE;
return event.getType() == GameEvent.EventType.ZONE_CHANGE;
}
@Override

View file

@ -90,11 +90,11 @@ public class DoIfCostPaid extends OneShotEffect {
message = CardUtil.replaceSourceName(message, mageObject.getName());
boolean result = true;
Outcome payOutcome = executingEffects.getOutcome(source, this.outcome);
if (cost.canPay(source, source.getSourceId(), player.getId(), game)
if (cost.canPay(source, source, player.getId(), game)
&& (!optional || player.chooseUse(payOutcome, message, source, game))) {
cost.clearPaid();
int bookmark = game.bookmarkState();
if (cost.pay(source, game, source.getSourceId(), player.getId(), false)) {
if (cost.pay(source, game, source, player.getId(), false)) {
game.informPlayers(player.getLogName() + " paid for " + mageObject.getLogName() + " - " + message);
for (Effect effect : executingEffects) {
effect.setTargetPointer(this.targetPointer);

View file

@ -89,10 +89,10 @@ public class DoUnlessAnyPlayerPaysEffect extends OneShotEffect {
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null && player.canRespond()
&& costToPay.canPay(source, source.getSourceId(), player.getId(), game)
&& costToPay.canPay(source, source, player.getId(), game)
&& player.chooseUse(Outcome.Detriment, message, source, game)) {
costToPay.clearPaid();
if (costToPay.pay(source, game, source.getSourceId(), player.getId(), false, null)) {
if (costToPay.pay(source, game, source, player.getId(), false, null)) {
if (!game.isSimulation()) {
game.informPlayers(player.getLogName() + " pays the cost to prevent the effect");
}

View file

@ -63,9 +63,9 @@ public class DoUnlessControllerPaysEffect extends OneShotEffect {
boolean doEffect = true;
// check if controller is willing to pay
if (cost.canPay(source, source.getSourceId(), controller.getId(), game) && controller.chooseUse(Outcome.Detriment, message, source, game)) {
if (cost.canPay(source, source, controller.getId(), game) && controller.chooseUse(Outcome.Detriment, message, source, game)) {
cost.clearPaid();
if (cost.pay(source, game, source.getSourceId(), controller.getId(), false, null)) {
if (cost.pay(source, game, source, controller.getId(), false, null)) {
if (!game.isSimulation()) {
game.informPlayers(controller.getLogName() + " pays the cost to prevent the effect");
}

View file

@ -96,10 +96,10 @@ public class DoUnlessTargetPlayerOrTargetsControllerPaysEffect extends OneShotEf
boolean doEffect = true;
// check if targetController is willing to pay
if (costToPay.canPay(source, source.getSourceId(), player.getId(), game)
if (costToPay.canPay(source, source, player.getId(), game)
&& player.chooseUse(Outcome.Detriment, message, source, game)) {
costToPay.clearPaid();
if (costToPay.pay(source, game, source.getSourceId(), player.getId(), false, null)) {
if (costToPay.pay(source, game, source, player.getId(), false, null)) {
if (!game.isSimulation()) {
game.informPlayers(player.getLogName() + " pays the cost to prevent the effect");
}

View file

@ -49,13 +49,13 @@ public class DoWhenCostPaid extends OneShotEffect {
}
String message = CardUtil.replaceSourceName(chooseUseText, mageObject.getLogName());
Outcome payOutcome = ability.getEffects().getOutcome(source, this.outcome);
if (!cost.canPay(source, source.getSourceId(), player.getId(), game)
if (!cost.canPay(source, source, player.getId(), game)
|| (optional && !player.chooseUse(payOutcome, message, source, game))) {
return false;
}
cost.clearPaid();
int bookmark = game.bookmarkState();
if (cost.pay(source, game, source.getSourceId(), player.getId(), false)) {
if (cost.pay(source, game, source, player.getId(), false)) {
ability.getEffects().setTargetPointer(getTargetPointer());
game.fireReflexiveTriggeredAbility(ability, source);
player.resetStoredBookmark(game);

View file

@ -87,14 +87,14 @@ public class DontUntapInControllersNextUntapStepTargetEffect extends ContinuousR
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.UNTAP_STEP || event.getType() == EventType.UNTAP;
return event.getType() == GameEvent.EventType.UNTAP_STEP || event.getType() == GameEvent.EventType.UNTAP;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
// the check if a permanent untap phase is already handled is needed if multiple effects are added to prevent untap in next untap step of controller
// if we don't check it for every untap step of a turn only one effect would be consumed instead of all be valid for the next untap step
if (event.getType() == EventType.UNTAP_STEP) {
if (event.getType() == GameEvent.EventType.UNTAP_STEP) {
boolean allHandled = true;
for (UUID targetId : getTargetPointer().getTargets(game, source)) {
Permanent permanent = game.getPermanent(targetId);
@ -120,7 +120,7 @@ public class DontUntapInControllersNextUntapStepTargetEffect extends ContinuousR
}
}
if (game.getTurn().getStepType() == PhaseStep.UNTAP && event.getType() == EventType.UNTAP) {
if (game.getTurn().getStepType() == PhaseStep.UNTAP && event.getType() == GameEvent.EventType.UNTAP) {
if (handledTargetsDuringTurn.containsKey(event.getTargetId())
&& !handledTargetsDuringTurn.get(event.getTargetId())
&& getTargetPointer().getTargets(game, source).contains(event.getTargetId())) {

View file

@ -51,7 +51,7 @@ public class DontUntapInControllersUntapStepAllEffect extends ContinuousRuleModi
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.UNTAP;
return event.getType() == GameEvent.EventType.UNTAP;
}
@Override

View file

@ -42,7 +42,7 @@ public class DontUntapInControllersUntapStepSourceEffect extends ContinuousRuleM
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.UNTAP;
return event.getType() == GameEvent.EventType.UNTAP;
}
@Override

View file

@ -65,7 +65,7 @@ public class DontUntapInPlayersNextUntapStepAllEffect extends ContinuousRuleModi
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.UNTAP_STEP || event.getType() == EventType.UNTAP;
return event.getType() == GameEvent.EventType.UNTAP_STEP || event.getType() == GameEvent.EventType.UNTAP;
}
@Override
@ -80,7 +80,7 @@ public class DontUntapInPlayersNextUntapStepAllEffect extends ContinuousRuleModi
return false;
}
// remember the turn of the untap step the effect has to be applied
if (event.getType() == EventType.UNTAP_STEP) {
if (event.getType() == GameEvent.EventType.UNTAP_STEP) {
if (game.isActivePlayer(getTargetPointer().getFirst(game, source))) {
if (validForTurnNum == game.getTurnNum()) { // the turn has a second untap step but the effect is already related to the first untap step
discard();
@ -90,7 +90,7 @@ public class DontUntapInPlayersNextUntapStepAllEffect extends ContinuousRuleModi
}
}
if (game.getTurn().getStepType() == PhaseStep.UNTAP && event.getType() == EventType.UNTAP) {
if (game.getTurn().getStepType() == PhaseStep.UNTAP && event.getType() == GameEvent.EventType.UNTAP) {
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent != null) {
Player controller = game.getPlayer(source.getControllerId());

View file

@ -59,7 +59,7 @@ public class DrawCardAllEffect extends OneShotEffect {
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
player.drawCards(amount.calculate(game, source, this), source.getSourceId(), game);
player.drawCards(amount.calculate(game, source, this), source, game);
}
}
break;
@ -67,7 +67,7 @@ public class DrawCardAllEffect extends OneShotEffect {
for (UUID playerId : game.getOpponents(controller.getId())) {
Player player = game.getPlayer(playerId);
if (player != null) {
player.drawCards(amount.calculate(game, source, this), source.getSourceId(), game);
player.drawCards(amount.calculate(game, source, this), source, game);
}
}
break;

View file

@ -49,7 +49,7 @@ public class DrawCardForEachColorAmongControlledPermanentsEffect extends OneShot
colors.add(ObjectColor.WHITE);
}
}
controller.drawCards(colors.size(), source.getSourceId(), game);
controller.drawCards(colors.size(), source, game);
return true;
}
return false;

View file

@ -53,7 +53,7 @@ public class DrawCardSourceControllerEffect extends OneShotEffect {
Player player = game.getPlayer(source.getControllerId());
if (player != null
&& player.canRespond()) {
player.drawCards(amount.calculate(game, source, this), source.getSourceId(), game);
player.drawCards(amount.calculate(game, source, this), source, game);
return true;
}
return false;

View file

@ -70,7 +70,7 @@ public class DrawCardTargetEffect extends OneShotEffect {
}
if (!optional
|| player.chooseUse(outcome, "Use draw effect?", source, game)) {
player.drawCards(cardsToDraw, source.getSourceId(), game);
player.drawCards(cardsToDraw, source, game);
}
}
}

View file

@ -58,8 +58,8 @@ public class DrawDiscardControllerEffect extends OneShotEffect {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
if (!optional || player.chooseUse(outcome, "Use draw, then discard effect?", source, game)) {
player.drawCards(cardsToDraw, source.getSourceId(), game);
player.discard(cardsToDiscard, false, source, game);
player.drawCards(cardsToDraw, source, game);
player.discard(cardsToDiscard, false, false, source, game);
}
return true;
}

View file

@ -46,7 +46,7 @@ public class DrawDiscardOneOfThemEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Cards initialHand = controller.getHand().copy();
controller.drawCards(cardsToDraw, source.getSourceId(), game);
controller.drawCards(cardsToDraw, source, game);
Cards drawnCards = new CardsImpl(controller.getHand().copy());
drawnCards.removeAll(initialHand);
if (!drawnCards.isEmpty()) {
@ -55,7 +55,7 @@ public class DrawDiscardOneOfThemEffect extends OneShotEffect {
if (controller.choose(Outcome.Discard, drawnCards, cardToDiscard, game)) {
Card card = controller.getHand().get(cardToDiscard.getFirstTarget(), game);
if (card != null) {
return controller.discard(card, source, game);
return controller.discard(card, false, source, game);
}
}
}

View file

@ -49,8 +49,8 @@ public class DrawDiscardTargetEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
if (player != null) {
player.drawCards(cardsToDraw, source.getSourceId(), game);
player.discard(cardsToDiscard, false, source, game);
player.drawCards(cardsToDraw, source, game);
player.discard(cardsToDiscard, false, false, source, game);
return true;
}
return false;

View file

@ -50,12 +50,12 @@ public class EnterBattlefieldPayCostOrPutGraveyardEffect extends ReplacementEffe
MageObject sourceObject = game.getObject(source.getSourceId());
if (player != null && cost != null && sourceObject != null) {
boolean replace = true;
if (cost.canPay(source, source.getSourceId(), player.getId(), game)) {
if (cost.canPay(source, source, player.getId(), game)) {
if (player.chooseUse(outcome,
cost.getText().substring(0, 1).toUpperCase(Locale.ENGLISH) + cost.getText().substring(1)
+ "? (otherwise " + sourceObject.getLogName() + " is put into graveyard)", source, game)) {
cost.clearPaid();
replace = !cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null);
replace = !cost.pay(source, game, source, source.getControllerId(), false, null);
}
}
if (replace) {

View file

@ -52,7 +52,7 @@ public class ExileAllEffect extends OneShotEffect {
if (controller != null) {
List<Permanent> permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game);
for (Permanent permanent : permanents) {
controller.moveCardToExileWithInfo(permanent, exileId, exileZone, source.getSourceId(), game, Zone.BATTLEFIELD, true);
controller.moveCardToExileWithInfo(permanent, exileId, exileZone, source, game, Zone.BATTLEFIELD, true);
}
return true;
}

View file

@ -34,7 +34,7 @@ public class ExileAndGainLifeEqualPowerTargetEffect extends OneShotEffect {
Player player = game.getPlayer(permanent.getControllerId());
if (player != null) {
int creaturePower = permanent.getPower().getValue();
permanent.moveToExile(null, null, source.getSourceId(), game);
permanent.moveToExile(null, null, source, game);
game.getState().processAction(game);
player.gainLife(creaturePower, game, source);
}

View file

@ -44,7 +44,7 @@ public class ExileCardFromOwnGraveyardControllerEffect extends OneShotEffect {
for (UUID targetId : target.getTargets()) {
Card card = player.getGraveyard().get(targetId, game);
if (card != null) {
card.moveToZone(Zone.EXILED, source.getSourceId(), game, false);
card.moveToZone(Zone.EXILED, source, game, false);
}
}
}

View file

@ -47,7 +47,7 @@ public class ExileCardYouChooseTargetOpponentEffect extends OneShotEffect {
if (controller.choose(Outcome.Exile, opponent.getHand(), target, game)) {
Card card = opponent.getHand().get(target.getFirstTarget(), game);
if (card != null) {
controller.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.HAND, true);
controller.moveCardToExileWithInfo(card, null, "", source, game, Zone.HAND, true);
}
}
}

View file

@ -35,7 +35,7 @@ public class ExileGraveyardAllTargetPlayerEffect extends OneShotEffect {
if (targetPlayer != null) {
List<UUID> graveyard = new ArrayList<>(targetPlayer.getGraveyard());
for (UUID cardId : graveyard) {
game.getCard(cardId).moveToZone(Zone.EXILED, cardId, game, false);
game.getCard(cardId).moveToZone(Zone.EXILED, source, game, false);
}
return true;
}

View file

@ -56,7 +56,7 @@ public class ExileReturnBattlefieldOwnerNextEndStepSourceEffect extends OneShotE
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
int zcc = game.getState().getZoneChangeCounter(permanent.getId());
boolean exiled = controller.moveCardToExileWithInfo(permanent, source.getSourceId(), permanent.getIdName(), source.getSourceId(), game, Zone.BATTLEFIELD, true);
boolean exiled = controller.moveCardToExileWithInfo(permanent, source.getSourceId(), permanent.getIdName(), source, game, Zone.BATTLEFIELD, true);
if (exiled || (returnAlways && (zcc == game.getState().getZoneChangeCounter(permanent.getId()) - 1))) {
//create delayed triggered ability and return it from every public zone it was next moved to
AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(

View file

@ -43,7 +43,7 @@ public class ExileSourceUnlessPaysEffect extends OneShotEffect {
message = Character.toUpperCase(message.charAt(0)) + message.substring(1);
if (controller.chooseUse(Outcome.Benefit, message, source, game)) {
cost.clearPaid();
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) {
if (cost.pay(source, game, source, source.getControllerId(), false, null)) {
return true;
}
}

View file

@ -40,7 +40,7 @@ public class ExileTargetAndSearchGraveyardHandLibraryEffect extends SearchTarget
Permanent permanentToExile = game.getPermanent(exileTarget.getFirstTarget());
if (permanentToExile != null) {
targetPlayerId = permanentToExile.getControllerId();
result = permanentToExile.moveToExile(null, "", source.getSourceId(), game);
result = permanentToExile.moveToExile(null, "", source, game);
this.applySearchAndExile(game, source, permanentToExile.getName(), targetPlayerId);
}
}

View file

@ -51,7 +51,7 @@ public class LivingDeathEffect extends OneShotEffect {
// Sacrifice all creatures
for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), game)) {
permanent.sacrifice(source.getSourceId(), game);
permanent.sacrifice(source, game);
}
game.getState().processAction(game);

View file

@ -46,7 +46,7 @@ public class LookLibraryMayPutToBottomEffect extends OneShotEffect {
}
controller.lookAtCards(sourceObject.getName(), new CardsImpl(card), game);
boolean toBottom = controller.chooseUse(outcome, "Put card on the bottom of your library?", source, game);
return controller.moveCardToLibraryWithInfo(card, source.getSourceId(), game, Zone.LIBRARY, !toBottom, false);
return controller.moveCardToLibraryWithInfo(card, source, game, Zone.LIBRARY, !toBottom, false);
}
return true;
}

View file

@ -75,7 +75,7 @@ public class LookLibraryTopCardTargetPlayerEffect extends OneShotEffect {
if (putToGraveyard) {
for (Card card : cards.getCards(game)) {
if (player.chooseUse(outcome, "Do you wish to put card into the player's graveyard?", source, game)) {
player.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
player.moveCardToGraveyardWithInfo(card, source, game, Zone.LIBRARY);
} else {
game.informPlayers(player.getLogName() + " puts the card back on top of the library.");
}

View file

@ -31,7 +31,7 @@ public class LoseHalfLifeEffect extends OneShotEffect {
if (player != null) {
int amount = (player.getLife() + 1) / 2;
if (amount > 0) {
player.loseLife(amount, game, false);
player.loseLife(amount, game, source, false);
return true;
}
}

View file

@ -33,7 +33,7 @@ public class LoseHalfLifeTargetEffect extends OneShotEffect {
if (player != null) {
Integer amount = (int) Math.ceil(player.getLife() / 2f);
if (amount > 0) {
player.loseLife(amount, game, false);
player.loseLife(amount, game, source, false);
return true;
}
}

View file

@ -45,7 +45,7 @@ public class LoseLifeAllPlayersEffect extends OneShotEffect {
for (UUID playerId: game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
player.loseLife(amount.calculate(game, source, this), game, false);
player.loseLife(amount.calculate(game, source, this), game, source, false);
}
}
return true;

View file

@ -50,7 +50,7 @@ public class LoseLifeControllerAttachedEffect extends OneShotEffect {
if (creature != null) {
Player player = game.getPlayer(creature.getControllerId());
if (player != null) {
player.loseLife(amount.calculate(game, source, this), game, false);
player.loseLife(amount.calculate(game, source, this), game, source, false);
return true;
}
}

View file

@ -54,7 +54,7 @@ public class LoseLifeDefendingPlayerEffect extends OneShotEffect {
defender = game.getPlayer(getTargetPointer().getFirst(game, source));
}
if (defender != null) {
defender.loseLife(amount.calculate(game, source, this), game, false);
defender.loseLife(amount.calculate(game, source, this), game, source, false);
}
return true;
}

View file

@ -39,7 +39,7 @@ public class LoseLifeOpponentsEffect extends OneShotEffect {
for (UUID opponentId : game.getOpponents(source.getControllerId())) {
Player player = game.getPlayer(opponentId);
if (player != null) {
player.loseLife(amount.calculate(game, source, this), game, false);
player.loseLife(amount.calculate(game, source, this), game, source, false);
}
}
return true;

View file

@ -48,7 +48,7 @@ public class LoseLifePermanentControllerEffect extends OneShotEffect {
player = game.getPlayer(permanent.getControllerId());
}
if (player != null) {
player.loseLife(amount.calculate(game, source, this), game, false);
player.loseLife(amount.calculate(game, source, this), game, source, false);
return true;
}
return false;

View file

@ -42,7 +42,7 @@ public class LoseLifeSourceControllerEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
player.loseLife(amount.calculate(game, source, this), game, false);
player.loseLife(amount.calculate(game, source, this), game, source, false);
return true;
}
return false;

View file

@ -65,7 +65,7 @@ public class LoseLifeTargetControllerEffect extends OneShotEffect {
}
if ( controller != null ) {
controller.loseLife(amount, game, false);
controller.loseLife(amount, game, source, false);
return true;
}
}

View file

@ -43,7 +43,7 @@ public class LoseLifeTargetEffect extends OneShotEffect {
for (UUID playerId : targetPointer.getTargets(game, source)) {
Player player = game.getPlayer(playerId);
if (player != null
&& player.loseLife(amount.calculate(game, source, this), game, false) > 0) {
&& player.loseLife(amount.calculate(game, source, this), game, source, false) > 0) {
applied = true;
}
}

View file

@ -31,7 +31,7 @@ public class MayTapOrUntapTargetEffect extends OneShotEffect {
target.untap(game);
}
} else if (player.chooseUse(Outcome.Tap, "Tap that permanent?", source, game)) {
target.tap(game);
target.tap(source, game);
}
return true;
}

View file

@ -26,7 +26,7 @@ public class MistmeadowWitchEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent != null) {
if (permanent.moveToExile(source.getSourceId(), "Mistmeadow Witch Exile", source.getSourceId(), game)) {
if (permanent.moveToExile(source.getSourceId(), "Mistmeadow Witch Exile", source, game)) {
//create delayed triggered ability
AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ReturnFromExileEffect(source.getSourceId(), Zone.BATTLEFIELD));
game.addDelayedTriggeredAbility(delayedAbility, source);

View file

@ -45,7 +45,7 @@ public class PermanentsEnterBattlefieldTappedEffect extends ReplacementEffectImp
Permanent target = ((EntersTheBattlefieldEvent) event).getTarget();
if (target != null) {
target.tap(game);
target.tap(source, game);
}
return false;

View file

@ -66,7 +66,7 @@ public class PopulateEffect extends OneShotEffect {
}
Target target = new TargetPermanent(filter);
target.setNotTarget(true);
if (!target.canChoose(source.getControllerId(), game)) {
if (!target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
return true;
}
player.choose(Outcome.Copy, target, source.getSourceId(), game);

View file

@ -10,6 +10,7 @@ import mage.game.Game;
import mage.game.events.DamageEvent;
import mage.game.events.GameEvent;
import mage.game.events.PreventDamageEvent;
import mage.game.events.PreventedDamageEvent;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.Target;
@ -79,18 +80,17 @@ public class PreventDamageToTargetMultiAmountEffect extends PreventionEffectImpl
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
int targetAmount = targetAmountMap.get(event.getTargetId());
GameEvent preventEvent = new PreventDamageEvent(event.getTargetId(), source.getSourceId(), source.getControllerId(), event.getAmount(), ((DamageEvent) event).isCombatDamage());
GameEvent preventEvent = new PreventDamageEvent(event.getTargetId(), source.getSourceId(), source, source.getControllerId(), event.getAmount(), ((DamageEvent) event).isCombatDamage());
if (!game.replaceEvent(preventEvent)) {
if (event.getAmount() >= targetAmount) {
int damage = targetAmount;
event.setAmount(event.getAmount() - targetAmount);
targetAmountMap.remove(event.getTargetId());
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE, event.getTargetId(), source.getSourceId(), source.getControllerId(), damage));
game.fireEvent(new PreventedDamageEvent(event.getTargetId(), source.getSourceId(), source, source.getControllerId(), targetAmount));
} else {
int damage = event.getAmount();
event.setAmount(0);
targetAmountMap.put(event.getTargetId(), targetAmount -= damage);
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE, event.getTargetId(), source.getSourceId(), source.getControllerId(), damage));
targetAmountMap.put(event.getTargetId(), targetAmount - damage);
game.fireEvent(new PreventedDamageEvent(event.getTargetId(), source.getSourceId(), source, source.getControllerId(), damage));
}
if (targetAmountMap.isEmpty()) {
this.used = true;

View file

@ -49,12 +49,12 @@ public class PutOnLibrarySourceEffect extends OneShotEffect {
return false;
}
if (sourceObject instanceof Permanent) {
((Permanent) sourceObject).moveToZone(Zone.LIBRARY, source.getSourceId(), game, onTop);
((Permanent) sourceObject).moveToZone(Zone.LIBRARY, source, game, onTop);
return true;
} else if (sourceObject instanceof Card && game.getState().getZone(source.getSourceId()) == Zone.GRAVEYARD) {
for (Player player : game.getPlayers().values()) {
if (player.getGraveyard().contains(sourceObject.getId())) {
((Card) sourceObject).moveToZone(Zone.LIBRARY, source.getSourceId(), game, onTop);
((Card) sourceObject).moveToZone(Zone.LIBRARY, source, game, onTop);
return true;
}
}

Some files were not shown because too many files have changed in this diff Show more