[CODE] Devotion

All code submission.
excessum
Posts: 220
Joined: Wed Jan 16, 2013 5:03 am
Contact:

[CODE] Devotion

Post by excessum »

*EDIT* Just realised that I forgot to attach the source file here... I figured that by adding a flag to "ListMaintainerAbility", it is possible to directly affect the values fed to "aslongas" and "foreach". Similarly, adding a check in the "type:blah:zone" code in WParsedInt will negate the need for another "else if" block so my original post is kind of outdated anyway.

This is my attempt to add the Theros mechanic Devotion into the game engine. There are only 16 cards that require this ability but I expect the next two expansions to include more.

I have identified at least three areas where the Devotion mechanic is required:
1) WParsedInt for damage and life gained/lost effects (Fanatic of Mogis, Gray Merchant of Asphodel and Nylea's Disciple)
2) AAsLongAs for "aslongas(devotion) blah >n" effect (five gods)
3) AForeach for "foreach(devotion) do blah" effects (everything else)

The attached file adds support for the first of the above so that the parser can now accept lines like "damage:devotion:r" and "life:devotion:g" for those three cards. I believe that the other two items can be solved by introducing the mana symbols as a candidate for TargetChooser and I will be working on that today. If this is possible, it will also add support for the Chroma mechanic.
excessum
Posts: 220
Joined: Wed Jan 16, 2013 5:03 am
Contact:

Re: [CODE] Devotion

Post by excessum »

The code for Devotion is now complete and attached. It is coded as a ParsedInt in the end which I realised could be used with this(variable{}) and thisforeach(variable{}). Examples of the new mechanic are given below.

The Theros Gods suffer from the problem of the engine not allowing creature to non-creature transforms so my implementation will not count as a creature spell anywhere. It is only on the battlefield that the (not)creature-type is correct.

Code: Select all

[card]
name=Gray Merchant of Asphodel
auto=life:-type:manab:mybattlefield opponent && life:type:manab controller
text=When Gray Merchant of Asphodel enters the battlefield, each opponent loses X life, where X is your devotion to black. You gain life equal to the life lost this way. (Each {B} in the mana costs of permanents you control counts toward your devotion to black.)
mana={3}{B}{B}
type=Creature
subtype=Zombie
power=2
toughness=4
[/card]
[card]
name=Master of Waves
abilities=protection from red
auto=lord(elemental|mybattlefield) 1/1
auto=thisforeach(variable{type:manau}) token(Elemental,Creature Elemental,1/0,blue)
text=Protection from red -- Elemental creatures you control get +1/+1. -- When Master of Waves enters the battlefield, put a number of 1/0 blue Elemental creature tokens onto the battlefield equal to your devotion to blue. (Each {U} in the mana costs of permanents you control counts toward your devotion to blue.)
mana={3}{U}
type=Creature
subtype=Merfolk Wizard
power=2
toughness=1
[/card]
[card]
name=Mogis's Marauder
auto=name(intimidate & haste) target(<upto:type:manab>creature) transforms((,newability[intimidate],newability[haste])) ueot
text=When Mogis's Marauder enters the battlefield, up to X target creatures each gain intimidate and haste until end of turn, where X is your devotion to black. (Each {B}in the mana costs of permanents you control counts toward your devotion to black.)
mana={2}{B}
type=Creature
subtype=Human Berserker
power=2
toughness=2
[/card]
[card]
name=Nykthos, Shrine to Nyx
auto={T}:add{1}
auto={2}{T}:name(Green) thisforeach(variable{type:manag}) add{G}
auto={2}{T}:name(Blue) thisforeach(variable{type:manau}) add{U}
auto={2}{T}:name(Red) thisforeach(variable{type:manar}) add{R}
auto={2}{T}:name(Black) thisforeach(variable{type:manab}) add{B}
auto={2}{T}:name(White) thisforeach(variable{type:manaw}) add{W}
text={T}: Add 1 to your mana pool. -- {2}{T}: Choose a color. Add to your mana pool an amount of mana of that color equal to your devotion to that color. (Your devotion to a color is the number of mana symbols of that color in the mana costs of permanents you control.)
type=Legendary Land
[/card]
[card]
name=Purphoros, God of the Forge
abilities=indestructible
auto=@movedto(other creature|mybattlefield):damage:2 opponent
auto={2}{R}:lord(creature|mybattlefield) 1/0 ueot
auto=this(variable{type:manar}>4) transforms((God Creature,setpower=6,settoughness=5))
text=Indestructible -- As long as your devotion to red is less than five, Purphoros isn't a creature. Whenever another creature enters the battlefield under your control, Purphoros deals 2 damage to each opponent. -- {2}{R}: Creatures you control get +1/+0 until end of turn.
mana={3}{R}
type=Legendary Enchantment
[/card]
[card]
name=Umbra Stalker
auto=thisforeach(variable{type:manab:mygraveyard}) 1/1
text=Chroma - Umbra Stalker's power and toughness are each equal to the number of black mana symbols in the mana costs of cards in your graveyard.
mana={4}{B}{B}{B}
type=Creature
subtype=Elemental
power=*
toughness=*
[/card]
Attachments

