mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
[DOM] Refactor Corrosive Ooze to use standard effect
This commit is contained in:
parent
0cf8baeb69
commit
4d770d3aac
3 changed files with 60 additions and 78 deletions
|
|
@ -0,0 +1,55 @@
|
|||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubType;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Quercitron
|
||||
*/
|
||||
|
||||
public class DestroyAllAttachedEquipmentEffect extends OneShotEffect {
|
||||
|
||||
public DestroyAllAttachedEquipmentEffect() {
|
||||
super(Outcome.Benefit);
|
||||
this.staticText = "Destroy all Equipment attached to that creature";
|
||||
}
|
||||
|
||||
public DestroyAllAttachedEquipmentEffect(final DestroyAllAttachedEquipmentEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DestroyAllAttachedEquipmentEffect copy() {
|
||||
return new DestroyAllAttachedEquipmentEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
Permanent target = game.getPermanent(source.getFirstTarget());
|
||||
if (target != null) {
|
||||
List<UUID> attachments = new ArrayList<>(target.getAttachments());
|
||||
for (UUID attachmentId : attachments) {
|
||||
Permanent attachment = game.getPermanent(attachmentId);
|
||||
if (attachment != null && attachment.hasSubtype(SubType.EQUIPMENT, game)) {
|
||||
attachment.destroy(source.getSourceId(), game, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue