forked from External/mage
Fixed EquipmentAttachedCount dynamic value. +1 test pass.
This commit is contained in:
parent
82b4213753
commit
bd03dce85b
4 changed files with 21 additions and 13 deletions
|
|
@ -27,7 +27,6 @@
|
|||
*/
|
||||
package mage.sets.mirrodin;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Duration;
|
||||
import mage.Constants.Rarity;
|
||||
|
|
@ -38,6 +37,8 @@ import mage.abilities.dynamicvalue.common.EquipmentAttachedCount;
|
|||
import mage.abilities.effects.common.continious.BoostSourceEffect;
|
||||
import mage.cards.CardImpl;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author North
|
||||
|
|
@ -54,6 +55,7 @@ public class LoxodonPunisher extends CardImpl<LoxodonPunisher> {
|
|||
this.power = new MageInt(2);
|
||||
this.toughness = new MageInt(2);
|
||||
|
||||
// Loxodon Punisher gets +2/+2 for each Equipment attached to it
|
||||
EquipmentAttachedCount amount = new EquipmentAttachedCount(2);
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostSourceEffect(amount, amount, Duration.WhileOnBattlefield)));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
*/
|
||||
package mage.sets.mirrodin;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Duration;
|
||||
import mage.Constants.Rarity;
|
||||
|
|
@ -38,6 +37,8 @@ import mage.abilities.dynamicvalue.common.EquipmentAttachedCount;
|
|||
import mage.abilities.effects.common.continious.BoostSourceEffect;
|
||||
import mage.cards.CardImpl;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author North
|
||||
|
|
@ -52,6 +53,7 @@ public class MyrAdapter extends CardImpl<MyrAdapter> {
|
|||
this.power = new MageInt(1);
|
||||
this.toughness = new MageInt(1);
|
||||
|
||||
// Myr Adapter gets +1/+1 for each Equipment attached to it.
|
||||
EquipmentAttachedCount amount = new EquipmentAttachedCount();
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostSourceEffect(amount, amount, Duration.WhileOnBattlefield)));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ public class GolemSkinGauntletsTest extends CardTestPlayerBase {
|
|||
Permanent eliteVanguard = getPermanent("Elite Vanguard", playerA.getId());
|
||||
Assert.assertTrue(eliteVanguard.getAttachments().size() == 2);
|
||||
Assert.assertEquals(4, eliteVanguard.getPower().getValue());
|
||||
Assert.assertEquals(1, eliteVanguard.getPower().getValue());
|
||||
Assert.assertEquals(1, eliteVanguard.getToughness().getValue());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,16 +27,17 @@
|
|||
*/
|
||||
package mage.abilities.dynamicvalue.common;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author North
|
||||
* @author North, noxx
|
||||
*/
|
||||
public class EquipmentAttachedCount implements DynamicValue {
|
||||
|
||||
|
|
@ -57,13 +58,16 @@ public class EquipmentAttachedCount implements DynamicValue {
|
|||
@Override
|
||||
public int calculate(Game game, Ability source) {
|
||||
int count = 0;
|
||||
Permanent p = game.getPermanent(source.getSourceId());
|
||||
if (p != null) {
|
||||
List<UUID> attachments = p.getAttachments();
|
||||
for (UUID attachmentId : attachments) {
|
||||
Permanent attached = game.getPermanent(attachmentId);
|
||||
if (attached != null && attached.getSubtype().contains("Equipment")) {
|
||||
count++;
|
||||
Permanent equipment = game.getPermanent(source.getSourceId());
|
||||
if (equipment != null) {
|
||||
Permanent permanent = game.getPermanent(equipment.getAttachedTo());
|
||||
if (permanent != null) {
|
||||
List<UUID> attachments = permanent.getAttachments();
|
||||
for (UUID attachmentId : attachments) {
|
||||
Permanent attached = game.getPermanent(attachmentId);
|
||||
if (attached != null && attached.getSubtype().contains("Equipment")) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue