mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
- Added a way to count the number of coin flips in AF FlipACoin without the need for recursive counting script (which no longer works in the current engine).
- Fixed Crazed Firecat.
This commit is contained in:
@@ -122,15 +122,27 @@ public class FlipCoinEffect extends SpellAbilityEffect {
|
|||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
public boolean flipCoinNoCall(final SpellAbility sa, final Player flipper, final int multiplier) {
|
public boolean flipCoinNoCall(final SpellAbility sa, final Player flipper, final int multiplier) {
|
||||||
boolean[] results = new boolean[multiplier];
|
boolean result = false;
|
||||||
for (int i = 0; i < multiplier; i++) {
|
int numSuccesses = 0;
|
||||||
final boolean resultIsHeads = MyRandom.getRandom().nextBoolean();
|
|
||||||
flipper.getGame().fireEvent(new GameEventFlipCoin());
|
do {
|
||||||
results[i] = resultIsHeads;
|
boolean[] results = new boolean[multiplier];
|
||||||
}
|
for (int i = 0; i < multiplier; i++) {
|
||||||
boolean result = multiplier == 1 ? results[0] : flipper.getController().chooseFlipResult(sa, flipper, results, false);
|
final boolean resultIsHeads = MyRandom.getRandom().nextBoolean();
|
||||||
|
flipper.getGame().fireEvent(new GameEventFlipCoin());
|
||||||
|
results[i] = resultIsHeads;
|
||||||
|
}
|
||||||
|
result = multiplier == 1 ? results[0] : flipper.getController().chooseFlipResult(sa, flipper, results, false);
|
||||||
|
if (result) {
|
||||||
|
numSuccesses++;
|
||||||
|
}
|
||||||
|
flipper.getGame().getAction().nofityOfValue(sa, flipper, result ? "heads" : "tails", null);
|
||||||
|
} while (sa.hasParam("FlipUntilYouLose") && result != false);
|
||||||
|
|
||||||
flipper.getGame().getAction().nofityOfValue(sa, flipper, result ? "heads" : "tails", null);
|
if (sa.hasParam("FlipUntilYouLose")) {
|
||||||
|
sa.getAdditonalAbility("LoseSubAbility").setSVar(sa.hasParam("SaveNumFlipsToSVar") ? sa.getParam("SaveNumFlipsToSVar") : "X", "Number$" + numSuccesses);
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,23 +159,36 @@ public class FlipCoinEffect extends SpellAbilityEffect {
|
|||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
public static boolean flipCoinCall(final Player caller, final SpellAbility sa, final int multiplier) {
|
public static boolean flipCoinCall(final Player caller, final SpellAbility sa, final int multiplier) {
|
||||||
boolean [] results = new boolean [multiplier];
|
boolean result = false;
|
||||||
final boolean choice = caller.getController().chooseBinary(sa, sa.getHostCard().getName() + " - Call coin flip", PlayerController.BinaryChoiceType.HeadsOrTails);
|
int numSuccesses = 0;
|
||||||
for (int i = 0; i < multiplier; i++) {
|
|
||||||
// Play the Flip A Coin sound
|
do {
|
||||||
caller.getGame().fireEvent(new GameEventFlipCoin());
|
boolean [] results = new boolean [multiplier];
|
||||||
final boolean flip = MyRandom.getRandom().nextBoolean();
|
final boolean choice = caller.getController().chooseBinary(sa, sa.getHostCard().getName() + " - Call coin flip", PlayerController.BinaryChoiceType.HeadsOrTails);
|
||||||
results[i] = flip == choice;
|
for (int i = 0; i < multiplier; i++) {
|
||||||
}
|
// Play the Flip A Coin sound
|
||||||
boolean result = multiplier == 1 ? results[0] : caller.getController().chooseFlipResult(sa, caller, results, true);
|
caller.getGame().fireEvent(new GameEventFlipCoin());
|
||||||
|
final boolean flip = MyRandom.getRandom().nextBoolean();
|
||||||
caller.getGame().getAction().nofityOfValue(sa, caller, result ? "win" : "lose", null);
|
results[i] = flip == choice;
|
||||||
|
}
|
||||||
|
result = multiplier == 1 ? results[0] : caller.getController().chooseFlipResult(sa, caller, results, true);
|
||||||
|
if (result) {
|
||||||
|
numSuccesses++;
|
||||||
|
}
|
||||||
|
|
||||||
|
caller.getGame().getAction().nofityOfValue(sa, caller, result ? "win" : "lose", null);
|
||||||
|
|
||||||
|
// Run triggers
|
||||||
|
Map<String,Object> runParams = Maps.newHashMap();
|
||||||
|
runParams.put("Player", caller);
|
||||||
|
runParams.put("Result", Boolean.valueOf(result));
|
||||||
|
caller.getGame().getTriggerHandler().runTrigger(TriggerType.FlippedCoin, runParams, false);
|
||||||
|
} while (sa.hasParam("FlipUntilYouLose") && result != false);
|
||||||
|
|
||||||
|
if (sa.hasParam("FlipUntilYouLose")) {
|
||||||
|
sa.getAdditonalAbility("LoseSubAbility").setSVar(sa.hasParam("SaveNumFlipsToSVar") ? sa.getParam("SaveNumFlipsToSVar") : "X", "Number$" + numSuccesses);
|
||||||
|
}
|
||||||
|
|
||||||
// Run triggers
|
|
||||||
Map<String,Object> runParams = Maps.newHashMap();
|
|
||||||
runParams.put("Player", caller);
|
|
||||||
runParams.put("Result", Boolean.valueOf(result));
|
|
||||||
caller.getGame().getTriggerHandler().runTrigger(TriggerType.FlippedCoin, runParams, false);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,8 @@ ManaCost:5 R R
|
|||||||
Types:Creature Elemental Cat
|
Types:Creature Elemental Cat
|
||||||
PT:4/4
|
PT:4/4
|
||||||
T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ TrigFlip | TriggerDescription$ When CARDNAME enters the battlefield, flip a coin until you lose a flip. Put a +1/+1 counter on CARDNAME for each flip you win.
|
T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ TrigFlip | TriggerDescription$ When CARDNAME enters the battlefield, flip a coin until you lose a flip. Put a +1/+1 counter on CARDNAME for each flip you win.
|
||||||
SVar:TrigFlip:AB$ FlipACoin | Cost$ 0 | WinSubAbility$ DBCountAndFlipAgain
|
SVar:TrigFlip:DB$ FlipACoin | FlipUntilYouLose$ True | SaveNumFlipsToSVar$ X | LoseSubAbility$ DBPutCounter
|
||||||
SVar:DBCountAndFlipAgain:DB$ StoreSVar | SVar$ X | Type$ CountSVar | Expression$ X/Plus.1 | SubAbility$ DBFlipAgain
|
SVar:DBPutCounter:DB$ PutCounter | Defined$ Self | CounterType$ P1P1 | CounterNum$ X | References$ X
|
||||||
SVar:DBFlipAgain:DB$ FlipACoin | Cost$ 0 | WinSubAbility$ DBCountAndFlipAgain | LoseSubAbility$ DBPutCounter
|
|
||||||
SVar:DBPutCounter:DB$ PutCounter | Cost$ 0 | Defined$ Self | CounterType$ P1P1 | CounterNum$ X | References$ X
|
|
||||||
SVar:X:Number$0
|
SVar:X:Number$0
|
||||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/crazed_firecat.jpg
|
SVar:Picture:http://www.wizards.com/global/images/magic/general/crazed_firecat.jpg
|
||||||
Oracle:When Crazed Firecat enters the battlefield, flip a coin until you lose a flip. Put a +1/+1 counter on Crazed Firecat for each flip you win.
|
Oracle:When Crazed Firecat enters the battlefield, flip a coin until you lose a flip. Put a +1/+1 counter on Crazed Firecat for each flip you win.
|
||||||
|
|||||||
Reference in New Issue
Block a user