Add Approach of the Second Sun

Add BranchEffect
This commit is contained in:
Sol
2017-04-30 20:27:15 +00:00
parent e39949895d
commit 8ccee98f5e
7 changed files with 61 additions and 1 deletions

2
.gitattributes vendored
View File

@@ -350,6 +350,7 @@ forge-game/src/main/java/forge/game/ability/effects/BecomeMonarchEffect.java -te
forge-game/src/main/java/forge/game/ability/effects/BecomesBlockedEffect.java -text
forge-game/src/main/java/forge/game/ability/effects/BidLifeEffect.java -text
forge-game/src/main/java/forge/game/ability/effects/BondEffect.java -text
forge-game/src/main/java/forge/game/ability/effects/BranchEffect.java -text
forge-game/src/main/java/forge/game/ability/effects/ChangeTargetsEffect.java -text
forge-game/src/main/java/forge/game/ability/effects/ChangeTextEffect.java -text
forge-game/src/main/java/forge/game/ability/effects/ChangeZoneAllEffect.java -text
@@ -16720,6 +16721,7 @@ forge-gui/res/cardsfolder/upcoming/angel_of_sanctions.txt -text
forge-gui/res/cardsfolder/upcoming/angler_drake.txt -text
forge-gui/res/cardsfolder/upcoming/anointed_procession.txt -text
forge-gui/res/cardsfolder/upcoming/anointer_priest.txt -text
forge-gui/res/cardsfolder/upcoming/approach_of_the_second_sun.txt -text
forge-gui/res/cardsfolder/upcoming/archfiend_of_ifnir.txt -text
forge-gui/res/cardsfolder/upcoming/aven_initiate.txt -text
forge-gui/res/cardsfolder/upcoming/aven_wind_guide.txt -text

View File

@@ -30,6 +30,7 @@ public enum SpellApiToAi {
.put(ApiType.BecomesBlocked, BecomesBlockedAi.class)
.put(ApiType.BidLife, BidLifeAi.class)
.put(ApiType.Bond, BondAi.class)
.put(ApiType.Branch, AlwaysPlayAi.class)
.put(ApiType.ChangeTargets, ChangeTargetsAi.class)
.put(ApiType.ChangeZone, ChangeZoneAi.class)
.put(ApiType.ChangeZoneAll, ChangeZoneAllAi.class)

View File

@@ -46,6 +46,7 @@ public final class AbilityFactory {
"WinSubAbility", "OtherwiseSubAbility", // Clash
"ChooseNumberSubAbility", "Lowest", "Highest", // ChooseNumber
"HeadsSubAbility", "TailsSubAbility", "LoseSubAbility", // FlipCoin
"TrueSubAbility", "FalseSubAbility", // Branch
"ChosenPile", "UnchosenPile", // MultiplePiles & TwoPiles
"RepeatSubAbility", // Repeat & RepeatEach
"Execute" // DelayedTrigger

View File

@@ -26,6 +26,7 @@ public enum ApiType {
BecomesBlocked (BecomesBlockedEffect.class),
BidLife (BidLifeEffect.class),
Bond (BondEffect.class),
Branch (BranchEffect.class),
ChangeTargets (ChangeTargetsEffect.class),
ChangeText (ChangeTextEffect.class),
ChangeZone (ChangeZoneEffect.class),

View File

@@ -0,0 +1,41 @@
package forge.game.ability.effects;
import forge.game.ability.AbilityUtils;
import forge.game.ability.SpellAbilityEffect;
import forge.game.card.Card;
import forge.game.player.Player;
import forge.game.spellability.AbilitySub;
import forge.game.spellability.SpellAbility;
import forge.util.Expressions;
import java.util.List;
public class BranchEffect extends SpellAbilityEffect {
@Override
public void resolve(SpellAbility sa) {
final Card host = sa.getHostCard();
final Player player = host.getController();
// TODO Reuse SpellAbilityCondition and areMet() here instead of repeating each
// For now branch conditions will only be an Svar Compare
String branchSVar = sa.getParam("BranchConditionSVar");
String branchCompare = sa.getParamOrDefault("BranchConditionSVarCompare", "GE1");
String operator = branchCompare.substring(0, 2);
String operand = branchCompare.substring(2);
final int svarValue = AbilityUtils.calculateAmount(host, branchSVar, sa);
final int operandValue = AbilityUtils.calculateAmount(host, operand, sa);
AbilitySub sub = null;
if (Expressions.compare(svarValue, operator, operandValue)) {
sub = sa.getAdditonalAbility("TrueSubAbility");
} else {
sub = sa.getAdditonalAbility("FalseSubAbility");
}
if (sub != null) {
AbilityUtils.resolve(sub);
}
}
}

View File

@@ -3787,7 +3787,8 @@ public class Card extends GameEntity implements Comparable<Card> {
// Takes one argument like Permanent.Blue+withFlying
@Override
public final boolean isValid(final String restriction, final Player sourceController, final Card source, SpellAbility spellAbility) {
if (isImmutable() && !source.isRemembered(this) && !restriction.startsWith("Emblem")) { // special case exclusion
if (isImmutable() && !source.isRemembered(this) &&
!(restriction.startsWith("Emblem") || restriction.startsWith("Effect"))) { // special case exclusion
return false;
}

View File

@@ -0,0 +1,13 @@
Name:Approach of the Second Sun
ManaCost:6 W
Types:Sorcery
T:Mode$ SpellCast | ValidCard$ Card.Self | Static$ True | Execute$ ApproachingSuns
SVar:ApproachingSuns:DB$ Effect | Name$ ApproachingSuns | Duration$ Permanent
A:SP$ Branch | Cost$ 6 W | References$ X,Y,Z | BranchConditionSVar$ X | BranchConditionSVarCompare$ EQ3 | TrueSubAbility$ WinGame | FalseSubAbility$ GainLife | SpellDescription$ If CARDNAME was cast from your hand and youve cast another spell named Approach of the Second Sun this game, you win the game. Otherwise, put CARDNAME into its owners library seventh from the top and you gain 7 life.
SVar:WinGame:DB$ WinsGame | Defined$ You
SVar:GainLife:DB$ GainLife | LifeAmount$ 7 | Defined$ You | SubAbility$ Reapproach
SVar:Reapproach:DB$ ChangeZone | Origin$ Stack | Destination$ Library | LibraryPosition$ 6 | Defined$ Self
SVar:Y:Count$ValidCommand Effect.YouCtrl+namedApproachingSuns/LimitMax.2
SVar:Z:Count$ValidStack Card.wasCastFromHand+Self/LimitMax.1
SVar:X:SVar$Y/Plus.Z
Oracle:If Approach of the Second Sun was cast from your hand and youve cast another spell named Approach of the Second Sun this game, you win the game. Otherwise, put Approach of the Second Sun into its owners library seventh from the top and you gain 7 life.