Skip to content

Commit

Permalink
Merge origin/master
Browse files Browse the repository at this point in the history
  • Loading branch information
fireshoes committed Apr 18, 2016
2 parents 3c3a9cc + 3e4a3f7 commit 194c817
Show file tree
Hide file tree
Showing 35 changed files with 332 additions and 314 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,9 @@ public boolean triggerAbility(TriggeredAbility source, Game game) {
if (options.isEmpty()) {
logger.debug("simulating -- triggered ability:" + ability);
game.getStack().push(new StackAbility(ability, playerId));
ability.activate(game, false);
if (ability.activate(game, false) && ability.isUsesStack()) {
game.fireEvent(new GameEvent(GameEvent.EventType.TRIGGERED_ABILITY, ability.getId(), ability.getSourceId(), ability.getControllerId()));
}
game.applyEffects();
game.getPlayers().resetPassed();
} else {
Expand All @@ -439,7 +441,9 @@ public boolean triggerAbility(TriggeredAbility source, Game game) {
protected void addAbilityNode(SimulationNode2 parent, Ability ability, int depth, Game game) {
Game sim = game.copy();
sim.getStack().push(new StackAbility(ability, playerId));
ability.activate(sim, false);
if (ability.activate(sim, false) && ability.isUsesStack()) {
game.fireEvent(new GameEvent(GameEvent.EventType.TRIGGERED_ABILITY, ability.getId(), ability.getSourceId(), ability.getControllerId()));
}
sim.applyEffects();
SimulationNode2 newNode = new SimulationNode2(parent, sim, depth, playerId);
logger.debug("simulating -- node #:" + SimulationNode2.getCount() + " triggered ability option");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import mage.constants.Outcome;
import mage.game.Game;
import mage.game.combat.CombatGroup;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.game.stack.StackAbility;
import mage.players.Player;
Expand Down Expand Up @@ -168,6 +169,7 @@ public boolean triggerAbility(TriggeredAbility source, Game game) {
if (ability.isUsesStack()) {
game.getStack().push(new StackAbility(ability, playerId));
if (ability.activate(game, false)) {
game.fireEvent(new GameEvent(GameEvent.EventType.TRIGGERED_ABILITY, ability.getId(), ability.getSourceId(), ability.getControllerId()));
actionCount++;
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

package mage.player.ai;

import java.util.*;
import java.util.concurrent.ConcurrentLinkedQueue;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.TriggeredAbility;
Expand All @@ -42,9 +44,6 @@
import mage.target.Target;
import org.apache.log4j.Logger;

import java.util.*;
import java.util.concurrent.ConcurrentLinkedQueue;

/**
*
* @author BetaSteward_at_googlemail.com
Expand Down Expand Up @@ -239,7 +238,9 @@ public boolean triggerAbility(TriggeredAbility source, Game game) {
if (logger.isDebugEnabled())
logger.debug("simulating -- triggered ability:" + ability);
game.getStack().push(new StackAbility(ability, playerId));
ability.activate(game, false);
if (ability.activate(game, false) && ability.isUsesStack()) {
game.fireEvent(new GameEvent(GameEvent.EventType.TRIGGERED_ABILITY, ability.getId(), ability.getSourceId(), ability.getControllerId()));
}
game.applyEffects();
game.getPlayers().resetPassed();
}
Expand All @@ -258,6 +259,9 @@ protected void addAbilityNode(SimulationNode parent, Ability ability, Game game)
Game sim = game.copy();
sim.getStack().push(new StackAbility(ability, playerId));
ability.activate(sim, false);
if (ability.activate(sim, false) && ability.isUsesStack()) {
game.fireEvent(new GameEvent(GameEvent.EventType.TRIGGERED_ABILITY, ability.getId(), ability.getSourceId(), ability.getControllerId()));
}
sim.applyEffects();
SimulationNode newNode = new SimulationNode(parent, sim, playerId);
logger.debug(indent(newNode.getDepth()) + "simulating -- node #:" + SimulationNode.getCount() + " triggered ability option");
Expand Down
48 changes: 5 additions & 43 deletions Mage.Sets/src/mage/sets/alarareborn/ClovenCasting.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,18 @@
package mage.sets.alarareborn;

import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.SpellCastControllerTriggeredAbility;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.CopyTargetSpellEffect;
import mage.abilities.effects.common.DoIfCostPaid;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.filter.FilterSpell;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.filter.predicate.mageobject.MulticoloredPredicate;
import mage.game.Game;
import mage.game.stack.Spell;
import mage.players.Player;

/**
*
Expand All @@ -65,8 +61,9 @@ public ClovenCasting(UUID ownerId) {
this.expansionSetCode = "ARB";

// Whenever you cast a multicolored instant or sorcery spell, you may pay {1}. If you do, copy that spell. You may choose new targets for the copy.
this.addAbility(new SpellCastControllerTriggeredAbility(new DoIfCostPaid(new ClovenCastingEffect(), new GenericManaCost(1)), filter, true, true));

Effect effect = new CopyTargetSpellEffect();
effect.setText("copy that spell. You may choose new targets for the copy");
this.addAbility(new SpellCastControllerTriggeredAbility(new DoIfCostPaid(effect, new GenericManaCost(1)), filter, true, true));
}

public ClovenCasting(final ClovenCasting card) {
Expand All @@ -78,38 +75,3 @@ public ClovenCasting copy() {
return new ClovenCasting(this);
}
}

class ClovenCastingEffect extends OneShotEffect {

public ClovenCastingEffect() {
super(Outcome.Copy);
staticText = "copy that spell. You may choose new targets for the copy";
}

public ClovenCastingEffect(final ClovenCastingEffect effect) {
super(effect);
}

@Override
public boolean apply(Game game, Ability source) {
Spell spell = game.getStack().getSpell(targetPointer.getFirst(game, source));
if (spell != null) {
Spell copy = spell.copySpell(source.getControllerId());
game.getStack().push(copy);
copy.chooseNewTargets(game, source.getControllerId());
Player player = game.getPlayer(source.getControllerId());
String activateMessage = copy.getActivatedMessage(game);
if (activateMessage.startsWith(" casts ")) {
activateMessage = activateMessage.substring(6);
}
game.informPlayers(player.getLogName() + " copies " + activateMessage);
return true;
}
return false;
}

@Override
public ClovenCastingEffect copy() {
return new ClovenCastingEffect(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public boolean apply(Game game, Ability source) {
}
}
}

game.fireEvent(new GameEvent(GameEvent.EventType.COPIED_STACKOBJECT, copy.getId(), spell.getId(), source.getControllerId()));
String activateMessage = copy.getActivatedMessage(game);
if (activateMessage.startsWith(" casts ")) {
activateMessage = activateMessage.substring(6);
Expand Down
48 changes: 5 additions & 43 deletions Mage.Sets/src/mage/sets/commander/RikuOfTwoReflections.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,15 @@

import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldControlledTriggeredAbility;
import mage.abilities.common.SpellCastControllerTriggeredAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CopyTargetSpellEffect;
import mage.abilities.effects.common.DoIfCostPaid;
import mage.abilities.effects.common.PutTokenOntoBattlefieldCopyTargetEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.SetTargetPointer;
import mage.constants.Zone;
Expand All @@ -49,9 +47,6 @@
import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.filter.predicate.permanent.AnotherPredicate;
import mage.filter.predicate.permanent.TokenPredicate;
import mage.game.Game;
import mage.game.stack.Spell;
import mage.players.Player;

/**
*
Expand Down Expand Up @@ -82,10 +77,12 @@ public RikuOfTwoReflections(UUID ownerId) {
this.toughness = new MageInt(2);

// Whenever you cast an instant or sorcery spell, you may pay {U}{R}. If you do, copy that spell. You may choose new targets for the copy.
this.addAbility(new SpellCastControllerTriggeredAbility(new DoIfCostPaid(new RikuOfTwoReflectionsCopyEffect(), new ManaCostsImpl("{U}{R}")), filter, false, true));
Effect effect = new CopyTargetSpellEffect();
effect.setText("copy that spell. You may choose new targets for the copy");
this.addAbility(new SpellCastControllerTriggeredAbility(new DoIfCostPaid(effect, new ManaCostsImpl("{U}{R}")), filter, false, true));

// Whenever another nontoken creature enters the battlefield under your control, you may pay {G}{U}. If you do, put a token that's a copy of that creature onto the battlefield.
Effect effect = new DoIfCostPaid(new PutTokenOntoBattlefieldCopyTargetEffect(),
effect = new DoIfCostPaid(new PutTokenOntoBattlefieldCopyTargetEffect(),
new ManaCostsImpl("{G}{U}"), "Put a token that's a copy of that creature onto the battlefield?");
effect.setText("you may pay {G}{U}. If you do, put a token that's a copy of that creature onto the battlefield");
this.addAbility(new EntersBattlefieldControlledTriggeredAbility(Zone.BATTLEFIELD, effect, filterPermanent, false, SetTargetPointer.PERMANENT, null));
Expand All @@ -100,38 +97,3 @@ public RikuOfTwoReflections copy() {
return new RikuOfTwoReflections(this);
}
}

class RikuOfTwoReflectionsCopyEffect extends OneShotEffect {

public RikuOfTwoReflectionsCopyEffect() {
super(Outcome.Copy);
staticText = "copy that spell. You may choose new targets for the copy";
}

public RikuOfTwoReflectionsCopyEffect(final RikuOfTwoReflectionsCopyEffect effect) {
super(effect);
}

@Override
public boolean apply(Game game, Ability source) {
Spell spell = game.getStack().getSpell(targetPointer.getFirst(game, source));
if (spell != null) {
Spell copy = spell.copySpell(source.getControllerId());;
game.getStack().push(copy);
copy.chooseNewTargets(game, source.getControllerId());
Player player = game.getPlayer(source.getControllerId());
String activateMessage = copy.getActivatedMessage(game);
if (activateMessage.startsWith(" casts ")) {
activateMessage = activateMessage.substring(6);
}
game.informPlayers(player.getLogName() + " copies " + activateMessage);
return true;
}
return false;
}

@Override
public RikuOfTwoReflectionsCopyEffect copy() {
return new RikuOfTwoReflectionsCopyEffect(this);
}
}
49 changes: 7 additions & 42 deletions Mage.Sets/src/mage/sets/commander/WildRicochet.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,15 @@
package mage.sets.commander;

import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.ChooseNewTargetsTargetEffect;
import mage.abilities.effects.common.CopyTargetSpellEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.filter.FilterStackObject;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.game.Game;
import mage.game.stack.Spell;
import mage.players.Player;
import mage.target.TargetStackObject;

/**
Expand All @@ -61,9 +58,11 @@ public WildRicochet(UUID ownerId) {
this.expansionSetCode = "CMD";

// You may choose new targets for target instant or sorcery spell. Then copy that spell. You may choose new targets for the copy.
this.getSpellAbility().addEffect(new WildRicochetEffect());
this.getSpellAbility().addEffect(new ChooseNewTargetsTargetEffect());
Effect effect = new CopyTargetSpellEffect();
effect.setText("Then copy that spell. You may choose new targets for the copy");
this.getSpellAbility().addEffect(effect);
this.getSpellAbility().addTarget(new TargetStackObject(filter));

}

public WildRicochet(final WildRicochet card) {
Expand All @@ -75,37 +74,3 @@ public WildRicochet copy() {
return new WildRicochet(this);
}
}

class WildRicochetEffect extends OneShotEffect {

public WildRicochetEffect() {
super(Outcome.Neutral);
staticText = "You may choose new targets for target instant or sorcery spell. Then copy that spell. You may choose new targets for the copy";
}

public WildRicochetEffect(final WildRicochetEffect effect) {
super(effect);
}

@Override
public boolean apply(Game game, Ability source) {
Spell spell = game.getStack().getSpell(source.getFirstTarget());
Player you = game.getPlayer(source.getControllerId());
if (spell != null && you != null && you.chooseUse(Outcome.Benefit, "Do you wish to choose new targets for " + spell.getName() + "?", source, game)) {
spell.chooseNewTargets(game, you.getId());
}
if (spell != null) {
Spell copy = spell.copySpell(source.getControllerId());;
game.getStack().push(copy);
if (you != null && you.chooseUse(Outcome.Benefit, "Do you wish to choose new targets for the copied " + spell.getName() + "?", source, game)) {
return copy.chooseNewTargets(game, you.getId());
}
}
return false;
}

@Override
public WildRicochetEffect copy() {
return new WildRicochetEffect(this);
}
}
15 changes: 8 additions & 7 deletions Mage.Sets/src/mage/sets/commander2014/MaliciousAffliction.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import mage.filter.predicate.mageobject.ColorPredicate;
import mage.game.Game;
import mage.game.stack.Spell;
import mage.game.stack.StackObject;
import mage.players.Player;
import mage.target.common.TargetCreaturePermanent;

Expand Down Expand Up @@ -106,14 +107,14 @@ public boolean apply(Game game, Ability source) {
if (controller != null) {
Spell spell = game.getStack().getSpell(source.getSourceId());
if (spell != null) {
Spell spellCopy = spell.copySpell(source.getControllerId());;
game.getStack().push(spellCopy);
spellCopy.chooseNewTargets(game, controller.getId());
String activateMessage = spellCopy.getActivatedMessage(game);
if (activateMessage.startsWith(" casts ")) {
activateMessage = activateMessage.substring(6);
StackObject stackObjectCopy = spell.createCopyOnStack(game, source, source.getControllerId(), true);
if (stackObjectCopy != null && stackObjectCopy instanceof Spell) {
String activateMessage = ((Spell) stackObjectCopy).getActivatedMessage(game);
if (activateMessage.startsWith(" casts ")) {
activateMessage = activateMessage.substring(6);
}
game.informPlayers(controller.getLogName() + " copies " + activateMessage);
}
game.informPlayers(controller.getLogName() + " copies " + activateMessage);
return true;
}
}
Expand Down
4 changes: 1 addition & 3 deletions Mage.Sets/src/mage/sets/darkascension/CurseOfEchoes.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,7 @@ public boolean apply(Game game, Ability source) {
if (!playerId.equals(spell.getControllerId())) {
Player player = game.getPlayer(playerId);
if (player.chooseUse(Outcome.Copy, chooseMessage, source, game)) {
Spell copy = spell.copySpell(source.getControllerId());
game.getStack().push(copy);
copy.chooseNewTargets(game, playerId);
spell.createCopyOnStack(game, source, player.getId(), true);
}
}
}
Expand Down
17 changes: 9 additions & 8 deletions Mage.Sets/src/mage/sets/darkascension/IncreasingVengeance.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.game.Game;
import mage.game.stack.Spell;
import mage.game.stack.StackObject;
import mage.players.Player;
import mage.target.Target;
import mage.target.TargetSpell;
Expand Down Expand Up @@ -99,17 +100,17 @@ public boolean apply(Game game, Ability source) {
if (controller != null) {
Spell spell = game.getStack().getSpell(targetPointer.getFirst(game, source));
if (spell != null) {
Spell copy = spell.copySpell(source.getControllerId());
game.getStack().push(copy);
copy.chooseNewTargets(game, source.getControllerId());
game.informPlayers(new StringBuilder(controller.getLogName()).append(copy.getActivatedMessage(game)).toString());
StackObject stackObjectCopy = spell.createCopyOnStack(game, source, source.getControllerId(), true);
if (stackObjectCopy != null && stackObjectCopy instanceof Spell) {
game.informPlayers(new StringBuilder(controller.getLogName()).append(((Spell) stackObjectCopy).getActivatedMessage(game)).toString());
}
Spell sourceSpell = (Spell) game.getStack().getStackObject(source.getSourceId());
if (sourceSpell != null) {
if (sourceSpell.getFromZone() == Zone.GRAVEYARD) {
copy = spell.copySpell(source.getControllerId());
game.getStack().push(copy);
copy.chooseNewTargets(game, source.getControllerId());
game.informPlayers(new StringBuilder(controller.getLogName()).append(copy.getActivatedMessage(game)).toString());
stackObjectCopy = spell.createCopyOnStack(game, source, source.getControllerId(), true);
if (stackObjectCopy != null && stackObjectCopy instanceof Spell) {
game.informPlayers(new StringBuilder(controller.getLogName()).append(((Spell) stackObjectCopy).getActivatedMessage(game)).toString());
}
}
}
return true;
Expand Down
Loading

0 comments on commit 194c817

Please sign in to comment.