It is currently 29 Oct 2025, 17:58
   
Text Size

Implementing new Ability Factories and Card Support Code

Post MTG Forge Related Programming Questions Here

Moderators: timmermac, Agetian, friarsol, Blacksmith, KrazyTheFox, CCGHQ Admins

Re: Implementing new Ability Factories and Card Support Code

Postby Agetian » 15 Nov 2012, 19:05

Nice job, Moomarc, thanks for your effort! :D Updating my SVN now as well! :)

- Agetian
Agetian
Programmer
 
Posts: 3490
Joined: 14 Mar 2011, 05:58
Has thanked: 684 times
Been thanked: 572 times

Re: Implementing new Ability Factories and Card Support Code

Postby Agetian » 16 Nov 2012, 14:56

OK, on to the next development target in the department of support code for new cards. I noticed four cards in our contributions which were listed as partly supported, namely:

Leviathan
Exalted Dragon
Reclamation
Flooded Woodlands

They were listed as partly supported because they didn't work properly with cards like Propaganda that, together with the card itself, required two "unless" costs to be paid simultaneously. Are there any special rulings in MTG related to that which I have to be aware of, or should the implementation of those multiple costs be as simple as "ask the player to pay the first cost, ask the player to pay the second cost, ..., ask the player to pay the N cost, if all costs are paid, proceed with resolving the effect"? I'll look at the code during the next few days and will see if I can tackle this one.

- Agetian
Agetian
Programmer
 
Posts: 3490
Joined: 14 Mar 2011, 05:58
Has thanked: 684 times
Been thanked: 572 times

Re: Implementing new Ability Factories and Card Support Code

Postby Sloth » 16 Nov 2012, 20:48

Agetian wrote:OK, on to the next development target in the department of support code for new cards. I noticed four cards in our contributions which were listed as partly supported, namely:

Leviathan
Exalted Dragon
Reclamation
Flooded Woodlands

They were listed as partly supported because they didn't work properly with cards like Propaganda that, together with the card itself, required two "unless" costs to be paid simultaneously. Are there any special rulings in MTG related to that which I have to be aware of, or should the implementation of those multiple costs be as simple as "ask the player to pay the first cost, ask the player to pay the second cost, ..., ask the player to pay the N cost, if all costs are paid, proceed with resolving the effect"?
Yes, this is exactly what's needed (undoing costs is not that important, because sacrificing can't be undone anyway yet).

Some info:
There is no problem on the AI part, the AI can already handle all these cards with no code changes. For the human, checkPropagandaEffects currently links to payCostDuringAbilityResolve, which is primary used by Unless costs. There are some costs in payCostDuringAbilityResolve that can be paid immediately, but some costs use "getMatch().getInput().setInput(...)". These inputs happen delayed, so if you want to use more than one you have to link them, i.e. the "paid" Command of the first leads to the next input and so on.

I think i remember Max saying he wants to work on decoupling Input and GameAction at some point in the future. Be sure to be coordinated.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: Implementing new Ability Factories and Card Support Code

Postby Agetian » 17 Nov 2012, 02:38

Thanks for the info, Sloth! I'll contact Max and find out about it!

- Agetian
Agetian
Programmer
 
Posts: 3490
Joined: 14 Mar 2011, 05:58
Has thanked: 684 times
Been thanked: 572 times

Re: Implementing new Ability Factories and Card Support Code

Postby Max mtg » 17 Nov 2012, 05:36

Hmm... I don't quite undestand what should I do about here.

Yes, I wanted to decouple inputs from the effects they produce, so that the selectCard method of a particular input does not contain game logics.

If you need some inputs chained and make them easier to convert to network play sometime, the InputSelectManyCards class (there's also a version of this class for players) might come handy.

There are 2 ways how you can use it:
1. pass Predicate<Card> allowedRule and Function<List<Card>, Input> onDone to its constructor discontinued
2. make a descendant (inlined one is also ok) which overloads
Code: Select all
forge.control.input.InputSelectManyCards.isValidChoice(Card),
forge.control.input.InputSelectManyCards.onDone(),
the following methods may also be overriden:
Code: Select all
    protected Input onCancel() { return null; }
    protected boolean canCancelWithSomethingSelected() { return false; }
    protected boolean hasEnoughTargets() { return selected.size() >= min; }
// Pyrexian Dreadnought needed the last two
onDone and onCancel should return the next input to set after this one is stopped. Or null if no specific input required.


If I didn't quite answer your question (got you wrong, language barrier or anything else) - let me know please.
Last edited by Max mtg on 17 Nov 2012, 16:39, edited 1 time in total.
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: Implementing new Ability Factories and Card Support Code

Postby Sloth » 17 Nov 2012, 07:56

Max mtg wrote:Hmm... I don't quite undestand what should I do about here.
Sorry, i didn't mean that you should help here. Only that future work on the input system could mess with payCostDuringAbilityResolve in a big way (or even make it obsolete).

I meant:
Coordinated = Not working on expanding code that has to be scrapped the next day.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: Implementing new Ability Factories and Card Support Code

Postby Agetian » 17 Nov 2012, 15:45

Gotcha, will look at the code and will inform you if I'm able to do anything with it! ;)

- Agetian
Agetian
Programmer
 
Posts: 3490
Joined: 14 Mar 2011, 05:58
Has thanked: 684 times
Been thanked: 572 times

Re: Implementing new Ability Factories and Card Support Code

Postby Agetian » 17 Nov 2012, 18:46

IMPORTANT UPDATE: As the first step in my ongoing implementation of support for Soul Burn, I changed the "spend only <color> mana on X" from using SVar:XColor to using the ability parameter XColor. This alone is not enough for Soul Burn, but I think it's more appropriate anyway as it's more ability-related. The scripts for Crypt Rats, Crimson Hellkite, Drain Life, and Consume Spirit were updated accordingly, please check those scripts if you're interested in the new implementation format.

E.g. in Drain Life:

Was:
Code: Select all
SVar:XColor:B
A:SP$ StoreSVar | Cost$ X 1 B | Tgt$ TgtCP | SVar$ Limit | Type$ Targeted | Expression$ CardToughness | SubAbility$ StoreTgtP | ConditionDefined$ Targeted | ConditionPresent$ Card.Creature | ConditionCompare$ GE1 | SpellDescription$ CARDNAME deals X damage to target creature or player. You gain life equal to the damage dealt, but not more life than the player's life total before CARDNAME dealt damage or the creature's toughness.
Became:
Code: Select all
A:SP$ StoreSVar | Cost$ X 1 B | XColor$ B | Tgt$ TgtCP | SVar$ Limit | Type$ Targeted | Expression$ CardToughness | SubAbility$ StoreTgtP | ConditionDefined$ Targeted | ConditionPresent$ Card.Creature | ConditionCompare$ GE1 | SpellDescription$ CARDNAME deals X damage to target creature or player. You gain life equal to the damage dealt, but not more life than the player's life total before CARDNAME dealt damage or the creature's toughness.
- Agetian
Agetian
Programmer
 
Posts: 3490
Joined: 14 Mar 2011, 05:58
Has thanked: 684 times
Been thanked: 572 times

Re: Implementing new Ability Factories and Card Support Code

Postby Agetian » 21 Nov 2012, 04:09

Just wanted to post a little status update - I'm going through a rather crazy period of time at work (which shouldn't last long), so I was a bit inactive during the last couple days, but I'll be returning to the developments outlined in this topic relatively shortly.

- Agetian
Agetian
Programmer
 
Posts: 3490
Joined: 14 Mar 2011, 05:58
Has thanked: 684 times
Been thanked: 572 times

Re: Implementing new Ability Factories and Card Support Code

Postby Agetian » 27 Nov 2012, 07:51

A little question regarding current card scriptability support: is Nafs Asp currently possible to script with the effect system similar to what Circles of Protection use? If not, what's currently blocking its implementation?

- Agetian
Agetian
Programmer
 
Posts: 3490
Joined: 14 Mar 2011, 05:58
Has thanked: 684 times
Been thanked: 572 times

Re: Implementing new Ability Factories and Card Support Code

Postby Sloth » 27 Nov 2012, 08:33

Agetian wrote:A little question regarding current card scriptability support: is Nafs Asp currently possible to script with the effect system similar to what Circles of Protection use? If not, what's currently blocking its implementation?

- Agetian
The problem is "unless he or she pays {1} before that draw step.". Here is what it means:

"The player can pay the {1} mana at any time after damage is done before the draw step of that player's turn. People commonly pay during upkeep."
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: Implementing new Ability Factories and Card Support Code

Postby moomarc » 27 Nov 2012, 09:22

Sloth wrote:
Agetian wrote:A little question regarding current card scriptability support: is Nafs Asp currently possible to script with the effect system similar to what Circles of Protection use? If not, what's currently blocking its implementation?

- Agetian
The problem is "unless he or she pays {1} before that draw step.". Here is what it means:

"The player can pay the {1} mana at any time after damage is done before the draw step of that player's turn. People commonly pay during upkeep."
I'm not so sure that it's not scriptable. If you create an effect with EffectOwner$TriggeredPlayer and Duration$Permanent, add the draw trigger that executes the life loss with a subability that exiles the effect. Also add a straightforward exile self with cost {1} and it should work because the triggered player owns the effect so can activate the ability.

The only issue is that I don't think we have a param to encourage the AI to exile what it sees as it's own card.
-Marc
User avatar
moomarc
Pixel Commander
 
