Return value of effect.apply()
Moderators: North, BetaSteward, noxx, jeffwadsworth, JayDi, TheElk801, LevelX, CCGHQ Admins
Return value of effect.apply()
by LevelX » 15 Jul 2014, 11:11
When exactly should the
I would say only in a situation where something happened what couldn't happen normally if no bug is involved.
Example for false:
1) game.getPlayer(ability.getControllerId) gives back null;
2) MageObject sourceObject = game.getObject(source.getSourceId()) gives back null;
Examples for true:
3) All works as intended (that's clear).
2) Counterspell tries to counter a spell but was replaced.
3) Add a counter to source but source is bounced back to hand before the effect resolves.
But that's only my opinion.
Any other opinions or ideas how to handle this best?
method of the effect give back false?public boolean apply(Game game, Ability source)
I would say only in a situation where something happened what couldn't happen normally if no bug is involved.
Example for false:
1) game.getPlayer(ability.getControllerId) gives back null;
2) MageObject sourceObject = game.getObject(source.getSourceId()) gives back null;
Examples for true:
3) All works as intended (that's clear).
2) Counterspell tries to counter a spell but was replaced.
3) Add a counter to source but source is bounced back to hand before the effect resolves.
But that's only my opinion.
Any other opinions or ideas how to handle this best?
-
LevelX - DEVELOPER
- Posts: 1677
- Joined: 08 Dec 2011, 15:08
- Has thanked: 174 times
- Been thanked: 374 times
Re: Return value of effect.apply()
by LevelX » 14 Aug 2014, 07:56
Any opinions on that topic?
Here an practical example:
1) You can have no Snow permanents on the battlefield.
2) The permanent can have left the battlefield since the spell went to stack.
So the questions stays, what does the return state mean for the apply method?
Here an practical example:
- Code: Select all
class SkredDamageEffect extends OneShotEffect {
private static final FilterControlledPermanent filter = new FilterControlledPermanent("equal to the number of snow permanents you control.");
static {
filter.add(new SupertypePredicate("Snow"));
}
public SkredDamageEffect() {
super(Outcome.Damage);
this.staticText = "{this} deals damage to target creature equal to the number of snow permanents you control.";
}
public SkredDamageEffect(final SkredDamageEffect effect) {
super(effect);
}
@Override
public SkredDamageEffect copy() {
return new SkredDamageEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
int amount = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game);
Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source));
if(amount > 0) {
if (permanent != null) {
permanent.damage(amount, source.getSourceId(), game, false, true);
return true;
}
}
return false;
}
}
- Code: Select all
@Override
public boolean apply(Game game, Ability source) {
int amount = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game);
Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source));
if(amount > 0 && permanent != null) {
permanent.damage(amount, source.getSourceId(), game, false, true);
}
return true;
}
1) You can have no Snow permanents on the battlefield.
2) The permanent can have left the battlefield since the spell went to stack.
So the questions stays, what does the return state mean for the apply method?
-
LevelX - DEVELOPER
- Posts: 1677
- Joined: 08 Dec 2011, 15:08
- Has thanked: 174 times
- Been thanked: 374 times
2 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 2 guests