mirror of
https://github.com/magefree/mage.git
synced 2026-01-24 04:09:54 -08:00
* Blinding Powder - Fixed check for source object.
This commit is contained in:
parent
3d66f662ec
commit
c8ba5fc50a
1 changed files with 12 additions and 8 deletions
|
|
@ -61,7 +61,7 @@ public class BlindingPowder extends CardImpl {
|
||||||
// Equipped creature has "Unattach Blinding Powder: Prevent all combat damage that would be dealt to this creature this turn."
|
// Equipped creature has "Unattach Blinding Powder: Prevent all combat damage that would be dealt to this creature this turn."
|
||||||
Effect effect = new PreventCombatDamageToSourceEffect(Duration.EndOfTurn);
|
Effect effect = new PreventCombatDamageToSourceEffect(Duration.EndOfTurn);
|
||||||
effect.setText("Prevent all combat damage that would be dealt to this creature this turn");
|
effect.setText("Prevent all combat damage that would be dealt to this creature this turn");
|
||||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new BlindingPowderUnattachCost());
|
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new BlindingPowderUnattachCost(getName(), getId()));
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(ability, AttachmentType.EQUIPMENT, Duration.WhileOnBattlefield)));
|
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(ability, AttachmentType.EQUIPMENT, Duration.WhileOnBattlefield)));
|
||||||
// Equip {2}
|
// Equip {2}
|
||||||
this.addAbility(new EquipAbility(Outcome.PreventDamage, new GenericManaCost(2)));
|
this.addAbility(new EquipAbility(Outcome.PreventDamage, new GenericManaCost(2)));
|
||||||
|
|
@ -79,21 +79,25 @@ public class BlindingPowder extends CardImpl {
|
||||||
|
|
||||||
class BlindingPowderUnattachCost extends CostImpl {
|
class BlindingPowderUnattachCost extends CostImpl {
|
||||||
|
|
||||||
public BlindingPowderUnattachCost() {
|
protected UUID sourceEquipmentId;
|
||||||
this.text = "Unattach Blinding Powder";
|
|
||||||
|
public BlindingPowderUnattachCost(String name, UUID sourceId) {
|
||||||
|
this.text = "Unattach " + name;
|
||||||
|
this.sourceEquipmentId = sourceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlindingPowderUnattachCost(final BlindingPowderUnattachCost cost) {
|
public BlindingPowderUnattachCost(final BlindingPowderUnattachCost cost) {
|
||||||
super(cost);
|
super(cost);
|
||||||
|
this.sourceEquipmentId = cost.sourceEquipmentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
|
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
|
||||||
Permanent permanent = game.getPermanent(sourceId);
|
Permanent permanent = game.getPermanent(sourceId);
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
for (UUID attachmentId :permanent.getAttachments()) {
|
for (UUID attachmentId : permanent.getAttachments()) {
|
||||||
Permanent attachment = game.getPermanent(attachmentId);
|
Permanent attachment = game.getPermanent(attachmentId);
|
||||||
if (attachment != null && attachment.getName().equals("Blinding Powder")) {
|
if (attachment != null && attachment.getId().equals(sourceEquipmentId)) {
|
||||||
paid = permanent.removeAttachment(attachmentId, game);
|
paid = permanent.removeAttachment(attachmentId, game);
|
||||||
if (paid) {
|
if (paid) {
|
||||||
break;
|
break;
|
||||||
|
|
@ -109,9 +113,9 @@ class BlindingPowderUnattachCost extends CostImpl {
|
||||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||||
Permanent permanent = game.getPermanent(sourceId);
|
Permanent permanent = game.getPermanent(sourceId);
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
for (UUID attachmentId :permanent.getAttachments()) {
|
for (UUID attachmentId : permanent.getAttachments()) {
|
||||||
Permanent attachment = game.getPermanent(attachmentId);
|
Permanent attachment = game.getPermanent(attachmentId);
|
||||||
if (attachment != null && attachment.getName().equals("Blinding Powder")) {
|
if (attachment != null && attachment.getId().equals(sourceEquipmentId)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue