Page 1 of 2

Restrictions for Card.isValidCard

PostPosted: 28 Aug 2010, 20:40
by Rob Cashwalker
Card.isValidCard takes a string array as a parameter. Each element follows the form:

CardType{.restriction}{+furtherRestriction}

The restrictions are optional.

CardType may be any type, generally the supertypes like Creature, Artifact, Enchantment, Land, etc. However, it could also be Elf or Goblin... though that would also include Elf Enchantments, for example. To specify an Elf Creature, then it should be "Creature.Elf". "Permanent" represents any permanent....

Restrictions other than type that are interpreted: (case sensitive)

  • Color, nonColor (White, nonWhite, etc)
  • Colorless, nonColorless
  • Multicolor, nonMulticolor

  • with{Keyword}, without{Keyword}
  • tapped, untapped
  • enchanted, unenchanted, enchanting
  • token, nonToken

  • power{cmp}{X or #}
  • toughness{cmp}{X or #}
  • cmc{cmp}{X or #}
  • {cmp} is a comparator:
    • LT - Less Than
    • LE - Less than or Equal
    • EQ - EQual
    • GE - Greater than or Equal
    • GT - Greater Than
    X is parsed from "SVar:X:Count$___"

Examples:

"Artifact or Enchantment" would be represented as a 2 element string array one element is "Artifact" the other "Enchantment"

"non-black, non-artifact creature" would be represented as a 1 element array - "Creature.nonBlack+nonArtifact"

"creature with power 2 or less" would be "Creature.powerLE2"

"nonbasic land" is "Land.nonBasic"

"creature with flying" is "Creature.withFlying"

Re: Restrictions for Card.isValidCard

PostPosted: 04 Sep 2010, 23:25
by Rob Cashwalker
I was recently reminded of the correct syntax - "+" between restrictions. For example:
non-black, non-artifact creature" would be represented as a 1 element array - "Creature.nonBlack+nonArtifact"

Re: Restrictions for Card.isValidCard

PostPosted: 05 Nov 2010, 21:27
by Sloth
I just added counters{cmp}{X or #}{countername}
(it only takes single digits for # though).
Code: Select all
Example: Creature.countersGE4LEVEL+Self
Although not on the list are: MonoColor, nonMonoColor, equipped, unequipped, equipping, attacking, notattacking and blocking.

Not to forget: YouCtrl, YouDontCtrl, Self, Other, Attached. But these are only avaiable if getValidCard is updated to send a Player and a Card variable. Note that these restrictions have to be at the end! Normal restrictions after that will be ignored.

Re: Restrictions for Card.isValidCard

PostPosted: 05 Nov 2010, 21:46
by friarsol
I copy/pasted this block into the Wiki but it can deal with some major formatting help.

http://www.slightlymagic.net/wiki/Forge_ValidCards

Re: Restrictions for Card.isValidCard

PostPosted: 16 Nov 2010, 16:51
by slapshot5
Is there a way to do the following with Valid?

I want to target a creature with power LE source creature's power.

I tried:
Code: Select all
A:AB$...|ValidTgts$Creature.powerLEX|...
SVar:X:Count$CardPower
But the X doesn't get interpreted until each individual card checks it, so I end up checking a card's power against 0 (since that card doesn't have the SVar, only the source card does...)

The specific card in question to determine targeting is Old Man of the Sea. I am only concerned with the initial targeting, not the "as long as..."

Thanks,
slapshot5

Re: Restrictions for Card.isValidCard

PostPosted: 16 Nov 2010, 17:53
by Sloth
slapshot5 wrote:Is there a way to do the following with Valid?

I want to target a creature with power LE source creature's power.

I tried:
Code: Select all
A:AB$...|ValidTgts$Creature.powerLEX|...
SVar:X:Count$CardPower
But the X doesn't get interpreted until each individual card checks it, so I end up checking a card's power against 0 (since that card doesn't have the SVar, only the source card does...)
Actually hasProperty searches for the SVar X on the card to check, which is really senseless. We would have to change hasProperty to take a source card as variable. I would be willing to change this, but it would mean a lot of cleanup and possible bugs (since all getValidCard calls must deliver a Card variable).

EDIT: Since this is long overdue and much cleaner, I'm gonna do this.

Re: Restrictions for Card.isValidCard

PostPosted: 16 Nov 2010, 21:40
by slapshot5
Sloth wrote:Actually hasProperty searches for the SVar X on the card to check, which is really senseless. We would have to change hasProperty to take a source card as variable. I would be willing to change this, but it would mean a lot of cleanup and possible bugs (since all getValidCard calls must deliver a Card variable).
Yeah, that's kind of what I thought. I started to pass a source Card through, but quickly found out it was much bigger than I'd hoped. Thought I'd better post for someone who is more familiar with this code than I.

Sloth wrote:EDIT: Since this is long overdue and much cleaner, I'm gonna do this.
Excellent. Thanks. I'm happy to help squash any bugs that come up.

-slapshot5

Re: Restrictions for Card.isValidCard

PostPosted: 16 Nov 2010, 22:40
by slapshot5
Ok, maybe that was too easy. Can Valid handle this targeting:

target creature whose controller controls an Island

?

-slapshot5

Re: Restrictions for Card.isValidCard

PostPosted: 17 Nov 2010, 07:24
by Sloth
slapshot5 wrote:Ok, maybe that was too easy.
Not really. I think I broke the restriction Other, but I can't find the mistake.


slapshot5 wrote:Can Valid handle this targeting:

target creature whose controller controls an Island

?

-slapshot5
It's possible, but anything more advanced like "target creature whose controller controls a blue permanent" would be a pain to find a syntax for.

Once I fixed the bug with Other, I will try to add a restriction like this:
ControllerControls[Type]

Is it to keyword Seasinger?

Re: Restrictions for Card.isValidCard

PostPosted: 17 Nov 2010, 07:33
by slapshot5
Sloth wrote:Is it to keyword Seasinger?
yep.

Re: Restrictions for Card.isValidCard

PostPosted: 17 Nov 2010, 07:40
by Sloth
The issue is fixed. I will give it a try now.

EDIT: ControllerControls[Type] is now usable, as well as YouOwn and YouDontOwn.

Re: Restrictions for Card.isValidCard

PostPosted: 18 Nov 2010, 19:49
by slapshot5
How do I use the ControllerControls?

I did this for Seasinger:

Code: Select all
|ValidTgts$Creature.ControllerControlsIsland|
and it didn't restrict properly. Do I use the []?

-slapshot5

Re: Restrictions for Card.isValidCard

PostPosted: 18 Nov 2010, 20:11
by friarsol
Sloth, is ControllerControls supposed to care about the card we're checking or the source?

Cause it looks like right now it's checking the Source. I'm not sure but maybe it could be something like:
Code: Select all
else if (Property.startsWith("ControllerControls")) {
   String type = Property.substring(18);
   CardList list = AllZoneUtil.getPlayerCardsInPlay(getController());
   if (list.getType(type).isEmpty()) return false;
}

Re: Restrictions for Card.isValidCard

PostPosted: 18 Nov 2010, 20:27
by slapshot5
It's supposed to care about the card we're checking. I tested Sol's change locally and it works. Seasinger is the only card that uses this, so I'll go ahead and commit this.

Thanks Sol.

-slapshot5

Re: Restrictions for Card.isValidCard

PostPosted: 18 Nov 2010, 20:48
by Sloth
Uh, ... Yes. This is what I intended. It seems I wasn't really into it. Sorry slapshot5.