forked from External/mage
refactor: common logic for getting controller of target object (#13038)
This commit is contained in:
parent
6cc2306784
commit
737e67963d
11 changed files with 53 additions and 126 deletions
|
|
@ -6,8 +6,6 @@ import mage.abilities.dynamicvalue.common.StaticValue;
|
|||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
|
|
@ -39,16 +37,7 @@ public class GainLifeTargetControllerEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player targetController = null;
|
||||
Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
|
||||
if (permanent != null) {
|
||||
targetController = game.getPlayer(permanent.getControllerId());
|
||||
} else {
|
||||
Spell spell = game.getSpellOrLKIStack(getTargetPointer().getFirst(game, source));
|
||||
if (spell != null) {
|
||||
targetController = game.getPlayer(spell.getControllerId());
|
||||
}
|
||||
}
|
||||
Player targetController = getTargetPointer().getControllerOfFirstTargetOrLKI(game, source);
|
||||
if (targetController != null) {
|
||||
targetController.gainLife(amount.calculate(game, source, this), game, source);
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue