- Added the option "NonMana" to StAb CantBeActivated.

- Converted Pithing Needle to script.
This commit is contained in:
Sloth
2011-11-05 07:39:33 +00:00
parent 230310e4b7
commit 2ecfbffda6
7 changed files with 119 additions and 109 deletions

2
.gitattributes vendored
View File

@@ -10480,7 +10480,7 @@ src/main/java/forge/card/spellability/TargetChoices.java svneol=native#text/plai
src/main/java/forge/card/spellability/TargetSelection.java svneol=native#text/plain
src/main/java/forge/card/spellability/package-info.java svneol=native#text/plain
src/main/java/forge/card/staticability/StaticAbility.java svneol=native#text/plain
src/main/java/forge/card/staticability/StaticAbilityCantBeCast.java -text svneol=native#text/plain
src/main/java/forge/card/staticability/StaticAbilityCantBeCast.java svneol=native#text/plain
src/main/java/forge/card/staticability/StaticAbilityContinuous.java svneol=native#text/plain
src/main/java/forge/card/staticability/StaticAbilityPreventDamage.java -text svneol=native#text/plain
src/main/java/forge/card/staticability/package-info.java svneol=native#text/plain

View File

@@ -1,7 +1,10 @@
Name:Pithing Needle
ManaCost:1
Types:Artifact
Text:As Pithing Needle enters the battlefield, name a card.\r\nActivated abilities of sources with the chosen name can't be activated unless they're mana abilities.
Text:no text
T:Mode$ ChangesZone | ValidCard$ Card.Self | Origin$ Any | Destination$ Battlefield | Execute$ TrigName | Static$ True | TriggerDescription$ As CARDNAME enters the battlefield, name a card.
SVar:TrigName:AB$ NameCard | Cost$ 0 | Defined$ You
S:Mode$ CantBeActivated | ValidCard$ Card.NamedCard | NonMana$ True | Description$ Activated abilities of sources with the chosen name can't be activated unless they're mana abilities.
SVar:RemRandomDeck:True
SVar:Rarity:Rare
SVar:Picture:http://www.wizards.com/global/images/magic/general/pithing_needle.jpg

View File

