mirror of
https://github.com/correl/mage.git
synced 2024-11-22 03:00:11 +00:00
Improvements to effects that use ADD_COUNTERS GameEvent (#10474)
* Fix Blightbeetle * Another adjustment to Laezel * Fix Vizier of Remedies * Make extra counters overflow safe * Inline variable instead of field (Doubling Season)
This commit is contained in:
parent
93726d6dd0
commit
0ce6df9ef7
11 changed files with 36 additions and 26 deletions
|
@ -75,14 +75,14 @@ class BlightbeetleEffect extends ContinuousRuleModifyingEffectImpl {
|
|||
if (!event.getData().equals(CounterType.P1P1.getName())) {
|
||||
return false;
|
||||
}
|
||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
Permanent permanent = game.getPermanentEntering(event.getTargetId());
|
||||
if (permanent == null) {
|
||||
permanent = game.getPermanent(event.getTargetId());
|
||||
}
|
||||
if (permanent == null || !permanent.isCreature(game)) {
|
||||
return false;
|
||||
}
|
||||
Player player = game.getPlayer(permanent.getControllerId());
|
||||
if (player == null || !player.hasOpponent(source.getControllerId(), game)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return player != null && player.hasOpponent(source.getControllerId(), game);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import mage.counters.CounterType;
|
|||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -63,7 +64,7 @@ class CorpsejackMenaceReplacementEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
event.setAmountForCounters(event.getAmount() * 2, true);
|
||||
event.setAmountForCounters(CardUtil.overflowMultiply(event.getAmount(), 2), true);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import mage.game.Game;
|
|||
import mage.game.events.CreateTokenEvent;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -80,8 +81,6 @@ class DoublingSeasonTokenEffect extends ReplacementEffectImpl {
|
|||
|
||||
class DoublingSeasonCounterEffect extends ReplacementEffectImpl {
|
||||
|
||||
private boolean landPlayed = false; // a played land is not an effect
|
||||
|
||||
DoublingSeasonCounterEffect() {
|
||||
super(Duration.WhileOnBattlefield, Outcome.BoostCreature, false);
|
||||
staticText = "If an effect would put one or more counters on a permanent you control, it puts twice that many of those counters on that permanent instead";
|
||||
|
@ -93,7 +92,7 @@ class DoublingSeasonCounterEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
event.setAmountForCounters(event.getAmount() * 2, true);
|
||||
event.setAmountForCounters(CardUtil.overflowMultiply(event.getAmount(), 2), true);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -110,13 +109,13 @@ class DoublingSeasonCounterEffect extends ReplacementEffectImpl {
|
|||
}
|
||||
if (permanent == null) {
|
||||
permanent = game.getPermanentEntering(event.getTargetId());
|
||||
landPlayed = (permanent != null
|
||||
&& permanent.isLand(game)); // a played land is not an effect
|
||||
if (permanent != null && permanent.isLand(game)) {
|
||||
return false; // a played land is not an effect (e.g. Gemstone Mine)
|
||||
}
|
||||
}
|
||||
return permanent != null
|
||||
&& permanent.isControlledBy(source.getControllerId())
|
||||
&& event.getAmount() > 0
|
||||
&& !landPlayed; // example: gemstone mine being played as a land drop
|
||||
&& event.getAmount() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -11,6 +11,7 @@ import mage.constants.*;
|
|||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -59,7 +60,7 @@ class LaezelVlaakithsChampionEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
event.setAmountForCounters(event.getAmount() + 1, true);
|
||||
event.setAmountForCounters(CardUtil.overflowInc(event.getAmount(), 1), true);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -70,7 +71,7 @@ class LaezelVlaakithsChampionEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (!source.isControlledBy(event.getPlayerId())) {
|
||||
if (event.getAmount() <= 0 || !source.isControlledBy(event.getPlayerId())) {
|
||||
return false;
|
||||
}
|
||||
if (source.isControlledBy(event.getTargetId())) {
|
||||
|
|
|
@ -13,6 +13,7 @@ import mage.counters.CounterType;
|
|||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -63,7 +64,7 @@ class MowuLoyalCompanionEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
event.setAmountForCounters(event.getAmount() + 1, true);
|
||||
event.setAmountForCounters(CardUtil.overflowInc(event.getAmount(), 1), true);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import mage.game.Game;
|
|||
import mage.game.events.CreateTokenEvent;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -96,7 +97,7 @@ class PrimalVigorCounterEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
event.setAmountForCounters(event.getAmount() * 2, true);
|
||||
event.setAmountForCounters(CardUtil.overflowMultiply(event.getAmount(), 2), true);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ import mage.constants.*;
|
|||
import mage.counters.CounterType;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -70,11 +71,14 @@ class VizierOfRemediesReplacementEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (source != null && source.getControllerId() != null) {
|
||||
return source.isControlledBy(game.getControllerId(event.getTargetId()))
|
||||
&& event.getData() != null && event.getData().equals(CounterType.M1M1.getName())
|
||||
&& event.getAmount() > 0;
|
||||
if (event.getAmount() <= 0 || !event.getData().equals(CounterType.M1M1.getName())) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
if (permanent == null) {
|
||||
permanent = game.getPermanentEntering(event.getTargetId());
|
||||
}
|
||||
return permanent != null && permanent.isControlledBy(source.getControllerId())
|
||||
&& permanent.isCreature(game);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import mage.game.Game;
|
|||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -73,7 +74,7 @@ class VorinclexMonstrousRaiderEffect extends ReplacementEffectImpl {
|
|||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
if (source.isControlledBy(event.getPlayerId())) {
|
||||
event.setAmountForCounters(2 * event.getAmount(), true);
|
||||
event.setAmountForCounters(CardUtil.overflowMultiply(event.getAmount(), 2), true);
|
||||
} else if (game.getOpponents(event.getPlayerId()).contains(source.getControllerId())) {
|
||||
event.setAmountForCounters(Math.floorDiv(event.getAmount(), 2), true);
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import mage.filter.StaticFilters;
|
|||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.players.Player;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -62,7 +63,7 @@ class WindingConstrictorPlayerEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
event.setAmountForCounters(event.getAmount() + 1, true);
|
||||
event.setAmountForCounters(CardUtil.overflowInc(event.getAmount(), 1), true);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import mage.game.events.GameEvent;
|
|||
import mage.game.permanent.Permanent;
|
||||
import mage.game.stack.StackObject;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -77,7 +78,7 @@ class ZabazTheGlimmerwaspEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
event.setAmountForCounters(event.getAmount() + 1, true);
|
||||
event.setAmountForCounters(CardUtil.overflowInc(event.getAmount(), 1), true);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ public class ModifyCountersAddedEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
event.setAmountForCounters(event.getAmount() + 1, true);
|
||||
event.setAmountForCounters(CardUtil.overflowInc(event.getAmount(), 1), true);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue