Card Development Questions
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
Re: Card Development Questions
by swordshine » 20 Feb 2013, 12:48
r19771moomarc wrote:Trying to script Razor Boomerang in an AI-friendly way (avoiding Pump:RememberObjects as the base ability) so I need to remember the unattached card by getting it from the sa's paidList. I've added the necessary code in AbilityUtils:HandleRemembering for RememberCostCards for "Unattached". I've also put in this.addListToHash(ability,"Unattach"); for human and AI, but it only works for the human. For the AI, it crashes atEdit: Nevermind!
- Code: Select all
final List<Card> paidListUnattached = sa.getPaidList("Unattached");
I just had the AI's addListToHash using "Attach".
I think you forgot to commit the changes in CostUnattach.
- swordshine
- Posts: 682
- Joined: 11 Jul 2010, 02:37
- Has thanked: 116 times
- Been thanked: 87 times
Re: Card Development Questions
by moomarc » 20 Feb 2013, 13:56
Thanks! Committed r19780.swordshine wrote:r19771
I think you forgot to commit the changes in CostUnattach.
-Marc
-
moomarc - Pixel Commander
- Posts: 2091
- Joined: 04 Jun 2010, 15:22
- Location: Johannesburg, South Africa
- Has thanked: 371 times
- Been thanked: 372 times
Re: Card Development Questions
by Max mtg » 26 Feb 2013, 08:06
I am not good at forge card scripts... yet can anyone explain me please, why this script:
http://svn.slightlymagic.net/websvn/fil ... &peg=19886
http://svn.slightlymagic.net/websvn/fil ... &peg=19886
- Code: Select all
Name:Jaded Response
ManaCost:1 U
Types:Instant
A:SP$ Counter | Cost$ 1 U | TargetType$ Spell | ValidTgts$ Card | AITgts$ Card.SharesColorWith Creature.YouCtrl | ConditionCheckSVar$ X | ConditionSVarCompare$ GE1 | References$ X | SpellDescription$ Counter target spell if it shares a color with a creature you control.
SVar:X:Targeted$Valid Card.SharesColorWith Creature.YouCtrl
SVar:Picture:http://www.wizards.com/global/images/magic/general/jaded_response.jpg
SetInfo:APC|Common|http://magiccards.info/scans/en/ap/26.jpg
Oracle:Counter target spell if it shares a color with a creature you control.
Single class for single responsibility.
- Max mtg
- Programmer
- Posts: 1997
- Joined: 02 Jul 2011, 14:26
- Has thanked: 173 times
- Been thanked: 334 times
Re: Card Development Questions
by swordshine » 26 Feb 2013, 09:07
You may target any spell with this card. If the targeted spell shares a color with a creature you control at the time Jaded Response resolves, that spell will be countered. "AITgts" part makes AI to give the correct decisions. Burnout has the similar effect.Max mtg wrote:I am not good at forge card scripts... yet can anyone explain me please, why this script:
http://svn.slightlymagic.net/websvn/fil ... &peg=19886Cannot read just ValidTgts$ Card.SharesColorWith Creature.YouCtrl ?
- Code: Select all
Name:Jaded Response
ManaCost:1 U
Types:Instant
A:SP$ Counter | Cost$ 1 U | TargetType$ Spell | ValidTgts$ Card | AITgts$ Card.SharesColorWith Creature.YouCtrl | ConditionCheckSVar$ X | ConditionSVarCompare$ GE1 | References$ X | SpellDescription$ Counter target spell if it shares a color with a creature you control.
SVar:X:Targeted$Valid Card.SharesColorWith Creature.YouCtrl
SVar:Picture:http://www.wizards.com/global/images/magic/general/jaded_response.jpg
SetInfo:APC|Common|http://magiccards.info/scans/en/ap/26.jpg
Oracle:Counter target spell if it shares a color with a creature you control.
- swordshine
- Posts: 682
- Joined: 11 Jul 2010, 02:37
- Has thanked: 116 times
- Been thanked: 87 times
Re: Card Development Questions
by Max mtg » 26 Feb 2013, 09:10
Ah, I got it! Any spell may be targeted, but it won't be countered if it does not share color with your creature.
Thanks for explaination, swordshine!
Thanks for explaination, swordshine!
Single class for single responsibility.
- Max mtg
- Programmer
- Posts: 1997
- Joined: 02 Jul 2011, 14:26
- Has thanked: 173 times
- Been thanked: 334 times
Re: Card Development Questions
by moomarc » 02 Mar 2013, 16:28
What was the problem when you tried to convert to script? I imagine the script would be something like:friarsol wrote:Ahhh sorry about that. I was trying to script it and ran into some issues, must have accidentally removed the hardcoded ability.cc-drake wrote: Temporal Aperture has no text and no ability.
- Code: Select all
A:AB$ Shuffle | Cost$ 5 T | Defined$ You | SubAbility$ RevealTop...
SVar:RevealTop:DB$ Dig | Num$ 1 | Reveal$ True | RememberRevealed$ True | NoMove$ True etc...
SVar:CoolEffect:DB$ Effect | RememberObjects$ Remembered | Triggers$ StillTopCheck | StaticAbilities$ PumpCanPlay | Keywords$ PlayRevealed | SVars... ...SubAbility$ DBCleanup
SVar:PlayRevealed:Play with the top card of your library revealed. (Just need to make sure that keywords of cards in Command zone are being parsed)
SVar:PumpCanPlay:Mode$ Continuous | Affected$ Card.TopLibrary+IsRemembered+YouCtrl | AffectedZone$ Library | AddHiddenKeyword$ May be played without paying its mana cost...
SVar:StillTopCheck:Mode$ Always | TriggerZones$ Command | IsPresent$ Card.TopLibrary+YouCtrl+IsNotRemembered | PresentZone$ Library | Execute$ ExileEffect...
SVar:ExileEffect....
SVar:DBCleanup....
-Marc
-
moomarc - Pixel Commander
- Posts: 2091
- Joined: 04 Jun 2010, 15:22
- Location: Johannesburg, South Africa
- Has thanked: 371 times
- Been thanked: 372 times
Re: Card Development Questions
by friarsol » 02 Mar 2013, 19:10
My "still on top of library" check wasn't working properly. Everything else was fine.moomarc wrote:What was the problem when you tried to convert to script? I imagine the script would be something like:
I had a few different versions, but this was the last one I was actually trying:
- Not quite working Temporal Aperture | Open
- A:AB$ Shuffle | Cost$ 5 T | SubAbility$ DBReveal | SpellDescription$ Shuffle your library, then reveal the top card. Until end of turn, for as long as that card remains on top of your library, play with the top card of your library revealed and you may play that card without paying its mana cost. (If it has X in its mana cost, X is 0.)
SVar:DBReveal:DB$ Dig | DigNum$ 1 | Reveal$ True | ChangeNum$ All | ChangeValid$ Card | DestinationZone$ Library | LibraryPosition$ 0 | LibraryPosition2$ 0 | RememberChanged$ True | SubAbility$ DBAperture
SVar:DBAperture:DB$ Effect | Name$ Temporal Aperture Effect | StaticAbilities$ STPlay | RememberObjects$ Remembered | Triggers$ TrigLeave | SVars$ ExileEffect | SpellDescription$ Until end of turn, for as long as that card remains on top of your library, play with the top card of your library revealed and you may play that card without paying its mana cost. | SubAbility$ DBCleanup
#Duration$ RememberedNotTopLibraryOrEOT
SVar:STPlay:Mode$ Continuous | EffectZone$ Command | Affected$ Card.IsRemembered+TopLibrary | AddKeyword$ May be played | AffectedZone$ Library
SVar:TrigLeave:Mode$ ChangesZone | ValidCard$ Card.IsRemembered | Origin$ Library | Destination$ Any | Execute$ ExileEffect | TriggerZones$ Command | Static$ True
SVar:ExileEffect:DB$ ChangeZone | Defined$ Self | Origin$ Command | Destination$ Exile
SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True
Using an Always is probably better. Feel free to test it out, I'll get back to it during the week if I don't see it checked in.
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Card Development Questions
by swordshine » 03 Mar 2013, 09:46
Does anyone have an idea to script Goblin Welder? "TargetsWithSameController" part is done. The remaining obstacle is "recheck if targets are illegal when resolving".
Last edited by swordshine on 03 Mar 2013, 11:52, edited 2 times in total.
- swordshine
- Posts: 682
- Joined: 11 Jul 2010, 02:37
- Has thanked: 116 times
- Been thanked: 87 times
Re: Card Development Questions
by Sloth » 03 Mar 2013, 11:48
I will add the condition "Condition$ AllTargetsLegal". That should do the trick.swordshine wrote:Does anyone have an idea to script Goblin Welder? "TargetsWithSameController" part is done. The remaining obstacle is "recheck if targets are illgel when resolving".
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: Card Development Questions
by swordshine » 03 Mar 2013, 11:59
That is great. I was thinking other tricks to script this card. I tried to add some awkward codes to Pump effect(just not to remember/imprint targeted cards if the targets are illegal when resolving).Sloth wrote:I will add the condition "Condition$ AllTargetsLegal". That should do the trick.
- swordshine
- Posts: 682
- Joined: 11 Jul 2010, 02:37
- Has thanked: 116 times
- Been thanked: 87 times
Re: Card Development Questions
by swordshine » 03 Mar 2013, 13:34
- about AllTargetsLegal | Open
- if (this.isAllTargetsLegal()) {
SpellAbility root = sa.getRootAbility();
for (Card c : root.getTarget().getTargetCards()) {
if (!CardFactoryUtil.isTargetStillValid(sa, c)) {
return false;
}
}
}
Goblin Welder has two targets in different zones, therefore one of the targets should be in a subability. I think rootability is not needed.
"for (Card c : sa.getTarget().getTargetCards())" is OK.
Here is a basic script:
- Goblin Welder | Open
- Name:Goblin Welder
ManaCost:R
Types:Creature Goblin Artificer
PT:1/1
A:AB$ Pump | Cost$ T | ValidTgts$ Artifact | TgtPrompt$ Select target artifact a player controls | RememberObjects$ Targeted | Condition$ AllTargetsLegal | StackDescription$ SpellDescription | SubAbility$ DBTargetYard | SpellDescription$ Choose target artifact a player controls and target artifact card in that player's graveyard. If both targets are still legal as this ability resolves, that player simultaneously sacrifices the artifact and returns the artifact card to the battlefield.
SVar:DBTargetYard:DB$ Pump | ValidTgts$ Artifact | TgtPrompt$ Select target artifact in that player's graveyard | TgtZone$ Graveyard | PumpZone$ Graveyard | TargetsWithSameController$ True | ImprintCards$ Targeted | Condition$ AllTargetsLegal | StackDescription$ None | SubAbility$ DBSacrifice
SVar:DBSacrifice:DB$ SacrificeAll | ValidCards$ Card.IsRemembered | ConditionDefined$ Remembered | ConditionPresent$ Artifact | ConditionCompare$ GE1 | ConditionCheckSVar$ CheckImprint | ConditionSVarCompare$ GE1 | SubAbility$ DBReturn | StackDescription$ None
SVar:DBReturn:DB$ ChangeZone | Defined$ Imprinted | Origin$ Graveyard | Destination$ Battlefield | SubAbility$ DBCleanup | ConditionDefined$ Remembered | ConditionPresent$ Artifact | ConditionCompare$ GE1 | ConditionCheckSVar$ CheckImprint | ConditionSVarCompare$ GE1 | StackDescription$ None
SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True | ClearImprinted$ True
SVar:CheckImprint:Imprinted$Valid Artifact.sharesControllerWith Remembered
SVar:Picture:http://www.wizards.com/global/images/magic/general/goblin_welder.jpg
Edit: Tested a few cases:
Case 1: etb and leave-the-battlefield triggers worked well. You can choose the order of resolving.
Case 2: Destroyed the first target, the second one did not go to battlefield. Good.
Case 3: Returned the second target to hand, the first was not sacrificed. Good.
Case 4: AI used Control Magic to control the first target, the second does not return.
Last edited by swordshine on 03 Mar 2013, 13:51, edited 1 time in total.
- swordshine
- Posts: 682
- Joined: 11 Jul 2010, 02:37
- Has thanked: 116 times
- Been thanked: 87 times
Re: Card Development Questions
by friarsol » 03 Mar 2013, 13:44
Re: Goblin Welder.
I think the Fizzling code may remove Targets from the Target object currently (even though this may not be 100% correct). So the AllTargetsLegal condition would really need to be a "This is how many things I'm still targeting" condition.
I think the Fizzling code may remove Targets from the Target object currently (even though this may not be 100% correct). So the AllTargetsLegal condition would really need to be a "This is how many things I'm still targeting" condition.
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Card Development Questions
by Sloth » 03 Mar 2013, 22:02
True. Do you need a "Condition$ TwoTargets" condition swordshine?friarsol wrote:Re: Goblin Welder.
I think the Fizzling code may remove Targets from the Target object currently (even though this may not be 100% correct). So the AllTargetsLegal condition would really need to be a "This is how many things I'm still targeting" condition.
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: Card Development Questions
by swordshine » 04 Mar 2013, 00:28
I think CardFactoryUtil.isTargetStillValid(sa,target) cannot deal with special targets right now (in this case, TargetsWithSameController), so I prefer using pump effect to remember/imprint the targets, and do a condition check if both targets share a controller in the subabilities. If the target is not legal when resolving, it would not be remembered/imprinted, therefore the subability sacrifice/changezone effect will not resolve. The AllTargetsLegal condition is so far so good.
- swordshine
- Posts: 682
- Joined: 11 Jul 2010, 02:37
- Has thanked: 116 times
- Been thanked: 87 times
Who is online
Users browsing this forum: No registered users and 28 guests