It is currently 15 Dec 2017, 13:52
   
Text Size

beginning of upkeep triggered ability that has two effect...

Moderators: noxx, Aurum, fireshoes, jeffwadsworth, TheElk801, BetaSteward, LevelX, North, escplan9, CCGHQ Admins

beginning of upkeep triggered ability that has two effect...

Postby MTGfan » 27 Sep 2017, 23:15

I'm trying to code Power Leak. My understanding of this card is that it always does damage in the range of 0 to 2 (or more if it is possible to mod the max?) depending on the target cards controller amount spent from 2 or more to 0 to prevent said damage. My first thought is to do this:

this.addAbility(new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new DoIfCostPaid(new DamageAttachedControllerEffect(new IntMinusDynamicValue(2, new ManacostVariableValue())), new VariableManaCost(), "", false), TargetController.CONTROLLER_ATTACHED_TO, false));

However assuming all of that works correctly to assign the correct amount of damage to the target cards controller it doesn't account for the possibility that damage can't be prevented due to some other card effect. Which is the dilemma because the BeginningOfUpkeepTriggeredAbility needs to both do the damage and prevent the damage so that it correctly abides prevention rules and any other applicable rules. But it can only have one effect but two are needed.
MTGfan
 
Posts: 28
Joined: 25 Oct 2016, 03:39
Has thanked: 1 time
Been thanked: 0 time

Re: beginning of upkeep triggered ability that has two effec

Postby TheElk801 » 28 Sep 2017, 15:42

You should probably do the whole thing as a single OneShotEffect. Here's the template I use for when I do one:

Code: Select all
class className extends OneShotEffect {
   
    className() {
        super(Outcome.Benefit);
        this.staticText = "effect text goes here";
    }
   
    className(final className effect) {
        super(effect);
    }
   
    @Override
    public className copy() {
        return new className(this);
    }
   
    @Override
    public boolean apply(Game game, Ability source) {
//      this is where the effect goes
        return true;
    }
}
Also you can always chat with the devs in our Gitter.
TheElk801
 
Posts: 35
Joined: 24 Aug 2017, 15:42
Has thanked: 0 time
Been thanked: 5 times

Re: beginning of upkeep triggered ability that has two effec

Postby MTGfan » 30 Sep 2017, 23:33

Ah so I should encompass both apply damage and prevent damage in a single OneShotEffect such as your example within the DoIfCostPaid. I should be able to handle that.
MTGfan
 
Posts: 28
Joined: 25 Oct 2016, 03:39
Has thanked: 1 time
Been thanked: 0 time

Re: beginning of upkeep triggered ability that has two effec

Postby MTGfan » 01 Oct 2017, 03:38

I can't find an example of calling a prevention effect within an one shot effect. So I am still stuck as to how to do both.
MTGfan
 
Posts: 28
Joined: 25 Oct 2016, 03:39
Has thanked: 1 time
Been thanked: 0 time

Re: beginning of upkeep triggered ability that has two effec

Postby LevelX » 02 Oct 2017, 20:46

I guess you have to add the prevention effect (as ContinuousEffect) first (checking that it's damage from that Power Leak source). After that do the damage to the controller of the enchanted enchantment.

So in the one shot effect of Power Leak the following things happen:
1) Ask controller for mana payment amount
2) Add the prevention effect to the game
3) Do the damage
User avatar
LevelX
DEVELOPER
 
Posts: 1611
Joined: 08 Dec 2011, 15:08
Has thanked: 173 times
Been thanked: 348 times

Re: beginning of upkeep triggered ability that has two effec

Postby MTGfan » 10 Oct 2017, 02:32

I have a couple bugs to work out with the card so I think I have it mostly figured out.
MTGfan
 
Posts: 28
Joined: 25 Oct 2016, 03:39
Has thanked: 1 time
Been thanked: 0 time


Return to Developers Talk

Who is online

Users browsing this forum: No registered users and 2 guests


Who is online

In total there are 2 users online :: 0 registered, 0 hidden and 2 guests (based on users active over the past 10 minutes)
Most users ever online was 279 on 11 Jul 2013, 22:03

Users browsing this forum: No registered users and 2 guests

Login Form