- The keyword "CARDNAME enters the battlefield tapped." will now be checked at runtime.

- Added the static ability ETBTapped and converted six cards to script.
This commit is contained in:
Sloth
2011-11-19 08:02:15 +00:00
parent 0336ab87f5
commit 94e50fe399
11 changed files with 86 additions and 18 deletions

View File

@@ -4,9 +4,9 @@ import java.util.ArrayList;
import java.util.Iterator;
import forge.Constant.Zone;
import forge.card.cardfactory.CardFactoryUtil;
import forge.card.spellability.Ability;
import forge.card.spellability.SpellAbility;
import forge.card.staticability.StaticAbility;
/**
* <p>
@@ -49,15 +49,23 @@ public class PlayerZoneComesIntoPlay extends DefaultPlayerZone {
final Card c = (Card) o;
final Player player = c.getController();
if (trigger
&& ((CardFactoryUtil.oppHasKismet(c.getController())
&& (c.isLand() || c.isCreature() || c.isArtifact()))
|| (AllZoneUtil.isCardInPlay("Urabrask the Hidden", c.getController().getOpponent()) && c
.isCreature())
|| (AllZoneUtil.isCardInPlay("Root Maze") && (c.isLand() || c.isArtifact())) || (AllZoneUtil
.isCardInPlay("Orb of Dreams") && c.isPermanent()))) {
// it enters the battlefield this way, and should not fire triggers
c.setTapped(true);
if (trigger) {
if (c.hasKeyword("CARDNAME enters the battlefield tapped.")) {
// it enters the battlefield this way, and should not fire triggers
c.setTapped(true);
} else {
// ETBTapped static abilities
final CardList allp = AllZoneUtil.getCardsIn(Zone.Battlefield);
for (final Card ca : allp) {
final ArrayList<StaticAbility> staticAbilities = ca.getStaticAbilities();
for (final StaticAbility stAb : staticAbilities) {
if (stAb.applyAbility("ETBTapped", c)) {
// it enters the battlefield this way, and should not fire triggers
c.setTapped(true);
}
}
}
}
}
// cannot use addComesIntoPlayCommand - trigger might be set to false;

View File

@@ -4932,7 +4932,7 @@ public class CardFactoryUtil {
*
*/
public static final void parseKeywords(final Card card, final String cardName) {
if (card.hasKeyword("CARDNAME enters the battlefield tapped.")) {
/*if (card.hasKeyword("CARDNAME enters the battlefield tapped.")) {
card.addComesIntoPlayCommand(new Command() {
private static final long serialVersionUID = 203335252453049234L;
@@ -4943,7 +4943,7 @@ public class CardFactoryUtil {
card.setTapped(true);
}
});
} // if "Comes into play tapped."
}*/ // if "Comes into play tapped."
if (card.hasKeyword("CARDNAME enters the battlefield tapped unless you control two or fewer other lands.")) {
card.addComesIntoPlayCommand(new Command() {
private static final long serialVersionUID = 6436821515525468682L;

View File

@@ -318,6 +318,24 @@ public class StaticAbility {
return false;
}
public final boolean applyAbility(final String mode, final Card card) {
// don't apply the ability if it hasn't got the right mode
if (!this.mapParams.get("Mode").equals(mode)) {
return false;
}
if (this.isSuppressed() || !this.checkConditions()) {
return false;
}
if (mode.equals("ETBTapped")) {
return StaticAbilityETBTapped.applyETBTappedAbility(this, card);
}
return false;
}
/**
* Check conditions.

View File

@@ -0,0 +1,35 @@
package forge.card.staticability;
import java.util.HashMap;
import forge.Card;
/**
* The Class StaticAbility_CantBeCast.
*/
public class StaticAbilityETBTapped {
/**
* TODO Write javadoc for this method.
*
* @param stAb
* a StaticAbility
* @param card
* the card
* @param activator
* the activator
* @return true, if successful
*/
public static boolean applyETBTappedAbility(final StaticAbility stAb, final Card card) {
final HashMap<String, String> params = stAb.getMapParams();
final Card hostCard = stAb.getHostCard();
if (params.containsKey("ValidCard")
&& !card.isValid(params.get("ValidCard").split(","), hostCard.getController(), hostCard)) {
return false;
}
return true;
}
}