forked from External/mage
reworked/simplified/consolidated effects which exchange life totals, added test (fixes #7668)
This commit is contained in:
parent
1abeec9595
commit
d4792e3665
16 changed files with 284 additions and 274 deletions
|
|
@ -0,0 +1,44 @@
|
|||
|
||||
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.players.Player;
|
||||
|
||||
/**
|
||||
* @author Styxo
|
||||
*/
|
||||
public class ExchangeLifeControllerTargetEffect extends OneShotEffect {
|
||||
|
||||
public ExchangeLifeControllerTargetEffect() {
|
||||
super(Outcome.Neutral);
|
||||
}
|
||||
|
||||
private ExchangeLifeControllerTargetEffect(final ExchangeLifeControllerTargetEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExchangeLifeControllerTargetEffect copy() {
|
||||
return new ExchangeLifeControllerTargetEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Player player = game.getPlayer(source.getFirstTarget());
|
||||
if (controller == null || player == null) {
|
||||
return false;
|
||||
}
|
||||
controller.exchangeLife(player, source, game);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
return "Exchange life totals with target " + mode.getTargets().get(0).getTargetName();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue