* Some minot code clean up.

This commit is contained in:
LevelX2 2020-07-24 12:08:08 +02:00
parent 653a2dd7b2
commit a90dbd8533
2 changed files with 17 additions and 27 deletions

View file

@ -1,6 +1,6 @@
package mage.cards.s; package mage.cards.s;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -19,18 +19,11 @@ import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType; import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.game.stack.StackObject;
import mage.players.Player; import mage.players.Player;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
import mage.target.targetadjustment.TargetAdjuster; import mage.target.targetadjustment.TargetAdjuster;
import mage.target.targetpointer.FixedTarget; import mage.target.targetpointer.FixedTarget;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/** /**
* @author LevelX2 * @author LevelX2
*/ */
@ -80,16 +73,15 @@ class SatyrFiredancerTriggeredAbility extends TriggeredAbilityImpl {
@Override @Override
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
boolean controlledBy = isControlledBy(game.getControllerId(event.getSourceId())); if (!isControlledBy(game.getControllerId(event.getSourceId()))) {
if (!controlledBy) {
return false; return false;
} }
MageObject damageSource = game.getObject(event.getSourceId()); MageObject damageSource = game.getObject(event.getSourceId());
if (damageSource == null) { if (damageSource == null) {
return false; return false;
} }
UUID damageTarget = event.getTargetId(); UUID damageTargetId = event.getTargetId();
if (!game.getOpponents(getControllerId()).contains(damageTarget)) { if (!game.getOpponents(getControllerId()).contains(damageTargetId)) {
return false; return false;
} }
MageObject sourceObject = game.getObject(event.getSourceId()); MageObject sourceObject = game.getObject(event.getSourceId());
@ -97,7 +89,7 @@ class SatyrFiredancerTriggeredAbility extends TriggeredAbilityImpl {
return false; return false;
} }
for (Effect effect : this.getEffects()) { for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(damageTarget)); // used by adjust targets effect.setTargetPointer(new FixedTarget(damageTargetId)); // used by adjust targets
effect.setValue("damage", event.getAmount()); effect.setValue("damage", event.getAmount());
} }
return true; return true;
@ -152,4 +144,4 @@ enum SatyrFiredancerAdjuster implements TargetAdjuster {
ability.getTargets().add(new TargetCreaturePermanent(filter)); ability.getTargets().add(new TargetCreaturePermanent(filter));
} }
} }
} }

View file

@ -1,4 +1,3 @@
package org.mage.test.cards.abilities.oneshot.damage; package org.mage.test.cards.abilities.oneshot.damage;
import mage.constants.PhaseStep; import mage.constants.PhaseStep;
@ -11,12 +10,11 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
* *
* @author LevelX2 * @author LevelX2
*/ */
public class SatyrFiredancerTest extends CardTestPlayerBase { public class SatyrFiredancerTest extends CardTestPlayerBase {
@Test @Test
public void testDamageFromInstantToPlayer() { public void testDamageFromInstantToPlayer() {
// Whenever an instant or sorcery spell you control deals damage to an opponent, Satyr Firedancer deals that much damage to target creature that player controls. // Whenever an instant or sorcery spell you control deals damage to an opponent, Satyr Firedancer deals that much damage to target creature that player controls.
addCard(Zone.BATTLEFIELD, playerA, "Satyr Firedancer"); addCard(Zone.BATTLEFIELD, playerA, "Satyr Firedancer");
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1); addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1);
addCard(Zone.HAND, playerA, "Lightning Bolt"); addCard(Zone.HAND, playerA, "Lightning Bolt");
@ -31,20 +29,20 @@ public class SatyrFiredancerTest extends CardTestPlayerBase {
assertLife(playerA, 20); assertLife(playerA, 20);
assertLife(playerB, 17); assertLife(playerB, 17);
assertGraveyardCount(playerA, "Lightning Bolt", 1); assertGraveyardCount(playerA, "Lightning Bolt", 1);
assertGraveyardCount(playerB, "Silvercoat Lion", 1); assertGraveyardCount(playerB, "Silvercoat Lion", 1);
} }
@Test @Test
public void testDamageFromAttackWontTrigger() { public void testDamageFromAttackWontTrigger() {
// Whenever an instant or sorcery spell you control deals damage to an opponent, Satyr Firedancer deals that much damage to target creature that player controls. // Whenever an instant or sorcery spell you control deals damage to an opponent, Satyr Firedancer deals that much damage to target creature that player controls.
addCard(Zone.BATTLEFIELD, playerA, "Satyr Firedancer"); addCard(Zone.BATTLEFIELD, playerA, "Satyr Firedancer");
addCard(Zone.BATTLEFIELD, playerA, "Pillarfield Ox", 1); addCard(Zone.BATTLEFIELD, playerA, "Pillarfield Ox", 1);
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion"); addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion");
attack(1, playerA, "Pillarfield Ox"); attack(1, playerA, "Pillarfield Ox");
addTarget(playerA, "Silvercoat Lion"); addTarget(playerA, "Silvercoat Lion");
setStopAt(1, PhaseStep.END_TURN); setStopAt(1, PhaseStep.END_TURN);
@ -52,29 +50,28 @@ public class SatyrFiredancerTest extends CardTestPlayerBase {
assertLife(playerA, 20); assertLife(playerA, 20);
assertLife(playerB, 18); assertLife(playerB, 18);
assertGraveyardCount(playerB, "Silvercoat Lion", 0); assertGraveyardCount(playerB, "Silvercoat Lion", 0);
assertPermanentCount(playerB, "Silvercoat Lion", 1); assertPermanentCount(playerB, "Silvercoat Lion", 1);
} }
@Test @Test
public void testDamageFromOtherCreature() { public void testDamageFromOtherCreature() {
// Whenever an instant or sorcery spell you control deals damage to an opponent, Satyr Firedancer deals that much damage to target creature that player controls. // Whenever an instant or sorcery spell you control deals damage to an opponent, Satyr Firedancer deals that much damage to target creature that player controls.
addCard(Zone.BATTLEFIELD, playerA, "Satyr Firedancer"); addCard(Zone.BATTLEFIELD, playerA, "Satyr Firedancer");
// {T}: Prodigal Pyromancer deals 1 damage to any target. // {T}: Prodigal Pyromancer deals 1 damage to any target.
addCard(Zone.BATTLEFIELD, playerA, "Prodigal Pyromancer", 1); addCard(Zone.BATTLEFIELD, playerA, "Prodigal Pyromancer", 1);
activateAbility(3, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: {source} deals", playerB); activateAbility(3, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: {source} deals", playerB);
addTarget(playerA, playerB); addTarget(playerA, playerB);
setStopAt(3, PhaseStep.END_TURN); setStopAt(3, PhaseStep.END_TURN);
execute(); execute();
assertLife(playerA, 20); assertLife(playerA, 20);
assertLife(playerB, 19); assertLife(playerB, 19);
} }
@Test @Test
@ -82,6 +79,7 @@ public class SatyrFiredancerTest extends CardTestPlayerBase {
playerC = createPlayer(currentGame, playerC, "PlayerC"); playerC = createPlayer(currentGame, playerC, "PlayerC");
addCard(Zone.BATTLEFIELD, playerA, "Satyr Firedancer", 1); addCard(Zone.BATTLEFIELD, playerA, "Satyr Firedancer", 1);
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2); addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2);
// Price of Progress deals damage to each player equal to twice the number of nonbasic lands that player controls.
addCard(Zone.HAND, playerA, "Price of Progress", 1); addCard(Zone.HAND, playerA, "Price of Progress", 1);
addCard(Zone.BATTLEFIELD, playerB, "Taiga", 1); addCard(Zone.BATTLEFIELD, playerB, "Taiga", 1);