mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 12:31:59 -08:00
initial refactor
This commit is contained in:
parent
ed700e68cc
commit
f5fffcf417
62 changed files with 75 additions and 80 deletions
|
|
@ -60,7 +60,7 @@ public class FlipCoinEffect extends OneShotEffect {
|
|||
MageObject mageObject = game.getObject(source.getSourceId());
|
||||
if (controller != null && mageObject != null) {
|
||||
boolean result = true;
|
||||
for (Effect effect : controller.flipCoin(game) ? executingEffectsWon : executingEffectsLost) {
|
||||
for (Effect effect : controller.flipCoin(game, true) ? executingEffectsWon : executingEffectsLost) {
|
||||
effect.setTargetPointer(this.targetPointer);
|
||||
if (effect instanceof OneShotEffect) {
|
||||
result &= effect.apply(game, source);
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ public class FlipUntilLoseEffect extends OneShotEffect {
|
|||
return false;
|
||||
}
|
||||
while (true) {
|
||||
if (!player.flipCoin(game)) {
|
||||
if (!player.flipCoin(game, true)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -395,9 +395,9 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
|
||||
boolean hasProtectionFrom(MageObject source, Game game);
|
||||
|
||||
boolean flipCoin(Game game);
|
||||
boolean flipCoin(Game game, boolean winnable);
|
||||
|
||||
boolean flipCoin(Game game, ArrayList<UUID> appliedEffects);
|
||||
boolean flipCoin(Game game, boolean winnable, ArrayList<UUID> appliedEffects);
|
||||
|
||||
int rollDice(Game game, int numSides);
|
||||
|
||||
|
|
|
|||
|
|
@ -2560,17 +2560,18 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean flipCoin(Game game) {
|
||||
return this.flipCoin(game, null);
|
||||
public boolean flipCoin(Game game, boolean winnable) {
|
||||
return this.flipCoin(game, true, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param game
|
||||
* @param winnable
|
||||
* @param appliedEffects
|
||||
* @return true if player won the toss
|
||||
*/
|
||||
@Override
|
||||
public boolean flipCoin(Game game, ArrayList<UUID> appliedEffects) {
|
||||
public boolean flipCoin(Game game, boolean winnable, ArrayList<UUID> appliedEffects) {
|
||||
boolean result = RandomUtil.nextBoolean();
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers("[Flip a coin] " + getLogName() + (result ? " won (head)." : " lost (tail)."));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue