mirror of
https://github.com/magefree/mage.git
synced 2025-12-27 05:52:06 -08:00
rework Banewasp Affliction
This commit is contained in:
parent
2d5ea0c1d5
commit
1c19280693
2 changed files with 60 additions and 41 deletions
|
|
@ -0,0 +1,52 @@
|
|||
package mage.abilities.dynamicvalue.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
* @author xenohedron
|
||||
*/
|
||||
public enum AttachedPermanentToughnessCount implements DynamicValue {
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
Permanent attachmentPermanent = game.getPermanent(sourceAbility.getSourceId());
|
||||
if (attachmentPermanent == null) {
|
||||
attachmentPermanent = (Permanent) game.getLastKnownInformation(sourceAbility.getSourceId(), Zone.BATTLEFIELD, sourceAbility.getSourceObjectZoneChangeCounter());
|
||||
}
|
||||
if (attachmentPermanent == null || attachmentPermanent.getAttachedTo() == null) {
|
||||
return 0;
|
||||
}
|
||||
Permanent attached;
|
||||
if (effect.getValue("attachedTo") instanceof Permanent) {
|
||||
// This way is needed to obtain correct LKI (e.g. Persist)
|
||||
attached = (Permanent) effect.getValue("attachedTo");
|
||||
} else {
|
||||
attached = game.getPermanentOrLKIBattlefield(attachmentPermanent.getAttachedTo());
|
||||
}
|
||||
if (attached != null && attached.getToughness().getValue() >= 0) {
|
||||
return attached.getToughness().getValue();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttachedPermanentToughnessCount copy() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "X";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return "its toughness";
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue