typo fixed (related to #11068), added backup ability docs

This commit is contained in:
Oleg Agafonov 2023-08-31 06:06:47 +04:00
parent 22961162ad
commit 6768184e18
2 changed files with 30 additions and 1 deletions

View file

@ -35,7 +35,7 @@ public class CombatDamageByToughnessTargetEffect extends ContinuousEffectImpl {
public boolean apply(Game game, Ability source) {
Set<Permanent> set = targetPointer.getTargets(game, source).stream()
.map(game::getPermanent)
.filter(Objects::isNull)
.filter(Objects::nonNull)
.collect(Collectors.toSet());
FilterCreaturePermanent filter = new FilterCreaturePermanent();

View file

@ -18,6 +18,25 @@ import java.util.ArrayList;
import java.util.List;
/**
* 702.165. Backup
* <p>
* 702.165a Backup is a triggered ability. Backup N means When this creature enters the battlefield,
* put N +1/+1 counters on target creature. If thats another creature, it also gains the non-backup
* abilities of this creature printed below this one until end of turn. Cards with backup have one or more
* abilities printed after the backup ability. (Some cards with backup also have abilities printed before
* the backup ability.)
* <p>
* 702.165b If a permanent enters the battlefield as a copy of a permanent with a backup ability or a token
* is created that is a copy of that permanent, the order of abilities printed on it is maintained.
* <p>
* 702.165c Only abilities printed on the object with backup are granted by its backup ability. Any abilities
* gained by a permanent, whether due to a copy effect, an effect that grants an ability to a permanent, or an
* effect that creates a token with certain abilities, are not granted by a backup ability.
* <p>
* 702.165d The abilities that a backup ability grants are determined as the ability is put on the stack.
* They wont change if the permanent with backup loses any abilities after the ability is put on the stack
* but before it resolves.
*
* @author TheElk801
*/
public class BackupAbility extends EntersBattlefieldTriggeredAbility {
@ -65,13 +84,23 @@ public class BackupAbility extends EntersBattlefieldTriggeredAbility {
addAbility(ability, null, dontAddToCard);
}
/**
*
* @param ability
* @param watcher
* @param dontAddToCard use it on multiple instances of backups (example: Conclave Sledge-Captain)
*/
public void addAbility(Ability ability, Watcher watcher, boolean dontAddToCard) {
if (watcher != null) {
ability.addWatcher(watcher);
}
// parent card must have only 1 instance of ability
if (!dontAddToCard) {
card.addAbility(ability);
}
// target permanent can have multiple instances of ability
abilitiesToAdd.add(ability);
CardUtil.castStream(this.getEffects().stream(), BackupEffect.class)
.forEach(backupEffect -> backupEffect.addAbility(ability));