Debt of Loyalty
Moderators: North, BetaSteward, noxx, jeffwadsworth, JayDi, TheElk801, LevelX, CCGHQ Admins
Debt of Loyalty
by 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?
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;
}
}
- 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
by 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.
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
2 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 6 guests