forked from External/mage
some changes to how sagas are built
This commit is contained in:
parent
bb31939079
commit
dd4b1684c8
6 changed files with 96 additions and 153 deletions
|
|
@ -1,7 +1,6 @@
|
|||
package mage.abilities.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.TriggeredAbility;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
|
|
@ -19,11 +18,10 @@ import mage.game.stack.StackAbility;
|
|||
import mage.game.stack.StackObject;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.target.Targets;
|
||||
import mage.target.targetadjustment.TargetAdjuster;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* @author LevelX2
|
||||
|
|
@ -89,40 +87,40 @@ public class SagaAbility extends SimpleStaticAbility {
|
|||
addChapterEffect(card, fromChapter, toChapter, effect, target, false);
|
||||
}
|
||||
|
||||
public void addChapterEffect(Card card, SagaChapter fromChapter, SagaChapter toChapter, Effect effect, Target target, boolean optional) {
|
||||
addChapterEffect(card, fromChapter, toChapter, new Effects(effect), new Targets(target), optional, null);
|
||||
}
|
||||
|
||||
public void addChapterEffect(Card card, SagaChapter fromChapter, SagaChapter toChapter, Effects effects, Target target) {
|
||||
addChapterEffect(card, fromChapter, toChapter, effects, new Targets(target));
|
||||
addChapterEffect(card, fromChapter, toChapter, effects, target, false);
|
||||
}
|
||||
|
||||
public void addChapterEffect(Card card, SagaChapter fromChapter, SagaChapter toChapter, Effects effects, Targets targets) {
|
||||
addChapterEffect(card, fromChapter, toChapter, effects, targets, false, null);
|
||||
public void addChapterEffect(Card card, SagaChapter fromChapter, SagaChapter toChapter, Effect effect, Target target, boolean optional) {
|
||||
addChapterEffect(card, fromChapter, toChapter, new Effects(effect), target, optional);
|
||||
}
|
||||
|
||||
public void addChapterEffect(Card card, SagaChapter fromChapter, SagaChapter toChapter, Effects effects, Targets targets, boolean optional, TargetAdjuster targetAdjuster, Mode... modes) {
|
||||
for (int i = fromChapter.getNumber(); i <= toChapter.getNumber(); i++) {
|
||||
ChapterTriggeredAbility ability = new ChapterTriggeredAbility(null, SagaChapter.getChapter(i), toChapter, optional, readAhead);
|
||||
public void addChapterEffect(Card card, SagaChapter fromChapter, SagaChapter toChapter, Consumer<TriggeredAbility> applier) {
|
||||
addChapterEffect(card, fromChapter, toChapter, false, applier);
|
||||
}
|
||||
|
||||
public void addChapterEffect(Card card, SagaChapter fromChapter, SagaChapter toChapter, Effects effects, Target target, boolean optional) {
|
||||
addChapterEffect(card, fromChapter, toChapter, optional, ability -> {
|
||||
for (Effect effect : effects) {
|
||||
if (effect != null) {
|
||||
ability.addEffect(effect.copy());
|
||||
}
|
||||
}
|
||||
for (Target target : targets) {
|
||||
if (target != null) {
|
||||
ability.addTarget(target.copy());
|
||||
}
|
||||
}
|
||||
for (Mode mode : modes) {
|
||||
ability.addMode(mode.copy());
|
||||
if (target != null) {
|
||||
ability.addTarget(target.copy());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void addChapterEffect(Card card, SagaChapter fromChapter, SagaChapter toChapter, boolean optional, Consumer<TriggeredAbility> applier) {
|
||||
for (int i = fromChapter.getNumber(); i <= toChapter.getNumber(); i++) {
|
||||
ChapterTriggeredAbility ability = new ChapterTriggeredAbility(
|
||||
SagaChapter.getChapter(i), toChapter, optional, readAhead
|
||||
);
|
||||
applier.accept(ability);
|
||||
if (i > fromChapter.getNumber()) {
|
||||
ability.setRuleVisible(false);
|
||||
}
|
||||
if (targetAdjuster != null) {
|
||||
ability.setTargetAdjuster(targetAdjuster);
|
||||
}
|
||||
card.addAbility(ability);
|
||||
}
|
||||
}
|
||||
|
|
@ -210,14 +208,14 @@ class ChapterTriggeredAbility extends TriggeredAbilityImpl {
|
|||
private final SagaChapter chapterFrom, chapterTo;
|
||||
private final boolean readAhead;
|
||||
|
||||
public ChapterTriggeredAbility(Effect effect, SagaChapter chapterFrom, SagaChapter chapterTo, boolean optional, boolean readAhead) {
|
||||
super(Zone.ALL, effect, optional);
|
||||
ChapterTriggeredAbility(SagaChapter chapterFrom, SagaChapter chapterTo, boolean optional, boolean readAhead) {
|
||||
super(Zone.ALL, null, optional);
|
||||
this.chapterFrom = chapterFrom;
|
||||
this.chapterTo = chapterTo;
|
||||
this.readAhead = readAhead;
|
||||
}
|
||||
|
||||
public ChapterTriggeredAbility(final ChapterTriggeredAbility ability) {
|
||||
private ChapterTriggeredAbility(final ChapterTriggeredAbility ability) {
|
||||
super(ability);
|
||||
this.chapterFrom = ability.chapterFrom;
|
||||
this.chapterTo = ability.chapterTo;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue