From ae00a74b4c2238488987ab63fcbb2aa2ad7a3822 Mon Sep 17 00:00:00 2001 From: Jeff Date: Sun, 17 Mar 2019 17:34:13 -0500 Subject: [PATCH] - refactored Krovikan Vampire. --- .../src/mage/cards/k/KrovikanVampire.java | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/Mage.Sets/src/mage/cards/k/KrovikanVampire.java b/Mage.Sets/src/mage/cards/k/KrovikanVampire.java index 22e57a47fe..47197080a5 100644 --- a/Mage.Sets/src/mage/cards/k/KrovikanVampire.java +++ b/Mage.Sets/src/mage/cards/k/KrovikanVampire.java @@ -47,7 +47,7 @@ public final class KrovikanVampire extends CardImpl { Zone.BATTLEFIELD, new KrovikanVampireEffect(), TargetController.ANY, - KrovikanVampireInterveningIfCondition.instance, + new KrovikanVampireInterveningIfCondition(), false); ability.addWatcher(new KrovikanVampireCreaturesDamagedWatcher()); ability.addWatcher(new KrovikanVampireCreaturesDiedWatcher()); @@ -85,14 +85,17 @@ class KrovikanVampireEffect extends OneShotEffect { if (creaturesAffected != null && controller != null && krovikanVampire != null) { - for (UUID creatureId : creaturesAffected) { + creaturesAffected.stream().map((creatureId) -> { controller.moveCards(game.getCard(creatureId), Zone.BATTLEFIELD, source, game, false, false, false, null); + return creatureId; + }).map((creatureId) -> { OneShotEffect effect = new SacrificeTargetEffect(); effect.setText("Sacrifice this if Krovikan Vampire leaves the battlefield or its current controller loses control of it."); effect.setTargetPointer(new FixedTarget(creatureId)); - KrovikanVampireDelayedTriggeredAbility dTA = new KrovikanVampireDelayedTriggeredAbility(effect, krovikanVampire.getId()); + return effect; + }).map((effect) -> new KrovikanVampireDelayedTriggeredAbility(effect, krovikanVampire.getId())).forEachOrdered((dTA) -> { game.addDelayedTriggeredAbility(dTA, source); - } + }); creaturesAffected.clear(); return true; } @@ -105,9 +108,8 @@ class KrovikanVampireEffect extends OneShotEffect { } } -enum KrovikanVampireInterveningIfCondition implements Condition { +class KrovikanVampireInterveningIfCondition implements Condition { - instance; Set creaturesAffected = new HashSet<>(); @Override @@ -116,16 +118,12 @@ enum KrovikanVampireInterveningIfCondition implements Condition { KrovikanVampireCreaturesDamagedWatcher watcherDamaged = game.getState().getWatcher(KrovikanVampireCreaturesDamagedWatcher.class); if (watcherDied != null) { Set creaturesThatDiedThisTurn = watcherDied.getDiedThisTurn(); - for (UUID mor : creaturesThatDiedThisTurn) { - if (watcherDamaged != null) { - for (UUID mor2 : watcherDamaged.getDamagedBySource()) { - if (mor2 != null - && mor == mor2) { - creaturesAffected.add(mor); - } - } - } - } + creaturesThatDiedThisTurn.stream().filter((mor) -> (watcherDamaged != null)).forEachOrdered((mor) -> { + watcherDamaged.getDamagedBySource().stream().filter((mor2) -> (mor2 != null + && mor == mor2)).forEachOrdered((_item) -> { + creaturesAffected.add(mor); + }); + }); if (creaturesAffected != null && creaturesAffected.size() > 0) { game.getState().setValue(source.getSourceId() + "creatureToGainControl", creaturesAffected);