[The extension zip has been deactivated and can no longer be displayed.]

sandman423
Posts: 806
Joined: Thu Sep 10, 2009 8:59 pm

Re: [CODE] Devotion

Post by sandman423 »

How do I add this code to my current SVN v4861 using PSP.
Tacoghandi
Posts: 1197
Joined: Thu Apr 28, 2011 11:34 pm

Re: [CODE] Devotion

Post by Tacoghandi »

Unless I am mistaken the gods have the subtype God all the time. Not just when they are creatures. Also do you think maybe an autograveyard and autohand line would be able to make the gods creatures while in those zones. Not sure how to fix it in library though.
Purphuros" firebreathing should be coded as all and not lord

Definitely gonna check this out though
!!Check out My Created Sets and other Stuff!!

viewtopic.php?f=22&t=3380
excessum
Posts: 220
Joined: Wed Jan 16, 2013 5:03 am
Contact:

Re: [CODE] Devotion

Post by excessum »

You will have to compile the entire project for the PSP with the amended source code which I have no idea how to do.

Yeah I forgot that non-creatures can also have subtypes... The problem is that you cannot "lose" the "creature" type while you can grant it using "transforms((". Changing this would require some serious hacking in the base types which I doubt is worth it so I just stuck with it working 100% in the battlefield only.

Actually "all" and "lord" are equivalent in this context, especially since they both create the ALord object with the same arguments unless I am missing something somewhere...
Tacoghandi
Posts: 1197
Joined: Thu Apr 28, 2011 11:34 pm

Re: [CODE] Devotion

Post by Tacoghandi »

excessum wrote:You will have to compile the entire project for the PSP with the amended source code which I have no idea how to do.

Yeah I forgot that non-creatures can also have subtypes... The problem is that you cannot "lose" the "creature" type while you can grant it using "transforms((". Changing this would require some serious hacking in the base types which I doubt is worth it so I just stuck with it working 100% in the battlefield only.

Actually "all" and "lord" are equivalent in this context, especially since they both create the ALord object with the same arguments unless I am missing something somewhere...
I understand the creature type issue. I was just telling you that they should always have the subtype god instead of using it in the transform line. The Lord vs All thing I just thought was more proper since it is an ueot effect and lord is more for continuous effects. Not an issue since ill end up coding all the missing cards once i compile this anyway and will code all Chroma cards as well since it is the same mechanic.

Thanks for the add. This will make a lot of people happy.
!!Check out My Created Sets and other Stuff!!

viewtopic.php?f=22&t=3380
William Ward
Posts: 211
Joined: Mon Sep 26, 2011 11:29 am

Re: [CODE] Devotion

Post by William Ward »

whats the attachment do?
excessum
Posts: 220
Joined: Wed Jan 16, 2013 5:03 am
Contact:

Re: [CODE] Devotion

Post by excessum »

They are the amended source code files for the engine. The header (.h) and code (.cpp) files go into the "include" and "src" folders of the project. After compiling them, the parser for mtg.txt will recognise the new "type:manaX:zone" keyword where "X" is the mana symbol (r/g/w/b/u) and "zone" is the usual game zone convention.
Niegen
Posts: 200
Joined: Sun Jul 12, 2009 9:46 am

Re: [CODE] Devotion

Post by Niegen »

Will your code work if Kitchen Finks is in play?
Tacoghandi
Posts: 1197
Joined: Thu Apr 28, 2011 11:34 pm

Re: [CODE] Devotion

Post by Tacoghandi »

Niegen wrote:Will your code work if Kitchen Finks is in play?
From looking at the source code he used it should. Hybrids were included.
!!Check out My Created Sets and other Stuff!!

viewtopic.php?f=22&t=3380
Locked