foul-magics/Mage/src/main/java/mage/abilities/effects/CreateTokenCopySourceEffect.java
Susucre f75b1c9f0a
Code cleanup: protect all copy constructors (#10750)
* apply regex to change public copy constructors to protected
* cleanup code using now protected constructors
* fix manaBuilder weird casting of Mana into ConditionalMana
2023-08-04 19:34:58 -04:00

56 lines
1.7 KiB
Java

package mage.abilities.effects;
import mage.abilities.Ability;
import mage.abilities.effects.common.CreateTokenCopyTargetEffect;
import mage.constants.Outcome;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTarget;
/**
* Created by glerman on 20/6/15.
*/
public class CreateTokenCopySourceEffect extends OneShotEffect {
private final int number;
private final boolean tapped;
public CreateTokenCopySourceEffect() {
this(1);
}
public CreateTokenCopySourceEffect(int copies) {
this(copies, false);
}
public CreateTokenCopySourceEffect(int copies, boolean tapped) {
super(Outcome.PutCreatureInPlay);
this.number = copies;
this.tapped = tapped;
staticText = "create a " + (tapped ? "tapped " : "") + "token that's a copy of {this}";
}
protected CreateTokenCopySourceEffect(final CreateTokenCopySourceEffect effect) {
super(effect);
this.number = effect.number;
this.tapped = effect.tapped;
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (permanent == null) {
return false;
}
CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(
source.getControllerId(), null, false, number, tapped, false
);
effect.setTargetPointer(new FixedTarget(source.getSourceId(), game));
return effect.apply(game, source);
}
@Override
public CreateTokenCopySourceEffect copy() {
return new CreateTokenCopySourceEffect(this);
}
}