It is currently 29 Oct 2025, 09:28
   
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: Considerations and Questions: Ability Factories

Postby Sloth » 09 Nov 2012, 12:44

Agetian wrote:P.S. If it's too much of a difficulty to code on my own (which it might be, given the complexity of the AI code), would anyone be willing to volunteer to provide the AI backing for either the AF ChooseSource I'm writing or the CoP AI logic? (I think the latter may be an even bigger problem for me than the former).
Just add the RemAIDeck SVar to the cards and leave the AI for later. I will take a look it when it has been commited.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: Considerations and Questions: Ability Factories

Postby Agetian » 09 Nov 2012, 13:17

Sloth wrote:
Agetian wrote:P.S. If it's too much of a difficulty to code on my own (which it might be, given the complexity of the AI code), would anyone be willing to volunteer to provide the AI backing for either the AF ChooseSource I'm writing or the CoP AI logic? (I think the latter may be an even bigger problem for me than the former).
Just add the RemAIDeck SVar to the cards and leave the AI for later. I will take a look it when it has been commited.
Alrighty, sounds good! Thanks, Sloth!

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

Re: Considerations and Questions: Ability Factories

Postby Agetian » 09 Nov 2012, 15:08

Progress report: all 6 CoPs and RoPs are in, they successfully prevent damage from permanent and stack sources, as well as from a good deal of referenced sources as well. I keep working on the referenced objects part of the deal, as well as testing. So far, so good. ;)

A couple teaser screenshots:

Circle of Protection: Red preventing damage from a source referenced by the effect on the stack coming from Electropotence; chosen is the referenced object, which is Raging Goblin
Ag_CoP_Preventing_Damage_From_RefObj.jpg


CoP Red and Rune of Protection: Artifacts prevent combat damage from two permanent sources
Ag_CoPs_Preventing_Combat_Damage.jpg


Enjoy! Hopefully I'll finish the code and the testing phase soon!

EDIT: A little question: is it somehow possible to name the card differently than the picture file? E.g. the card should be named "Circle of Protection: Artifacts", but if I name it that way (in which case the SetInfo script runs file btw), the picture won't show because the picture files for it are called "Circle of Protection Artifacts.full.jpg" (without the colon). Is it possible for the card to have a custom name compared to the referenced picture file name, or should they always be the same (in that case, I'll just leave the names without the colon after running SetInfo).

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

Re: Considerations and Questions: Ability Factories

Postby friarsol » 09 Nov 2012, 16:05

Well, we already drop commas and apostrophes from filenames, so we should definitely drop colons too. I think COPs and ROPs are the only cards that actually use Colons.

(Oh wait, it looks like you are talking about the actual card listed inside the card file)

In that case, I'd say use the full name as listed in Gatherer, and we should fix the bug that doesn't drop the Colon when looking up the picture. (Wherever that happens to be) Since colons are illegal characters for Windows users, and would generally be avoided as a file name due to that.

Agetian wrote:EDIT: A little question: is it somehow possible to name the card differently than the picture file? E.g. the card should be named "Circle of Protection: Artifacts", but if I name it that way (in which case the SetInfo script runs file btw), the picture won't show because the picture files for it are called "Circle of Protection Artifacts.full.jpg" (without the colon). Is it possible for the card to have a custom name compared to the referenced picture file name, or should they always be the same (in that case, I'll just leave the names without the colon after running SetInfo).
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Considerations and Questions: Ability Factories

Postby Agetian » 09 Nov 2012, 17:03

Ok, got that problem with file names fixed, hope I didn't break anything else in the process (I shouldn't have).

Alright, CoP targeting tests according to the checklist for the "Objects referenced by other objects" mentioned on the previous page seems to have been successful. As such, everything that I'm aware of that can count as a source (either a permanent, or on the stack, or referenced by an effect on the stack) is selectable via AF ChooseSource.

There's only one rather major problem remaining: since the GuiChoose.one dialog that allows you to choose the origin of the source, as well as the GuiChoose.one dialog that allows you to choose the source itself, fire inside the resolve method of the ability factory, there's no way to cancel targeting, especially in case in which after filtering (according to color/type) there are no more valid sources left. That leads to the situation in which if, for instance, you click on CoP White but there are no valid white sources anywhere, one mana will be wasted and the effect will still resolve but nothing will happen (which is likely an illegal play?) To be honest, I think that something has to be done with the initial targeting mechanism in order to make sure that CoP can't be activated if there are no valid targets for it, but that means that the code for choosing targets has to either be moved somewhere (perhaps TargetSelection? <-- that is a big mystery for me) or at least supplemented with some other limiting code that fires before the resolve() method does.

