- Added an Effect to gain Control of Spells.

- Added Commandeer
This commit is contained in:
Sol
2014-02-16 17:15:44 +00:00
parent 4525633ad8
commit 1982f73e3d
8 changed files with 102 additions and 10 deletions

View File

@@ -38,6 +38,7 @@ public enum ApiType {
Clone (CloneEffect.class),
CopyPermanent (CopyPermanentEffect.class),
CopySpellAbility (CopySpellAbilityEffect.class),
ControlSpell (ControlSpellEffect.class),
ControlPlayer (ControlPlayerEffect.class),
Counter (CounterEffect.class),
DamageAll (DamageAllEffect.class),

View File

@@ -45,6 +45,7 @@ public class ChangeTargetsEffect extends SpellAbilityEffect {
Player chooser = sa.getActivatingPlayer();
// Redirect rules read 'you MAY choose new targets' ... okay!
// TODO: Don't even ask to change targets, if the SA and subs don't actually have targets
boolean isOptional = sa.hasParam("Optional");
if( isOptional && !chooser.getController().confirmAction(sa, null, "Do you want to change targets of " + tgtSA.getHostCard() + "?"))
continue;
@@ -90,8 +91,8 @@ public class ChangeTargetsEffect extends SpellAbilityEffect {
GameObject choice = Aggregates.random(candidates);
changingTgtSA.getTargets().add(choice);
changingTgtSI.updateTarget(changingTgtSA.getTargets());
} else if (sa.hasParam("Defined")){
GameObject newTarget = Iterables.getFirst(getDefinedCardsOrTargeted(sa), null);
} else if (sa.hasParam("DefinedMagnet")){
GameObject newTarget = Iterables.getFirst(getDefinedCardsOrTargeted(sa, "DefinedMagnet"), null);
if(changingTgtSA.canTarget(newTarget)) {
changingTgtSA.resetTargets();
changingTgtSA.getTargets().add(newTarget);

View File

@@ -0,0 +1,74 @@
package forge.game.ability.effects;
import forge.game.Game;
import forge.game.ability.SpellAbilityEffect;
import forge.game.card.Card;
import forge.game.player.Player;
import forge.game.spellability.SpellAbility;
import forge.game.spellability.SpellAbilityStackInstance;
import java.util.List;
public class ControlSpellEffect extends SpellAbilityEffect {
/* (non-Javadoc)
* @see forge.card.abilityfactory.SpellEffect#getStackDescription(java.util.Map, forge.card.spellability.SpellAbility)
*/
@Override
protected String getStackDescription(SpellAbility sa) {
final StringBuilder sb = new StringBuilder();
List<Player> newController = getTargetPlayers(sa, "NewController");
if (newController.isEmpty()) {
newController.add(sa.getActivatingPlayer());
}
sb.append(newController).append(" gains control of ");
for(SpellAbility spell : getTargetSpells(sa)) {
Card c = spell.getHostCard();
sb.append(" ");
if (c.isFaceDown()) {
sb.append("Morph");
} else {
sb.append(c);
}
}
sb.append(".");
return sb.toString();
}
@Override
public void resolve(SpellAbility sa) {
// Gaining Control of Spells is a permanent effect
Card source = sa.getHostCard();
boolean exchange = sa.getParam("Mode").equals("Exchange");
final List<Player> controllers = getDefinedPlayersOrTargeted(sa, "NewController");
final Player newController = controllers.isEmpty() ? sa.getActivatingPlayer() : controllers.get(0);
final Game game = newController.getGame();
List<SpellAbility> tgtSpells = getTargetSpells(sa);
// If an Exchange needs to happen, make sure both parties are still in the right zones
for(SpellAbility spell : tgtSpells) {
if (exchange) {
// Currently the only Exchange Control for Spells, is a Permanent Trigger
// Use "DefinedExchange" to Reference Object that is Exchanging the other direction
}
Card tgtC = spell.getHostCard();
if (!tgtC.equals(sa.getHostCard()) && !sa.getHostCard().getGainControlTargets().contains(tgtC)) {
sa.getHostCard().addGainControlTarget(tgtC);
}
long tStamp = game.getNextTimestamp();
tgtC.setController(newController, tStamp);
SpellAbilityStackInstance si = game.getStack().getInstanceFromSpellAbility(spell);
si.setActivator(newController);
}
}
}

View File

@@ -42,19 +42,16 @@ public class SpellAbilityStackInstance {
// gets cleared from the base SI
// Coming off the Stack would work similarly, except it would just add the
// full active SI instead of each of the parts
/** The ability. */
private SpellAbility ability = null;
/** The sub instace. */
private SpellAbilityStackInstance subInstace = null;
private final Player activator;
private Player activator;
// When going to a SubAbility that SA has a Instance Choice object
/** The tc. */
private TargetChoices tc = new TargetChoices();
private List<Card> splicedCards = null;
/** The stack description. */
private String stackDescription = null;
// Adjusted Mana Cost
@@ -297,7 +294,15 @@ public class SpellAbilityStackInstance {
return true;
}
public Player getActivator() {
return activator;
}
public void setActivator(Player activator) {
this.activator = activator;
}
@Override
public String toString() {
return String.format("%s->%s", getSourceCard(), stackDescription);