Merge origin/master

This commit is contained in:
LevelX2 2018-02-23 16:01:22 +01:00
commit eb537712d6
10 changed files with 75 additions and 77 deletions

View file

@ -64,7 +64,6 @@ public class FeedbackPanel extends javax.swing.JPanel {
private static final Logger LOGGER = Logger.getLogger(FeedbackPanel.class);
public enum FeedbackMode {
INFORM, QUESTION, CONFIRM, CANCEL, SELECT, END
}

View file

@ -394,7 +394,7 @@ public class HelperPanel extends JPanel {
}
} else {
// inform about other players
this.setOpaque(false);
this.mainPanel.setOpaque(false);
}
if (buttons.size() == 0) {

View file

@ -381,7 +381,6 @@ public class ConsolePanel extends javax.swing.JPanel {
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
ConsoleFrame.getSession().toggleActivation(userName);
return;
}
}
}//GEN-LAST:event_btnDeActivateActionPerformed

View file

@ -28,24 +28,22 @@
package mage.cards.e;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.DamageEvent;
import mage.game.events.GameEvent;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
import mage.target.TargetSource;
/**
*
* @author MarcoMarin
*
* @author L_J
*/
public class EyeForAnEye extends CardImpl {
@ -53,8 +51,7 @@ public class EyeForAnEye extends CardImpl {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{W}{W}");
// The next time a source of your choice would deal damage to you this turn, instead that source deals that much damage to you and Eye for an Eye deals that much damage to that source's controller.
this.addAbility(new EyeForAnEyeTriggeredAbility(new EyeForAnEyeEffect()));
this.getSpellAbility().addEffect(new EyeForAnEyeEffect());
}
public EyeForAnEye(final EyeForAnEye card) {
@ -67,48 +64,19 @@ public class EyeForAnEye extends CardImpl {
}
}
class EyeForAnEyeTriggeredAbility extends TriggeredAbilityImpl {
class EyeForAnEyeEffect extends ReplacementEffectImpl {
public EyeForAnEyeTriggeredAbility(Effect effect) {
super(Zone.BATTLEFIELD, effect);
}
public EyeForAnEyeTriggeredAbility(final EyeForAnEyeTriggeredAbility ability) {
super(ability);
}
@Override
public EyeForAnEyeTriggeredAbility copy() {
return new EyeForAnEyeTriggeredAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.DAMAGED_PLAYER;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
MageObject sourceObject = game.getObject(event.getSourceId());
this.getEffects().get(0).setValue("damageAmount", event.getAmount());
this.getEffects().get(0).setTargetPointer(new FixedTarget(game.getControllerId(sourceObject.getId())));
return true;
}
@Override
public String getRule() {
return "The next time a source of your choice would deal damage to you this turn, instead that source deals that much damage to you and {this} deals that much damage to that source's controller.";
}
}
class EyeForAnEyeEffect extends OneShotEffect {
private final TargetSource damageSource;
public EyeForAnEyeEffect() {
super(Outcome.Damage);
super(Duration.EndOfTurn, Outcome.RedirectDamage);
staticText = "The next time a source of your choice would deal damage to you this turn, instead that source deals that much damage to you and {this} deals that much damage to that source's controller";
this.damageSource = new TargetSource();
}
public EyeForAnEyeEffect(final EyeForAnEyeEffect effect) {
super(effect);
this.damageSource = effect.damageSource.copy();
}
@Override
@ -116,15 +84,48 @@ class EyeForAnEyeEffect extends OneShotEffect {
return new EyeForAnEyeEffect(this);
}
@Override
public void init(Ability source, Game game) {
this.damageSource.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), game);
super.init(source, game);
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.DAMAGE_PLAYER;
}
@Override
public boolean apply(Game game, Ability source) {
Integer damageAmount = (Integer) this.getValue("damageAmount");
UUID targetId = this.targetPointer.getFirst(game, source);
if (damageAmount != null && targetId != null) {
Player player = game.getPlayer(targetId);
if (player != null) {
player.damage(damageAmount, targetId, game, false, true);
return true;
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Player controller = game.getPlayer(source.getControllerId());
DamageEvent damageEvent = (DamageEvent) event;
if (controller != null) {
controller.damage(damageEvent.getAmount(), damageEvent.getSourceId(), game, damageEvent.isCombatDamage(), damageEvent.isPreventable(), damageEvent.getAppliedEffects());
UUID sourceControllerId = game.getControllerId(damageEvent.getSourceId());
if (sourceControllerId != null) {
Player sourceController = game.getPlayer(sourceControllerId);
if (sourceController != null) {
sourceController.damage(damageEvent.getAmount(), source.getSourceId(), game, false, true);
return true;
}
}
}
return false;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
Player controller = game.getPlayer(source.getControllerId());
DamageEvent damageEvent = (DamageEvent) event;
if (controller != null) {
if (controller.getId() == damageEvent.getTargetId() && damageEvent.getSourceId().equals(damageSource.getFirstTarget())) {
this.discard();
return true;
}
}
return false;

View file

@ -93,11 +93,6 @@ class ProgenitusProtectionAbility extends ProtectionAbility {
return new ProgenitusProtectionAbility(this);
}
@Override
public String getRule() {
return "Protection from everything";
}
@Override
public boolean canTarget(MageObject source, Game game) {
return false;

View file

@ -141,12 +141,7 @@ class TeferisProtectionAbility extends ProtectionAbility {
public TeferisProtectionAbility copy() {
return new TeferisProtectionAbility(this);
}
@Override
public String getRule() {
return "Protection from everything";
}
@Override
public boolean canTarget(MageObject source, Game game) {
return false;

View file

@ -86,7 +86,7 @@ class TormentOfHailfireEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int repeat = source.getManaCostsToPay().getX();
for (int i = 0; i < repeat; i++) {
for (int i = 1; i <= repeat; i++) {
for (UUID opponentId : game.getOpponents(source.getControllerId())) {
Player opponent = game.getPlayer(opponentId);
if (opponent != null) {
@ -97,8 +97,9 @@ class TormentOfHailfireEffect extends OneShotEffect {
if (opponent.choose(outcome, target, source.getSourceId(), game)) {
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) {
permanent.sacrifice(source.getSourceId(), game);
continue;
if (permanent.sacrifice(source.getSourceId(), game)) {
continue;
}
}
}
}

View file

@ -80,28 +80,28 @@ public class CairnWandererTest extends CardTestPlayerBase {
addCard(Zone.GRAVEYARD, playerA, "Typhoid Rats");
// Testing HasteAbility.
addCard(Zone.GRAVEYARD, playerA, "Raging Goblin");
addCard(Zone.GRAVEYARD, playerB, "Raging Goblin");
// Testing LandwalkAbility.
addCard(Zone.GRAVEYARD, playerA, "Zodiac Rooster");
addCard(Zone.GRAVEYARD, playerB, "Zodiac Rooster");
// Testing LifelinkAbility.
addCard(Zone.GRAVEYARD, playerA, "Trained Caracal");
addCard(Zone.GRAVEYARD, playerB, "Trained Caracal");
// Testing ProtectionAbility.
addCard(Zone.GRAVEYARD, playerA, "Progenitus");
addCard(Zone.GRAVEYARD, playerB, "Progenitus");
// Testing ReachAbility.
addCard(Zone.GRAVEYARD, playerA, "Tree Monkey");
addCard(Zone.GRAVEYARD, playerB, "Tree Monkey");
// Testing TrampleAbility.
addCard(Zone.GRAVEYARD, playerA, "Defiant Elf");
addCard(Zone.GRAVEYARD, playerB, "Defiant Elf");
// Testing ShroudAbility.
addCard(Zone.GRAVEYARD, playerA, "Elvish Lookout");
addCard(Zone.GRAVEYARD, playerB, "Elvish Lookout");
// Testing VigilanceAbility.
addCard(Zone.GRAVEYARD, playerA, "Veteran Cavalier");
addCard(Zone.GRAVEYARD, playerB, "Veteran Cavalier");
execute();

View file

@ -87,4 +87,13 @@ public class FixedTargets implements TargetPointer {
return new FixedTargets(this);
}
@Override
public FixedTarget getFixedTarget(Game game, Ability source) {
this.init(game, source);
UUID firstId = getFirst(game, source);
if (firstId != null) {
return new FixedTarget(firstId, game.getState().getZoneChangeCounter(firstId));
}
return null;
}
}

View file

@ -80,6 +80,5 @@ public class SecondTargetPointer implements TargetPointer {
return new FixedTarget(firstId, game.getState().getZoneChangeCounter(firstId));
}
return null;
}
}