forked from External/mage
Refactor some cost modification effects
This commit is contained in:
parent
2c745109e4
commit
e8dbd2a3c8
49 changed files with 174 additions and 180 deletions
|
|
@ -29,9 +29,7 @@ public class AffinityEffect extends CostModificationEffectImpl {
|
|||
public boolean apply(Game game, Ability source, Ability abilityToModify) {
|
||||
// abilityToModify.getControllerId() works with Sen Triplets and in multiplayer games, see https://github.com/magefree/mage/issues/5931
|
||||
int count = game.getBattlefield().getActivePermanents(filter, abilityToModify.getControllerId(), source.getId(), game).size();
|
||||
if (count > 0) {
|
||||
CardUtil.reduceCost(abilityToModify, count);
|
||||
}
|
||||
CardUtil.reduceCost(abilityToModify, count);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,53 @@
|
|||
package mage.abilities.effects.common.cost;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.constants.CostModificationType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.util.CardUtil;
|
||||
import mage.watchers.common.PlanarRollWatcher;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author JayDi85
|
||||
*/
|
||||
public class PlanarDieRollCostIncreasingEffect extends CostModificationEffectImpl {
|
||||
|
||||
private final UUID originalId;
|
||||
|
||||
public PlanarDieRollCostIncreasingEffect(UUID originalId) {
|
||||
super(Duration.EndOfGame, Outcome.Benefit, CostModificationType.INCREASE_COST);
|
||||
this.originalId = originalId;
|
||||
}
|
||||
|
||||
private PlanarDieRollCostIncreasingEffect(final PlanarDieRollCostIncreasingEffect effect) {
|
||||
super(effect);
|
||||
this.originalId = effect.originalId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source, Ability abilityToModify) {
|
||||
Player activePlayer = game.getPlayer(game.getActivePlayerId());
|
||||
PlanarRollWatcher watcher = game.getState().getWatcher(PlanarRollWatcher.class);
|
||||
if (activePlayer == null && watcher == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int rolledCounter = watcher.getNumberTimesPlanarDieRolled(activePlayer.getId());
|
||||
CardUtil.increaseCost(abilityToModify, rolledCounter);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||
return abilityToModify.getOriginalId().equals(originalId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlanarDieRollCostIncreasingEffect copy() {
|
||||
return new PlanarDieRollCostIncreasingEffect(this);
|
||||
}
|
||||
}
|
||||
|
|
@ -26,9 +26,7 @@ public class SpellCostReductionSourceForOpponentsEffect extends CostModification
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source, Ability abilityToModify) {
|
||||
int count = game.getOpponents(source.getControllerId()).size();
|
||||
if (count > 0) {
|
||||
CardUtil.reduceCost(abilityToModify, count);
|
||||
}
|
||||
CardUtil.reduceCost(abilityToModify, count);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue