It is currently 10 Sep 2025, 20:11
   
Text Size

Profane Command

Post MTG Forge Related Programming Questions Here

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

Profane Command

Postby moomarc » 04 Oct 2012, 08:54

Okey dokey, I'm trying to convert Profane Command to script because it's a monster piece of code (about 500 lines) that could be taken out when I get this right. So far I've got the script (that is, each of the charm's abilities work as expected). I've also expanded Sol's work on XCantBe0 so that X has to be larger than a specified SVar or integer (my stuff id separate from the XCantBe0 stuff for now, although they could probably be merged at some stage). This allows us to actually choose a value for X other than a targeted card's cmc (or whatever else) for cards such as Postmortem Lunge or Minamo Sightbender. Not sure when you might want to, but at least you'd have the option. (Edit: I suppose if the AI were smarter and you had a permanent that could boost power, then it might add a little extra to an activation of Minamo Sightbender so that you don't pump the target's power above X. :wink: )

Anyway, this would enable Profane Command to work as a scripted card IF I could find a way to get the Targeted$CardManaCost and Targeted$Amount of the specific Charm sa. At the moment Targeted$CardManaCost return the cmc of either of the last three abilities when I only need the cmc of the card targeted by the second choice. Likewise, Targeted$Amount needs to only return the number targeted by the last ability.

Any idea's on how to do this? Ideally what I'd want is something similar to StoreSVar for targeting that lets you set a specific SVar based on a specified expression.
-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: Profane Command

Postby friarsol » 04 Oct 2012, 12:17

I think what Targeted$ is doing is gathering up every target in an SAs chain of abilities, and using all of those to base its calculation off of. We can probably check each SA that actually uses the Targeted$ format and see if any of them actually need "all" of the targets. I'm not sure if bubbling up through the SAs is necessary (once you actually find some targets). I know certain Targeted$ things do rely on looking at the parent abilities targets.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Profane Command

Postby moomarc » 04 Oct 2012, 16:54

Am I right in thinking that Charm adds the selected mode/s as a subability?
-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: Profane Command

Postby Sloth » 04 Oct 2012, 18:19

moomarc wrote:Am I right in thinking that Charm adds the selected mode/s as a subability?
Yes.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: Profane Command

Postby moomarc » 04 Oct 2012, 18:41

In that case I think I know how to get this right. Will see in the morning if it works, but should be able to use something like CharmTargeted$CardManaCost. Then at the start of CalculateAmount, before the method starts checking what type it is, check the subabilities for a param XCountRefsThis. Pass that sa (instead of the default ability) through the rest of CalculateAmount replacing CharmTargeted with Targeted (coded a bit more generically obviously).

Does that sound plausible?
-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: Profane Command

Postby friarsol » 04 Oct 2012, 19:22

moomarc wrote:In that case I think I know how to get this right. Will see in the morning if it works, but should be able to use something like CharmTargeted$CardManaCost. Then at the start of CalculateAmount, before the method starts checking what type it is, check the subabilities for a param XCountRefsThis. Pass that sa (instead of the default ability) through the rest of CalculateAmount replacing CharmTargeted with Targeted (coded a bit more generically obviously).

Does that sound plausible?
Sounds like it would work, I'd probably use different nomenclature for this than CharmTargeted (since non-charm SAs could actually use this beneficially) but I'm not sure what I would call it.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Profane Command

Postby moomarc » 04 Oct 2012, 19:34

I'll probably go with SpecifiedTargeted or just SpecTargeted. Or perhaps SpecSATargeted is more descriptive?

If that works, all I have to do then is get the XNotLessThan<var> code to take two svars and use the biggest (I can't think of any situation where we'd need to compare more than two svars).

I'm quite happy with how the code is turning out. Nice and clean (at least I think it is). Two months ago this would still have been beyond me but I've learnt enough java now to learn quickly :D
-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: Profane Command

Postby friarsol » 05 Oct 2012, 00:26

moomarc wrote:I'll probably go with SpecifiedTargeted or just SpecTargeted. Or perhaps SpecSATargeted is more descriptive?

If that works, all I have to do then is get the XNotLessThan<var> code to take two svars and use the biggest (I can't think of any situation where we'd need to compare more than two svars).

I'm quite happy with how the code is turning out. Nice and clean (at least I think it is). Two months ago this would still have been beyond me but I've learnt enough java now to learn quickly :D
SpecificTargeted works for me. I wouldn't put SA in there since it would mean something a bit different to me. Glad to see some of the most brutal hardcoded cards disappearing.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Profane Command

Postby moomarc » 05 Oct 2012, 08:50

  ](*,) Just not getting anywhere here. The root charm ability has no subabilities as far as I can tell. A println outputs something like this for the root sa of Profane Command:
Code: Select all
Choose two - Target player loses X life; or return target creature card with converted mana cost X or less from your graveyard to the battlefield; or target creature gets -X/-X until end of turn; or up to X target creatures gain fear until end of turn. (They can't be blocked except by artifact creatures and/or black creatures.) Target player loses X life. Target creature gets -X/-X until end of turn.
which translates to
Code: Select all
Choice1 Choice2 Choice3 Choice4 Chosen1 Chosen2
That's the output from ability.getSourceCard().getSpells().get(0), but everything I tried seemed to come to the same conclusion. Trying to get the subability of that gets a NPE so I'm not sure what else to do short of changing how Charm works (which I'm not even considering an option really). Any more ideas? Anyone? Maybe? :-k
-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: Profane Command

Postby friarsol » 05 Oct 2012, 13:08

Post your card and your diff of whatever source you changed, I'll take a look this afternoon.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Profane Command

Postby moomarc » 05 Oct 2012, 13:16

The calculateAmount bit deteriorated into a mass of println's trying to find out what was happening, and I never got around to finalizing returning the larger of two calculated amounts (seeing as I was still trying to get the amounts). So I just need to get it back into some sort of "this should have worked" state then I'll post here. Thanks for looking into it.
-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: Profane Command

Postby friarsol » 05 Oct 2012, 13:30

We do already have LimitMax for finding the larger of two values (in the count structure). It looks like Ana Sanctuary (and other APC Sanctuaries) uses them.

Edit: Ugh. These are poorly named, since LimitMax actually finds the Minimum of two values, and LimitMin finds the Maximum of two values.

It doesn't seem like anything actually uses LimitMin, but that's the one you'd want.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Profane Command

Postby moomarc » 05 Oct 2012, 13:45

friarsol wrote:We do already have LimitMax for finding the larger of two values (in the count structure). It looks like Ana Sanctuary (and other APC Sanctuaries) uses them.

Edit: Ugh. These are poorly named, since LimitMax actually finds the Minimum of two values, and LimitMin finds the Maximum of two values.

It doesn't seem like anything actually uses LimitMin, but that's the one you'd want.
For my purposes it was easier to just use
Code: Select all
                for (final String xGEvar : xGESplit) {
                    int amount = AbilityFactory.calculateAmount(sa.getSourceCard(), xGEvar, sa);
                    if (amount > xGE) {
                        xGE = amount;
                    }
                }
-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: Profane Command

Postby Hellfish » 05 Oct 2012, 15:38

I named em that because they Limit to a max or min value.I swear ot made sense at the time. :lol:
So now you're
Screaming for the blood of the cookie monster
Evil puppet demon of obesity
Time to change the tune of his fearful ballad
C is for "Lettuce," that's good enough for me
User avatar
Hellfish
Programmer
 
Posts: 1297
Joined: 07 Jun 2009, 10:41
Location: South of the Pumphouse
Has thanked: 110 times
Been thanked: 169 times

Re: Profane Command

Postby moomarc » 05 Oct 2012, 16:15

Hellfish wrote:I named em that because they Limit to a max or min value.I swear ot made sense at the time. :lol:
I remember it making sense within context of its use. LimitMax limits the maximum value that will be returned by an xCount, it just happens to do that by returning the min. :P
-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

Next

Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 16 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 16 users online :: 0 registered, 0 hidden and 16 guests (based on users active over the past 10 minutes)
Most users ever online was 7967 on 09 Sep 2025, 23:08

Users browsing this forum: No registered users and 16 guests

Login Form