mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
Fixed a bug that the effect failed when the source attachment of the effect left meanwhile the battlefield.
This commit is contained in:
parent
09aba1bd87
commit
bc7ffd1201
1 changed files with 8 additions and 2 deletions
|
@ -29,6 +29,7 @@
|
|||
package mage.abilities.effects.common.counter;
|
||||
|
||||
import mage.Constants.Outcome;
|
||||
import mage.Constants.Zone;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.counters.common.PlusOneCounter;
|
||||
|
@ -62,6 +63,9 @@ public class AddPlusOneCountersAttachedEffect extends OneShotEffect<AddPlusOneCo
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent enchantment = game.getPermanent(source.getSourceId());
|
||||
if (enchantment == null) {
|
||||
enchantment = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
|
||||
}
|
||||
if (enchantment != null && enchantment.getAttachedTo() != null) {
|
||||
Permanent creature = game.getPermanent(enchantment.getAttachedTo());
|
||||
if (creature != null) {
|
||||
|
@ -72,10 +76,12 @@ public class AddPlusOneCountersAttachedEffect extends OneShotEffect<AddPlusOneCo
|
|||
}
|
||||
|
||||
private void setText() {
|
||||
if (amount > 1)
|
||||
if (amount > 1) {
|
||||
staticText = "put " + Integer.toString(amount) + " +1/+1 counters on enchanted creature";
|
||||
else
|
||||
}
|
||||
else {
|
||||
staticText = "put a +1/+1 counter on enchanted creature";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue