mirror of
https://github.com/magefree/mage.git
synced 2025-12-29 06:52:02 -08:00
new TargetPlayerGainControlSourceEffect
rework Drooling Ogre and others to use it
This commit is contained in:
parent
94ca1626c7
commit
d6e7ff6dad
16 changed files with 139 additions and 549 deletions
|
|
@ -0,0 +1,61 @@
|
|||
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 TargetPlayerGainControlSourceEffect extends OneShotEffect {
|
||||
|
||||
private final String playerDescription;
|
||||
|
||||
public TargetPlayerGainControlSourceEffect() {
|
||||
this("");
|
||||
}
|
||||
|
||||
public TargetPlayerGainControlSourceEffect(String playerDescription) {
|
||||
super(Outcome.Benefit);
|
||||
this.playerDescription = playerDescription;
|
||||
}
|
||||
|
||||
protected TargetPlayerGainControlSourceEffect(final TargetPlayerGainControlSourceEffect effect) {
|
||||
super(effect);
|
||||
this.playerDescription = effect.playerDescription;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
|
||||
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
|
||||
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 TargetPlayerGainControlSourceEffect copy() {
|
||||
return new TargetPlayerGainControlSourceEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
return (playerDescription.isEmpty() ? getTargetPointer().describeTargets(mode.getTargets(), "that player") : playerDescription) +
|
||||
" gains control of {this}";
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue