forked from External/mage
Restructured Mage module
This commit is contained in:
parent
727d62babb
commit
46eb6c0525
1502 changed files with 11 additions and 9 deletions
|
|
@ -0,0 +1,56 @@
|
|||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
* @author Loki
|
||||
*/
|
||||
public class MayTapOrUntapTargetEffect extends OneShotEffect {
|
||||
|
||||
public MayTapOrUntapTargetEffect() {
|
||||
super(Outcome.Benefit);
|
||||
}
|
||||
|
||||
public MayTapOrUntapTargetEffect(final MayTapOrUntapTargetEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent target = game.getPermanent(targetPointer.getFirst(game, source));
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (target != null && player != null) {
|
||||
if (target.isTapped()) {
|
||||
if (player.chooseUse(Outcome.Untap, "Untap that permanent?", source, game)) {
|
||||
target.untap(game);
|
||||
}
|
||||
} else {
|
||||
if (player.chooseUse(Outcome.Tap, "Tap that permanent?", source, game)) {
|
||||
target.tap(game);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MayTapOrUntapTargetEffect copy() {
|
||||
return new MayTapOrUntapTargetEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
if (mode.getTargets().isEmpty()) {
|
||||
return "you may tap or untap it";
|
||||
} else {
|
||||
return "you may tap or untap target " + mode.getTargets().get(0).getTargetName();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue