[CMB1] Implement Frogkin Kidnapper (#11137)

This commit is contained in:
Susucre 2023-09-15 23:55:24 +02:00 committed by GitHub
parent f4b0b83612
commit 58fdbc9345
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 176 additions and 2 deletions

View file

@ -6,21 +6,30 @@ import mage.abilities.SpecialAction;
import mage.abilities.effects.OneShotEffect;
import mage.game.Game;
import java.util.UUID;
/**
* @author BetaSteward_at_googlemail.com
*/
public class CreateSpecialActionEffect extends OneShotEffect {
protected SpecialAction action;
private final SpecialAction action;
private final UUID playerId; // If set, that player can activate the special action. If null, use the source controller instead.
public CreateSpecialActionEffect(SpecialAction action) {
this(action, null);
}
public CreateSpecialActionEffect(SpecialAction action, UUID playerId) {
super(action.getEffects().getOutcome(action));
this.action = action;
this.playerId = playerId;
}
protected CreateSpecialActionEffect(final CreateSpecialActionEffect effect) {
super(effect);
this.action = (SpecialAction) effect.action.copy();
this.playerId = effect.playerId;
}
@Override
@ -32,7 +41,7 @@ public class CreateSpecialActionEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
SpecialAction newAction = (SpecialAction) action.copy();
newAction.setSourceId(source.getSourceId());
newAction.setControllerId(source.getControllerId());
newAction.setControllerId(playerId == null ? source.getControllerId() : playerId);
newAction.getTargets().addAll(source.getTargets());
game.getState().getSpecialActions().add(newAction);
return true;