- Added Sol's "May be played" keyword implementation for non-land cards.

- Added Garruk's Horde.
This commit is contained in:
Sloth
2011-10-24 07:32:49 +00:00
parent e88d5d495b
commit 27b96a3430
8 changed files with 55 additions and 30 deletions

View File

@@ -5057,21 +5057,25 @@ public class Card extends GameEntity implements Comparable<Card> {
CardList list = this.getOwner().getCardsIn(Zone.Graveyard);
if (!list.getAbove(source, this))
return false;
}else if (Property.startsWith("DirectlyAbove")){ // "Are Directly Above" Source
} else if (Property.startsWith("DirectlyAbove")){ // "Are Directly Above" Source
CardList list = this.getOwner().getCardsIn(Zone.Graveyard);
if (!list.getDirectlyAbove(source, this))
return false;
}else if (Property.startsWith("TopGraveyardCreature")){
} else if (Property.startsWith("TopGraveyardCreature")){
CardList list = this.getOwner().getCardsIn(Zone.Graveyard);
list = list.getType("Creature");
list.reverse();
if (list.isEmpty() || !this.equals(list.get(0)))
return false;
}else if (Property.startsWith("TopGraveyard")){
} else if (Property.startsWith("TopGraveyard")){
CardList list = this.getOwner().getCardsIn(Zone.Graveyard);
list.reverse();
if (list.isEmpty() || !this.equals(list.get(0)))
return false;
} else if (Property.startsWith("TopLibrary")){
CardList list = this.getOwner().getCardsIn(Zone.Library);
if (list.isEmpty() || !this.equals(list.get(0)))
return false;
} else if (Property.startsWith("Cloned")) {
if (cloneOrigin == null || !cloneOrigin.equals(source)) return false;
} else if (Property.startsWith("DamagedBy")) {

View File

@@ -797,7 +797,7 @@ public class ComputerUtil {
CardList lands = computer.getCardsIn(Zone.Graveyard).getType("Land");
for (Card crd : lands){
if (crd.isLand() && crd.hasKeyword("May be played"))
if (crd.isLand() && crd.hasStartOfKeyword("May be played"))
landList.add(crd);
}

View File

@@ -1584,7 +1584,7 @@ public class GameAction {
if (c.isLand() && human.canPlayLand()) {
PlayerZone zone = AllZone.getZoneOf(c);
if (zone.is(Zone.Hand) || (!zone.is(Zone.Battlefield)) && c.hasKeyword("May be played")) {
if (zone.is(Zone.Hand) || (!zone.is(Zone.Battlefield)) && c.hasStartOfKeyword("May be played")) {
choices.add("Play land");
}
}
@@ -1630,23 +1630,10 @@ public class GameAction {
* @param c a {@link forge.Card} object.
*/
public final void playCardNoCost(final Card c) {
//SpellAbility[] choices = (SpellAbility[]) c.getSpells().toArray();
ArrayList<SpellAbility> choices = c.getBasicSpells();
SpellAbility sa;
//TODO add Buyback, Kicker, ... , spells here
/*
ArrayList<SpellAbility> additional = c.getAdditionalCostSpells();
for (SpellAbility s : additional)
{
}
*/
/*
System.out.println(choices.length);
for(int i = 0; i < choices.length; i++)
System.out.println(choices[i]);
*/
if (choices.size() == 0) {
return;
} else if (choices.size() == 1) {

View File

@@ -718,13 +718,16 @@ public class AbilityFactory_Pump {
}
}
Zone pumpZone = params.containsKey("PumpZone") ? Zone.smartValueOf(params.get("PumpZone")) : Zone.Battlefield;
int size = tgtCards.size();
for (int j = 0; j < size; j++) {
final Card tgtC = tgtCards.get(j);
// only pump things in play
if (!AllZoneUtil.isCardInPlay(tgtC))
// only pump things in PumpZone
if (!AllZoneUtil.getCardsIn(pumpZone).contains(tgtC)) {
continue;
}
// if pump is a target, make sure we can still target now
if (tgt != null && !CardFactoryUtil.canTarget(AF.getHostCard(), tgtC))
@@ -736,8 +739,10 @@ public class AbilityFactory_Pump {
for(int i=0;i<untargetedCards.size();i++) {
final Card tgtC = untargetedCards.get(i);
if(!AllZoneUtil.isCardInPlay(tgtC))
continue;
// only pump things in PumpZone
if (!AllZoneUtil.getCardsIn(pumpZone).contains(tgtC)) {
continue;
}
applyPump(sa,tgtC);
}

View File

@@ -2630,6 +2630,7 @@ public class CardFactoryUtil {
List<Zone> sb = new ArrayList<Constant.Zone>(3);
sb.add(Constant.Zone.Graveyard);
sb.add(Constant.Zone.Exile);
sb.add(Constant.Zone.Library);
sb.add(Constant.Zone.Command);
CardList cl = player.getCardsIn(sb);
cl.addAll(AllZone.getStackZone().getCards());
@@ -2661,20 +2662,21 @@ public class CardFactoryUtil {
}
if (c.isLand() && !zone.is(Constant.Zone.Battlefield) && c.hasKeyword("May be played")) {
if (c.isLand() && !zone.is(Constant.Zone.Battlefield) && c.hasStartOfKeyword("May be played")) {
return true;
}
for (SpellAbility sa : c.getSpellAbility()) {
if (AllZone.getZoneOf(c).is(sa.getRestrictions().getZone())) {
Zone restrictZone = sa.getRestrictions().getZone();
if (zone.is(restrictZone)) {
return true;
}
// TODO - Yawgmoth's Will check here, lots of testing before adding
// this though
// if (!zone.is(Constant.Zone.Battlefield) &&
// c.hasKeyword("May be played") && sa.isSpell())
// return true;
if (sa.isSpell() && !zone.is(Zone.Battlefield) && c.hasStartOfKeyword("May be played")
&& restrictZone.equals(Zone.Hand))
{
return true;
}
}
return false;

View File

@@ -147,8 +147,21 @@ public class SpellAbility_Restriction extends SpellAbility_Variables {
* @return a boolean.
*/
public boolean canPlay(Card c, SpellAbility sa) {
if (!AllZone.getZoneOf(c).is(zone) || c.isPhasedOut())
if (c.isPhasedOut()) {
return false;
}
PlayerZone cardZone = AllZone.getZoneOf(c);
if (!cardZone.is(zone)) {
// If Card is not in the default activating zone, do some additional checks
// Not a Spell, or on Battlefield, return false
if (!sa.isSpell() || cardZone.is(Zone.Battlefield)) {
return false;
}
else if (!c.hasStartOfKeyword("May be played") || !zone.equals(Zone.Hand)) {
return false;
}
}
Player activator = sa.getActivatingPlayer();
if (activator == null) {