mirror of
https://github.com/magefree/mage.git
synced 2025-12-21 02:52:02 -08:00
parent
67d9127027
commit
f46ac4c5ee
1 changed files with 13 additions and 17 deletions
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
package mage.abilities.effects.common;
|
package mage.abilities.effects.common;
|
||||||
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
|
|
@ -38,25 +37,22 @@ public class LoseLifeControllerAttachedEffect extends OneShotEffect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Permanent enchantment = game.getPermanent(source.getSourceId());
|
Permanent attachment = source.getSourcePermanentOrLKI(game);
|
||||||
if (enchantment == null) {
|
if (attachment == null || attachment.getAttachedTo() == null) {
|
||||||
enchantment = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
|
return false;
|
||||||
}
|
}
|
||||||
if (enchantment != null && enchantment.getAttachedTo() != null) {
|
Permanent attachedTo = (Permanent) game.getLastKnownInformation(attachment.getAttachedTo(),
|
||||||
Permanent creature = game.getPermanent(enchantment.getAttachedTo());
|
Zone.BATTLEFIELD, attachment.getAttachedToZoneChangeCounter());
|
||||||
if (creature == null) {
|
if (attachedTo == null) {
|
||||||
creature = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
|
return false;
|
||||||
|
}
|
||||||
|
Player player = game.getPlayer(attachedTo.getControllerId());
|
||||||
|
if (player == null) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
if (creature != null) {
|
|
||||||
Player player = game.getPlayer(creature.getControllerId());
|
|
||||||
if (player != null) {
|
|
||||||
player.loseLife(amount.calculate(game, source, this), game, source, false);
|
player.loseLife(amount.calculate(game, source, this), game, source, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setText() {
|
private void setText() {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue