It is currently 21 Nov 2019, 22:12
   
Text Size

Debt of Loyalty

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

Debt of Loyalty

Postby CloudenFog » 10 Jul 2016, 18:22

Hi, I'm trying to implement Debt of Loyalty

I thought the best way to implement its effect would be to subclass RegenerateTargetEffect. The regeneration still works in my subclass but the take control part doesn't seem to be functional. Is there something obvious that I'm missing?

Code: Select all
class DebtOfLoyaltyEffect extends RegenerateTargetEffect {
        public DebtOfLoyaltyEffect ( ) {
            super();
            this.staticText = "Regenerate target creature. You gain control of that creature if it regenerates this way.";
        }

        public DebtOfLoyaltyEffect(final DebtOfLoyaltyEffect effect) {
            super(effect);
        }
       
        @Override
        public boolean apply(Game game, Ability source) {
            Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source));
            if (super.apply(game, source) && permanent != null) {
                GainControlTargetEffect effect = new GainControlTargetEffect(Duration.EndOfGame);
                effect.setTargetPointer(targetPointer);
                game.addEffect(effect, source);
                return true;
            }
            return false;
        }
    }
If it helps the rest of the Debt of Loyalty class is here:
More Code | Open
Code: Select all
public DebtOfLoyalty(UUID ownerId) {
        super(ownerId, 127, "Debt of Loyalty", Rarity.RARE, new CardType[]{CardType.INSTANT}, "{1}{W}{W}");
        this.expansionSetCode = "WTH";

        // Regenerate target creature. You gain control of that creature if it regenerates this way.
        this.getSpellAbility().addTarget(new TargetCreaturePermanent());
        this.getSpellAbility().addEffect(new DebtOfLoyaltyEffect());
    }

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

    @Override
    public DebtOfLoyalty copy() {
        return new DebtOfLoyalty(this);
    }
CloudenFog
 
Posts: 3
Joined: 09 Jul 2016, 17:31
Has thanked: 0 time
Been thanked: 0 time

Re: Debt of Loyalty

Postby CloudenFog » 10 Jul 2016, 22:24

Alright, after a lot of debugging and creating a test file I figured out what was wrong. I forgot to override the copy method in DebtOfLoyaltyEffect.

Hopefully my mistake will be helpful to others in the future.
CloudenFog
 
Posts: 3
Joined: 09 Jul 2016, 17:31
Has thanked: 0 time
Been thanked: 0 time


Return to Developers Talk

Who is online

Users browsing this forum: No registered users and 0 guests


Who is online

In total there are 0 users online :: 0 registered, 0 hidden and 0 guests (based on users active over the past 10 minutes)
Most users ever online was 553 on 18 Nov 2019, 23:05

Users browsing this forum: No registered users and 0 guests

Login Form