@@ -1226,7 +1226,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
} // *************** END ************ END **************************
// *************** START *********** START **************************
else if (cardName.equals("Pithing Needle")) {
/*else if (cardName.equals("Pithing Needle")) {
final SpellAbility ability = new AbilityStatic(card, "0") {
@Override
public void resolve() {
@@ -1276,7 +1276,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface {
card.addComesIntoPlayCommand(intoPlay);
card.addLeavesPlayCommand(leavesPlay);
} // *************** END ************ END **************************
}*/ // *************** END ************ END **************************
// *************** START *********** START **************************
else if (cardName.equals("Phyrexian Processor")) {

View File

@@ -18,8 +18,6 @@ import forge.Constant.Zone;
* @version $Id$
*/
public abstract class Ability extends SpellAbility {
// Slight hack for Pithing Needle
private final String sourceCardName;
/**
* <p>
@@ -34,7 +32,6 @@ public abstract class Ability extends SpellAbility {
public Ability(final Card sourceCard, final String manaCost) {
super(SpellAbility.getAbility(), sourceCard);
this.setManaCost(manaCost);
this.sourceCardName = sourceCard.getName();
}
/**
@@ -62,17 +59,6 @@ public abstract class Ability extends SpellAbility {
return false;
}
CardList pithing = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield);
pithing.addAll(AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield));
pithing = pithing.getName("Pithing Needle");
pithing = pithing.filter(new CardListFilter() {
@Override
public boolean addCard(final Card c) {
return c.getSVar("PithingTarget").equals(Ability.this.sourceCardName);
}
});
return AllZoneUtil.isCardInPlay(this.getSourceCard()) && !this.getSourceCard().isFaceDown()
&& !this.getSourceCard().getName().equals("Spreading Seas") && (pithing.size() == 0);
return AllZoneUtil.isCardInPlay(this.getSourceCard()) && !this.getSourceCard().isFaceDown();
}
}

View File

@@ -81,7 +81,7 @@ public abstract class AbilityActivated extends SpellAbility implements java.io.S
for (final Card ca : allp) {
final ArrayList<StaticAbility> staticAbilities = ca.getStaticAbilities();
for (final StaticAbility stAb : staticAbilities) {
if (stAb.applyAbility("CantBeActivated", c, activator)) {
if (stAb.applyAbility("CantBeActivated", c, activator, this)) {
return false;
}
}
@@ -91,20 +91,6 @@ public abstract class AbilityActivated extends SpellAbility implements java.io.S
return false;
}
CardList pithing = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield);
pithing.addAll(AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield));
pithing = pithing.getName("Pithing Needle");
pithing = pithing.filter(new CardListFilter() {
@Override
public boolean addCard(final Card crd) {
return crd.getSVar("PithingTarget").equals(c.getName());
}
});
if ((pithing.size() != 0) && !(this instanceof AbilityMana)) {
return false;
}
if (!(this.getRestrictions().canPlay(c, this))) {
return false;
}

View File

@@ -10,6 +10,7 @@ import forge.Constant.Zone;
import forge.GameEntity;
import forge.Player;
import forge.card.abilityfactory.AbilityFactory;
import forge.card.spellability.SpellAbility;
/**
* The Class StaticAbility.
@@ -282,8 +283,35 @@ public class StaticAbility {
return StaticAbilityCantBeCast.applyCantBeCastAbility(this, card, activator);
}
return false;
}
/**
* Apply ability.
*
* @param mode
* the mode
* @param card
* the card
* @param activator
* the activator
* @param sa
* the ability
* @return true, if successful
*/
public final boolean applyAbility(final String mode, final Card card, final Player activator, SpellAbility sa) {
// 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("CantBeActivated")) {
return StaticAbilityCantBeCast.applyCantBeActivatedAbility(this, card, activator);
return StaticAbilityCantBeCast.applyCantBeActivatedAbility(this, card, activator, sa);
}
return false;

View File

@@ -1,74 +1,81 @@
package forge.card.staticability;
import java.util.HashMap;
import forge.Card;
import forge.Phase;
import forge.Player;
/**
* The Class StaticAbility_CantBeCast.
*/
public class StaticAbilityCantBeCast {
/**
* 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 applyCantBeCastAbility(final StaticAbility stAb, final Card card, final Player activator) {
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;
}
if (params.containsKey("Caster") && (activator != null)
&& !activator.isValid(params.get("Caster"), hostCard.getController(), hostCard)) {
return false;
}
if (params.containsKey("OnlySorcerySpeed") && (activator != null) && Phase.canCastSorcery(activator)) {
return false;
}
return true;
}
/**
* 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 applyCantBeActivatedAbility(final StaticAbility stAb, final Card card, final Player activator) {
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;
}
if (params.containsKey("Activator") && (activator != null)
&& !activator.isValid(params.get("Activator"), hostCard.getController(), hostCard)) {
return false;
}
return true;
}
}
package forge.card.staticability;
import java.util.HashMap;
import forge.Card;
import forge.Phase;
import forge.Player;
import forge.card.spellability.AbilityMana;
import forge.card.spellability.SpellAbility;
/**
* The Class StaticAbility_CantBeCast.
*/
public class StaticAbilityCantBeCast {
/**
* 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 applyCantBeCastAbility(final StaticAbility stAb, final Card card, final Player activator) {
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;
}
if (params.containsKey("Caster") && (activator != null)
&& !activator.isValid(params.get("Caster"), hostCard.getController(), hostCard)) {
return false;
}
if (params.containsKey("OnlySorcerySpeed") && (activator != null) && Phase.canCastSorcery(activator)) {
return false;
}
return true;
}
/**
* 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 applyCantBeActivatedAbility(final StaticAbility stAb, final Card card,
final Player activator, SpellAbility sa) {
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;
}
if (params.containsKey("Activator") && (activator != null)
&& !activator.isValid(params.get("Activator"), hostCard.getController(), hostCard)) {
return false;
}
if (params.containsKey("NonMana") && sa instanceof AbilityMana) {
return false;
}
return true;
}
}