Page 1 of 1

Debt of Loyalty

PostPosted: 10 Jul 2016, 18:22
by CloudenFog
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 ( ) {
            this.staticText = "Regenerate target creature. You gain control of that creature if it regenerates this way.";

        public DebtOfLoyaltyEffect(final DebtOfLoyaltyEffect effect) {
        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);
                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) {

    public DebtOfLoyalty copy() {
        return new DebtOfLoyalty(this);

Re: Debt of Loyalty

PostPosted: 10 Jul 2016, 22:24
by CloudenFog
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.