Posts: 2091
Joined: 04 Jun 2010, 15:22
Location: Johannesburg, South Africa
Has thanked: 371 times
Been thanked: 372 times

Re: Implementing new Ability Factories and Card Support Code

Postby Agetian » 27 Nov 2012, 10:08

That's interesting, Moomarc! If you ever have some time for it, can you please make a mockup script or something? If there are any issues with it, I'd like to take a look, and if not, it might be interesting to implement it. As for the AI side of the question, I might try to look into where that code would go, unless someone else more competent in AI would be willing to take it.

- Agetian
Agetian
Programmer
 
Posts: 3490
Joined: 14 Mar 2011, 05:58
Has thanked: 684 times
Been thanked: 572 times

Re: Implementing new Ability Factories and Card Support Code

Postby moomarc » 27 Nov 2012, 11:14

Agetian wrote:That's interesting, Moomarc! If you ever have some time for it, can you please make a mockup script or something? If there are any issues with it, I'd like to take a look, and if not, it might be interesting to implement it. As for the AI side of the question, I might try to look into where that code would go, unless someone else more competent in AI would be willing to take it.

- Agetian
Here's the full script:
Nafs Asp | Open
Code: Select all
Name:Nafs Asp
ManaCost:G
Types:Creature Snake
Text:no text
PT:1/1
T:Mode$ DamageDone | ValidSource$ Card.Self | ValidTarget$ Player | Execute$ NafsEffect | TriggerZones$ Battlefield | TriggerDescription$ Whenever CARDNAME deals damage to a player, that player loses 1 life at the beginning of his or her next draw step unless he or she pays 1 before that draw step.
SVar:NafsEffect:AB$ Effect | Cost$ 0 | Name$ Nafs Effect | EffectOwner$ TriggeredTarget | Duration$ Permanent | Triggers$ DrawTrig | Abilities$ PayUp | SVars$ Bleed,ExileEffect
SVar:DrawTrig:Mode$ Phase | Phase$ Draw | ValidPlayer$ You | TriggerZones$ Battlefield | Execute$ Bleed | TriggerDescription$ You lose 1 life at the beginning of your next draw step unless you pay 1 before that draw step.
SVar:Bleed:AB$ LoseLife | Cost$ 0 | Defined$ You | LifeAmount$ 1 | SubAbility$ ExileEffect
SVar:ExileEffect:DB$ ChangeZone | Defined$ Self | Origin$ Battlefield | Destination$ Exile
SVar:PayUp:AB$ ChangeZone | Cost$ 1 | Defined$ Self | Origin$ Battlefield | Destination$ Exile | Static$ True | SpellDescription$ Pay 1 to remove this effect.
SVar:Rarity:Common
SVar:Picture:http://www.wizards.com/global/images/magic/general/nafs_asp.jpg
SetInfo:4ED|Common|http://magiccards.info/scans/en/4e/148.jpg
SetInfo:ARN|Common|http://magiccards.info/scans/en/an/36.jpg|2
Oracle:Whenever Nafs Asp deals damage to a player, that player loses 1 life at the beginning of his or her next draw step unless he or she pays {1} before that draw step.
End
As suspected the ai won't actually pay to exile the effect, so it would need some new parameter or svar. And a RemAIDeck flag obviously doesn't help seeing as it uses the Asps well against me, it just doesn't know how to deal with the effect.

One other small issue that I've come across in the past as well. The spell description of an activated ability on an effect doesn't display in the card info panel.

Aside from those the card is good to go.

EDIT: Small aside - I considered adding a second subability that would add an extra ability to the asp so that payment could be made by clicking on either the asp or the effect, but there were a few issues. There would be no way to remove just that ability after using it, and you would have to remember the effect and exile Remembered. That would cause issues thou if it managed to deal more than one set of damage between draws (similar to the issue we have with Astral Slide when cycling multiple cards before the trigger).
-Marc
User avatar
moomarc
Pixel Commander
 
Posts: 2091
Joined: 04 Jun 2010, 15:22
Location: Johannesburg, South Africa
Has thanked: 371 times
Been thanked: 372 times

Re: Implementing new Ability Factories and Card Support Code

Postby Agetian » 27 Nov 2012, 15:19

Thank you very much, Moomarc, I'll take a look at what I can do with the AI aspect of it. :)

- Agetian
Agetian
Programmer
 
Posts: 3490
Joined: 14 Mar 2011, 05:58
Has thanked: 684 times
Been thanked: 572 times

PreviousNext

Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 17 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 17 users online :: 0 registered, 0 hidden and 17 guests (based on users active over the past 10 minutes)
Most users ever online was 9298 on 10 Oct 2025, 12:54

Users browsing this forum: No registered users and 17 guests

Login Form