mirror of
https://github.com/magefree/mage.git
synced 2026-01-09 12:22:10 -08:00
fix some inner classes (#11798)
* make inner class static * rework to remove inner class * static filter cleanup * ManaCostsImpl<> * fix copy constructor * new TargetPlayerGainControlTargetPermanentEffect * make some inner classes no longer inner classes
This commit is contained in:
parent
fa92dc8580
commit
824e4c6b7a
31 changed files with 393 additions and 560 deletions
|
|
@ -0,0 +1,67 @@
|
|||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.continuous.GainControlTargetEffect;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
/**
|
||||
* @author xenohedron
|
||||
*/
|
||||
public class TargetPlayerGainControlTargetPermanentEffect extends OneShotEffect {
|
||||
|
||||
private final String playerDescription;
|
||||
|
||||
public TargetPlayerGainControlTargetPermanentEffect() {
|
||||
this("");
|
||||
}
|
||||
|
||||
public TargetPlayerGainControlTargetPermanentEffect(String playerDescription) {
|
||||
super(Outcome.Benefit);
|
||||
this.playerDescription = playerDescription;
|
||||
}
|
||||
|
||||
protected TargetPlayerGainControlTargetPermanentEffect(final TargetPlayerGainControlTargetPermanentEffect effect) {
|
||||
super(effect);
|
||||
this.playerDescription = effect.playerDescription;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
if (source.getTargets().size() != 2) {
|
||||
throw new IllegalStateException("It must have two targets, but found " + source.getTargets().size());
|
||||
}
|
||||
Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
|
||||
Permanent permanent = game.getPermanent(source.getTargets().get(1).getFirstTarget());
|
||||
if (player == null || permanent == null) {
|
||||
return false;
|
||||
}
|
||||
game.addEffect(new GainControlTargetEffect(
|
||||
Duration.Custom, true, player.getId()
|
||||
).setTargetPointer(new FixedTarget(permanent, game)), source);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetPlayerGainControlTargetPermanentEffect copy() {
|
||||
return new TargetPlayerGainControlTargetPermanentEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
if (mode.getTargets().size() != 2) {
|
||||
throw new IllegalStateException("It must have two targets, but found " + mode.getTargets().size());
|
||||
}
|
||||
return (playerDescription.isEmpty() ? mode.getTargets().get(0).getDescription() : playerDescription) +
|
||||
" gains control of " + mode.getTargets().get(1).getDescription();
|
||||
}
|
||||
}
|
||||
|
|
@ -21,7 +21,7 @@ import java.util.UUID;
|
|||
public class GainControlTargetEffect extends ContinuousEffectImpl {
|
||||
|
||||
protected UUID controllingPlayerId;
|
||||
private boolean fixedControl;
|
||||
private final boolean fixedControl;
|
||||
private boolean firstControlChange = true;
|
||||
private final Condition condition;
|
||||
|
||||
|
|
@ -63,6 +63,7 @@ public class GainControlTargetEffect extends ContinuousEffectImpl {
|
|||
this.controllingPlayerId = effect.controllingPlayerId;
|
||||
this.fixedControl = effect.fixedControl;
|
||||
this.condition = effect.condition;
|
||||
this.firstControlChange = effect.firstControlChange;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue