- Added Evangelize

This commit is contained in:
swordshine
2014-03-10 13:32:03 +00:00
parent a0b26dfe02
commit 2b14baabb5
11 changed files with 57 additions and 5 deletions

1
.gitattributes vendored
View File

@@ -4249,6 +4249,7 @@ forge-gui/res/cardsfolder/e/eureka.txt -text
forge-gui/res/cardsfolder/e/evacuation.txt svneol=native#text/plain
forge-gui/res/cardsfolder/e/evanescent_intellect.txt -text
forge-gui/res/cardsfolder/e/evangel_of_heliod.txt -text
forge-gui/res/cardsfolder/e/evangelize.txt -text
forge-gui/res/cardsfolder/e/evaporate.txt svneol=native#text/plain
forge-gui/res/cardsfolder/e/evasive_action.txt svneol=native#text/plain
forge-gui/res/cardsfolder/e/even_the_odds.txt svneol=native#text/plain

View File

@@ -312,7 +312,9 @@ public class ComputerUtilCost {
* @return a boolean.
*/
public static boolean canPayCost(final SpellAbility sa, final Player player) {
if (sa.getActivatingPlayer() == null) {
sa.setActivatingPlayer(player); // complaints on NPE had came before this line was added.
}
// Check for stuff like Nether Void
int extraManaNeeded = 0;

View File

@@ -631,6 +631,7 @@ public class PlayerControllerAi extends PlayerController {
private void prepareSingleSa(final Card host, final SpellAbility sa, boolean isMandatory){
if (sa.hasParam("TargetingPlayer")) {
Player targetingPlayer = AbilityUtils.getDefinedPlayers(host, sa.getParam("TargetingPlayer"), sa).get(0);
sa.setTargetingPlayer(targetingPlayer);
targetingPlayer.getController().chooseTargetsFor(sa);
} else {
brains.doTrigger(sa, isMandatory);

View File

@@ -18,6 +18,8 @@
package forge.ai.ability;
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import forge.ai.ComputerUtilCard;
import forge.ai.SpellAbilityAi;
import forge.game.Game;
@@ -32,7 +34,9 @@ import forge.game.spellability.TargetRestrictions;
import forge.game.zone.ZoneType;
import forge.util.Aggregates;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -85,6 +89,11 @@ public class ControlGainAi extends SpellAbilityAi {
return true;
} else {
sa.resetTargets();
if (sa.hasParam("TargetingPlayer")) {
Player targetingPlayer = AbilityUtils.getDefinedPlayers(sa.getHostCard(), sa.getParam("TargetingPlayer"), sa).get(0);
sa.setTargetingPlayer(targetingPlayer);
return targetingPlayer.getController().chooseTargetsFor(sa);
}
if (tgt.canOnlyTgtOpponent()) {
if (!opp.canBeTargetedBy(sa)) {
return false;
@@ -189,7 +198,7 @@ public class ControlGainAi extends SpellAbilityAi {
return true;
}
} else {
if(!this.canPlayAI(ai, sa) && mandatory) {
if(sa.hasParam("TargetingPlayer") || (!this.canPlayAI(ai, sa) && mandatory)) {
List<Card> list = CardLists.getTargetableCards(ai.getCardsIn(ZoneType.Battlefield), sa);
if (list.isEmpty()) {
return false;
@@ -225,4 +234,14 @@ public class ControlGainAi extends SpellAbilityAi {
return true;
} // pumpDrawbackAI()
@Override
protected Player chooseSinglePlayer(Player ai, SpellAbility sa, Collection<Player> options) {
final List<Card> cards = new ArrayList<Card>();
for (Player p : options) {
cards.addAll(p.getCreaturesInPlay());
}
Card chosen = ComputerUtilCard.getBestCreatureAI(cards);
return chosen != null ? chosen.getController() : Iterables.getFirst(options, null);
}
}

View File

@@ -53,6 +53,7 @@ public class CopyPermanentAi extends SpellAbilityAi {
sa.resetTargets();
if (sa.hasParam("TargetingPlayer")) {
Player targetingPlayer = AbilityUtils.getDefinedPlayers(source, sa.getParam("TargetingPlayer"), sa).get(0);
sa.setTargetingPlayer(targetingPlayer);
return targetingPlayer.getController().chooseTargetsFor(sa);
}
List<Card> list = aiPlayer.getGame().getCardsIn(ZoneType.Battlefield);

View File

@@ -70,6 +70,7 @@ public class DestroyAi extends SpellAbilityAi {
sa.resetTargets();
if (sa.hasParam("TargetingPlayer")) {
Player targetingPlayer = AbilityUtils.getDefinedPlayers(source, sa.getParam("TargetingPlayer"), sa).get(0);
sa.setTargetingPlayer(targetingPlayer);
return targetingPlayer.getController().chooseTargetsFor(sa);
}
list = CardLists.getTargetableCards(ai.getOpponent().getCardsIn(ZoneType.Battlefield), sa);

View File

@@ -6,8 +6,6 @@ import forge.game.card.Card;
import forge.game.player.Player;
import forge.game.spellability.SpellAbility;
import forge.game.spellability.TargetRestrictions;
import org.apache.commons.lang3.StringUtils;
import java.util.List;
import java.util.Random;

View File

@@ -65,6 +65,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
private String stackDescription = "";
private ManaCost multiKickerManaCost = null;
private Player activatingPlayer = null;
private Player targetingPlayer = null;
private boolean basicLandAbility; // granted by basic land type
@@ -263,6 +264,20 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
}
}
/**
* @return the targetingPlayer
*/
public Player getTargetingPlayer() {
return targetingPlayer;
}
/**
* @param targetingPlayer the targetingPlayer to set
*/
public void setTargetingPlayer(Player targetingPlayer) {
this.targetingPlayer = targetingPlayer;
}
/**
* <p>
* isSpell.
@@ -1031,6 +1046,12 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
}
}
}
if (hasParam("TargetingPlayerControls") && entity instanceof Card) {
final Card c = (Card) entity;
if (!c.getController().equals(targetingPlayer)) {
return false;
}
}
String[] validTgt = tr.getValidTgts();
if (entity instanceof GameEntity && !((GameEntity) entity).isValid(validTgt, this.getActivatingPlayer(), this.getHostCard()))

View File

@@ -0,0 +1,7 @@
Name:Evangelize
ManaCost:4 W
Types:Sorcery
K:Buyback 2 W W
A:SP$ GainControl | Cost$ 4 W | ValidTgts$ Creature | TargetingPlayer$ Player.Opponent | TargetingPlayerControls$ True | SpellDescription$ Gain control of target creature of an opponent's choice he or she controls.
SVar:Picture:http://www.wizards.com/global/images/magic/general/evangelize.jpg
Oracle:Buyback {2}{W}{W} (You may pay an additional {2}{W}{W} as you cast this spell. If you do, put this card into your hand as it resolves.)\nGain control of target creature of an opponent's choice he or she controls.

View File

@@ -149,7 +149,7 @@ public class HumanPlaySpellAbility {
} else {
targetingPlayer = ability.getActivatingPlayer();
}
currentAbility.setTargetingPlayer(targetingPlayer);
if (!targetingPlayer.getController().chooseTargetsFor(currentAbility))
return false;
}

View File

@@ -491,6 +491,7 @@ public class PlayerControllerForTests extends PlayerController {
private void prepareSingleSa(final Card host, final SpellAbility sa, boolean isMandatory){
if (sa.hasParam("TargetingPlayer")) {
Player targetingPlayer = AbilityUtils.getDefinedPlayers(host, sa.getParam("TargetingPlayer"), sa).get(0);
sa.setTargetingPlayer(targetingPlayer);
targetingPlayer.getController().chooseTargetsFor(sa);
} else {
// this code is no longer possible!