- BNG: Added Nessian Wilds Ravager and Pharagax Giant

This commit is contained in:
swordshine
2014-01-14 04:40:40 +00:00
parent 13a6310ac0
commit d234975cde
5 changed files with 85 additions and 2 deletions

View File

@@ -1,10 +1,12 @@
package forge.ai.ability;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Random;
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import forge.ai.ComputerUtil;
import forge.ai.ComputerUtilCard;
@@ -13,15 +15,18 @@ import forge.ai.ComputerUtilMana;
import forge.ai.SpellAbilityAi;
import forge.game.ability.AbilityUtils;
import forge.game.card.Card;
import forge.game.card.CardFactoryUtil;
import forge.game.card.CardLists;
import forge.game.card.CounterType;
import forge.game.cost.Cost;
import forge.game.phase.PhaseType;
import forge.game.player.Player;
import forge.game.player.PlayerActionConfirmMode;
import forge.game.spellability.SpellAbility;
import forge.game.spellability.TargetRestrictions;
import forge.game.zone.ZoneType;
import forge.util.Aggregates;
import forge.util.Expressions;
import forge.util.MyRandom;
public class CountersPutAi extends SpellAbilityAi {
@@ -344,4 +349,35 @@ public class CountersPutAi extends SpellAbilityAi {
return true;
}
/* (non-Javadoc)
* @see forge.card.ability.SpellAbilityAi#confirmAction(forge.game.player.Player, forge.card.spellability.SpellAbility, forge.game.player.PlayerActionConfirmMode, java.lang.String)
*/
@Override
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) {
final Card source = sa.getSourceCard();
if (mode == PlayerActionConfirmMode.Tribute && source.hasSVar("TributeAILogic")) {
final String logic = source.getSVar("TributeAILogic");
for (final String tributeAI : logic.split(" & ")) {
String sVar = tributeAI.split(" ")[0];
String comparator = tributeAI.split(" ")[1];
String compareTo = comparator.substring(2);
int x = CardFactoryUtil.xCount(source, sVar);
int y = CardFactoryUtil.xCount(source, compareTo);
if (!Expressions.compare(x, comparator, y)) {
return false;
}
}
}
return true;
}
/* (non-Javadoc)
* @see forge.card.ability.SpellAbilityAi#chooseSinglePlayer(Player, SpellAbility, Collection<Player>)
*/
@Override
public Player chooseSinglePlayer(Player ai, SpellAbility sa, Collection<Player> options) {
// logic?
return Iterables.getFirst(options, null);
}
}

View File

@@ -8,6 +8,8 @@ import forge.game.ability.AbilityUtils;
import forge.game.ability.SpellAbilityEffect;
import forge.game.card.Card;
import forge.game.card.CounterType;
import forge.game.player.Player;
import forge.game.player.PlayerActionConfirmMode;
import forge.game.spellability.SpellAbility;
import forge.game.trigger.TriggerType;
import forge.game.zone.Zone;
@@ -62,6 +64,7 @@ public class CountersPutEffect extends SpellAbilityEffect {
@Override
public void resolve(SpellAbility sa) {
final Card card = sa.getSourceCard();
final Player activator = sa.getActivatingPlayer();
CounterType counterType;
@@ -77,7 +80,7 @@ public class CountersPutEffect extends SpellAbilityEffect {
final int max = sa.hasParam("MaxFromEffect") ? Integer.parseInt(sa.getParam("MaxFromEffect")) : -1;
if (sa.hasParam("UpTo")) {
counterAmount = sa.getActivatingPlayer().getController().chooseNumber(sa, "How many counters?", 0, counterAmount);
counterAmount = activator.getController().chooseNumber(sa, "How many counters?", 0, counterAmount);
}
List<Card> tgtCards = getDefinedCardsOrTargeted(sa);
@@ -90,6 +93,15 @@ public class CountersPutEffect extends SpellAbilityEffect {
}
final Zone zone = tgtCard.getGame().getZoneOf(tgtCard);
if (zone == null || zone.is(ZoneType.Battlefield) || zone.is(ZoneType.Stack)) {
if (sa.hasParam("Tribute")) {
String message = "Do you want to put " + tgtCard.getKeywordMagnitude("Tribute") + " +1/+1 counters on " + tgtCard + " ?";
Player chooser = activator.getController().chooseSingleEntityForEffect(activator.getOpponents(), sa, "Choose an opponent");
if (chooser.getController().confirmAction(sa, PlayerActionConfirmMode.Tribute, message)) {
tgtCard.setTributed(true);
} else {
continue;
}
}
tgtCard.addCounter(counterType, counterAmount, true);
if (remember) {
final int value = tgtCard.getTotalCountersToAdd();

View File

@@ -179,6 +179,7 @@ public class Card extends GameEntity implements Comparable<Card> {
private boolean bestow = false;
private boolean suspendCast = false;
private boolean suspend = false;
private boolean tributed = false;
private boolean phasedOut = false;
private boolean directlyPhasedOut = true;
@@ -5640,6 +5641,10 @@ public class Card extends GameEntity implements Comparable<Card> {
if (!this.hauntedBy.contains(source)) {
return false;
}
} else if (property.startsWith("notTributed")) {
if (this.tributed) {
return false;
}
} else if (property.contains("Paired")) {
if (property.contains("With")) { // PairedWith
if (!this.isPaired() || this.pairedWith != source) {
@@ -7716,6 +7721,18 @@ public class Card extends GameEntity implements Comparable<Card> {
return this.evoked;
}
/**
* <p>
* Setter for the field <code>tributed</code>.
* </p>
*
* @param b
* a boolean.
*/
public final void setTributed(final boolean b) {
this.tributed = b;
}
/**
* <p>
* Setter for the field <code>monstrous</code>.

View File

@@ -2516,6 +2516,23 @@ public class CardFactoryUtil {
card.setSVar("EvolveAddCounter", abString);
}
if (card.hasStartOfKeyword("Tribute")) {
final int tributeAmount = card.getKeywordMagnitude("Tribute");
final String actualRep = "Event$ Moved | Destination$ Battlefield | ValidCard$ Card.Self |"
+ " ReplaceWith$ TributeAddCounter | Secondary$ True | Description$ Tribute "
+ tributeAmount + " (As this creature enters the battlefield, an opponent of your"
+ " choice may put " + tributeAmount + " +1/+1 counter on it.)";
final String abString = "DB$ PutCounter | Defined$ ReplacedCard | Tribute$ True | "
+ "CounterType$ P1P1 | CounterNum$ " + tributeAmount
+ " | SubAbility$ TributeMoveToPlay";
final String moveToPlay = "DB$ ChangeZone | Origin$ All | Destination$ Battlefield | "
+ "Defined$ ReplacedCard | Hidden$ True";
card.setSVar("TributeAddCounter", abString);
card.setSVar("TributeMoveToPlay", moveToPlay);
card.addReplacementEffect(ReplacementHandler.parseReplacement(actualRep, card, true));
}
if (card.hasStartOfKeyword("Amplify")) {
// find position of Amplify keyword
final int ampPos = card.getKeywordPosition("Amplify");

View File

@@ -10,7 +10,8 @@ public enum PlayerActionConfirmMode {
FromOpeningHand,
ChangeZoneToAltDestination,
ChangeZoneFromAltSource,
ChangeZoneGeneral;
ChangeZoneGeneral,
Tribute;
// Ripple;