Page 1 of 2

Implementing cards

PostPosted: 11 Aug 2014, 14:45
by eljinete7
Hello. I send you one card I'd like to play in XMage. This is Cruel Bargain. I'm not familiar with Java or GitHub, so this is a card already implemented with other name (Infernal Contract) but with the same mechanic. I hope it is helpful.

Thanks for all your hard work in XMage.

(Sorry for my English).

Re: Implementing cards

PostPosted: 11 Aug 2014, 16:21
by eljinete7
Another one. Restless Dead from Mirage set.

Re: Implementing cards

PostPosted: 14 Aug 2014, 14:38
by LevelX
Hello eljinete7,

cards are added.
But normally we only need the specific adding ability/affects part, because the complete card frame is generated automically by a script.

So if you want to contribute further look at https://github.com/magefree/mage/wiki/Developer-Getting-Started.
There are some steps to use java + netbeans + XMage. Then you are perfectly equipped to contribute.
Manually create cards and copy code parts is always a pain.

If you try and have any questions feel free to ask here for help.

Re: Implementing cards

PostPosted: 29 Aug 2014, 17:46
by eljinete7
This is my try for Culling the Weak from Exdous set, a card needed for some good Legacy decks. Correct it if necessary.

Sorry if don't use GitHub yet, but it's too difficult for me to use it just now.

Re: Implementing cards

PostPosted: 05 Nov 2014, 15:46
by jeffwadsworth
Working on .Mana Reflection. This is a replacement effect, but apparently "Tapped_For_Mana" is not implemented for it. Is this the case?

Re: Implementing cards

PostPosted: 05 Nov 2014, 16:12
by LevelX
jeffwadsworth wrote:Working on .Mana Reflection. This is a replacement effect, but apparently "Tapped_For_Mana" is not implemented for it. Is this the case?
I guess you have to replace "ADD_MANA" (because here you get the Mana object and can manipulate it) and check if the producing source was tapped before by using a watcher that checks and remembers the "Tapped_For_Mana" event.
Ony a rough plan.

Re: Implementing cards

PostPosted: 10 Nov 2014, 15:57
by jeffwadsworth
Is there a way to get the cost information from a "ADD_MANA" event? I have tried a few techniques with no success. The watcher technique does not appear to cover every case, unfortunately.

Re: Implementing cards

PostPosted: 10 Nov 2014, 16:42
by LevelX
jeffwadsworth wrote:Is there a way to get the cost information from a "ADD_MANA" event? I have tried a few techniques with no success. The watcher technique does not appear to cover every case, unfortunately.
Why did the watcher technique not work?
Can you give an example?

Re: Implementing cards

PostPosted: 10 Nov 2014, 17:20
by jeffwadsworth
I erased the watcher code last week during testing of multiple variations, etc. Anyway, here is an example of a missed case:

Mana Reflection is played. A permanent is tapped for mana. The same permanent adds mana to the pool via counter removal, etc. The watcher will check and see that the permanent was tapped for mana that turn and double the second case.

Re: Implementing cards

PostPosted: 10 Nov 2014, 17:40
by LevelX
jeffwadsworth wrote:I erased the watcher code last week during testing of multiple variations, etc. Anyway, here is an example of a missed case:

Mana Reflection is played. A permanent is tapped for mana. The same permanent adds mana to the pool via counter removal, etc. The watcher will check and see that the permanent was tapped for mana that turn and double the second case.
But because mana effects don't go to the stack you can get always the last info (tapped_for_mana or not) from the watcher and clear the saved data of the watcher as you retrieve the info from watcher. So you can't get a wrong old information from the watcher.

Re: Implementing cards

PostPosted: 10 Nov 2014, 19:00
by emerald000
I have a question about implementing Nahiri, the Lithomancer. How can I check that the Kor Soldier can be equipped by the chosen Equipment? In some weird cases, the Equipment might not be equipable (it turned into a creature for example). The only way I could find in the code was related to Auras and don't apply (checking the spell targets). So anything already exists?

EDIT: After some more looking around, I guess it doesn't exist. O-Naginata and Konda's Banner equipping restriction are implemented as EmptyEffect and checked only on its own Equip ability.

Re: Implementing cards

PostPosted: 10 Nov 2014, 20:46
by LevelX
emerald000 wrote:I have a question about implementing Nahiri, the Lithomancer. How can I check that the Kor Soldier can be equipped by the chosen Equipment? In some weird cases, the Equipment might not be equipable (it turned into a creature for example). The only way I could find in the code was related to Auras and don't apply (checking the spell targets). So anything already exists?

EDIT: After some more looking around, I guess it doesn't exist. O-Naginata and Konda's Banner equipping restriction are implemented as EmptyEffect and checked only on its own Equip ability.
It should be possible to get the target from the equip ability of the equipment and check if it canTarget() the creature it should be attached to.

Re: Implementing cards

PostPosted: 10 Nov 2014, 22:05
by emerald000
LevelX wrote:
emerald000 wrote:I have a question about implementing Nahiri, the Lithomancer. How can I check that the Kor Soldier can be equipped by the chosen Equipment? In some weird cases, the Equipment might not be equipable (it turned into a creature for example). The only way I could find in the code was related to Auras and don't apply (checking the spell targets). So anything already exists?

EDIT: After some more looking around, I guess it doesn't exist. O-Naginata and Konda's Banner equipping restriction are implemented as EmptyEffect and checked only on its own Equip ability.
It should be possible to get the target from the equip ability of the equipment and check if it canTarget() the creature it should be attached to.
What if it lost its Equip ability? Gained another one? Also you should be able to attach through Shroud.

Re: Implementing cards

PostPosted: 11 Nov 2014, 00:09
by LevelX
emerald000 wrote:What if it lost its Equip ability?
Than you can get the target from the card if you need it to check if the Equipment can be attached to the created token.

emerald000 wrote:Gained another one?
You mean another EquipAbility?
Which card does such a thing?
Than the Equipment probably copies all abilites from another Equipment, so it would be correct.

emerald000 wrote:Also you should be able to attach through Shroud.
Copy the target and set notTarget = true before you check.

This will probably work in 99,9 % of all cases. So if we get aware of the 0,1 % case we can think how to solve it.

Re: Implementing cards

PostPosted: 11 Nov 2014, 02:09
by emerald000
Puresteel Paladin lets you gain a second EquipAbility.

Also, the main problem I see with the current setup is that the equip restrictions aren't checked (as far as I know) on SBAs. I don't know how Auras are working, but it should be possible to use something quite similar, as they are extremely similar once on the battlefield. There is no rule distinction of enchant vs equip. (If you manage to get an Enchantment Artifact - Equipment Aura, the attached permanent will get both bonuses and can be moved around with the Equip ability.)