Other than that,
* CoPs correctly prevent damage to the player from sources of all kinds known to me.
* RoPs correctly do so as well, as well as have the Cycling ability.
* The proper Gatherer names are used for the cards, with the card picture showing up correctly despite the colon (per the little patch I just submitted to the SVN).
* The "choose a source" box correctly lists only the sources of the color that CoP is meant for, as well as does not list categories that are not currently available (e.g. if there's nothing on the stack, only the "Permanent" category will be available for choosing).

The current limitations and issues are:
* No AI support, so all CoPs/RoPs are currently listed as RemAIDeck (Sloth said he'd look into that eventually).
* The "targeting on resolve" problem mentioned above.

I'm not sure if I'll be able to resolve the second problem on my own, so I'd really appreciate it if someone more efficient in arcane arts such as TargetSelection and whatnot could look at the code and either move the targeting to the right part or at least give me a detailed explanation of how that can be done...

I'm currently in two minds about:
a) either uploading the code and the card files here (so they don't yet go to the SVN as it may be a bit early for that);
b) actually committing the code to the SVN so that everyone can take a look and fix up or advise things as necessary.

Please tell me what you'd like me to do.

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

Re: Considerations and Questions: Ability Factories

Postby Sloth » 09 Nov 2012, 17:14

Agetian wrote:There's only one rather major problem remaining: since the GuiChoose.one dialog that allows you to choose the origin of the source, as well as the GuiChoose.one dialog that allows you to choose the source itself, fire inside the resolve method of the ability factory, there's no way to cancel targeting, especially in case in which after filtering (according to color/type) there are no more valid sources left. That leads to the situation in which if, for instance, you click on CoP White but there are no valid white sources anywhere, one mana will be wasted and the effect will still resolve but nothing will happen (which is likely an illegal play?) To be honest, I think that something has to be done with the initial targeting mechanism in order to make sure that CoP can't be activated if there are no valid targets for it, but that means that the code for choosing targets has to either be moved somewhere (perhaps TargetSelection? <-- that is a big mystery for me) or at least supplemented with some other limiting code that fires before the resolve() method does.
The CoP's ability does not include the word target, so it doesn't target and you can't make an illegal play. Everything's fine.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: Considerations and Questions: Ability Factories

Postby Agetian » 09 Nov 2012, 17:17

Oh OK, it's all good then! Thanks for telling me, Sloth! Alright, I'll make some final tests then and will then commit to SVN unless anything serious shows up.

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

Re: Considerations and Questions: Ability Factories

Postby friarsol » 09 Nov 2012, 17:36

Looks like there's almost 50 cards that could use ChooseSource. I'm sure not all of them will be scriptable right away, but it looks like a lot of these are from older sets.

Good stuff Agetian.

http://magiccards.info/query?q=o%3A%22n ... rd&s=cname
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Considerations and Questions: Ability Factories

Postby Sloth » 09 Nov 2012, 18:47

friarsol wrote:Looks like there's almost 50 cards that could use ChooseSource. I'm sure not all of them will be scriptable right away, but it looks like a lot of these are from older sets.

Good stuff Agetian.

http://magiccards.info/query?q=o%3A%22n ... rd&s=cname
It's actually more than 60 possible cards:

http://magiccards.info/query?q=o%3A%22s ... rd&s=cname
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: Considerations and Questions: Ability Factories

Postby friarsol » 09 Nov 2012, 18:54

Oh yea, I wasn't even thinking about the prevention bubbles that would last the whole turn instead of just the next damage instance.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Considerations and Questions: Ability Factories

Postby Max mtg » 09 Nov 2012, 19:50

Where are you going to mantain those bubbles? On an object being protected or on possible damage source... or maybe on none of them, but somewhere else?
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: Considerations and Questions: Ability Factories

Postby friarsol » 09 Nov 2012, 19:57

Max mtg wrote:Where are you going to mantain those bubbles? On an object being protected or on possible damage source... or maybe on none of them, but somewhere else?
It's creating an Effect Object that's visible on the battlefield, the screenshot below shows them.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Considerations and Questions: Ability Factories

Postby Agetian » 10 Nov 2012, 02:20

Hehe thanks, I'm glad what I'm doing will be useful for more than just CoPs! :) I'm looking into a way of optimizing the way of choosing the source, btw, and then I'm done - I should be ready either later today or early tomorrow and I'll commit everything to SVN. :)

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

Re: Considerations and Questions: Ability Factories

Postby Sloth » 10 Nov 2012, 08:52

Agetian wrote:Hehe thanks, I'm glad what I'm doing will be useful for more than just CoPs! :) I'm looking into a way of optimizing the way of choosing the source, btw, and then I'm done - I should be ready either later today or early tomorrow and I'll commit everything to SVN. :)
If it's working, better commit earlier than later. You never know when Max makes another widespread change to the code base.

Optimizing can happen after.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: Considerations and Questions: Ability Factories

Postby Agetian » 10 Nov 2012, 09:57

Alrighty, I'll be ready within an hour! :)

- 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 10 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 10 users online :: 0 registered, 0 hidden and 10 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 10 guests

Login Form