mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
add support for multiple called flips to FlipCoinEffect
This commit is contained in:
@@ -62,8 +62,12 @@ public class FlipCoinEffect extends SpellAbilityEffect {
|
||||
final boolean noCall = sa.hasParam("NoCall");
|
||||
String varName = sa.hasParam("SaveNumFlipsToSVar") ? sa.getParam("SaveNumFlipsToSVar") : "X";
|
||||
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));
|
||||
victory = flipCoinCall(caller.get(0), sa, flipMultiplier, varName);
|
||||
}
|
||||
@@ -77,11 +81,6 @@ public class FlipCoinEffect extends SpellAbilityEffect {
|
||||
int countHeads = 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) {
|
||||
final boolean resultIsHeads = flipCoinNoCall(sa, flipper, flipMultiplier, varName);
|
||||
|
||||
@@ -113,6 +112,43 @@ public class FlipCoinEffect extends SpellAbilityEffect {
|
||||
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 {
|
||||
if (victory) {
|
||||
if (sa.getParam("RememberWinner") != null) {
|
||||
|
||||
Reference in New Issue
Block a user