mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
Xantcha, Sleeper Agent implemented.
Added a new effect (LoseLifePermanentControllerEffect).
This commit is contained in:
parent
6be69d7e08
commit
f4515efe41
3 changed files with 162 additions and 0 deletions
|
|
@ -0,0 +1,63 @@
|
|||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
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.players.Player;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This effect applies to the permanent's controller which originated the ability, but not to the controller of that
|
||||
* source ability.
|
||||
* @author jesusjbr
|
||||
*/
|
||||
public class LoseLifePermanentControllerEffect extends OneShotEffect {
|
||||
|
||||
protected DynamicValue amount;
|
||||
|
||||
public LoseLifePermanentControllerEffect(int amount) {
|
||||
this(new StaticValue(amount));
|
||||
}
|
||||
|
||||
public LoseLifePermanentControllerEffect(DynamicValue amount) {
|
||||
super(Outcome.LoseLife);
|
||||
this.amount = amount;
|
||||
setText();
|
||||
}
|
||||
|
||||
public LoseLifePermanentControllerEffect(final LoseLifePermanentControllerEffect effect) {
|
||||
super(effect);
|
||||
this.amount = effect.amount.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoseLifePermanentControllerEffect copy() {
|
||||
return new LoseLifePermanentControllerEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
|
||||
Player player = null;
|
||||
if (permanent != null) {
|
||||
player = game.getPlayer(permanent.getControllerId());
|
||||
}
|
||||
if (player != null) {
|
||||
player.loseLife(amount.calculate(game, source, this), game, false);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void setText() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("controller ").append("loses").append(amount.toString()).append("life");
|
||||
staticText += sb.toString();
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue