mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 13:02:06 -08:00
Refactor: replaced sourceId by source and introduced source param in some methods;
This commit is contained in:
parent
2bb472607b
commit
db239a1055
3205 changed files with 7080 additions and 6795 deletions
|
|
@ -156,7 +156,7 @@ public abstract class AbilityImpl implements Ability {
|
|||
if (checkIfClause(game)) {
|
||||
// Ability has started resolving. Fire event.
|
||||
// Used for abilities counting the number of resolutions like Ashling the Pilgrim.
|
||||
game.fireEvent(new GameEvent(GameEvent.EventType.RESOLVING_ABILITY, this.getOriginalId(), this.getSourceId(), this.getControllerId()));
|
||||
game.fireEvent(new GameEvent(GameEvent.EventType.RESOLVING_ABILITY, this.getOriginalId(), this, this.getControllerId()));
|
||||
if (this instanceof TriggeredAbility) {
|
||||
for (UUID modeId : this.getModes().getSelectedModes()) {
|
||||
this.getModes().setActiveMode(modeId);
|
||||
|
|
@ -288,11 +288,11 @@ public abstract class AbilityImpl implements Ability {
|
|||
|
||||
// For effects from cards like Void Winnower x costs have to be set
|
||||
if (this.getAbilityType() == AbilityType.SPELL
|
||||
&& game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.CAST_SPELL_LATE, getId(), getSourceId(), getControllerId()), this)) {
|
||||
&& game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.CAST_SPELL_LATE, this.getId(), this, getControllerId()), this)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
handlePhyrexianManaCosts(game, sourceId, controller);
|
||||
handlePhyrexianManaCosts(game, controller);
|
||||
|
||||
/* 20130201 - 601.2b
|
||||
* If the spell is modal the player announces the mode choice (see rule 700.2).
|
||||
|
|
@ -351,7 +351,7 @@ public abstract class AbilityImpl implements Ability {
|
|||
} // end modes
|
||||
|
||||
// this is a hack to prevent mana abilities with mana costs from causing endless loops - pay other costs first
|
||||
if (this instanceof ActivatedManaAbilityImpl && !costs.pay(this, game, sourceId, controllerId, noMana, null)) {
|
||||
if (this instanceof ActivatedManaAbilityImpl && !costs.pay(this, game, this, controllerId, noMana, null)) {
|
||||
logger.debug("activate mana ability failed - non mana costs");
|
||||
return false;
|
||||
}
|
||||
|
|
@ -375,12 +375,12 @@ public abstract class AbilityImpl implements Ability {
|
|||
}
|
||||
|
||||
//20100716 - 601.2f (noMana is not used here, because mana costs were cleared for this ability before adding additional costs and applying cost modification effects)
|
||||
if (!manaCostsToPay.pay(this, game, sourceId, activatorId, false, null)) {
|
||||
if (!manaCostsToPay.pay(this, game, this, activatorId, false, null)) {
|
||||
return false; // cancel during mana payment
|
||||
}
|
||||
|
||||
//20100716 - 601.2g
|
||||
if (!costs.pay(this, game, sourceId, activatorId, noMana, null)) {
|
||||
if (!costs.pay(this, game, this, activatorId, noMana, null)) {
|
||||
logger.debug("activate failed - non mana costs");
|
||||
return false;
|
||||
}
|
||||
|
|
@ -510,7 +510,7 @@ public abstract class AbilityImpl implements Ability {
|
|||
* Phyrexian mana symbols, the player announces whether they intend to pay 2
|
||||
* life or the corresponding colored mana cost for each of those symbols.
|
||||
*/
|
||||
private void handlePhyrexianManaCosts(Game game, UUID sourceId, Player controller) {
|
||||
private void handlePhyrexianManaCosts(Game game, Player controller) {
|
||||
Iterator<ManaCost> costIterator = manaCostsToPay.iterator();
|
||||
while (costIterator.hasNext()) {
|
||||
ManaCost cost = costIterator.next();
|
||||
|
|
@ -518,7 +518,7 @@ public abstract class AbilityImpl implements Ability {
|
|||
if (cost instanceof PhyrexianManaCost) {
|
||||
PhyrexianManaCost phyrexianManaCost = (PhyrexianManaCost) cost;
|
||||
PayLifeCost payLifeCost = new PayLifeCost(2);
|
||||
if (payLifeCost.canPay(this, sourceId, controller.getId(), game)
|
||||
if (payLifeCost.canPay(this, this, controller.getId(), game)
|
||||
&& controller.chooseUse(Outcome.LoseLife, "Pay 2 life instead of " + phyrexianManaCost.getBaseText() + '?', this, game)) {
|
||||
costIterator.remove();
|
||||
costs.add(payLifeCost);
|
||||
|
|
@ -529,7 +529,7 @@ public abstract class AbilityImpl implements Ability {
|
|||
|
||||
public int handleManaXMultiplier(Game game, int value) {
|
||||
// some spells can change X value without new pays (Unbound Flourishing doubles X)
|
||||
GameEvent xEvent = GameEvent.getEvent(GameEvent.EventType.X_MANA_ANNOUNCE, getId(), getSourceId(), getControllerId(), value);
|
||||
GameEvent xEvent = GameEvent.getEvent(GameEvent.EventType.X_MANA_ANNOUNCE, this.getId(), this, getControllerId(), value);
|
||||
game.replaceEvent(xEvent, this);
|
||||
return xEvent.getAmount();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ public abstract class ActivatedAbilityImpl extends AbilityImpl implements Activa
|
|||
if (timing == TimingRule.INSTANT
|
||||
|| game.canPlaySorcery(playerId)
|
||||
|| null != approvingObject) {
|
||||
if (costs.canPay(this, sourceId, playerId, game)
|
||||
if (costs.canPay(this, this, playerId, game)
|
||||
&& canChooseTarget(game)) {
|
||||
this.activatorId = playerId;
|
||||
return new ActivationStatus(true, approvingObject);
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ public class SpellAbility extends ActivatedAbilityImpl {
|
|||
// Check if rule modifying events prevent to cast the spell in check playable mode
|
||||
if (game.inCheckPlayableState()) {
|
||||
if (game.getContinuousEffects().preventedByRuleModification(
|
||||
GameEvent.getEvent(GameEvent.EventType.CAST_SPELL, this.getId(), this.getSourceId(), playerId), this, game, true)) {
|
||||
GameEvent.getEvent(GameEvent.EventType.CAST_SPELL, this.getId(), this, playerId), this, game, true)) {
|
||||
return ActivationStatus.getFalse();
|
||||
}
|
||||
}
|
||||
|
|
@ -104,7 +104,7 @@ public class SpellAbility extends ActivatedAbilityImpl {
|
|||
return ActivationStatus.getFalse();
|
||||
}
|
||||
}
|
||||
if (costs.canPay(this, sourceId, playerId, game)) {
|
||||
if (costs.canPay(this, this, playerId, game)) {
|
||||
if (getSpellAbilityType() == SpellAbilityType.SPLIT_FUSED) {
|
||||
SplitCard splitCard = (SplitCard) game.getCard(getSourceId());
|
||||
if (splitCard != null) {
|
||||
|
|
|
|||
|
|
@ -61,12 +61,8 @@ public class TriggeredAbilities extends ConcurrentHashMap<String, TriggeredAbili
|
|||
if (object != null) {
|
||||
boolean controllerSet = false;
|
||||
if (ability.getZone() != Zone.COMMAND && event != null
|
||||
&& event.getTargetId() != null // && event.getTargetId().equals(ability.getSourceId())
|
||||
&& event.getTargetId() != null
|
||||
&& ability.isLeavesTheBattlefieldTrigger()
|
||||
// && ((event.getType().equals(EventType.ZONE_CHANGE)
|
||||
// && ((ZoneChangeEvent) event).getFromZone().equals(Zone.BATTLEFIELD))
|
||||
// || event.getType().equals(EventType.DESTROYED_PERMANENT)
|
||||
// || event.getType().equals(EventType.SACRIFICED_PERMANENT))
|
||||
&& game.getLKI().get(Zone.BATTLEFIELD) != null && game.getLKI().get(Zone.BATTLEFIELD).containsKey(ability.getSourceId())) {
|
||||
// need to check if object was face down for dies and destroy events because the ability triggers in the new zone, zone counter -1 is used
|
||||
Permanent permanent = (Permanent) game.getLastKnownInformation(ability.getSourceId(), Zone.BATTLEFIELD, ability.getSourceObjectZoneChangeCounter() - 1);
|
||||
|
|
@ -92,7 +88,7 @@ public class TriggeredAbilities extends ConcurrentHashMap<String, TriggeredAbili
|
|||
}
|
||||
|
||||
if (ability.checkTrigger(event, game)) {
|
||||
NumberOfTriggersEvent numberOfTriggersEvent = new NumberOfTriggersEvent(ability.getControllerId(), ability.getSourceId(), event);
|
||||
NumberOfTriggersEvent numberOfTriggersEvent = new NumberOfTriggersEvent(ability, event);
|
||||
if (!game.replaceEvent(numberOfTriggersEvent)) {
|
||||
for (int i = 0; i < numberOfTriggersEvent.getAmount(); i++) {
|
||||
ability.trigger(game, ability.getControllerId());
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public interface TriggeredAbility extends Ability {
|
|||
* This method checks if the event has to trigger the ability. It's
|
||||
* important to do nothing unique within this method, that can't be done
|
||||
* multiple times. Because some abilities call this to check if an ability
|
||||
* is relevant (e.g. Torpor Orb), so the method is calle dmultiple times for
|
||||
* is relevant (e.g. Torpor Orb), so the method is called multiple times for
|
||||
* the same event.
|
||||
*
|
||||
* @param event
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ public class AttacksAloneTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == EventType.DECLARED_ATTACKERS;
|
||||
return event.getType() == GameEvent.EventType.DECLARED_ATTACKERS;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ public class AttacksAndIsNotBlockedTriggeredAbility extends TriggeredAbilityImpl
|
|||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == EventType.DECLARE_BLOCKERS_STEP;
|
||||
return event.getType() == GameEvent.EventType.DECLARE_BLOCKERS_STEP;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ public class BecomesAuraAttachToManifestSourceEffect extends OneShotEffect {
|
|||
new ManifestEffect(1).apply(game, source);
|
||||
Permanent enchantedCreature = game.getPermanent(card.getId());
|
||||
if (enchantedCreature != null) {
|
||||
enchantedCreature.addAttachment(enchantment.getId(), game);
|
||||
enchantedCreature.addAttachment(enchantment.getId(), source, game);
|
||||
FilterCreaturePermanent filter = new FilterCreaturePermanent();
|
||||
Target target = new TargetCreaturePermanent(filter);
|
||||
target.addTarget(enchantedCreature.getId(), source, game);
|
||||
|
|
|
|||
|
|
@ -1,43 +0,0 @@
|
|||
|
||||
package mage.abilities.common;
|
||||
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author North
|
||||
*/
|
||||
public class BecomesBlockedTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
public BecomesBlockedTriggeredAbility(Effect effect, boolean optional) {
|
||||
super(Zone.BATTLEFIELD, effect, optional);
|
||||
}
|
||||
|
||||
public BecomesBlockedTriggeredAbility(final BecomesBlockedTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.CREATURE_BLOCKED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
return event.getTargetId().equals(this.getSourceId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever {this} becomes blocked, " + super.getRule();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BecomesBlockedTriggeredAbility copy() {
|
||||
return new BecomesBlockedTriggeredAbility(this);
|
||||
}
|
||||
}
|
||||
|
|
@ -33,7 +33,7 @@ public class BecomesExertSourceTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
return event.getSourceId().equals(this.getSourceId());
|
||||
return event.getTargetId().equals(this.getSourceId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ public class BecomesTargetAttachedTriggeredAbility extends TriggeredAbilityImpl
|
|||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == EventType.TARGETED;
|
||||
return event.getType() == GameEvent.EventType.TARGETED;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ public class BeginningOfEndStepTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == EventType.END_TURN_STEP_PRE;
|
||||
return event.getType() == GameEvent.EventType.END_TURN_STEP_PRE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ class CantHaveMoreThanAmountCountersSourceEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType() == EventType.ADD_COUNTER;
|
||||
return event.getType() == GameEvent.EventType.ADD_COUNTER;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -49,14 +49,14 @@ public class ControlledCreaturesDealCombatDamagePlayerTriggeredAbility extends T
|
|||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == EventType.DAMAGED_PLAYER
|
||||
|| event.getType() == EventType.COMBAT_DAMAGE_STEP_PRIORITY
|
||||
|| event.getType() == EventType.ZONE_CHANGE;
|
||||
return event.getType() == GameEvent.EventType.DAMAGED_PLAYER
|
||||
|| event.getType() == GameEvent.EventType.COMBAT_DAMAGE_STEP_PRIORITY
|
||||
|| event.getType() == GameEvent.EventType.ZONE_CHANGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getType() == EventType.DAMAGED_PLAYER) {
|
||||
if (event.getType() == GameEvent.EventType.DAMAGED_PLAYER) {
|
||||
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
|
||||
Permanent p = game.getPermanent(event.getSourceId());
|
||||
if (damageEvent.isCombatDamage() && p != null && p.isControlledBy(this.getControllerId()) && !damagedPlayerIds.contains(event.getPlayerId())) {
|
||||
|
|
@ -69,8 +69,8 @@ public class ControlledCreaturesDealCombatDamagePlayerTriggeredAbility extends T
|
|||
return true;
|
||||
}
|
||||
}
|
||||
if (event.getType() == EventType.COMBAT_DAMAGE_STEP_PRIORITY ||
|
||||
(event.getType() == EventType.ZONE_CHANGE && event.getTargetId().equals(getSourceId()))) {
|
||||
if (event.getType() == GameEvent.EventType.COMBAT_DAMAGE_STEP_PRIORITY ||
|
||||
(event.getType() == GameEvent.EventType.ZONE_CHANGE && event.getTargetId().equals(getSourceId()))) {
|
||||
damagedPlayerIds.clear();
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public class ControllerPlaysLandTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == EventType.LAND_PLAYED;
|
||||
return event.getType() == GameEvent.EventType.LAND_PLAYED;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ public class DealsDamageToACreatureAllTriggeredAbility extends TriggeredAbilityI
|
|||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == EventType.DAMAGED_CREATURE;
|
||||
return event.getType() == GameEvent.EventType.DAMAGED_CREATURE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public class DealtDamageAttachedTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == EventType.DAMAGED_CREATURE;
|
||||
return event.getType() == GameEvent.EventType.DAMAGED_CREATURE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ public class DiscardedByOpponentTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == EventType.DISCARDED_CARD;
|
||||
return event.getType() == GameEvent.EventType.DISCARDED_CARD;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -99,7 +99,6 @@ public class EntersBattlefieldAllTriggeredAbility extends TriggeredAbilityImpl {
|
|||
effect.setTargetPointer(new FixedTarget(permanent.getControllerId()));
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -71,13 +71,13 @@ public class EntersBattlefieldOrAttacksAllTriggeredAbility extends TriggeredAbil
|
|||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD || event.getType() == GameEvent.EventType.ATTACKER_DECLARED;
|
||||
return event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD
|
||||
|| event.getType() == GameEvent.EventType.ATTACKER_DECLARED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
Permanent attacker = game.getPermanent(event.getSourceId());
|
||||
if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD
|
||||
&& permanent != null && filter.match(permanent, getSourceId(), getControllerId(), game)) {
|
||||
if (setTargetPointer != SetTargetPointer.NONE) {
|
||||
|
|
@ -95,7 +95,8 @@ public class EntersBattlefieldOrAttacksAllTriggeredAbility extends TriggeredAbil
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Permanent attacker = game.getPermanent(event.getSourceId());
|
||||
if (event.getType() == GameEvent.EventType.ATTACKER_DECLARED
|
||||
&& attacker != null && filter.match(attacker, getSourceId(), getControllerId(), game)) {
|
||||
if (setTargetPointer != SetTargetPointer.NONE) {
|
||||
|
|
|
|||
|
|
@ -32,7 +32,8 @@ public class EntersBattlefieldOrAttacksSourceTriggeredAbility extends TriggeredA
|
|||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.ATTACKER_DECLARED || event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD;
|
||||
return event.getType() == GameEvent.EventType.ATTACKER_DECLARED
|
||||
|| event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -41,8 +41,8 @@ public class EntersBattlefieldOrDiesSourceTriggeredAbility extends TriggeredAbil
|
|||
&& event.getTargetId().equals(getSourceId())) {
|
||||
return true;
|
||||
}
|
||||
if (event.getType() == EventType.ZONE_CHANGE && event.getTargetId().equals(this.getSourceId())) {
|
||||
ZoneChangeEvent zEvent = (ZoneChangeEvent)event;
|
||||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && event.getTargetId().equals(this.getSourceId())) {
|
||||
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
||||
if (zEvent.isDiesEvent()) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ public class EntersBattlefieldOrLeavesSourceTriggeredAbility extends TriggeredAb
|
|||
&& event.getTargetId().equals(getSourceId())) {
|
||||
return true;
|
||||
}
|
||||
if (event.getType() == EventType.ZONE_CHANGE && event.getTargetId().equals(this.getSourceId())) {
|
||||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && event.getTargetId().equals(this.getSourceId())) {
|
||||
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
||||
if (zEvent.getFromZone() == Zone.BATTLEFIELD) {
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ public class PutIntoGraveFromBattlefieldAllTriggeredAbility extends TriggeredAbi
|
|||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == EventType.ZONE_CHANGE;
|
||||
return event.getType() == GameEvent.EventType.ZONE_CHANGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ public class SacrificeIfCastAtInstantTimeTriggeredAbility extends TriggeredAbili
|
|||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == EventType.SPELL_CAST;
|
||||
return event.getType() == GameEvent.EventType.SPELL_CAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ public class SacrificeSourceTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
return event.getTargetId().equals(sourceId);
|
||||
return event.getTargetId().equals(this.getSourceId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ class ChapterTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == EventType.COUNTER_ADDED;
|
||||
return event.getType() == GameEvent.EventType.COUNTER_ADDED;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ public class SpellCounteredControllerTriggeredAbility extends TriggeredAbilityIm
|
|||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == EventType.COUNTERED;
|
||||
return event.getType() == GameEvent.EventType.COUNTERED;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -16,15 +16,18 @@ import mage.target.targetpointer.FixedTarget;
|
|||
public class TapLandForManaAllTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
private final boolean setTargetPointer;
|
||||
private final boolean landMustExists;
|
||||
|
||||
public TapLandForManaAllTriggeredAbility(Effect effect, boolean optional, boolean setTargetPointer) {
|
||||
public TapLandForManaAllTriggeredAbility(Effect effect, boolean optional, boolean setTargetPointer, boolean landMustExists) {
|
||||
super(Zone.BATTLEFIELD, effect, optional);
|
||||
this.setTargetPointer = setTargetPointer;
|
||||
this.landMustExists = landMustExists;
|
||||
}
|
||||
|
||||
public TapLandForManaAllTriggeredAbility(final TapLandForManaAllTriggeredAbility ability) {
|
||||
super(ability);
|
||||
this.setTargetPointer = ability.setTargetPointer;
|
||||
this.landMustExists = ability.landMustExists;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -37,7 +40,14 @@ public class TapLandForManaAllTriggeredAbility extends TriggeredAbilityImpl {
|
|||
if (game.inCheckPlayableState()) { // Ignored - see GameEvent.TAPPED_FOR_MANA
|
||||
return false;
|
||||
}
|
||||
Permanent permanent = game.getPermanentOrLKIBattlefield(event.getSourceId());
|
||||
|
||||
Permanent permanent;
|
||||
if (landMustExists) {
|
||||
permanent = game.getPermanent(event.getSourceId());
|
||||
} else {
|
||||
permanent = game.getPermanentOrLKIBattlefield(event.getSourceId());
|
||||
}
|
||||
|
||||
if (permanent != null && permanent.isLand()) {
|
||||
if (setTargetPointer) {
|
||||
getEffects().get(0).setTargetPointer(new FixedTarget(permanent, game));
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ class TurnFaceUpEffect extends OneShotEffect {
|
|||
if (controller != null && card != null) {
|
||||
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
||||
if (sourcePermanent != null) {
|
||||
if (sourcePermanent.turnFaceUp(game, source.getControllerId())) {
|
||||
if (sourcePermanent.turnFaceUp(source, game, source.getControllerId())) {
|
||||
if (megamorph) {
|
||||
sourcePermanent.addCounters(CounterType.P1P1.createInstance(), source, game);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ public class TurnedFaceUpSourceTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == EventType.TURNEDFACEUP;
|
||||
return event.getType() == GameEvent.EventType.TURNEDFACEUP;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ public class ZoneChangeTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == EventType.ZONE_CHANGE;
|
||||
return event.getType() == GameEvent.EventType.ZONE_CHANGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ class PactEffect extends OneShotEffect {
|
|||
if (player != null) {
|
||||
if (player.chooseUse(Outcome.Benefit, "Pay " + cost.getText() + '?', 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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public enum ProwlCostWasPaidCondition implements Condition {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Card card = game.getCard(source.getSourceId());
|
||||
if (card != null) {
|
||||
for (Ability ability : card.getAbilities()) {
|
||||
for (Ability ability : card.getAbilities(game)) {
|
||||
if (ability instanceof ProwlAbility) {
|
||||
if (((ProwlAbility) ability).isActivated(source, game)) {
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ public class AlternativeCostSourceAbility extends StaticAbility implements Alter
|
|||
} else {
|
||||
costChoiceText = alternativeCostsToCheck.isEmpty() ? "Cast without paying its mana cost?" : "Pay alternative costs? (" + alternativeCostsToCheck.getText() + ')';
|
||||
}
|
||||
if (alternativeCostsToCheck.canPay(ability, ability.getSourceId(), ability.getControllerId(), game)
|
||||
if (alternativeCostsToCheck.canPay(ability, ability, ability.getControllerId(), game)
|
||||
&& player.chooseUse(Outcome.Benefit, costChoiceText, this, game)) {
|
||||
if (ability instanceof SpellAbility) {
|
||||
ability.getManaCostsToPay().removeIf(manaCost -> manaCost instanceof VariableCost);
|
||||
|
|
|
|||
|
|
@ -39,19 +39,19 @@ public class CompositeCost implements Cost {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
return firstCost.canPay(ability, sourceId, controllerId, game) && secondCost.canPay(ability, sourceId, controllerId, game);
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
return firstCost.canPay(ability, source, controllerId, game) && secondCost.canPay(ability, source, controllerId, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
|
||||
return pay(ability, game, sourceId, controllerId, noMana, this);
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana) {
|
||||
return pay(ability, game, source, controllerId, noMana, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
return firstCost.pay(ability, game, sourceId, controllerId, noMana, costToPay)
|
||||
&& secondCost.pay(ability, game, sourceId, controllerId, noMana, costToPay);
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
return firstCost.pay(ability, game, source, controllerId, noMana, costToPay)
|
||||
&& secondCost.pay(ability, game, source, controllerId, noMana, costToPay);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -19,11 +19,11 @@ public interface Cost extends Serializable {
|
|||
* Check is it possible to pay
|
||||
* For mana it checks only single color and amount available, not total mana cost
|
||||
*/
|
||||
boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game);
|
||||
boolean canPay(Ability ability, Ability source, UUID controllerId, Game game);
|
||||
|
||||
boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana);
|
||||
boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana);
|
||||
|
||||
boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay);
|
||||
boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay);
|
||||
|
||||
boolean isPaid();
|
||||
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ public abstract class CostImpl implements Cost {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
|
||||
return pay(ability, game, sourceId, controllerId, noMana, this);
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana) {
|
||||
return pay(ability, game, source, controllerId, noMana, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -61,9 +61,9 @@ public class CostsImpl<T extends Cost> extends ArrayList<T> implements Costs<T>
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
for (T cost : this) {
|
||||
if (!cost.canPay(ability, sourceId, controllerId, game)) {
|
||||
if (!cost.canPay(ability, source, controllerId, game)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -71,16 +71,16 @@ public class CostsImpl<T extends Cost> extends ArrayList<T> implements Costs<T>
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
|
||||
return pay(ability, game, sourceId, controllerId, noMana, this);
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana) {
|
||||
return pay(ability, game, source, controllerId, noMana, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
if (this.size() > 0) {
|
||||
while (!isPaid()) {
|
||||
T cost = getFirstUnpaid();
|
||||
if (!cost.pay(ability, game, sourceId, controllerId, noMana, costToPay)) {
|
||||
if (!cost.pay(ability, game, source, controllerId, noMana, costToPay)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,23 +46,23 @@ public class OrCost implements Cost {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
return firstCost.canPay(ability, sourceId, controllerId, game) || secondCost.canPay(ability, sourceId, controllerId, game);
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
return firstCost.canPay(ability, source, controllerId, game) || secondCost.canPay(ability, source, controllerId, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
|
||||
return pay(ability, game, sourceId, controllerId, noMana, this);
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana) {
|
||||
return pay(ability, game, source, controllerId, noMana, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
selectedCost = null;
|
||||
// if only one can be paid select it
|
||||
if (!firstCost.canPay(ability, sourceId, controllerId, game)) {
|
||||
if (!firstCost.canPay(ability, source, controllerId, game)) {
|
||||
selectedCost = secondCost;
|
||||
}
|
||||
if (!secondCost.canPay(ability, sourceId, controllerId, game)) {
|
||||
if (!secondCost.canPay(ability, source, controllerId, game)) {
|
||||
selectedCost = firstCost;
|
||||
}
|
||||
// if both can be paid player has to select
|
||||
|
|
@ -84,7 +84,7 @@ public class OrCost implements Cost {
|
|||
if (selectedCost == null) {
|
||||
return false;
|
||||
}
|
||||
return selectedCost.pay(ability, game, sourceId, controllerId, noMana, costToPay);
|
||||
return selectedCost.pay(ability, game, source, controllerId, noMana, costToPay);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,11 +27,11 @@ public abstract class UseAttachedCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
if (mageObjectReference == null) {
|
||||
return false;
|
||||
}
|
||||
Permanent permanent = game.getPermanent(sourceId);
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
return permanent != null
|
||||
&& permanent
|
||||
.getAttachments()
|
||||
|
|
|
|||
|
|
@ -99,19 +99,19 @@ public abstract class VariableCostImpl implements Cost, VariableCost {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
|
||||
return pay(ability, game, sourceId, controllerId, noMana, this);
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana) {
|
||||
return pay(ability, game, source, controllerId, noMana, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
return true;
|
||||
/* not used */
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
return true;
|
||||
/* not used */
|
||||
|
||||
|
|
|
|||
|
|
@ -22,12 +22,12 @@ public class ControlPermanentCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
return game.getBattlefield().contains(filter, controllerId, 1, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
this.paid = true;
|
||||
return paid;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,21 +26,21 @@ public class CyclingDiscardCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
return game.getPlayer(controllerId).getHand().contains(sourceId);
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
return game.getPlayer(controllerId).getHand().contains(source.getSourceId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Player player = game.getPlayer(controllerId);
|
||||
if (player != null) {
|
||||
Card card = player.getHand().get(sourceId, game);
|
||||
Card card = player.getHand().get(source.getSourceId(), game);
|
||||
if (card != null) {
|
||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.CYCLE_CARD, card.getId(), card.getId(), card.getOwnerId()));
|
||||
paid = player.discard(card, null, game);
|
||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.CYCLE_CARD, card.getId(), source, card.getOwnerId()));
|
||||
paid = player.discard(card, true, source, game);
|
||||
if (paid) {
|
||||
cycledCard = new MageObjectReference(card, game);
|
||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.CYCLED_CARD, card.getId(), card.getId(), card.getOwnerId()));
|
||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.CYCLED_CARD, card.getId(), source, card.getOwnerId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,17 +27,17 @@ public class DiscardHandCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Player player = game.getPlayer(controllerId);
|
||||
if (player == null) {
|
||||
return paid;
|
||||
}
|
||||
player.discard(player.getHand(), ability, game);
|
||||
player.discard(player.getHand(), true, source, game);
|
||||
paid = true;
|
||||
return paid;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,16 +31,16 @@ public class DiscardSourceCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
return game.getPlayer(controllerId).getHand().contains(sourceId);
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
return game.getPlayer(controllerId).getHand().contains(source.getSourceId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Player player = game.getPlayer(controllerId);
|
||||
if (player != null) {
|
||||
Card card = player.getHand().get(sourceId, game);
|
||||
paid = player.discard(card, null, game);
|
||||
Card card = player.getHand().get(source.getSourceId(), game);
|
||||
paid = player.discard(card, true, source, game);
|
||||
|
||||
}
|
||||
return paid;
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ public class DiscardTargetCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
this.cards.clear();
|
||||
this.targets.clearChosen();
|
||||
Player player = game.getPlayer(controllerId);
|
||||
|
|
@ -49,11 +49,11 @@ public class DiscardTargetCost extends CostImpl {
|
|||
}
|
||||
int amount = this.getTargets().get(0).getNumberOfTargets();
|
||||
if (randomDiscard) {
|
||||
this.cards.addAll(player.discard(amount, true, ability, game).getCards(game));
|
||||
} else if (targets.choose(Outcome.Discard, controllerId, sourceId, game)) {
|
||||
this.cards.addAll(player.discard(amount, true, true, source, game).getCards(game));
|
||||
} else if (targets.choose(Outcome.Discard, controllerId, source.getSourceId(), game)) {
|
||||
Cards toDiscard = new CardsImpl();
|
||||
toDiscard.addAll(targets.get(0).getTargets());
|
||||
Cards discarded = player.discard(toDiscard, ability, game);
|
||||
Cards discarded = player.discard(toDiscard, true, source, game);
|
||||
if (!discarded.isEmpty()) {
|
||||
cards.addAll(discarded.getCards(game));
|
||||
}
|
||||
|
|
@ -70,8 +70,8 @@ public class DiscardTargetCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
return targets.canChoose(sourceId, controllerId, game);
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
return targets.canChoose(source.getSourceId(), controllerId, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -24,15 +24,15 @@ public class DynamicValueGenericManaCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
Cost cost = ManaUtil.createManaCost(amount, game, ability, null);
|
||||
return cost.canPay(ability, sourceId, controllerId, game);
|
||||
return cost.canPay(ability, source, controllerId, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Cost cost = ManaUtil.createManaCost(amount, game, ability, null);
|
||||
paid = cost.pay(ability, game, sourceId, controllerId, noMana);
|
||||
paid = cost.pay(ability, game, source, controllerId, noMana);
|
||||
return paid;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,16 +29,16 @@ public class ExertSourceCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Player player = game.getPlayer(controllerId);
|
||||
Permanent permanent = game.getPermanent(sourceId);
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (player != null && permanent != null) {
|
||||
game.fireEvent(GameEvent.getEvent(EventType.BECOMES_EXERTED, permanent.getId(), permanent.getId(), permanent.getControllerId()));
|
||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.BECOMES_EXERTED, permanent.getId(), source, source.getControllerId()));
|
||||
ContinuousEffect effect = new DontUntapInControllersNextUntapStepTargetEffect("", permanent.getControllerId());
|
||||
effect.setTargetPointer(new FixedTarget(permanent, game));
|
||||
game.addEffect(effect, ability);
|
||||
|
|
|
|||
|
|
@ -63,10 +63,10 @@ public class ExileFromGraveCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
if (controller != null) {
|
||||
if (targets.choose(Outcome.Exile, controllerId, sourceId, game)) {
|
||||
if (targets.choose(Outcome.Exile, controllerId, source.getSourceId(), game)) {
|
||||
for (UUID targetId : targets.get(0).getTargets()) {
|
||||
Card card = game.getCard(targetId);
|
||||
if (card == null || game.getState().getZone(targetId) != Zone.GRAVEYARD) {
|
||||
|
|
@ -85,8 +85,8 @@ public class ExileFromGraveCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
return targets.canChoose(controllerId, game);
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
return targets.canChoose(source.getSourceId(), controllerId, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -49,8 +49,8 @@ public class ExileFromHandCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
if (targets.choose(Outcome.Exile, controllerId, sourceId, game)) {
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
if (targets.choose(Outcome.Exile, controllerId, source.getSourceId(), game)) {
|
||||
Player player = game.getPlayer(controllerId);
|
||||
int cmc = 0;
|
||||
for (UUID targetId : targets.get(0).getTargets()) {
|
||||
|
|
@ -78,8 +78,8 @@ public class ExileFromHandCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
return targets.canChoose(sourceId, controllerId, game);
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
return targets.canChoose(source.getSourceId(), controllerId, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ public class ExileFromStackCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
if (targets.choose(Outcome.Exile, controllerId, sourceId, game)) {
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
if (targets.choose(Outcome.Exile, controllerId, source.getSourceId(), game)) {
|
||||
Player player = game.getPlayer(controllerId);
|
||||
for (UUID targetId : targets.get(0).getTargets()) {
|
||||
Spell spellToExile = game.getStack().getSpell(targetId);
|
||||
|
|
@ -39,7 +39,7 @@ public class ExileFromStackCost extends CostImpl {
|
|||
if (spellToExile.isCopy()) {
|
||||
game.getStack().remove(spellToExile, game);
|
||||
} else {
|
||||
spellToExile.moveToExile(null, "", ability.getSourceId(), game);
|
||||
spellToExile.moveToExile(null, "", ability, game);
|
||||
}
|
||||
paid = true;
|
||||
if (!game.isSimulation()) {
|
||||
|
|
@ -51,8 +51,8 @@ public class ExileFromStackCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
return targets.canChoose(controllerId, game);
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
return targets.canChoose(source.getSourceId(), controllerId, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ public class ExileFromTopOfLibraryCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
if (controller == null) {
|
||||
return false;
|
||||
|
|
@ -39,7 +39,7 @@ public class ExileFromTopOfLibraryCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
if (controller != null) {
|
||||
controller.moveCards(controller.getLibrary().getTopCards(game, amount), Zone.EXILED, ability, game);
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ public class ExileOpponentsCardFromExileToGraveyardCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
if (controller != null) {
|
||||
FilterCard filter = new FilterCard();
|
||||
|
|
@ -56,7 +56,7 @@ public class ExileOpponentsCardFromExileToGraveyardCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
if (controller != null) {
|
||||
for (Card card : game.getExile().getAllCards(game)) {
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public class ExileSourceCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
MageObject sourceObject = ability.getSourceObject(game);
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
if (controller != null && sourceObject instanceof Card) {
|
||||
|
|
@ -52,7 +52,7 @@ public class ExileSourceCost extends CostImpl {
|
|||
exileZoneName = sourceObject.getName();
|
||||
game.getState().setValue(sourceObject.getId().toString(), ability.getSourceObjectZoneChangeCounter());
|
||||
}
|
||||
controller.moveCardToExileWithInfo((Card) sourceObject, exileZoneId, exileZoneName, sourceId, game, game.getState().getZone(sourceObject.getId()), true);
|
||||
controller.moveCardToExileWithInfo((Card) sourceObject, exileZoneId, exileZoneName, source, game, game.getState().getZone(sourceObject.getId()), true);
|
||||
// 117.11. The actions performed when paying a cost may be modified by effects.
|
||||
// Even if they are, meaning the actions that are performed don't match the actions
|
||||
// that are called for, the cost has still been paid.
|
||||
|
|
@ -63,8 +63,8 @@ public class ExileSourceCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
Permanent permanent = game.getPermanent(sourceId);
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
return permanent != null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,12 +25,12 @@ public class ExileSourceFromGraveCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
if (controller != null) {
|
||||
Card card = game.getCard(sourceId);
|
||||
if (card != null && game.getState().getZone(sourceId) == Zone.GRAVEYARD) {
|
||||
controller.moveCardToExileWithInfo(card, null, "", sourceId, game, Zone.GRAVEYARD, true);
|
||||
Card card = game.getCard(source.getSourceId());
|
||||
if (card != null && game.getState().getZone(source.getSourceId()) == Zone.GRAVEYARD) {
|
||||
controller.moveCardToExileWithInfo(card, null, "", source, game, Zone.GRAVEYARD, true);
|
||||
// 117.11. The actions performed when paying a cost may be modified by effects.
|
||||
// Even if they are, meaning the actions that are performed don't match the actions
|
||||
// that are called for, the cost has still been paid.
|
||||
|
|
@ -42,9 +42,9 @@ public class ExileSourceFromGraveCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
Card card = game.getCard(sourceId);
|
||||
return card != null && game.getState().getZone(sourceId) == Zone.GRAVEYARD;
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
Card card = game.getCard(source.getSourceId());
|
||||
return card != null && game.getState().getZone(source.getSourceId()) == Zone.GRAVEYARD;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -39,8 +39,8 @@ public class ExileTargetCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
if (targets.choose(Outcome.Exile, controllerId, sourceId, game)) {
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
if (targets.choose(Outcome.Exile, controllerId, source.getSourceId(), game)) {
|
||||
for (UUID targetId: targets.get(0).getTargets()) {
|
||||
Permanent permanent = game.getPermanent(targetId);
|
||||
if (permanent == null) {
|
||||
|
|
@ -51,7 +51,7 @@ public class ExileTargetCost extends CostImpl {
|
|||
// Even if they are, meaning the actions that are performed don't match the actions
|
||||
// that are called for, the cost has still been paid.
|
||||
// so return state here is not important because the user indended to exile the target anyway
|
||||
game.getPlayer(ability.getControllerId()).moveCardToExileWithInfo(permanent, null, null, sourceId, game, Zone.BATTLEFIELD, true);
|
||||
game.getPlayer(ability.getControllerId()).moveCardToExileWithInfo(permanent, null, null, source, game, Zone.BATTLEFIELD, true);
|
||||
}
|
||||
paid = true;
|
||||
}
|
||||
|
|
@ -59,8 +59,8 @@ public class ExileTargetCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
return targets.canChoose(controllerId, game);
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
return targets.canChoose(source.getSourceId(), controllerId, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ public class ExileTopCardOfGraveyardCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
if(controller == null) {
|
||||
return false;
|
||||
|
|
@ -42,7 +42,7 @@ public class ExileTopCardOfGraveyardCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
if(controller != null) {
|
||||
Card topCard = null;
|
||||
|
|
@ -50,7 +50,7 @@ public class ExileTopCardOfGraveyardCost extends CostImpl {
|
|||
topCard = card;
|
||||
}
|
||||
if (topCard != null) {
|
||||
controller.moveCardToExileWithInfo(topCard, null, "", ability.getSourceId(), game, Zone.GRAVEYARD, true);
|
||||
controller.moveCardToExileWithInfo(topCard, null, "", source, game, Zone.GRAVEYARD, true);
|
||||
paid = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ public class ExileTopCreatureCardOfGraveyardCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
if(controller == null) {
|
||||
return false;
|
||||
|
|
@ -42,7 +42,7 @@ public class ExileTopCreatureCardOfGraveyardCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
if(controller != null) {
|
||||
Card topCard = null;
|
||||
|
|
@ -52,7 +52,7 @@ public class ExileTopCreatureCardOfGraveyardCost extends CostImpl {
|
|||
}
|
||||
}
|
||||
if (topCard != null) {
|
||||
controller.moveCardToExileWithInfo(topCard, null, "", ability.getSourceId(), game, Zone.GRAVEYARD, true);
|
||||
controller.moveCardToExileWithInfo(topCard, null, "", source, game, Zone.GRAVEYARD, true);
|
||||
paid = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public class GainLifeOpponentCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
if (controller != null) {
|
||||
for (UUID opponentId : game.getOpponents(controllerId)) {
|
||||
|
|
@ -59,14 +59,14 @@ public class GainLifeOpponentCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
if (controller != null) {
|
||||
TargetPlayer target = new TargetPlayer(1, 1, true, filter);
|
||||
if (controller.chooseTarget(Outcome.Detriment, target, ability, game)) {
|
||||
Player opponent = game.getPlayer(target.getFirstTarget());
|
||||
if (opponent != null) {
|
||||
opponent.gainLife(amount, game, sourceId);
|
||||
opponent.gainLife(amount, game, source);
|
||||
paid = true;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ public class GainLifePlayersCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
if (controller != null) {
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
|
|
@ -45,14 +45,14 @@ public class GainLifePlayersCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
if (controller != null) {
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
if (!playerId.equals(controllerId)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
player.gainLife(amount, game, sourceId);
|
||||
player.gainLife(amount, game, source);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ public class MillCardsCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Player player = game.getPlayer(controllerId);
|
||||
if (player != null && player.getLibrary().size() >= numberOfCards) {
|
||||
paid = true;
|
||||
|
|
@ -43,7 +43,7 @@ public class MillCardsCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
Player player = game.getPlayer(controllerId);
|
||||
return player != null && player.getLibrary().size() >= numberOfCards;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,13 +28,13 @@ public class PayEnergyCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
Player player = game.getPlayer(controllerId);
|
||||
return player != null && player.getCounters().getCount(CounterType.ENERGY) >= amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Player player = game.getPlayer(controllerId);
|
||||
if (player != null && player.getCounters().getCount(CounterType.ENERGY) >= amount) {
|
||||
player.getCounters().removeCounter(CounterType.ENERGY, amount);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import mage.abilities.dynamicvalue.DynamicValue;
|
|||
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.players.Player;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
|
@ -32,7 +34,7 @@ public class PayLifeCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
//118.4. If a cost or effect allows a player to pay an amount of life greater than 0,
|
||||
//the player may do so only if their life total is greater than or equal to the
|
||||
//amount of the payment. If a player pays life, the payment is subtracted from their
|
||||
|
|
@ -46,13 +48,14 @@ public class PayLifeCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
int lifeToPayAmount = amount.calculate(game, ability, null);
|
||||
this.paid = game.getPlayer(controllerId).loseLife(lifeToPayAmount, game, false) == lifeToPayAmount;
|
||||
if (paid) {
|
||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.LIFE_PAID, controllerId, sourceId, controllerId, lifeToPayAmount));
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
if (controller == null) {
|
||||
return false;
|
||||
}
|
||||
return paid;
|
||||
int lifeToPayAmount = amount.calculate(game, ability, null);
|
||||
this.paid = CardUtil.tryPayLife(lifeToPayAmount, controller, source, game);
|
||||
return this.paid;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -32,8 +32,8 @@ public class PayLoyaltyCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
Permanent planeswalker = game.getPermanent(sourceId);
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
Permanent planeswalker = game.getPermanent(source.getSourceId());
|
||||
return planeswalker != null && planeswalker.getCounters(game).getCount(CounterType.LOYALTY) + amount >= 0 && planeswalker.canLoyaltyBeUsed(game);
|
||||
}
|
||||
|
||||
|
|
@ -46,13 +46,13 @@ public class PayLoyaltyCost extends CostImpl {
|
|||
*
|
||||
*/
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Permanent planeswalker = game.getPermanent(sourceId);
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Permanent planeswalker = game.getPermanent(source.getSourceId());
|
||||
if (planeswalker != null && planeswalker.getCounters(game).getCount(CounterType.LOYALTY) + amount >= 0 && planeswalker.canLoyaltyBeUsed(game)) {
|
||||
if (amount > 0) {
|
||||
planeswalker.addCounters(CounterType.LOYALTY.createInstance(amount), ability, game, false);
|
||||
} else if (amount < 0) {
|
||||
planeswalker.removeCounters(CounterType.LOYALTY.getName(), Math.abs(amount), game);
|
||||
planeswalker.removeCounters(CounterType.LOYALTY.getName(), Math.abs(amount), source, game);
|
||||
}
|
||||
planeswalker.addLoyaltyUsed();
|
||||
this.paid = true;
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@ public class PayVariableLoyaltyCost extends VariableCostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
Permanent planeswalker = game.getPermanent(sourceId);
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
Permanent planeswalker = game.getPermanent(source.getSourceId());
|
||||
return planeswalker!= null && planeswalker.canLoyaltyBeUsed(game);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,21 +32,21 @@ public class PutCardFromHandOnTopOfLibraryCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
TargetCardInHand targetCardInHand = new TargetCardInHand();
|
||||
targetCardInHand.setRequired(false);
|
||||
Card card;
|
||||
if (targetCardInHand.canChoose(controllerId, game)
|
||||
&& controller.choose(Outcome.PreventDamage, targetCardInHand, sourceId, game)) {
|
||||
if (targetCardInHand.canChoose(source.getSourceId(), controllerId, game)
|
||||
&& controller.choose(Outcome.PreventDamage, targetCardInHand, source.getSourceId(), game)) {
|
||||
card = game.getCard(targetCardInHand.getFirstTarget());
|
||||
paid = card != null && controller.moveCardToLibraryWithInfo(card, sourceId, game, Zone.HAND, true, true);
|
||||
paid = card != null && controller.moveCardToLibraryWithInfo(card, source, game, Zone.HAND, true, true);
|
||||
}
|
||||
return paid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
return (controller != null
|
||||
&& !controller.getHand().isEmpty());
|
||||
|
|
|
|||
|
|
@ -38,13 +38,13 @@ public class PutCountersSourceCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Permanent permanent = game.getPermanent(sourceId);
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
this.paid = permanent.addCounters(counter, ability, game, false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,9 +25,9 @@ public class PutSourceOnBottomOwnerLibraryCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Player player = game.getPlayer(controllerId);
|
||||
Permanent sourcePermanent = game.getPermanent(sourceId);
|
||||
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
||||
if (player != null && sourcePermanent != null) {
|
||||
paid = true;
|
||||
player.putCardsOnBottomOfLibrary(new CardsImpl(sourcePermanent), game, ability, false);
|
||||
|
|
@ -36,8 +36,8 @@ public class PutSourceOnBottomOwnerLibraryCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
return game.getPermanent(sourceId) != null;
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
return game.getPermanent(source.getSourceId()) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -29,18 +29,18 @@ public class RemoveAllCountersSourceCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
Permanent permanent = game.getPermanent(sourceId);
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
return permanent != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Permanent permanent = game.getPermanent(ability.getSourceId());
|
||||
if (permanent != null) {
|
||||
this.removedCounters = permanent.getCounters(game).getCount(counterType);
|
||||
if (this.removedCounters > 0) {
|
||||
permanent.removeCounters(counterType.createInstance(this.removedCounters), game);
|
||||
permanent.removeCounters(counterType.createInstance(this.removedCounters), source, game);
|
||||
}
|
||||
}
|
||||
this.paid = true;
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ public class RemoveCounterCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
paid = false;
|
||||
int countersRemoved = 0;
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
|
|
@ -62,7 +62,7 @@ public class RemoveCounterCost extends CostImpl {
|
|||
return paid = true;
|
||||
}
|
||||
target.clearChosen();
|
||||
if (target.choose(Outcome.UnboostCreature, controllerId, sourceId, game)) {
|
||||
if (target.choose(Outcome.UnboostCreature, controllerId, source.getSourceId(), game)) {
|
||||
for (UUID targetId : target.getTargets()) {
|
||||
Permanent permanent = game.getPermanent(targetId);
|
||||
if (permanent != null) {
|
||||
|
|
@ -100,7 +100,7 @@ public class RemoveCounterCost extends CostImpl {
|
|||
numberOfCountersSelected = controller.getAmount(1, Math.min(countersLeft, countersOnPermanent),
|
||||
new StringBuilder("Remove how many counters from ").append(permanent.getIdName()).toString(), game);
|
||||
}
|
||||
permanent.removeCounters(counterName, numberOfCountersSelected, game);
|
||||
permanent.removeCounters(counterName, numberOfCountersSelected, source, game);
|
||||
countersRemoved += numberOfCountersSelected;
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(new StringBuilder(controller.getLogName())
|
||||
|
|
@ -123,8 +123,8 @@ public class RemoveCounterCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
return target.canChoose(controllerId, game);
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
return target.canChoose(source.getSourceId(), controllerId, game);
|
||||
}
|
||||
|
||||
private String setText() {
|
||||
|
|
|
|||
|
|
@ -36,16 +36,16 @@ public class RemoveCountersSourceCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
Permanent permanent = game.getPermanent(sourceId);
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
return permanent != null && permanent.getCounters(game).getCount(name) >= amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Permanent permanent = game.getPermanent(sourceId);
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null && permanent.getCounters(game).getCount(name) >= amount) {
|
||||
permanent.removeCounters(name, amount, game);
|
||||
permanent.removeCounters(name, amount, source, game);
|
||||
this.paid = true;
|
||||
}
|
||||
return paid;
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public class RemoveVariableCountersTargetCost extends VariableCostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
return paid;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,17 +42,17 @@ public class ReturnToHandChosenControlledPermanentCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
if (controller != null) {
|
||||
if (targets.choose(Outcome.ReturnToHand, controllerId, sourceId, game)) {
|
||||
if (targets.choose(Outcome.ReturnToHand, controllerId, source.getSourceId(), game)) {
|
||||
Set<Card> permanentsToReturn = new HashSet<>();
|
||||
for (UUID targetId : targets.get(0).getTargets()) {
|
||||
Permanent permanent = game.getPermanent(targetId);
|
||||
if (permanent == null) {
|
||||
return false;
|
||||
}
|
||||
permanentsToReturn.add((Card) permanent);
|
||||
permanentsToReturn.add(permanent);
|
||||
}
|
||||
controller.moveCards(permanentsToReturn, Zone.HAND, ability, game);
|
||||
paid = true;
|
||||
|
|
@ -62,8 +62,8 @@ public class ReturnToHandChosenControlledPermanentCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
return targets.canChoose(controllerId, game);
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
return targets.canChoose(source.getSourceId(), controllerId, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ public class ReturnToHandFromBattlefieldSourceCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Permanent permanent = game.getPermanent(sourceId);
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
if (permanent == null || controller == null) {
|
||||
return false;
|
||||
|
|
@ -36,8 +36,8 @@ public class ReturnToHandFromBattlefieldSourceCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
return game.getBattlefield().containsPermanent(sourceId);
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
return game.getBattlefield().containsPermanent(source.getSourceId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -34,10 +34,10 @@ public class ReturnToHandFromGraveyardCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
if (controller != null) {
|
||||
if (targets.choose(Outcome.ReturnToHand, controllerId, sourceId, game)) {
|
||||
if (targets.choose(Outcome.ReturnToHand, controllerId, source.getSourceId(), game)) {
|
||||
Set<Card> cardsToMove = new LinkedHashSet<>();
|
||||
for (UUID targetId : targets.get(0).getTargets()) {
|
||||
mage.cards.Card targetCard = game.getCard(targetId);
|
||||
|
|
@ -55,8 +55,8 @@ public class ReturnToHandFromGraveyardCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
return targets.canChoose(controllerId, game);
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
return targets.canChoose(source.getSourceId(), controllerId, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -25,9 +25,9 @@ public class RevealHandSourceControllerCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
MageObject sourceObject = game.getObject(sourceId);
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
if (controller != null && sourceObject != null) {
|
||||
controller.revealCards(sourceObject.getName(), controller.getHand(), game);
|
||||
paid = true;
|
||||
|
|
@ -36,7 +36,7 @@ public class RevealHandSourceControllerCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,27 +27,27 @@ public class RevealSecretOpponentCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
UUID playerThatChoseId = (UUID) game.getState().getValue(sourceId + ChooseSecretOpponentEffect.SECRET_OWNER);
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
UUID playerThatChoseId = (UUID) game.getState().getValue(source.getSourceId() + ChooseSecretOpponentEffect.SECRET_OWNER);
|
||||
if (playerThatChoseId == null || !playerThatChoseId.equals(controllerId)) {
|
||||
return false;
|
||||
}
|
||||
UUID opponentId = (UUID) game.getState().getValue(sourceId + ChooseSecretOpponentEffect.SECRET_OPPONENT);
|
||||
UUID opponentId = (UUID) game.getState().getValue(source.getSourceId() + ChooseSecretOpponentEffect.SECRET_OPPONENT);
|
||||
return opponentId != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
UUID playerThatChoseId = (UUID) game.getState().getValue(sourceId + ChooseSecretOpponentEffect.SECRET_OWNER);
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
UUID playerThatChoseId = (UUID) game.getState().getValue(source.getSourceId() + ChooseSecretOpponentEffect.SECRET_OWNER);
|
||||
if (playerThatChoseId == null || !playerThatChoseId.equals(controllerId)) {
|
||||
return false;
|
||||
}
|
||||
UUID opponentId = (UUID) game.getState().getValue(sourceId + ChooseSecretOpponentEffect.SECRET_OPPONENT);
|
||||
UUID opponentId = (UUID) game.getState().getValue(source.getSourceId() + ChooseSecretOpponentEffect.SECRET_OPPONENT);
|
||||
if (opponentId != null) {
|
||||
game.getState().setValue(sourceId + ChooseSecretOpponentEffect.SECRET_OWNER, null); // because only once, the vale is set to null
|
||||
game.getState().setValue(source.getSourceId() + ChooseSecretOpponentEffect.SECRET_OWNER, null); // because only once, the vale is set to null
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
Player opponent = game.getPlayer(opponentId);
|
||||
MageObject sourceObject = game.getObject(sourceId);
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
if (controller != null && opponent != null && sourceObject != null) {
|
||||
if (sourceObject instanceof Permanent) {
|
||||
((Permanent) sourceObject).addInfo(ChooseSecretOpponentEffect.SECRET_OPPONENT, null, game);
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ public class RevealSourceFromYourHandCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
paid = false;
|
||||
Player player = game.getPlayer(controllerId);
|
||||
if (player != null) {
|
||||
|
|
@ -44,8 +44,8 @@ public class RevealSourceFromYourHandCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
return game.getState().getZone(sourceId) == Zone.HAND;
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
return game.getState().getZone(source.getSourceId()) == Zone.HAND;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
|
||||
// author jeffwadsworth
|
||||
package mage.abilities.costs.common;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -17,6 +15,10 @@ import mage.game.Game;
|
|||
import mage.players.Player;
|
||||
import mage.target.common.TargetCardInHand;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jeffwadsworth
|
||||
*/
|
||||
public class RevealTargetFromHandCost extends CostImpl {
|
||||
|
||||
public int convertedManaCosts = 0;
|
||||
|
|
@ -37,8 +39,8 @@ public class RevealTargetFromHandCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
if (targets.choose(Outcome.Benefit, controllerId, sourceId, game)) {
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
if (targets.choose(Outcome.Benefit, controllerId, source.getSourceId(), game)) {
|
||||
convertedManaCosts = 0;
|
||||
numberCardsRevealed = 0;
|
||||
Player player = game.getPlayer(controllerId);
|
||||
|
|
@ -53,7 +55,7 @@ public class RevealTargetFromHandCost extends CostImpl {
|
|||
}
|
||||
}
|
||||
if (numberCardsRevealed > 0) {
|
||||
MageObject baseObject = game.getBaseObject(sourceId);
|
||||
MageObject baseObject = game.getBaseObject(source.getSourceId());
|
||||
player.revealCards(baseObject == null ? "card cost" : baseObject.getIdName(), cards, game);
|
||||
}
|
||||
if (targets.get(0).getNumberOfTargets() <= numberCardsRevealed) {
|
||||
|
|
@ -78,8 +80,8 @@ public class RevealTargetFromHandCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
return targets.canChoose(controllerId, game);
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
return targets.canChoose(source.getSourceId(), controllerId, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -34,9 +34,9 @@ public class SacrificeAllCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, controllerId, game)) {
|
||||
if (permanent.sacrifice(sourceId, game)) {
|
||||
if (permanent.sacrifice(source, game)) {
|
||||
permanents.add(permanent.copy());
|
||||
}
|
||||
}
|
||||
|
|
@ -45,7 +45,7 @@ public class SacrificeAllCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
UUID activator = controllerId;
|
||||
if (ability.getAbilityType() == AbilityType.ACTIVATED || ability.getAbilityType() == AbilityType.SPECIAL_ACTION) {
|
||||
if (((ActivatedAbilityImpl) ability).getActivatorId() != null) {
|
||||
|
|
@ -57,7 +57,7 @@ public class SacrificeAllCost extends CostImpl {
|
|||
}
|
||||
|
||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, controllerId, game)) {
|
||||
if (!game.getPlayer(activator).canPaySacrificeCost(permanent, sourceId, controllerId, game)) {
|
||||
if (!game.getPlayer(activator).canPaySacrificeCost(permanent, source, controllerId, game)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,20 +23,20 @@ public class SacrificeAttachedCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Permanent attachment = game.getPermanentOrLKIBattlefield(sourceId);
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Permanent attachment = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
||||
Permanent permanent = game.getPermanent(attachment.getAttachedTo());
|
||||
if (permanent != null) {
|
||||
paid = permanent.sacrifice(sourceId, game);
|
||||
paid = permanent.sacrifice(source, game);
|
||||
}
|
||||
return paid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
Permanent attachment = game.getPermanentOrLKIBattlefield(sourceId);
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
Permanent attachment = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
||||
Permanent permanent = game.getPermanent(attachment.getAttachedTo());
|
||||
return permanent != null && game.getPlayer(controllerId).canPaySacrificeCost(permanent, sourceId, controllerId, game);
|
||||
return permanent != null && game.getPlayer(controllerId).canPaySacrificeCost(permanent, source, controllerId, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -22,11 +22,11 @@ public class SacrificeAttachmentCost extends UseAttachedCost {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
if (mageObjectReference == null) {
|
||||
return false;
|
||||
}
|
||||
Permanent permanent = game.getPermanent(sourceId);
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent == null) {
|
||||
return paid;
|
||||
}
|
||||
|
|
@ -37,7 +37,7 @@ public class SacrificeAttachmentCost extends UseAttachedCost {
|
|||
Permanent attachment = game.getPermanent(attachmentId);
|
||||
paid = attachment != null
|
||||
&& attachment.isControlledBy(controllerId)
|
||||
&& attachment.sacrifice(sourceId, game);
|
||||
&& attachment.sacrifice(source, game);
|
||||
if (paid) {
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,19 +23,18 @@ public class SacrificeSourceCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Permanent permanent = game.getPermanent(sourceId);
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
paid = permanent.sacrifice(sourceId, game);
|
||||
paid = permanent.sacrifice(source, game);
|
||||
}
|
||||
return paid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
Permanent permanent = game.getPermanent(sourceId);
|
||||
|
||||
return permanent != null && game.getPlayer(controllerId).canPaySacrificeCost(permanent, sourceId, controllerId, game);
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
return permanent != null && game.getPlayer(controllerId).canPaySacrificeCost(permanent, source, controllerId, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -51,20 +51,20 @@ public class SacrificeTargetCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
UUID activator = controllerId;
|
||||
if (ability.getAbilityType() == AbilityType.ACTIVATED || ability.getAbilityType() == AbilityType.SPECIAL_ACTION) {
|
||||
activator = ((ActivatedAbilityImpl) ability).getActivatorId();
|
||||
}
|
||||
// can be cancel by user
|
||||
if (targets.choose(Outcome.Sacrifice, activator, sourceId, game)) {
|
||||
if (targets.choose(Outcome.Sacrifice, activator, source.getSourceId(), game)) {
|
||||
for (UUID targetId : targets.get(0).getTargets()) {
|
||||
Permanent permanent = game.getPermanent(targetId);
|
||||
if (permanent == null) {
|
||||
return false;
|
||||
}
|
||||
permanents.add(permanent.copy());
|
||||
paid |= permanent.sacrifice(sourceId, game);
|
||||
paid |= permanent.sacrifice(source, game);
|
||||
}
|
||||
if (!paid && targets.get(0).getNumberOfTargets() == 0) {
|
||||
paid = true; // e.g. for Devouring Rage
|
||||
|
|
@ -74,7 +74,7 @@ public class SacrificeTargetCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
UUID activator = controllerId;
|
||||
if (ability.getAbilityType() == AbilityType.ACTIVATED || ability.getAbilityType() == AbilityType.SPECIAL_ACTION) {
|
||||
if (((ActivatedAbilityImpl) ability).getActivatorId() != null) {
|
||||
|
|
@ -88,7 +88,7 @@ public class SacrificeTargetCost extends CostImpl {
|
|||
int validTargets = 0;
|
||||
int neededtargets = targets.get(0).getNumberOfTargets();
|
||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(((TargetControlledPermanent) targets.get(0)).getFilter(), controllerId, game)) {
|
||||
if (game.getPlayer(activator).canPaySacrificeCost(permanent, sourceId, controllerId, game)) {
|
||||
if (game.getPlayer(activator).canPaySacrificeCost(permanent, source, controllerId, game)) {
|
||||
validTargets++;
|
||||
if (validTargets >= neededtargets) {
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -23,18 +23,18 @@ public class TapAttachedCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Permanent attachment = game.getPermanentOrLKIBattlefield(sourceId);
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Permanent attachment = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
||||
Permanent permanent = game.getPermanent(attachment.getAttachedTo());
|
||||
if (permanent != null) {
|
||||
paid = permanent.tap(game);
|
||||
paid = permanent.tap(source, game);
|
||||
}
|
||||
return paid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
Permanent attachment = game.getPermanentOrLKIBattlefield(sourceId);
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
Permanent attachment = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
||||
Permanent permanent = game.getPermanent(attachment.getAttachedTo());
|
||||
if (permanent != null) {
|
||||
// return true; // Technically the more correct implementation, but all cards using this cost also come with an "untapped" condition
|
||||
|
|
|
|||
|
|
@ -24,20 +24,20 @@ public class TapSourceCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Permanent permanent = game.getPermanent(sourceId);
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
paid = permanent.tap(game);
|
||||
paid = permanent.tap(source, game);
|
||||
}
|
||||
return paid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
Permanent permanent = game.getPermanent(sourceId);
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
return !permanent.isTapped()
|
||||
&& (permanent.canTap() || null != game.getContinuousEffects().asThough(sourceId, AsThoughEffectType.ACTIVATE_HASTE, ability, controllerId, game));
|
||||
&& (permanent.canTap() || null != game.getContinuousEffects().asThough(source.getSourceId(), AsThoughEffectType.ACTIVATE_HASTE, ability, controllerId, game));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,22 +35,22 @@ public class TapTargetCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
if (target.choose(Outcome.Tap, controllerId, sourceId, game)) {
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
if (target.choose(Outcome.Tap, controllerId, source.getSourceId(), game)) {
|
||||
for (UUID targetId : target.getTargets()) {
|
||||
Permanent permanent = game.getPermanent(targetId);
|
||||
if (permanent == null) {
|
||||
return false;
|
||||
}
|
||||
paid |= permanent.tap(game);
|
||||
paid |= permanent.tap(source, game);
|
||||
}
|
||||
}
|
||||
return paid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
return target.canChoose(sourceId, controllerId, game);
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
return target.canChoose(source.getSourceId(), controllerId, game);
|
||||
}
|
||||
|
||||
public TargetControlledPermanent getTarget() {
|
||||
|
|
|
|||
|
|
@ -22,11 +22,11 @@ public class UnattachCost extends UseAttachedCost {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
if (mageObjectReference == null) {
|
||||
return false;
|
||||
}
|
||||
Permanent permanent = game.getPermanent(sourceId);
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent == null) {
|
||||
return paid;
|
||||
}
|
||||
|
|
@ -34,7 +34,7 @@ public class UnattachCost extends UseAttachedCost {
|
|||
if (!this.mageObjectReference.refersTo(attachmentId, game)) {
|
||||
continue;
|
||||
}
|
||||
paid = permanent.removeAttachment(attachmentId, game);
|
||||
paid = permanent.removeAttachment(attachmentId, source, game);
|
||||
if (paid) {
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ public class UntapSourceCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Permanent permanent = game.getPermanent(sourceId);
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
paid = permanent.untap(game);
|
||||
}
|
||||
|
|
@ -33,10 +33,10 @@ public class UntapSourceCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
Permanent permanent = game.getPermanent(sourceId);
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
return permanent.isTapped() && (permanent.canTap() || null != game.getContinuousEffects().asThough(sourceId, AsThoughEffectType.ACTIVATE_HASTE, ability, controllerId, game));
|
||||
return permanent.isTapped() && (permanent.canTap() || null != game.getContinuousEffects().asThough(source.getSourceId(), AsThoughEffectType.ACTIVATE_HASTE, ability, controllerId, game));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,8 +32,8 @@ public class UntapTargetCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
if (target.choose(Outcome.Untap, controllerId, sourceId, game)) {
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
if (target.choose(Outcome.Untap, controllerId, source.getSourceId(), game)) {
|
||||
for (UUID targetId : (List<UUID>) target.getTargets()) {
|
||||
Permanent permanent = game.getPermanent(targetId);
|
||||
if (permanent == null) {
|
||||
|
|
@ -46,8 +46,8 @@ public class UntapTargetCost extends CostImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
return target.canChoose(controllerId, game);
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
return target.canChoose(source.getSourceId(), controllerId, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -213,12 +213,12 @@ public abstract class ManaCostImpl extends CostImpl implements ManaCost {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
if (noMana) {
|
||||
setPaid();
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public interface ManaCosts<T extends ManaCost> extends List<T>, ManaCost {
|
|||
|
||||
List<String> getSymbols();
|
||||
|
||||
boolean payOrRollback(Ability ability, Game game, UUID sourceId, UUID payingPlayerId);
|
||||
boolean payOrRollback(Ability ability, Game game, Ability source, UUID payingPlayerId);
|
||||
|
||||
@Override
|
||||
Mana getMana();
|
||||
|
|
|
|||
|
|
@ -108,12 +108,12 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements M
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
|
||||
return pay(ability, game, sourceId, controllerId, noMana, this);
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana) {
|
||||
return pay(ability, game, source, controllerId, noMana, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID playerId, boolean noMana, Cost costToPay) {
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID playerId, boolean noMana, Cost costToPay) {
|
||||
if (this.isEmpty() || noMana) {
|
||||
setPaid();
|
||||
return true;
|
||||
|
|
@ -154,12 +154,12 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements M
|
|||
* @return true if the cost was paid
|
||||
*/
|
||||
@Override
|
||||
public boolean payOrRollback(Ability ability, Game game, UUID sourceId, UUID payingPlayerId) {
|
||||
public boolean payOrRollback(Ability ability, Game game, Ability source, UUID payingPlayerId) {
|
||||
Player payingPlayer = game.getPlayer(payingPlayerId);
|
||||
if (payingPlayer != null) {
|
||||
int bookmark = game.bookmarkState();
|
||||
handlePhyrexianManaCosts(payingPlayer, ability, game);
|
||||
if (pay(ability, game, sourceId, payingPlayerId, false, null)) {
|
||||
handlePhyrexianManaCosts(ability, payingPlayer, source, game);
|
||||
if (pay(ability, game, source, payingPlayerId, false, null)) {
|
||||
game.removeBookmark(bookmark);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -168,7 +168,7 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements M
|
|||
return false;
|
||||
}
|
||||
|
||||
private void handlePhyrexianManaCosts(Player payingPlayer, Ability source, Game game) {
|
||||
private void handlePhyrexianManaCosts(Ability abilityToPay, Player payingPlayer, Ability source, Game game) {
|
||||
if (this.isEmpty()) {
|
||||
return; // nothing to be done without any mana costs. prevents NRE from occurring here
|
||||
}
|
||||
|
|
@ -180,7 +180,7 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements M
|
|||
if (manaCost instanceof PhyrexianManaCost) {
|
||||
PhyrexianManaCost phyrexianManaCost = (PhyrexianManaCost) manaCost;
|
||||
PayLifeCost payLifeCost = new PayLifeCost(2);
|
||||
if (payLifeCost.canPay(source, source.getSourceId(), payingPlayer.getId(), game)
|
||||
if (payLifeCost.canPay(abilityToPay, source, payingPlayer.getId(), game)
|
||||
&& payingPlayer.chooseUse(Outcome.LoseLife, "Pay 2 life instead of " + phyrexianManaCost.getBaseText() + '?', source, game)) {
|
||||
manaCostIterator.remove();
|
||||
tempCosts.add(payLifeCost);
|
||||
|
|
@ -188,7 +188,7 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements M
|
|||
}
|
||||
}
|
||||
|
||||
tempCosts.pay(source, game, source.getSourceId(), payingPlayer.getId(), false, null);
|
||||
tempCosts.pay(source, game, source, payingPlayer.getId(), false, null);
|
||||
}
|
||||
|
||||
private void handleLikePhyrexianManaCosts(Player player, Ability source, Game game) {
|
||||
|
|
@ -220,14 +220,14 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements M
|
|||
|
||||
if (tempPhyrexianCost != null) {
|
||||
PayLifeCost payLifeCost = new PayLifeCost(2);
|
||||
if (payLifeCost.canPay(source, source.getSourceId(), player.getId(), game)
|
||||
if (payLifeCost.canPay(source, source, player.getId(), game)
|
||||
&& player.chooseUse(Outcome.LoseLife, "Pay 2 life (using an active ability) instead of " + tempPhyrexianCost.getBaseText() + '?', source, game)) {
|
||||
manaCostIterator.remove();
|
||||
tempCosts.add(payLifeCost);
|
||||
}
|
||||
}
|
||||
}
|
||||
tempCosts.pay(source, game, source.getSourceId(), player.getId(), false, null);
|
||||
tempCosts.pay(source, game, source, player.getId(), false, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -566,9 +566,9 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements M
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
for (T cost : this) {
|
||||
if (!cost.canPay(ability, sourceId, controllerId, game)) {
|
||||
if (!cost.canPay(ability, source, controllerId, game)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,12 +19,12 @@ public enum AttachedPermanentToughnessValue implements DynamicValue {
|
|||
instance;
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability source, Effect effect) {
|
||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
// In the case that the enchantment is blinked
|
||||
Permanent enchantment = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
|
||||
Permanent enchantment = (Permanent) game.getLastKnownInformation(sourceAbility.getSourceId(), Zone.BATTLEFIELD);
|
||||
if (enchantment == null) {
|
||||
// It was not blinked, use the standard method
|
||||
enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
||||
enchantment = game.getPermanentOrLKIBattlefield(sourceAbility.getSourceId());
|
||||
}
|
||||
if (enchantment == null) {
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -31,9 +31,9 @@ public class AuraAttachedCount implements DynamicValue {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability source, Effect effect) {
|
||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
int count = 0;
|
||||
Permanent p = game.getPermanent(source.getSourceId());
|
||||
Permanent p = game.getPermanent(sourceAbility.getSourceId());
|
||||
if (p != null) {
|
||||
List<UUID> attachments = p.getAttachments();
|
||||
for (UUID attachmentId : attachments) {
|
||||
|
|
|
|||
|
|
@ -32,11 +32,11 @@ public class ColorsOfManaSpentToCastCount implements DynamicValue {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability source, Effect effect) {
|
||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
int count = 0;
|
||||
Spell spell = game.getStack().getSpell(source.getSourceId());
|
||||
Spell spell = game.getStack().getSpell(sourceAbility.getSourceId());
|
||||
if (spell == null) {
|
||||
MageObject mageObject = game.getLastKnownInformation(source.getSourceId(), Zone.STACK);
|
||||
MageObject mageObject = game.getLastKnownInformation(sourceAbility.getSourceId(), Zone.STACK);
|
||||
if (mageObject instanceof Spell) {
|
||||
spell = (Spell) mageObject;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@ public enum CommanderCastCountValue implements DynamicValue {
|
|||
instance;
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability source, Effect effect) {
|
||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
CommanderPlaysCountWatcher watcher = game.getState().getWatcher(CommanderPlaysCountWatcher.class);
|
||||
return watcher != null ? watcher.getPlayerCount(source.getControllerId()) : 0;
|
||||
return watcher != null ? watcher.getPlayerCount(sourceAbility.getControllerId()) : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ public class EffectKeyValue implements DynamicValue {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability source, Effect effect) {
|
||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
return (Integer)effect.getValue(key);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,9 +32,9 @@ public class EquipmentAttachedCount implements DynamicValue {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability source, Effect effect) {
|
||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
int count = 0;
|
||||
Permanent permanent = game.getPermanent(source.getSourceId()); // don't change this - may affect other cards
|
||||
Permanent permanent = game.getPermanent(sourceAbility.getSourceId()); // don't change this - may affect other cards
|
||||
if (permanent != null) {
|
||||
List<UUID> attachments = permanent.getAttachments();
|
||||
for (UUID attachmentId : attachments) {
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue