Merge branch 'yusri' into 'master'

MH2: Yusri and support

See merge request core-developers/forge!4750
This commit is contained in:
Michael Kamensky
2021-05-26 04:32:52 +00:00
2 changed files with 59 additions and 6 deletions

View File

@@ -62,8 +62,12 @@ public class FlipCoinEffect extends SpellAbilityEffect {
final boolean noCall = sa.hasParam("NoCall"); final boolean noCall = sa.hasParam("NoCall");
String varName = sa.hasParam("SaveNumFlipsToSVar") ? sa.getParam("SaveNumFlipsToSVar") : "X"; String varName = sa.hasParam("SaveNumFlipsToSVar") ? sa.getParam("SaveNumFlipsToSVar") : "X";
boolean victory = false; boolean victory = false;
int amount = 1;
if (sa.hasParam("Amount")) {
amount = AbilityUtils.calculateAmount(host, sa.getParam("Amount"), sa);
}
if (!noCall) { if ((!noCall) && (amount == 1)) {
flipMultiplier = getFilpMultiplier(caller.get(0)); flipMultiplier = getFilpMultiplier(caller.get(0));
victory = flipCoinCall(caller.get(0), sa, flipMultiplier, varName); victory = flipCoinCall(caller.get(0), sa, flipMultiplier, varName);
} }
@@ -77,11 +81,6 @@ public class FlipCoinEffect extends SpellAbilityEffect {
int countHeads = 0; int countHeads = 0;
int countTails = 0; int countTails = 0;
int amount = 1;
if (sa.hasParam("Amount")) {
amount = AbilityUtils.calculateAmount(host, sa.getParam("Amount"), sa);
}
for(int i = 0; i < amount; ++i) { for(int i = 0; i < amount; ++i) {
final boolean resultIsHeads = flipCoinNoCall(sa, flipper, flipMultiplier, varName); final boolean resultIsHeads = flipCoinNoCall(sa, flipper, flipMultiplier, varName);
@@ -113,6 +112,43 @@ public class FlipCoinEffect extends SpellAbilityEffect {
AbilityUtils.resolve(sub); AbilityUtils.resolve(sub);
} }
} }
} else if (amount > 1){
flipMultiplier = getFilpMultiplier(flipper);
int countWins = 0;
int countLosses = 0;
for(int i = 0; i < amount; ++i) {
final boolean win = flipCoinCall(caller.get(0), sa, flipMultiplier, varName);
if (win) {
countWins++;
} else {
countLosses++;
}
}
if (countWins > 0) {
SpellAbility sub = sa.getAdditionalAbility("WinSubAbility");
if (sub != null) {
sub.setSVar("Wins", "Number$" + countWins);
AbilityUtils.resolve(sub);
}
}
if (countLosses > 0) {
SpellAbility sub = sa.getAdditionalAbility("LoseSubAbility");
if (sub != null) {
sub.setSVar("Losses", "Number$" + countLosses);
AbilityUtils.resolve(sub);
}
}
if (sa.hasParam("RememberNumber")) {
String toRemember = sa.getParam("RememberNumber");
if (toRemember.startsWith("Win")) {
host.addRemembered(countWins);
} else if (toRemember.startsWith("Loss")) {
host.addRemembered(countLosses);
}
}
} else { } else {
if (victory) { if (victory) {
if (sa.getParam("RememberWinner") != null) { if (sa.getParam("RememberWinner") != null) {

View File

@@ -0,0 +1,17 @@
Name:Yusri, Fortune's Flame
ManaCost:1 U R
Types:Legendary Creature Efreet
PT:2/3
K:Flying
T:Mode$ Attacks | ValidCard$ Card.Self | Execute$ TrigChooseNumber | TriggerDescription$ Whenever CARDNAME attacks, choose a number between 1 and 5. Flip that many coins. For each flip you win, draw a card. For each flip you lose, NICKNAME deals 2 damage to you. If you won five flips this way, you may cast spells from your hand this turn without paying their mana costs.
SVar:TrigChooseNumber:DB$ ChooseNumber | Defined$ You | Min$ 1 | Max$ 5 | AILogic$ Max | SubAbility$ FlipCoin
SVar:FlipCoin:DB$ FlipACoin | Amount$ X | WinSubAbility$ DBDraw | LoseSubAbility$ DBDamage | RememberNumber$ Wins | SubAbility$ DBEffect
SVar:DBDraw:DB$ Draw | Defined$ You | NumCards$ Wins
SVar:DBDamage:DB$ DealDamage | NumDmg$ Damage | Defined$ You
SVar:DBEffect:DB$ Effect | StaticAbilities$ MayPlay | Stackable$ False | ConditionCheckSVar$ Y | ConditionSVarCompare$ EQ5 | SubAbility$ DBCleanup
SVar:MayPlay:Mode$ Continuous | EffectZone$ Command | Affected$ Card.nonLand+YouOwn | MayPlay$ True | MayPlayWithoutManaCost$ True | AffectedZone$ Hand | Description$ You may cast spells from your hand this turn without paying their mana costs.
SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True
SVar:X:Number$ChosenNumber
SVar:Y:Count$RememberedNumber
SVar:Damage:SVar$Losses/Times.2
Oracle:Flying\nWhenever Yusri, Fortune's Flame attacks, choose a number between 1 and 5. Flip that many coins. For each flip you win, draw a card. For each flip you lose, Yusri deals 2 damage to you. If you won five flips this way, you may cast spells from your hand this turn without paying their mana costs.