It is currently 23 Apr 2024, 11:25
   
Text Size

Help implementing a card

Moderators: North, BetaSteward, noxx, jeffwadsworth, JayDi, TheElk801, LevelX, CCGHQ Admins

Re: Help implementing a card

Postby MarcoMarin » 09 Apr 2016, 16:59

Huge notes produced while mowing through the Antiquities set. :twisted:

Take any one card question I ask below to help me out and feel free to ignore the rest. [-o< I'll be glad to clarify any poorly written passage here :oops:

Some may like to know there were 3 requested cards amongst them: Artifact Possession, Tawnos's Coffin and Shapeshifter. Let me know if there is a bug in Tawnos' Coffin, 'cause I'll have to fix Oubliette as well.

| Open
Artifact Possession (hey! my first 'requested' card completed :)):
Non-fatal "bug": the effect: "DamageAttachedControllerEffect"'s static text says "creature's controller", although the code begs to differ so it won't cause any problems here.

Haunting Wind & Powerleech: the effect: DamageControllerEffect, will damage the source of the event (whatever triggered it) OR the controller of Haunting Winds itself?; Either that card or Powerleech (which is the opposite) will need further work depending on the answer.; Also, do weird game modes (e.g. 2 headed giant) assign anything other than "opponent" to any other player? There should probably be a constant for that (SourceController.OPPONENT), but I could not find any (except target, tho N/A).. no prob in this case, cause the event was conveniently available (not always the case I've found out other times =/)

Artifact Ward: is that any different from (today's) vanilla protection from artifact? Maybe the last part about "target of abilities" would have to be added?

btw, sometimes I have to create a duplicate ability inside the same set and Java complains. I'm renaming them with integers (2, 3, etc) to avoid breaking all cards if 1 is modified. Of course, the ideal would be to have a canonical ability to call from every one but.. until then, this seems the most future proof.

No Rest for the Wicked, its watcher says it only intercepts controller events, but I see nothing specific in the code. Is the Target there referring to this? It would seem like it refers to the card itself, the source which triggered the event. No? (also, the watcher scope is set to 'game' not 'player')

Urza's Miter: gotta test if sourceFirstTarget from the triggered Ability indeed corresponds to the sacrificed artifact. Otherwise the symptom will be it allowing you to gain life for sacrificed artifacts.

Jandor's Ring: Wow.. had to weave together a whole bunch of stuff for this one, not particularly complex any of them but numerous. Question: Should I create a new effect inside a oneShotEffect (much easier, I don't have the target card available at construction time), or should I extend the effect I want and set my own private variables to the values I need once they get available (inside apply)

Rocket Launcher (but also for above, Jandors Ring): should I used cleanup step Post, or At end of turn, or even end of turn post, or even beginning of the next turn? I know the card says "at the end", but in code I have to ensure there is no way to cast stuff in between because I'm resetting the counter that says a new turn begins so the watcher can keep track of the new turn without denying the last turn effect (if any). Im going with clean up post.

Goblin Artisans: The text seem to explicit exclude itself ("ANOTHER"), right? This would allow for untapping and "re-sacrificing" the same artifact. But it could also be a more loose meaning of "another". This was obviously meant to avoid the same player buying many cards for the price of 1(which I'm not even sure it does, it doesn't forbid the flip if you don't have an artifact tho it thought(ought?) it did? :)), but back then there wasn't many (any?) cards that could say, rename cards (into artisan), redirect targets (so an opponent could target the player's artifact before he does) or even outright add abilities so it could any targets.

Also, I'm taking "counter" here to mean sacrifice. And I'm doing it directly, should I call the sacrifice target effect instead? (I already handled the playerId so maybe not necessary?)

A bit more technical: I did not see a overridable init which means it would be very inefficient to have a "targettedByName"(or Id, etc) Predicate, since it would have to go over and over again through each and every card in the battlefield for every one else(every input).. with init, it can save the results of the initial filter (since it's "byName" predicate), which arguably can never have more than 8 cards on the BF in the worst case (and usually only 1: the very source of this, I'd bet).

Noticed something strange in the code: SourceOnBattlefieldControlUnchangedCondition, shouldnt the permanent controller be compared somewhere? Unless the ability that triggers the condition doesn't change controller as the source does (which sounds strange to me)

Reverse Polarity: Doesn't seem like the game has this history capability, which is probably why everything changed to "the next event like this that happens (e.g. prevent damage)", even though it would be extremely useful.. I know I said that before for Jandor's Ring, since I didn't know about watchers yet. (Hey, bumped the ARN completion to 92.31%)

This time doesn't seem to have a work around (ok, I think I saw a way to access the log :p) But, this would lessen the need for watchers (actually it is like having built-in watchers, from the start of each duel, as a clue ;)) or at least reducing somewhat the complexity of coding cards. Is there a better way to do this? I think I better wait for this feature?

Clockwork Avian: gen-cards.pl complained about "Set not found in known sets: Beatdown Box set"
A question also for Helix Pinnacle (from where I copied this effect), should there be another "true" after "inform players", so the counters are putOnCard? (that's the name of the flag).

Armageddon Clock: Just wondering.. new Counter(CounterType.DOOM.getName(), 1) is equivalent to CounterType.DOOM.createInstance())? Or is the enum different from the string? (returned by getName)

Tetravus: While researching for this card, noticed another weird thing on another card: "Living Artifact", it seems to be marking false for the isOptional flag, which the card says "you may" so should be true?

I've seen other abilities which had a flag to enable/disable multiple uses (say, at the same turn), I don't see it on BeginningOfUpkeepTriggeredAbility, does this mean it is enable for default? (I think it should) Or will I have to code an ability to take RemovedCountersForCostValue instead? If someone could test tetravus please, that'd be great.

I've created a brand new Ability: CantBeEnchantedAbility, the IDE warns me the IF statement (when I check if it's being target by enchantment/aura) is redundant tho, I can't see why. This happens with either conditions alone.

BTW, that new ability may be useful for spjspj, who's marked he's coding Guardian Beast from ARN? It just need to bring the "keep auras already there" from the protection ability. Guardian Beast now only needs a way to avoid artifacts taking control.

Technically, the rule doesn't say if "Tetravite" is the card's name or subtype, probably both and if only 1 is true/important then I'd say it's the latter. There are cards that change subtype, are there cards that change name? Just wondering..

Still on Tetravus, the ability to take counters off and create tokens, asks for a condition (namely, having 1+ counter). I don't see the need to ask if the player controls a token, to reverse this process, since I already filter for that specific token, it just wouldn't find any. Does this cause problems, and if not, why ask in the former case for that matter? Not having counters wouldn't just deny the player the ability anyway? I'd assume it's being used in the "canPay" function?

Tawnos's Coffin: btw, Fixed Oubliette (returns tapped), please have the requester of Tawnos' Coffin test it, because any problems there I gotta fix Oubliette as well. I think I see a bug already, about returning to the owner instead of the controller. But I'm also worried about the default behavior of the built-in Exile/ReturnFromExile Effects, as it concerns Counters.

Shapeshifter: Some heavy shenanigans with global, I mean, 'public' variables there :) need testing.. Speaking of which, in the card Mindblaze, its "apply" function never returns true. :-/

gen-card.pl Script got verbose all of a sudden? :) it repeats every name of every card twice, and before outputting "cards generated" it repeats everything again...
Last edited by MarcoMarin on 09 Apr 2016, 17:25, edited 2 times in total.
MarcoMarin
 
Posts: 32
Joined: 20 Mar 2016, 07:49
Has thanked: 16 times
Been thanked: 2 times

Re: Help implementing a card

Postby escplan9 » 09 Apr 2016, 17:10

gen-card.pl Script got verbose all of a sudden? :) it repeats every name of every card twice, and before outputting "cards generated" it repeats everything again...
See this commit by spjspj: https://github.com/magefree/mage/commit ... 5ee1c4dedd

Looks like he did it so he can just copy the gvim command afterwards to edit the card there. I also find it a little annoying to see the extra lines, but not a big deal.
escplan9
 
Posts: 257
Joined: 10 Aug 2015, 22:38
Has thanked: 26 times
Been thanked: 40 times

Re: Help implementing a card

Postby Doctor Weird » 09 Apr 2016, 18:29

I'm just going to throw some answers to stuff I know, everything code-related I'm going to ignore because that should be answered by devs.

MarcoMarin wrote:Artifact Ward: is that any different from (today's) vanilla protection from artifact? Maybe the last part about "target of abilities" would have to be added?
Yes, if it was the same as Protection the current oracle text would just have it give Protection from Artifacts. The key differences are that Protection does mainly four things:
Prevent all that damage from mentioned sources.
Make it so the protected card can't be equipped or enchanted by things of that kind.
Can't be blocked by creatures of said type/color/whatever it refers to.
Can't be the target of whatever it has protection from.
Meanwhile, Artifact Ward doesn't cover a few possibilities that protection does. For example, protection from artifacts would cause any equipment artifacts attached to its creature to fall, but Artifact Ward does not do that. Likewise, protection makes it so auras already on that creature that gains protection from them to be dropped, but the Ward does not. But there are no artifact auras, right? Well, yes, but cards like Mycosynth Lattice and Memnarch, just to name a couple, can make auras become artifacts as well.

So no, Artifact Ward does not give Protection from Artifacts.

MarcoMarin wrote:Rocket Launcher (ut also for above, Jandors Ring): should I used cleanup step Post, or At end of turn, or even end of turn post, or even beginning of the next turn? I know the card says "at the end", but in code I have to ensure there is no way to cast stuff in between because I'm resetting the counter that says a new turn begins so the watcher can keep track of the new turn without denying the last turn effect (if any). Im going with clean up post.
Rocket Launcher says "at the beginning of the next end step" which is not the absolute last thing of a turn and things can still be played after it. I'm going to do some boring rule quoting to better explain it:

513. End Step | Open
513.1. First, all abilities that trigger “at the beginning of the end step” or “at the beginning of the next end step” go on the stack. (See rule 603, “Handling Triggered Abilities.”)

513.1a Previously, abilities that trigger at the beginning of the end step were printed with the trigger condition “at end of turn.” Cards that were printed with that text have received errata in the Oracle card reference to say “at the beginning of the end step” or “at the beginning of the next end step.”

513.2. Second, the active player gets priority. Players may cast spells and activate abilities.
513.3. If a permanent with an ability that triggers “at the beginning of the end step” enters the battlefield during this step, that ability won’t trigger until the next turn’s end step. Likewise, if a delayed triggered ability that triggers “at the beginning of the next end step” is created during this step, that ability won’t trigger until the next turn’s end step. In other words, the step doesn’t “back up” so those abilities can go on the stack. This rule applies only to triggered abilities; it doesn’t apply to continuous effects whose durations say “until end of turn” or “this turn.” (See rule 514, “Cleanup Step.”)
The cleanup step only happens after this step and is a completely different step of its own, the Launcher's ability should be already done with by that point. You want its ability to trigger as soon as the End Step starts (which is the step before cleanup), together with any other similar abilities, and if there's more than one then the controller(s) of them chooses the order they go on the stack and then players get priority to play spells and abilities, so, as you can see, there's no way it can be the absolutely last thing to happen or be played on a turn. Try maybe looking at other cards with "at the beginning of the end step" effects if you still need to get a reference, there's plenty, like for example Ball Lightning. But remember that it's "destroy" and not "sacrifice" in the Launcher's case.

MarcoMarin wrote:Goblin Artisans
You've gotta read the current oracle text of the card, you're really getting a whole lot of stuff wrong (place your mouse cursor over the name on the above quote, the text you see is the current one).

For starters, the "another" means other cards with that name, yes, so it itself can target the same artifact spell again while the first ability is on the stack if you find a way to untap it, for example, because it only makes sure other Artisans can't pick at that spell, not itself.

MarcoMarin wrote:it doesn't forbid the flip if you don't have an artifact
Yes, it kind of does. Read the text, it says "target artifact spell you control" so the ability requires a valid target in order to be called, if there's no artifact spell controlled by you currently on the stack you do not have a valid target and can't activate it.

MarcoMarin wrote:Also, I'm taking "counter" here to mean sacrifice.
Nope, not at all. Sacrificing is for permanents, we're talking about a spell on the stack, which is something that didn't "form" on the battlefield yet, you can't sacrifice spells. "Counter" is what old Interrupts used to do (think Counterspell or Force of Will) and is simply to take a spell from the stack and put it on the graveyard without doing whatever it was meant to do. Basically, to say "no" to whatever was supposed to happen once that spell resolved, which in this case means to negate the artifact from even entering play in the first place.

MarcoMarin wrote:which arguably can never have more than 8 cards on the BF in the worst case (and usually only 1: the very source of this, I'd bet).
I take it you're thinking of a 1 on 1 game and that players can't have more than 4 copies of a card in their deck each. You're forgetting many things, such as multiplayer games, Clone effects that can cause countless copies of anything to be in play, and even things that straight up break the "4 copies" rule, like Relentless Rats.

MarcoMarin wrote:Technically, the rule doesn't say if "Tetravite" is the card's name or subtype, probably both and if only 1 is true/important then I'd say it's the latter.
If the effect that creates a token does not say what it's named then its name will be its subtype, in this case, "Tetravite" is its name as well as its subtype.

If it serves you of any help, try looking at the code for Pentavus and Triskelavus for references, since they're somewhat similar and inspired by the original.

MarcoMarin wrote:Tawnos's Coffin
While it doesn't do counters, Flickerform is a card that might give you some help if you look at its code as far as everything else goes.
Doctor Weird
 
Posts: 180
Joined: 25 May 2015, 01:33
Has thanked: 7 times
Been thanked: 52 times

Re: Help implementing a card

Postby escplan9 » 10 Apr 2016, 15:35

Working on the card Earthbind and have it correctly detecting flying and dealing 2 the creature with flying. But the last part of it, where the creature then loses flying, isn't working right. When I check in the debugger for enchanted.getAbilities().remove(FlyingInstance.getInstance()) it returned true, and I see enchanted.getAbilities() no longer listing flying, however the card tooltip for Air Elemental (etc) still shows flying afterwards.

Code below:

Code: Select all
package mage.sets.revisededition;

import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.keyword.EnchantAbility;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.TargetPermanent;
import mage.target.common.TargetCreaturePermanent;

/**
 *
 * @author escplan9 (Derek Monturo - dmontur1 at gmail dot com)
 */
public class Earthbind extends CardImpl {

    public Earthbind(UUID ownerId) {
        super(ownerId, 146, "Earthbind", Rarity.COMMON, new CardType[]{CardType.ENCHANTMENT}, "{R}");
        this.expansionSetCode = "3ED";
        this.subtype.add("Aura");

        // Enchant creature
        TargetPermanent auraTarget = new TargetCreaturePermanent();
        this.getSpellAbility().addTarget(auraTarget);
        this.getSpellAbility().addEffect(new AttachEffect(Outcome.LoseAbility));
        Ability ability = new EnchantAbility(auraTarget.getTargetName());
        this.addAbility(ability);
       
        // When Earthbind enters the battlefield, if enchanted creature has flying, Earthbind deals 2 damage to that creature and Earthbind gains "Enchanted creature loses flying."
        this.addAbility(new EntersBattlefieldTriggeredAbility(new EarthbindEffect()));
    }

    public Earthbind(final Earthbind card) {
        super(card);
    }

    @Override
    public Earthbind copy() {
        return new Earthbind(this);
    }
}

class EarthbindEffect extends OneShotEffect {

    public EarthbindEffect() {
        super(Outcome.Damage);
        staticText = "if enchanted creature has flying, {this} deals 2 damage to that creature and Earthbind gains 'Enchanted creature loses flying.'";
    }

    public EarthbindEffect(final EarthbindEffect effect) {
        super(effect);
    }

    @Override
    public EarthbindEffect copy() {
        return new EarthbindEffect(this);
    }

    @Override
    public boolean apply(Game game, Ability source) {
        Permanent attachment = game.getPermanent(source.getSourceId());
        if (attachment != null && attachment.getAttachedTo() != null) {           
            Permanent enchanted = game.getPermanent(attachment.getAttachedTo());
            if (enchanted != null) {
                if (enchanted.getAbilities().contains(FlyingAbility.getInstance())) {               
                    enchanted.damage(2, source.getSourceId(), game, false, true);
                    enchanted.getAbilities().remove(FlyingAbility.getInstance());
                }
                return true;
            }
        }

        return false;
    }
}

escplan9
 
Posts: 257
Joined: 10 Aug 2015, 22:38
Has thanked: 26 times
Been thanked: 40 times

Re: Help implementing a card

Postby MarcoMarin » 10 Apr 2016, 20:51

> I'm just going to throw some answers to stuff I know,
Thanks, Dr. Weird :)

> Ward doesn't cover a few possibilities that protection does.
Hmm.. I think the original protection effect has an option to keep the auras, not sure about attached artifacts. Will look into it. [indeed, there is a convenient: .setRemovesAuras(false)]

> Rocket Launcher says "at the beginning of the next end step"
Sorry, I should've been clearer (but I'm sure your clarification will be useful soon). The "destroy at end of turn" is fine. The issue here is the having control of rocket launcher since the beginning.. I have to pick a step to begin "watching" from, the questions above refer to effects that could take control of Rocket Launcher, or otherwise mess this up. I think I got the '1st turn on bf' figured out, since it is not "since the beginning", BUT what if it is ressurrected from the graveyard or something (and not cast from hand, during main phase), which could probably be cast any time as well..

> the text you see is the current one).
heh, I was thinking that was the old one.. I was pretty sure they didn't yet had their "mtg language" together (part of that "crazyness" we discussed about :)) and were referring to cards already on the bf as spells, "discard" loosely, etc. Now I saw the old text and indeed they specifically limit to when you cast an artifact AND "more than one artisan"..

> For starters, the "another" means other cards with that name, yes,
at least got that one right, probably the only one hehehe.. thx, I'll mark that one as bugged :)

> I take it you're thinking of a 1 on 1 game and that players can't have more than
hehehe, yes, you're right.. That makes the argument for a "init" there even stronger, so this scanning doesn't have to be repeated over and over. But that's the worst case, yeah.. I believe the usual case is "finally got that card, gotta use it".. not much room for probablity to get more and more of the same on the same game :), save for combos maybe, etc..

thanks.. will do. The way I did will probably be fine, except maybe for some edge cases, let's see.

> While it doesn't do counters, Flickerform is a card
Thanks, it adds to my belief that the default behavior keeps auras already, no need for further work there. But yea, not sure about counters tho..
MarcoMarin
 
Posts: 32
Joined: 20 Mar 2016, 07:49
Has thanked: 16 times
Been thanked: 2 times

Re: Help implementing a card

Postby Doctor Weird » 10 Apr 2016, 22:16

MarcoMarin wrote:Hmm.. I think the original protection effect has an option to keep the auras, not sure about attached artifacts. Will look into it. [indeed, there is a convenient: .setRemovesAuras(false)]
That probably exists because of Spectra Ward. Still, I'd refrain from giving any kind of actual "Protection" ability with Artifact Ward because that is not how the card is meant to work and there could always be consequences to making a card do something that isn't exactly what it should.

MarcoMarin wrote:Sorry, I should've been clearer (but I'm sure your clarification will be useful soon). The "destroy at end of turn" is fine. The issue here is the having control of rocket launcher since the beginning.. I have to pick a step to begin "watching" from, the questions above refer to effects that could take control of Rocket Launcher, or otherwise mess this up. I think I got the '1st turn on bf' figured out, since it is not "since the beginning", BUT what if it is ressurrected from the graveyard or something (and not cast from hand, during main phase), which could probably be cast any time as well..
My bad. Try looking up cards with the Echo ability (e.g.: Goblin Patrol), that's the closest you will find to that effect already implemented. But if I had to guess I'd say the most practical way to do it would be to set some kind of "flag" when the Launcher comes into play, set to false, and then, when your next untap step comes around it switches to true (you have to control it since the beginning of your turn, so it has to already be on your side of the table by the time you're untapping your permanents). At the same time, it would switch to false whenever it switched controller. As for everything else, let's see:

If it dies and returns to play from the graveyard it will be a new object that should have no recollection of what it was before, so it is only now coming under your control.
If it is exiled and returns, same thing applies, it's a new fresh Launcher coming into play.
If it goes back to hand/library and is recast, likewise, it's a new card, no memory of what it was before.
Phasing shouldn't matter because, if phasing is properly implemented, the card never leaves your control or the battlefield when phasing out.
And as I said, if it switches controllers, while it's still the same object (it never leaves the battlefield, just switches sides), it can no longer be activated that turn, even if you regain control right after, because it was not under your control continuously since the start of your most recent turn.

So yeah, basically a "false" state when it EtB that switches to "true" on your next untap step and that also switches to "false" when switching control should cover it, I would think. Either that or whatever equivalent is usually used in Java/XMage. I could be forgetting some possible scenario, though, in which case if you still have doubts just remind of what I missed. :D
Doctor Weird
 
Posts: 180
Joined: 25 May 2015, 01:33
Has thanked: 7 times
Been thanked: 52 times

Re: Help implementing a card

Postby emerald000 » 11 Apr 2016, 22:23

escplan9 wrote:Working on the card Earthbind and have it correctly detecting flying and dealing 2 the creature with flying. But the last part of it, where the creature then loses flying, isn't working right. When I check in the debugger for enchanted.getAbilities().remove(FlyingInstance.getInstance()) it returned true, and I see enchanted.getAbilities() no longer listing flying, however the card tooltip for Air Elemental (etc) still shows flying afterwards.
This is currently a one-shot effect, so it loses Flying for a fraction of second then regains it right after. You'll have to add a ContinuousEffect to that creature that makes it lose Flying. LoseAbilityAttachedEffect is probably what you are looking for.
User avatar
emerald000
 
Posts: 92
Joined: 07 Jul 2014, 16:55
Has thanked: 1 time
Been thanked: 9 times

Re: Help implementing a card

Postby escplan9 » 11 Apr 2016, 23:58

emerald000 wrote:
escplan9 wrote:Working on the card Earthbind and have it correctly detecting flying and dealing 2 the creature with flying. But the last part of it, where the creature then loses flying, isn't working right. When I check in the debugger for enchanted.getAbilities().remove(FlyingInstance.getInstance()) it returned true, and I see enchanted.getAbilities() no longer listing flying, however the card tooltip for Air Elemental (etc) still shows flying afterwards.
This is currently a one-shot effect, so it loses Flying for a fraction of second then regains it right after. You'll have to add a ContinuousEffect to that creature that makes it lose Flying. LoseAbilityAttachedEffect is probably what you are looking for.
#-o of course! thanks! Was driving myself crazy with that and just gave up on it - spent like 2 hours trying to figure out something so simple. :lol:
escplan9
 
Posts: 257
Joined: 10 Aug 2015, 22:38
Has thanked: 26 times
Been thanked: 40 times

Re: Help implementing a card

Postby MarcoMarin » 12 Apr 2016, 15:59

I need a bit of help. Trying to fix Oubliette, exiling works but returning doesn't.

I'm adding a triggered ability (leaves the BattleField) to the Permanent (oubliette) inside its 1'st effect (which is triggered by enterTheBattleField)

I can see (debugger) it DOES get registered as an Ability in the card but it isn't triggered.

Flickerform registered directly on the game object, but I can't do that here because it isn't a "at Phase" trigger but depends on the permanent leaving.
MarcoMarin
 
Posts: 32
Joined: 20 Mar 2016, 07:49
Has thanked: 16 times
Been thanked: 2 times

Re: Help implementing a card

Postby Doctor Weird » 12 Apr 2016, 16:52

Look up how Oblivion Ring works, for example, and it might help you learn how it's done, unless the problem is somewhere else, of course. Just saying what I would do in your position, an actual dev can just give you the direct explanation of what to use.
Doctor Weird
 
Posts: 180
Joined: 25 May 2015, 01:33
Has thanked: 7 times
Been thanked: 52 times

Re: Help implementing a card

Postby MarcoMarin » 12 Apr 2016, 17:49

Took a look but the problem we have here is that those are "vanilla" exile effects, so they have the benefit of using the built-in functions.

Flickerform has to keep track of Auras to get them back, Oubliette has an even harder problem of keeping track of counters which are not permanents with ids etc, but that's still after this problem. :S

If I could do on the constructor like Oblivion Ring, that would be great, but I have to pass the exiled creature/aura/etc to the effect, just like Flickerform does.

Maybe there is something else this 'on contructor' method do to "activate" the ability, but Flickerform only adds to the game object and is done. I try to do the same to the oubliette permanent, it does register as an ability, but when I disenchant oubliette, nothing happens. :cry:
MarcoMarin
 
Posts: 32
Joined: 20 Mar 2016, 07:49
Has thanked: 16 times
Been thanked: 2 times

Re: Help implementing a card

Postby Doctor Weird » 12 Apr 2016, 18:38

Probably for the best if you just post your code and let the guys who actually know how it's done have a look and reply with an actually useful suggestion of what you should do, instead of chasing after my guesses.
Doctor Weird
 
Posts: 180
Joined: 25 May 2015, 01:33
Has thanked: 7 times
Been thanked: 52 times

Re: Help implementing a card

Postby escplan9 » 12 Apr 2016, 19:05

Yes, please post the full code you are working with.
escplan9
 
Posts: 257
Joined: 10 Aug 2015, 22:38
Has thanked: 26 times
Been thanked: 40 times

Re: Help implementing a card

Postby MarcoMarin » 12 Apr 2016, 19:59

ok, I'll post the apply method of the effect which is working (triggered by enter the BF).

Here is the part that works: (i.e. exiling shows auras and the target on the little window)
| Open
Code: Select all
@Override
    public boolean apply(Game game, Ability source) {
        // Exile enchanted creature and all Auras attached to it.
        Permanent enchantment = game.getPermanent(source.getSourceId());
        if (enchantment == null) {
            enchantment = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
        }       
        UUID targetId=source.getFirstTarget();
       
        if (targetId==null) return false; // if previous scan somehow failed, simply quit
       
        if (enchantment != null) { //back to code (mostly) copied from Flickerform
            Permanent enchantedCreature = game.getPermanent(targetId);
            if (enchantedCreature != null) {
                UUID exileZoneId = UUID.randomUUID();
                enchantedCreature.moveToExile(exileZoneId, enchantment.getName(), source.getSourceId(), game);
                for (UUID attachementId : enchantedCreature.getAttachments()) {
                    Permanent attachment = game.getPermanent(attachementId);
                    if (attachment != null && filter.match(attachment, game)) {
                        attachment.moveToExile(exileZoneId, enchantment.getName(), source.getSourceId(), game);
                    }
                }
Here is the part that manages to register the ability, but it never gets called(triggered) later:
| Open
Code: Select all
if (!(enchantedCreature instanceof Token)) {
               
                    // If you do, return the other cards exiled this way to the battlefield under their owners' control attached to that creature
                    LeavesBattlefieldTriggeredAbility triggeredAbility = new LeavesBattlefieldTriggeredAbility(
                            new OublietteReturnEffect(enchantedCreature.getId(), exileZoneId, enchantment), false);
                    enchantment.addAbility(triggeredAbility, source.getSourceId(), game);                   
                }
                return true;
            }
        }

        return false;
    }
}
MarcoMarin
 
Posts: 32
Joined: 20 Mar 2016, 07:49
Has thanked: 16 times
Been thanked: 2 times

Re: Help implementing a card

Postby escplan9 » 12 Apr 2016, 21:22

No, really, the full code for the card.
escplan9
 
Posts: 257
Joined: 10 Aug 2015, 22:38
Has thanked: 26 times
Been thanked: 40 times

PreviousNext

Return to Developers Talk

Who is online

Users browsing this forum: No registered users and 10 guests


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 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 10 guests

Login Form