mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 21:29:17 -08:00
refactor: added runtime check for wrong usage of AddContinuousEffectToGame (closes #12427)
This commit is contained in:
parent
37dbdb4b4b
commit
a071593d47
1 changed files with 9 additions and 0 deletions
|
|
@ -8,6 +8,7 @@ import mage.abilities.effects.Effects;
|
|||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.target.targetpointer.FirstTargetPointer;
|
||||
|
||||
/**
|
||||
* @author noxx
|
||||
|
|
@ -36,6 +37,14 @@ public class AddContinuousEffectToGame extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
for (Effect effect : this.effects) {
|
||||
// runtime check
|
||||
if (!effect.getTargetPointer().getClass().equals(FirstTargetPointer.class)
|
||||
&& !effect.getTargetPointer().getClass().equals(this.getTargetPointer().getClass())) {
|
||||
throw new IllegalArgumentException("Wrong code usage: found diff target pointers, must set target pointers to AddContinuousEffectToGame, not to inner effects"
|
||||
+ " - " + source.getClass().getSimpleName()
|
||||
+ " - " + source
|
||||
);
|
||||
}
|
||||
effect.setTargetPointer(this.getTargetPointer().copy());
|
||||
game.addEffect((ContinuousEffect) effect, source);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue