This commit is contained in:
magenoxx 2014-08-15 00:12:29 +04:00
parent 7ddd36af0f
commit 5ede7221c8
199 changed files with 637 additions and 557 deletions

View file

@ -30,11 +30,11 @@ package mage.abilities.costs.common;
import mage.abilities.Ability;
import mage.abilities.costs.CostImpl;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.game.Game;
import java.util.UUID;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue;
/**
*
@ -65,7 +65,7 @@ public class PayLifeCost extends CostImpl {
//the player may do so only if his or her life total is greater than or equal to the
//amount of the payment. If a player pays life, the payment is subtracted from his or
//her life total; in other words, the player loses that much life. (Players can always pay 0 life.)
int lifeToPayAmount = amount.calculate(game, ability);
int lifeToPayAmount = amount.calculate(game, ability, null);
if (lifeToPayAmount > 0 && !game.getPlayer(controllerId).canPayLifeCost()) {
return false;
}
@ -74,7 +74,7 @@ public class PayLifeCost extends CostImpl {
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
int lifeToPayAmount = amount.calculate(game, ability);
int lifeToPayAmount = amount.calculate(game, ability, null);
this.paid = game.getPlayer(controllerId).loseLife(lifeToPayAmount, game) == lifeToPayAmount;
return paid;
}

View file

@ -1,12 +1,13 @@
package mage.abilities.dynamicvalue;
import mage.abilities.Ability;
import mage.abilities.effects.Effect;
import mage.game.Game;
import java.io.Serializable;
public interface DynamicValue extends Serializable {
int calculate(Game game, Ability sourceAbility);
int calculate(Game game, Ability sourceAbility, Effect effect);
DynamicValue copy();
String getMessage();
}

View file

@ -29,6 +29,7 @@
package mage.abilities.dynamicvalue;
import mage.abilities.Ability;
import mage.abilities.effects.Effect;
import mage.game.Game;
/**
@ -51,8 +52,8 @@ public class IntPlusDynamicValue implements DynamicValue {
}
@Override
public int calculate(Game game, Ability sourceAbility) {
return baseValue + value.calculate(game, sourceAbility);
public int calculate(Game game, Ability sourceAbility, Effect effect) {
return baseValue + value.calculate(game, sourceAbility, effect);
}
@Override

View file

@ -29,6 +29,7 @@
package mage.abilities.dynamicvalue;
import mage.abilities.Ability;
import mage.abilities.effects.Effect;
import mage.game.Game;
/**
@ -51,8 +52,8 @@ public class MultipliedValue implements DynamicValue {
}
@Override
public int calculate(Game game, Ability sourceAbility) {
return multplier * value.calculate(game, sourceAbility);
public int calculate(Game game, Ability sourceAbility, Effect effect) {
return multplier * value.calculate(game, sourceAbility, effect);
}
@Override

View file

@ -30,6 +30,7 @@ package mage.abilities.dynamicvalue.common;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.game.Game;
import mage.game.combat.CombatGroup;
@ -57,7 +58,7 @@ public class AttackingCreatureCount implements DynamicValue {
}
@Override
public int calculate(Game game, Ability sourceAbility) {
public int calculate(Game game, Ability sourceAbility, Effect effect) {
int count = 0;
for (CombatGroup combatGroup : game.getCombat().getGroups()) {
count += combatGroup.getAttackers().size();

View file

@ -27,13 +27,15 @@
*/
package mage.abilities.dynamicvalue.common;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.game.Game;
import mage.game.permanent.Permanent;
import java.util.List;
import java.util.UUID;
/**
*
* @author North
@ -55,7 +57,7 @@ public class AuraAttachedCount implements DynamicValue {
}
@Override
public int calculate(Game game, Ability source) {
public int calculate(Game game, Ability source, Effect effect) {
int count = 0;
Permanent p = game.getPermanent(source.getSourceId());
if (p != null) {

View file

@ -4,14 +4,16 @@
*/
package mage.abilities.dynamicvalue.common;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.filter.FilterCard;
import mage.game.Game;
import mage.players.Player;
import mage.players.PlayerList;
import java.util.UUID;
/**
*
* @author North
@ -33,7 +35,7 @@ public class CardsInAllGraveyardsCount implements DynamicValue {
}
@Override
public int calculate(Game game, Ability sourceAbility) {
public int calculate(Game game, Ability sourceAbility, Effect effect) {
int amount = 0;
PlayerList playerList = game.getPlayerList();
for (UUID playerUUID : playerList) {

View file

@ -2,6 +2,7 @@ package mage.abilities.dynamicvalue.common;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.filter.FilterCard;
import mage.game.Game;
import mage.players.Player;
@ -34,7 +35,7 @@ public class CardsInControllerGraveyardCount implements DynamicValue {
}
@Override
public int calculate(Game game, Ability sourceAbility) {
public int calculate(Game game, Ability sourceAbility, Effect effect) {
Player player = game.getPlayer(sourceAbility.getControllerId());
if (player != null) {
return amount * player.getGraveyard().count(filter, game);

View file

@ -2,12 +2,13 @@ package mage.abilities.dynamicvalue.common;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.game.Game;
import mage.players.Player;
public class CardsInControllerHandCount implements DynamicValue {
@Override
public int calculate(Game game, Ability sourceAbility) {
public int calculate(Game game, Ability sourceAbility, Effect effect) {
if (sourceAbility != null) {
Player controller = game.getPlayer(sourceAbility.getControllerId());
if (controller != null) {

View file

@ -28,15 +28,17 @@
package mage.abilities.dynamicvalue.common;
import java.io.ObjectStreamException;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.MageSingleton;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.cards.Card;
import mage.game.Game;
import mage.watchers.common.PlayerGainedLifeWatcher;
import java.io.ObjectStreamException;
import java.util.UUID;
/**
* Amount of life the controller got this turn.
*
@ -57,7 +59,7 @@ public class ControllerGotLifeCount implements DynamicValue, MageSingleton {
}
@Override
public int calculate(Game game, Ability sourceAbility) {
public int calculate(Game game, Ability sourceAbility, Effect effect) {
return this.calculate(game, sourceAbility.getControllerId());
}

View file

@ -2,12 +2,13 @@ package mage.abilities.dynamicvalue.common;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.game.Game;
import mage.players.Player;
public class ControllerLifeCount implements DynamicValue {
@Override
public int calculate(Game game, Ability sourceAbility) {
public int calculate(Game game, Ability sourceAbility, Effect effect) {
Player p = game.getPlayer(sourceAbility.getControllerId());
if (p != null) {
return p.getLife();

View file

@ -3,6 +3,7 @@ package mage.abilities.dynamicvalue.common;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.game.Game;
@ -20,7 +21,7 @@ public class CountersCount implements DynamicValue {
}
@Override
public int calculate(Game game, Ability sourceAbility) {
public int calculate(Game game, Ability sourceAbility, Effect effect) {
Permanent p = game.getPermanent(sourceAbility.getSourceId());
// if permanent already leaves the battlefield, try to find counters count via last known information
if (p == null) {

View file

@ -4,15 +4,17 @@
*/
package mage.abilities.dynamicvalue.common;
import java.util.ArrayList;
import java.util.Arrays;
import mage.abilities.Ability;
import mage.abilities.costs.mana.ManaCost;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.constants.ColoredManaSymbol;
import mage.game.Game;
import mage.game.permanent.Permanent;
import java.util.ArrayList;
import java.util.Arrays;
/**
* Each colored mana symbol (e.g. {U}) in the mana costs of permanents you control counts toward your devotion to that color.
*
@ -31,7 +33,7 @@ public class DevotionCount implements DynamicValue {
}
@Override
public int calculate(Game game, Ability sourceAbility) {
public int calculate(Game game, Ability sourceAbility, Effect effect) {
int devotion = 0;
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(sourceAbility.getControllerId())) {
for(ManaCost manaCost :permanent.getManaCost()) {

View file

@ -60,14 +60,14 @@ public class DevouredCreaturesCount implements DynamicValue {
}
@Override
public int calculate(Game game, Ability sourceAbility) {
public int calculate(Game game, Ability sourceAbility, Effect effect) {
Permanent sourcePermanent = game.getPermanent(sourceAbility.getSourceId());
if (sourcePermanent != null) {
for (Ability ability : sourcePermanent.getAbilities()) {
if (ability instanceof DevourAbility) {
for (Effect effect: ability.getEffects()) {
if (effect instanceof DevourEffect) {
DevourEffect devourEffect = (DevourEffect) effect;
for (Effect abilityEffect: ability.getEffects()) {
if (abilityEffect instanceof DevourEffect) {
DevourEffect devourEffect = (DevourEffect) abilityEffect;
return devourEffect.getDevouredCreaturesAmount(game, sourcePermanent.getId()) * multiplier;
}
}

View file

@ -4,6 +4,7 @@ import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.common.DiscardCardCost;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.cards.Card;
import mage.game.Game;
@ -13,7 +14,7 @@ import mage.game.Game;
public class DiscardCostCardConvertedMana implements DynamicValue {
@Override
public int calculate(Game game, Ability sourceAbility) {
public int calculate(Game game, Ability sourceAbility, Effect effect) {
for (Cost cost: sourceAbility.getCosts()) {
if (cost instanceof DiscardCardCost) {
DiscardCardCost discardCost = (DiscardCardCost) cost;

View file

@ -2,6 +2,7 @@ package mage.abilities.dynamicvalue.common;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.constants.CardType;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -25,7 +26,7 @@ public class DomainValue implements DynamicValue {
}
@Override
public int calculate(Game game, Ability sourceAbility) {
public int calculate(Game game, Ability sourceAbility, Effect effect) {
int havePlains = 0;
int haveIslands = 0;
int haveMountains = 0;

View file

@ -29,6 +29,7 @@ package mage.abilities.dynamicvalue.common;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -56,7 +57,7 @@ public class EquipmentAttachedCount implements DynamicValue {
}
@Override
public int calculate(Game game, Ability source) {
public int calculate(Game game, Ability source, Effect effect) {
int count = 0;
Permanent permanent = game.getPermanent(source.getSourceId()); // don't change this - may affect other cards
if (permanent != null) {

View file

@ -31,6 +31,7 @@ import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.common.ExileFromHandCost;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.cards.Card;
import mage.game.Game;
@ -47,7 +48,7 @@ import mage.game.Game;
public class ExileFromHandCostCardConvertedMana implements DynamicValue {
@Override
public int calculate(Game game, Ability sourceAbility) {
public int calculate(Game game, Ability sourceAbility, Effect effect) {
for (Cost cost: sourceAbility.getCosts()) {
if (cost.isPaid() && cost instanceof ExileFromHandCost) {
int xValue = 0;

View file

@ -30,6 +30,7 @@ package mage.abilities.dynamicvalue.common;
import mage.abilities.Ability;
import mage.abilities.costs.VariableCost;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.game.Game;
/**
@ -38,7 +39,7 @@ import mage.game.Game;
*/
public class GetXValue implements DynamicValue {
@Override
public int calculate(Game game, Ability sourceAbility) {
public int calculate(Game game, Ability sourceAbility, Effect effect) {
int amount = 0;
for (VariableCost cost: sourceAbility.getCosts().getVariableCosts()) {
amount += cost.getAmount();

View file

@ -29,6 +29,7 @@ package mage.abilities.dynamicvalue.common;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.game.Game;
import mage.game.stack.Spell;
import mage.game.stack.StackObject;
@ -43,7 +44,7 @@ public class ManaSpentToCastCount implements DynamicValue{
}
@Override
public int calculate(Game game, Ability source) {
public int calculate(Game game, Ability source, Effect effect) {
if (!game.getStack().isEmpty()) {
for (StackObject stackObject : game.getStack()) {
if (stackObject instanceof Spell && ((Spell)stackObject).getSourceId().equals(source.getSourceId())) {

View file

@ -1,8 +1,9 @@
package mage.abilities.dynamicvalue.common;
import mage.constants.ManaType;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.constants.ManaType;
import mage.game.Game;
import mage.players.Player;
@ -23,7 +24,7 @@ public class ManaTypeInManaPoolCount implements DynamicValue {
}
@Override
public int calculate(Game game, Ability sourceAbility) {
public int calculate(Game game, Ability sourceAbility, Effect effect) {
int amount = 0;
Player player = game.getPlayer(sourceAbility.getControllerId());
if (player != null) {

View file

@ -2,12 +2,13 @@ package mage.abilities.dynamicvalue.common;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.game.Game;
public class ManacostVariableValue implements DynamicValue {
@Override
public int calculate(Game game, Ability sourceAbility) {
public int calculate(Game game, Ability sourceAbility, Effect effect) {
return sourceAbility.getManaCostsToPay().getX();
}

View file

@ -29,6 +29,7 @@ package mage.abilities.dynamicvalue.common;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.abilities.keyword.KickerAbility;
import mage.cards.Card;
import mage.game.Game;
@ -43,7 +44,7 @@ public class MultikickerCount implements DynamicValue {
}
@Override
public int calculate(Game game, Ability source) {
public int calculate(Game game, Ability source, Effect effect) {
int count = 0;
Card card = game.getCard(source.getSourceId());
if (card != null) {

View file

@ -28,12 +28,14 @@
package mage.abilities.dynamicvalue.common;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.game.Game;
import mage.watchers.common.PlayerLostLifeWatcher;
import java.util.UUID;
/**
*
* @author LevelX2
@ -42,7 +44,7 @@ import mage.watchers.common.PlayerLostLifeWatcher;
public class OpponentsLostLifeCount implements DynamicValue {
@Override
public int calculate(Game game, Ability sourceAbility) {
public int calculate(Game game, Ability sourceAbility, Effect effect) {
return this.calculate(game, sourceAbility.getControllerId());
}

View file

@ -2,6 +2,7 @@ package mage.abilities.dynamicvalue.common;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.filter.FilterPermanent;
import mage.game.Game;
@ -33,7 +34,7 @@ public class PermanentsOnBattlefieldCount implements DynamicValue {
}
@Override
public int calculate(Game game, Ability sourceAbility) {
public int calculate(Game game, Ability sourceAbility, Effect effect) {
int value = game.getBattlefield().count(filter, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game);
if (multiplier != null) {
value *= multiplier;

View file

@ -10,6 +10,7 @@ import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.common.RemoveVariableCountersSourceCost;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.game.Game;
/**
@ -19,7 +20,7 @@ import mage.game.Game;
public class RemovedCountersForCostValue implements DynamicValue {
@Override
public int calculate(Game game, Ability sourceAbility) {
public int calculate(Game game, Ability sourceAbility, Effect effect) {
for (Cost cost: sourceAbility.getCosts()) {
if (cost instanceof RemoveVariableCountersSourceCost) {
return ((RemoveVariableCountersSourceCost) cost).getAmount();

View file

@ -10,6 +10,7 @@ import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.common.RevealTargetFromHandCost;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.game.Game;
/**
@ -19,7 +20,7 @@ import mage.game.Game;
public class RevealTargetFromHandCostCount implements DynamicValue {
@Override
public int calculate(Game game, Ability sourceAbility) {
public int calculate(Game game, Ability sourceAbility, Effect effect) {
for (Cost cost: sourceAbility.getCosts()) {
if (cost instanceof RevealTargetFromHandCost) {
return ((RevealTargetFromHandCost) cost).getNumberRevealedCards();

View file

@ -4,6 +4,7 @@ import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.common.SacrificeTargetCost;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -13,7 +14,7 @@ import mage.game.permanent.Permanent;
public class SacrificeCostCreaturesPower implements DynamicValue {
@Override
public int calculate(Game game, Ability sourceAbility) {
public int calculate(Game game, Ability sourceAbility, Effect effect) {
for (Cost cost: sourceAbility.getCosts()) {
if (cost instanceof SacrificeTargetCost) {
SacrificeTargetCost sacrificeCost = (SacrificeTargetCost) cost;

View file

@ -4,6 +4,7 @@ import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.common.SacrificeTargetCost;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -13,7 +14,7 @@ import mage.game.permanent.Permanent;
public class SacrificeCostCreaturesToughness implements DynamicValue {
@Override
public int calculate(Game game, Ability sourceAbility) {
public int calculate(Game game, Ability sourceAbility, Effect effect) {
for (Cost cost: sourceAbility.getCosts()) {
if (cost instanceof SacrificeTargetCost) {
SacrificeTargetCost sacrificeCost = (SacrificeTargetCost) cost;

View file

@ -2,6 +2,7 @@ package mage.abilities.dynamicvalue.common;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.game.Game;
public class SignInversionDynamicValue implements DynamicValue {
@ -16,8 +17,8 @@ public class SignInversionDynamicValue implements DynamicValue {
}
@Override
public int calculate(Game game, Ability sourceAbility) {
return -1 * value.calculate(game, sourceAbility);
public int calculate(Game game, Ability sourceAbility, Effect effect) {
return -1 * value.calculate(game, sourceAbility, effect);
}
@Override

View file

@ -2,6 +2,7 @@ package mage.abilities.dynamicvalue.common;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -11,7 +12,7 @@ import mage.game.permanent.Permanent;
*/
public class SourcePermanentPowerCount implements DynamicValue {
@Override
public int calculate(Game game, Ability sourceAbility) {
public int calculate(Game game, Ability sourceAbility, Effect effect) {
Permanent sourcePermanent = game.getPermanent(sourceAbility.getSourceId());
if (sourcePermanent == null) {
sourcePermanent = (Permanent) game.getLastKnownInformation(sourceAbility.getSourceId(), Zone.BATTLEFIELD);

View file

@ -28,13 +28,15 @@
package mage.abilities.dynamicvalue.common;
import java.io.ObjectStreamException;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import java.io.ObjectStreamException;
/**
*
* @author LevelX2
@ -53,7 +55,7 @@ public class SourcePermanentToughnessValue implements DynamicValue {
}
@Override
public int calculate(Game game, Ability sourceAbility) {
public int calculate(Game game, Ability sourceAbility, Effect effect) {
Permanent sourcePermanent = game.getPermanent(sourceAbility.getSourceId());
if (sourcePermanent == null) {
sourcePermanent = (Permanent) game.getLastKnownInformation(sourceAbility.getSourceId(), Zone.BATTLEFIELD);

View file

@ -3,6 +3,7 @@ package mage.abilities.dynamicvalue.common;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.game.Game;
public class StaticValue implements DynamicValue {
@ -23,7 +24,7 @@ public class StaticValue implements DynamicValue {
}
@Override
public int calculate(Game game, Ability sourceAbility) {
public int calculate(Game game, Ability sourceAbility, Effect effect) {
return value;
}

View file

@ -31,6 +31,7 @@ package mage.abilities.dynamicvalue.common;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.game.Game;
import mage.game.stack.Spell;
import mage.game.stack.StackObject;
@ -47,7 +48,7 @@ public class SunburstCount implements DynamicValue{
}
@Override
public int calculate(Game game, Ability source) {
public int calculate(Game game, Ability source, Effect effect) {
int count = 0;
if (!game.getStack().isEmpty()) {
StackObject spell = game.getStack().getFirst();

View file

@ -29,6 +29,7 @@ package mage.abilities.dynamicvalue.common;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.cards.Card;
import mage.game.Game;
@ -48,7 +49,7 @@ public class SweepNumber implements DynamicValue {
}
@Override
public int calculate(Game game, Ability source) {
public int calculate(Game game, Ability source, Effect effect) {
if (zoneChangeCounter == 0) {
Card card = game.getCard(source.getSourceId());
if (card != null) {

View file

@ -29,6 +29,7 @@ package mage.abilities.dynamicvalue.common;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.cards.Card;
import mage.game.Game;
@ -39,7 +40,7 @@ import mage.game.Game;
public class TargetConvertedManaCost implements DynamicValue {
@Override
public int calculate(Game game, Ability source) {
public int calculate(Game game, Ability source, Effect effect) {
Card card = game.getCard(source.getFirstTarget());
if (card != null) {
return card.getManaCost().convertedManaCost();

View file

@ -28,13 +28,15 @@
package mage.abilities.dynamicvalue.common;
import java.io.ObjectStreamException;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import java.io.ObjectStreamException;
/**
*
* @author LevelX2
@ -53,7 +55,7 @@ public class TargetPermanenToughnessValue implements DynamicValue {
}
@Override
public int calculate(Game game, Ability sourceAbility) {
public int calculate(Game game, Ability sourceAbility, Effect effect) {
Permanent sourcePermanent = game.getPermanent(sourceAbility.getFirstTarget());
if (sourcePermanent == null) {
sourcePermanent = (Permanent) game.getLastKnownInformation(sourceAbility.getFirstTarget(), Zone.BATTLEFIELD);

View file

@ -27,9 +27,10 @@
*/
package mage.abilities.dynamicvalue.common;
import mage.constants.Zone;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -40,7 +41,7 @@ import mage.game.permanent.Permanent;
public class TargetPermanentPowerCount implements DynamicValue {
@Override
public int calculate(Game game, Ability sourceAbility) {
public int calculate(Game game, Ability sourceAbility, Effect effect) {
Permanent sourcePermanent = game.getPermanent(sourceAbility.getFirstTarget());
if (sourcePermanent == null) {
sourcePermanent = (Permanent) game.getLastKnownInformation(sourceAbility.getFirstTarget(), Zone.BATTLEFIELD);

View file

@ -2,6 +2,7 @@ package mage.abilities.dynamicvalue.common;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.filter.common.FilterControlledPermanent;
import mage.filter.predicate.mageobject.NamePredicate;
import mage.game.Game;
@ -14,11 +15,11 @@ public class UrzaTerrainValue implements DynamicValue {
}
@Override
public int calculate(Game game, Ability sourceAbility) {
public int calculate(Game game, Ability sourceAbility, Effect effect) {
FilterControlledPermanent pp = new FilterControlledPermanent("Urza's Power Plant");
pp.add(new NamePredicate("Urza's Power Plant"));
PermanentsOnBattlefieldCount ppP = new PermanentsOnBattlefieldCount(pp);
if (ppP.calculate(game, sourceAbility) < 1)
if (ppP.calculate(game, sourceAbility, effect) < 1)
{
return 1;
}
@ -26,7 +27,7 @@ public class UrzaTerrainValue implements DynamicValue {
FilterControlledPermanent to = new FilterControlledPermanent("Urza's Tower");
to.add(new NamePredicate("Urza's Tower"));
PermanentsOnBattlefieldCount toP = new PermanentsOnBattlefieldCount(to);
if (toP.calculate(game, sourceAbility) < 1)
if (toP.calculate(game, sourceAbility, effect) < 1)
{
return 1;
}
@ -34,7 +35,7 @@ public class UrzaTerrainValue implements DynamicValue {
FilterControlledPermanent mi = new FilterControlledPermanent("Urza's Mine");
mi.add(new NamePredicate("Urza's Mine"));
PermanentsOnBattlefieldCount miP = new PermanentsOnBattlefieldCount(mi);
if (miP.calculate(game, sourceAbility) < 1)
if (miP.calculate(game, sourceAbility, effect) < 1)
{
return 1;
}

View file

@ -28,17 +28,6 @@
package mage.abilities.effects;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import mage.constants.Duration;
import mage.constants.EffectType;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.abilities.Ability;
import mage.abilities.ActivatedAbility;
import mage.abilities.MageSingleton;
@ -47,8 +36,11 @@ import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.DomainValue;
import mage.abilities.dynamicvalue.common.SignInversionDynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.constants.*;
import mage.game.Game;
import java.util.*;
/**
*
@ -190,7 +182,7 @@ public abstract class ContinuousEffectImpl extends EffectImpl implements Continu
protected static boolean isCanKill(DynamicValue toughness) {
if (toughness instanceof StaticValue) {
return toughness.calculate(null, null) < 0;
return toughness.calculate(null, null, null) < 0;
}
if (toughness instanceof SignInversionDynamicValue) {
// count this class as used for "-{something_positive}"

View file

@ -84,7 +84,7 @@ public class CounterUnlessPaysEffect extends OneShotEffect {
if (cost != null) {
costToPay = cost.copy();
} else {
costToPay = new GenericManaCost(genericMana.calculate(game, source));
costToPay = new GenericManaCost(genericMana.calculate(game, source, this));
}
String message;
if (costToPay instanceof ManaCost) {

View file

@ -91,7 +91,7 @@ public class CreateTokenEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
int value = amount.calculate(game, source);
int value = amount.calculate(game, source, this);
Token tokenCopy = token.copy();
tokenCopy.getAbilities().newId(); // neccessary if token has ability like DevourAbility()
tokenCopy.putOntoBattlefield(value, game, source.getSourceId(), source.getControllerId(), tapped, attacking);

View file

@ -58,7 +58,7 @@ public class CreateTokenTargetEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
int value = amount.calculate(game, source);
int value = amount.calculate(game, source, this);
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
if (value < 1) {

View file

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

View file

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

View file

@ -80,12 +80,12 @@ public class DamageEverythingEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
List<Permanent> permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game);
for (Permanent permanent: permanents) {
permanent.damage(amount.calculate(game, source), source.getSourceId(), game, false, true);
permanent.damage(amount.calculate(game, source, this), source.getSourceId(), game, false, true);
}
for (UUID playerId: game.getPlayer(source.getControllerId()).getInRange()) {
Player player = game.getPlayer(playerId);
if (player != null) {
player.damage(amount.calculate(game, source), source.getSourceId(), game, false, true);
player.damage(amount.calculate(game, source, this), source.getSourceId(), game, false, true);
}
}
return true;

View file

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

View file

@ -27,18 +27,19 @@
*/
package mage.abilities.effects.common;
import java.util.UUID;
import mage.constants.Outcome;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.OneShotEffect;
import mage.constants.Outcome;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.Target;
import java.util.UUID;
/**
*
* @author BetaSteward_at_googlemail.com
@ -79,7 +80,7 @@ public class DamageTargetEffect extends OneShotEffect {
public int getAmount() {
if (amount instanceof StaticValue) {
return amount.calculate(null, null);
return amount.calculate(null, null, this);
} else {
return 0;
}
@ -108,11 +109,11 @@ public class DamageTargetEffect extends OneShotEffect {
for (UUID targetId : target.getTargets()) {
Permanent permanent = game.getPermanent(targetId);
if (permanent != null) {
permanent.damage(amount.calculate(game, source), source.getSourceId(), game, false, preventable);
permanent.damage(amount.calculate(game, source, this), source.getSourceId(), game, false, preventable);
}
Player player = game.getPlayer(targetId);
if (player != null) {
player.damage(amount.calculate(game, source), source.getSourceId(), game, false, preventable);
player.damage(amount.calculate(game, source, this), source.getSourceId(), game, false, preventable);
}
}
}
@ -121,11 +122,11 @@ public class DamageTargetEffect extends OneShotEffect {
for (UUID targetId :this.getTargetPointer().getTargets(game, source)) {
Permanent permanent = game.getPermanent(targetId);
if (permanent != null) {
permanent.damage(amount.calculate(game, source), source.getSourceId(), game, false, preventable);
permanent.damage(amount.calculate(game, source, this), source.getSourceId(), game, false, preventable);
} else {
Player player = game.getPlayer(targetId);
if (player != null) {
player.damage(amount.calculate(game, source), source.getSourceId(), game, false, preventable);
player.damage(amount.calculate(game, source, this), source.getSourceId(), game, false, preventable);
}
}
}

View file

@ -86,7 +86,7 @@ public class DrawCardAllEffect extends OneShotEffect {
for (UUID playerId: sourcePlayer.getInRange()) {
Player player = game.getPlayer(playerId);
if (player != null) {
player.drawCards(amount.calculate(game, source), game);
player.drawCards(amount.calculate(game, source, this), game);
}
}
break;
@ -94,7 +94,7 @@ public class DrawCardAllEffect extends OneShotEffect {
for (UUID playerId: game.getOpponents(sourcePlayer.getId())) {
Player player = game.getPlayer(playerId);
if (player != null) {
player.drawCards(amount.calculate(game, source), game);
player.drawCards(amount.calculate(game, source, this), game);
}
}
break;

View file

@ -69,7 +69,7 @@ public class DrawCardSourceControllerEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
player.drawCards(amount.calculate(game, source), game);
player.drawCards(amount.calculate(game, source, this), game);
return true;
}
return false;
@ -77,7 +77,7 @@ public class DrawCardSourceControllerEffect extends OneShotEffect {
private void setText() {
StringBuilder sb = new StringBuilder();
boolean oneCard = (amount instanceof StaticValue && amount.calculate(null, null) == 1)
boolean oneCard = (amount instanceof StaticValue && amount.calculate(null, null, this) == 1)
|| amount instanceof PermanentsOnBattlefieldCount || amount.toString().equals("1");
sb.append("draw ").append(oneCard ? "a" : CardUtil.numberToText(amount.toString())).append(" card");
if (!oneCard) {

View file

@ -86,7 +86,7 @@ public class DrawCardTargetEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(targetPointer.getFirst(game, source));
if (player != null) {
int cardsToDraw = amount.calculate(game, source);
int cardsToDraw = amount.calculate(game, source, this);
if (upTo) {
cardsToDraw = player.getAmount(0, cardsToDraw, "Draw how many cards?", game);
}

View file

@ -85,7 +85,7 @@ public class DynamicManaEffect extends BasicManaEffect {
public Mana computeMana(Game game, Ability source){
this.computedMana.clear();
int count = amount.calculate(game, source);
int count = amount.calculate(game, source, this);
if (mana.getBlack() > 0) {
computedMana.setBlack(count);
} else if (mana.getBlue() > 0) {

View file

@ -74,7 +74,7 @@ public class GainLifeEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
player.gainLife(life.calculate(game, source), game);
player.gainLife(life.calculate(game, source, this), game);
}
return true;
}

View file

@ -71,7 +71,7 @@ public class GainLifeTargetEffect extends OneShotEffect {
for (UUID playerId: targetPointer.getTargets(game, source)) {
Player player = game.getPlayer(playerId);
if (player != null) {
player.gainLife(life.calculate(game, source), game);
player.gainLife(life.calculate(game, source, this), game);
}
}
return true;

View file

@ -29,8 +29,6 @@
*/
package mage.abilities.effects.common;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.dynamicvalue.DynamicValue;
@ -45,6 +43,9 @@ import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
import java.util.List;
import java.util.UUID;
/**
*
* @author LevelX
@ -116,7 +117,7 @@ public class LookLibraryAndPickControllerEffect extends LookLibraryControllerEff
}
@Override
protected void cardLooked(Card card, Game game, Ability source) {
if (numberToPick.calculate(game, source) > 0 && filter.match(card, game)) {
if (numberToPick.calculate(game, source, this) > 0 && filter.match(card, game)) {
++foundCardsToPick;
}
}
@ -128,7 +129,7 @@ public class LookLibraryAndPickControllerEffect extends LookLibraryControllerEff
if (!optional || player.chooseUse(Outcome.DrawCard, getMayText(), game)) {
FilterCard pickFilter = filter.copy();
pickFilter.setMessage(getPickText());
TargetCard target = new TargetCard((upTo ? 0:numberToPick.calculate(game, source)),numberToPick.calculate(game, source), Zone.PICK, pickFilter);
TargetCard target = new TargetCard((upTo ? 0:numberToPick.calculate(game, source, this)),numberToPick.calculate(game, source, this), Zone.PICK, pickFilter);
if (player.choose(Outcome.DrawCard, cards, target, game)) {
Cards reveal = new CardsImpl();
for (UUID cardId : (List<UUID>)target.getTargets()) {
@ -202,7 +203,7 @@ public class LookLibraryAndPickControllerEffect extends LookLibraryControllerEff
return staticText;
}
StringBuilder sb = new StringBuilder();
if (numberToPick.calculate(null, null) > 0) {
if (numberToPick.calculate(null, null, this) > 0) {
if (revealPickedCards) {
sb.append(". You may reveal ");

View file

@ -128,7 +128,7 @@ public class LookLibraryControllerEffect extends OneShotEffect {
boolean topCardRevealed = player.isTopCardRevealed();
player.setTopCardRevealed(false);
Cards cards = new CardsImpl(Zone.PICK);
int count = Math.min(player.getLibrary().size(), this.numberOfCards.calculate(game, source));
int count = Math.min(player.getLibrary().size(), this.numberOfCards.calculate(game, source, this));
for (int i = 0; i < count; i++) {
Card card = player.getLibrary().removeFromTop(game);
if (card != null) {

View file

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

View file

@ -70,7 +70,7 @@ public class LoseLifeDefendingPlayerEffect extends OneShotEffect {
for (UUID defenderId : game.getCombat().getDefenders()) {
Player defender = game.getPlayer(defenderId);
if (defender != null) {
defender.loseLife(amount.calculate(game, source), game);
defender.loseLife(amount.calculate(game, source, this), game);
}
}
return true;

View file

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

View file

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

View file

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

View file

@ -53,7 +53,7 @@ public class ManaInAnyCombinationEffect extends ManaEffect {
Player player = game.getPlayer(source.getControllerId());
if (player != null){
Mana mana = new Mana();
int amountOfManaLeft = amount.calculate(game, source);
int amountOfManaLeft = amount.calculate(game, source, this);
while (amountOfManaLeft > 0 && player.isInGame()) {
for (ColoredManaSymbol coloredManaSymbol: manaSymbols) {

View file

@ -76,7 +76,7 @@ public class PutLibraryIntoGraveTargetEffect extends OneShotEffect {
Player player = game.getPlayer(targetPointer.getFirst(game, source));
if (player != null) {
// putting cards to grave shouldn't end the game, so getting minimun available
int cardsCount = Math.min(amount.calculate(game, source), player.getLibrary().size());
int cardsCount = Math.min(amount.calculate(game, source, this), player.getLibrary().size());
for (int i = 0; i < cardsCount; i++) {
Card card = player.getLibrary().getFromTop(game);
if (card != null) {

View file

@ -70,7 +70,7 @@ public class PutTopCardOfLibraryIntoGraveTargetEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(targetPointer.getFirst(game, source));
if (player != null) {
int cardsCount = Math.min(numberCards.calculate(game, source), player.getLibrary().size());
int cardsCount = Math.min(numberCards.calculate(game, source, this), player.getLibrary().size());
for (int i = 0; i < cardsCount; i++) {
Card card = player.getLibrary().removeFromTop(game);
if (card != null) {

View file

@ -89,7 +89,7 @@ public class SacrificeAllEffect extends OneShotEffect {
for (UUID playerId : controller.getInRange()) {
Player player = game.getPlayer(playerId);
if (player != null) {
int numTargets = Math.min(amount.calculate(game, source), game.getBattlefield().countAll(filter, player.getId(), game));
int numTargets = Math.min(amount.calculate(game, source, this), game.getBattlefield().countAll(filter, player.getId(), game));
TargetControlledPermanent target = new TargetControlledPermanent(numTargets, numTargets, filter, false);
if (target.canChoose(player.getId(), game)) {
while (!target.isChosen() && player.isInGame()) {

View file

@ -83,7 +83,7 @@ public class SacrificeEffect extends OneShotEffect{
filter.add(new ControllerPredicate(TargetController.YOU));
int amount = count.calculate(game, source);
int amount = count.calculate(game, source, this);
int realCount = game.getBattlefield().countAll(filter, player.getId(), game);
amount = Math.min(amount, realCount);

View file

@ -85,7 +85,7 @@ public class SacrificeOpponentsEffect extends OneShotEffect {
for (UUID playerId : game.getOpponents(source.getControllerId())) {
Player player = game.getPlayer(playerId);
if (player != null) {
int numTargets = Math.min(amount.calculate(game, source), game.getBattlefield().countAll(filter, player.getId(), game));
int numTargets = Math.min(amount.calculate(game, source, this), game.getBattlefield().countAll(filter, player.getId(), game));
TargetControlledPermanent target = new TargetControlledPermanent(numTargets, numTargets, filter, false);
if (target.canChoose(player.getId(), game)) {
while (!target.isChosen() && player.isInGame()) {

View file

@ -116,8 +116,8 @@ public class BoostAllEffect extends ContinuousEffectImpl {
}
}
if (lockedInPT) {
power = new StaticValue(power.calculate(game, source));
toughness = new StaticValue(toughness.calculate(game, source));
power = new StaticValue(power.calculate(game, source, this));
toughness = new StaticValue(toughness.calculate(game, source, this));
}
}
@ -126,8 +126,8 @@ public class BoostAllEffect extends ContinuousEffectImpl {
for (Permanent perm: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
if (!this.affectedObjectsSet || objects.contains(perm.getId())) {
if (!(excludeSource && perm.getId().equals(source.getSourceId()))) {
perm.addPower(power.calculate(game, source));
perm.addToughness(toughness.calculate(game, source));
perm.addPower(power.calculate(game, source, this));
perm.addToughness(toughness.calculate(game, source, this));
}
}
}

View file

@ -119,8 +119,8 @@ public class BoostControlledEffect extends ContinuousEffectImpl {
}
}
if (this.lockedIn) {
power = new StaticValue(power.calculate(game, source));
toughness = new StaticValue(toughness.calculate(game, source));
power = new StaticValue(power.calculate(game, source, this));
toughness = new StaticValue(toughness.calculate(game, source, this));
}
}
@ -129,8 +129,8 @@ public class BoostControlledEffect extends ContinuousEffectImpl {
for (Permanent perm : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) {
if (!this.affectedObjectsSet || objects.contains(perm.getId())) {
if (!(excludeSource && perm.getId().equals(source.getSourceId()))) {
perm.addPower(power.calculate(game, source));
perm.addToughness(toughness.calculate(game, source));
perm.addPower(power.calculate(game, source, this));
perm.addToughness(toughness.calculate(game, source, this));
}
}
}

View file

@ -84,8 +84,8 @@ public class BoostEnchantedEffect extends ContinuousEffectImpl {
if (enchantment != null && enchantment.getAttachedTo() != null) {
Permanent creature = game.getPermanent(enchantment.getAttachedTo());
if (creature != null) {
creature.addPower(power.calculate(game, source));
creature.addToughness(toughness.calculate(game, source));
creature.addPower(power.calculate(game, source, this));
creature.addToughness(toughness.calculate(game, source, this));
}
}
return true;

View file

@ -107,8 +107,8 @@ public class BoostEquippedEffect extends ContinuousEffectImpl {
}
if (creature != null) {
creature.addPower(power.calculate(game, source));
creature.addToughness(toughness.calculate(game, source));
creature.addPower(power.calculate(game, source, this));
creature.addToughness(toughness.calculate(game, source, this));
}
return true;

View file

@ -87,8 +87,8 @@ public class BoostSourceEffect extends ContinuousEffectImpl implements SourceEff
super.init(source, game);
getAffectedObjects().add(source.getSourceId());
if (lockedIn) {
power = new StaticValue(power.calculate(game, source));
toughness = new StaticValue(toughness.calculate(game, source));
power = new StaticValue(power.calculate(game, source, this));
toughness = new StaticValue(toughness.calculate(game, source, this));
}
}
@ -96,8 +96,8 @@ public class BoostSourceEffect extends ContinuousEffectImpl implements SourceEff
public boolean apply(Game game, Ability source) {
Permanent target = game.getPermanent(source.getSourceId());
if (target != null) {
target.addPower(power.calculate(game, source));
target.addToughness(toughness.calculate(game, source));
target.addPower(power.calculate(game, source, this));
target.addToughness(toughness.calculate(game, source, this));
return true;
}
return false;

View file

@ -89,8 +89,8 @@ public class BoostTargetEffect extends ContinuousEffectImpl {
public void init(Ability source, Game game) {
super.init(source, game);
if (lockedIn) {
power = new StaticValue(power.calculate(game, source));
toughness = new StaticValue(toughness.calculate(game, source));
power = new StaticValue(power.calculate(game, source, this));
toughness = new StaticValue(toughness.calculate(game, source, this));
}
}
@ -100,8 +100,8 @@ public class BoostTargetEffect extends ContinuousEffectImpl {
for (UUID permanentId : targetPointer.getTargets(game, source)) {
Permanent target = game.getPermanent(permanentId);
if (target != null) {
target.addPower(power.calculate(game, source));
target.addToughness(toughness.calculate(game, source));
target.addPower(power.calculate(game, source, this));
target.addToughness(toughness.calculate(game, source, this));
affectedTargets++;
}
}

View file

@ -75,7 +75,7 @@ public class LoseCreatureTypeSourceEffect extends ContinuousEffectImpl implement
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
if (dynamicValue.calculate(game, source) >= lessThan) {
if (dynamicValue.calculate(game, source, this) >= lessThan) {
return false;
}
Permanent permanent = game.getPermanent(source.getSourceId());

View file

@ -67,11 +67,11 @@ public class SetPowerSourceEffect extends ContinuousEffectImpl {
public boolean apply(Game game, Ability source) {
MageObject mageObject = game.getObject(source.getSourceId());
if (mageObject != null) {
int value = amount.calculate(game, source);
int value = amount.calculate(game, source, this);
mageObject.getPower().setValue(value);
return true;
}
return false;
}
}
}

View file

@ -93,15 +93,15 @@ public class SetPowerToughnessAllEffect extends ContinuousEffectImpl {
}
}
if (lockedInPT) {
power = new StaticValue(power.calculate(game, source));
toughness = new StaticValue(toughness.calculate(game, source));
power = new StaticValue(power.calculate(game, source, this));
toughness = new StaticValue(toughness.calculate(game, source, this));
}
}
@Override
public boolean apply(Game game, Ability source) {
int newPower = power.calculate(game, source);
int newToughness = toughness.calculate(game, source);
int newPower = power.calculate(game, source, this);
int newToughness = toughness.calculate(game, source, this);
if (affectedObjectsSet) {
for (UUID permanentId :objects) {
Permanent permanent = game.getPermanent(permanentId);

View file

@ -80,7 +80,7 @@ public class SetPowerToughnessSourceEffect extends ContinuousEffectImpl {
return false;
}
if (amount != null) {
int value = amount.calculate(game, source);
int value = amount.calculate(game, source, this);
mageObject.getPower().setValue(value);
mageObject.getToughness().setValue(value);
return true;

View file

@ -77,8 +77,8 @@ public class SetPowerToughnessTargetEffect extends ContinuousEffectImpl {
for (UUID targetId: this.getTargetPointer().getTargets(game, source)) {
Permanent target = game.getPermanent(targetId);
if (target != null) {
target.getPower().setValue(power.calculate(game, source));
target.getToughness().setValue(toughness.calculate(game, source));
target.getPower().setValue(power.calculate(game, source, this));
target.getToughness().setValue(toughness.calculate(game, source, this));
result = true;
}
}

View file

@ -65,7 +65,7 @@ public class SetToughnessSourceEffect extends ContinuousEffectImpl {
public boolean apply(Game game, Ability source) {
MageObject mageObject = game.getObject(source.getSourceId());
if (mageObject != null) {
int value = amount.calculate(game, source);
int value = amount.calculate(game, source, this);
mageObject.getToughness().setValue(value);
return true;
}

View file

@ -82,7 +82,7 @@ public class AddCountersAttachedEffect extends OneShotEffect {
Permanent attachedTo = game.getPermanent(permanent.getAttachedTo());
if (attachedTo != null && counter != null) {
Counter newCounter = counter.copy();
newCounter.add(amount.calculate(game, source));
newCounter.add(amount.calculate(game, source, this));
attachedTo.addCounters(newCounter, game);
}
return true;

View file

@ -95,7 +95,7 @@ public class AddCountersSourceEffect extends OneShotEffect {
if (card != null) {
if (counter != null) {
Counter newCounter = counter.copy();
int countersToAdd = amount.calculate(game, source);
int countersToAdd = amount.calculate(game, source, this);
if (countersToAdd > 0 && newCounter.getCount() == 1) {
countersToAdd--;
}
@ -115,7 +115,7 @@ public class AddCountersSourceEffect extends OneShotEffect {
if (permanent != null) {
if (counter != null) {
Counter newCounter = counter.copy();
int countersToAdd = amount.calculate(game, source);
int countersToAdd = amount.calculate(game, source, this);
if (countersToAdd > 0 && newCounter.getCount() == 1) {
countersToAdd--;
}

View file

@ -90,7 +90,7 @@ public class AddCountersTargetEffect extends OneShotEffect {
if (permanent != null) {
if (counter != null) {
Counter newCounter = counter.copy();
newCounter.add(amount.calculate(game, source));
newCounter.add(amount.calculate(game, source, this));
permanent.addCounters(newCounter, game);
affectedTargets ++;
game.informPlayers(new StringBuilder(sourceObject.getLogName()).append(": ")
@ -102,7 +102,7 @@ public class AddCountersTargetEffect extends OneShotEffect {
Player player = game.getPlayer(uuid);
if (player != null) {
Counter newCounter = counter.copy();
newCounter.add(amount.calculate(game, source));
newCounter.add(amount.calculate(game, source, this));
player.addCounters(newCounter, game);
affectedTargets ++;
game.informPlayers(new StringBuilder(sourceObject.getLogName()).append(": ")

View file

@ -129,7 +129,7 @@ public class DiscardCardYouChooseTargetEffect extends OneShotEffect {
if (revealAllCards) {
this.numberCardsToReveal = new StaticValue(player.getHand().size());
}
int numberToReveal = this.numberCardsToReveal.calculate(game, source);
int numberToReveal = this.numberCardsToReveal.calculate(game, source, this);
if (numberToReveal > 0) {
Cards revealedCards = new CardsImpl(Zone.HAND);
numberToReveal = Math.min(player.getHand().size(), numberToReveal);
@ -155,7 +155,7 @@ public class DiscardCardYouChooseTargetEffect extends OneShotEffect {
boolean result = true;
int filteredCardsCount = revealedCards.count(filter, source.getSourceId(), source.getControllerId(), game);
int numberToDiscard = Math.min(this.numberCardsToDiscard.calculate(game, source), filteredCardsCount);
int numberToDiscard = Math.min(this.numberCardsToDiscard.calculate(game, source, this), filteredCardsCount);
if (numberToDiscard > 0) {
TargetCard target = new TargetCard(numberToDiscard, Zone.HAND, filter);
if (controller.choose(Outcome.Benefit, revealedCards, target, game)) {

View file

@ -82,7 +82,7 @@ public class DiscardControllerEffect extends OneShotEffect {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
if (randomDiscard) {
int maxAmount = Math.min(amount.calculate(game, source), player.getHand().size());
int maxAmount = Math.min(amount.calculate(game, source, this), player.getHand().size());
for (int i = 0; i < maxAmount; i++) {
Card card = player.getHand().getRandom(game);
if (card != null) {
@ -90,7 +90,7 @@ public class DiscardControllerEffect extends OneShotEffect {
}
}
} else {
player.discard(amount.calculate(game, source), source, game);
player.discard(amount.calculate(game, source, this), source, game);
result = true;
}
}

View file

@ -79,7 +79,7 @@ public class DiscardEachPlayerEffect extends OneShotEffect {
}
break;
}
int numberOfCardsToDiscard = Math.min(amount.calculate(game, source), player.getHand().size());
int numberOfCardsToDiscard = Math.min(amount.calculate(game, source, this), player.getHand().size());
Cards cards = new CardsImpl();
if (randomDiscard) {
while (player.isInGame() && cards.size() < numberOfCardsToDiscard) {

View file

@ -92,7 +92,7 @@ public class DiscardTargetEffect extends OneShotEffect {
Player player = game.getPlayer(targetPointer.getFirst(game, source));
if (player != null) {
if (randomDiscard) {
int maxAmount = Math.min(amount.calculate(game, source), player.getHand().size());
int maxAmount = Math.min(amount.calculate(game, source, this), player.getHand().size());
for (int i = 0; i < maxAmount; i++) {
Card card = player.getHand().getRandom(game);
if (card != null) {
@ -105,7 +105,7 @@ public class DiscardTargetEffect extends OneShotEffect {
}
}
} else {
player.discard(amount.calculate(game, source), source, game);
player.discard(amount.calculate(game, source, this), source, game);
}
return true;

View file

@ -31,6 +31,7 @@ import mage.abilities.Ability;
import mage.abilities.common.BlocksOrBecomesBlockedTriggeredAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.continious.BoostSourceEffect;
import mage.constants.Duration;
import mage.game.Game;
@ -65,8 +66,8 @@ public class BushidoAbility extends BlocksOrBecomesBlockedTriggeredAbility {
return new BushidoAbility(this);
}
public int getValue(Ability source, Game game) {
return value.calculate(game, source);
public int getValue(Ability source, Game game, Effect effect) {
return value.calculate(game, source, effect);
}
@Override

View file

@ -98,10 +98,10 @@ class SunburstEffect extends OneShotEffect {
if (permanent != null) {
Counter counter;
if(permanent.getCardType().contains(CardType.CREATURE)){
counter = CounterType.P1P1.createInstance(amount.calculate(game, source));
counter = CounterType.P1P1.createInstance(amount.calculate(game, source, this));
}
else{
counter = CounterType.CHARGE.createInstance(amount.calculate(game, source));
counter = CounterType.CHARGE.createInstance(amount.calculate(game, source, this));
}
if (counter != null) {

View file

@ -28,9 +28,6 @@
package mage.game.match;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import mage.cards.decks.Deck;
import mage.game.Game;
import mage.game.GameException;
@ -38,6 +35,10 @@ import mage.game.events.Listener;
import mage.game.events.TableEvent;
import mage.players.Player;
import java.util.Date;
import java.util.List;
import java.util.UUID;
/**
*
* @author BetaSteward_at_googlemail.com

View file

@ -28,14 +28,15 @@
package mage.target;
import java.util.*;
import mage.constants.Outcome;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.constants.Outcome;
import mage.game.Game;
import mage.players.Player;
import java.util.*;
/**
*
* @author BetaSteward_at_googlemail.com
@ -95,7 +96,7 @@ public abstract class TargetAmount extends TargetImpl {
}
public void setAmount(Ability source, Game game) {
remainingAmount = amount.calculate(game, source);
remainingAmount = amount.calculate(game, source, null);
amountWasSet = true;
}