initial refactor

This commit is contained in:
Evan Kranzler 2019-01-15 11:51:49 -05:00
parent ed700e68cc
commit f5fffcf417
62 changed files with 75 additions and 80 deletions

View file

@ -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);

View file

@ -34,7 +34,7 @@ public class FlipUntilLoseEffect extends OneShotEffect {
return false;
}
while (true) {
if (!player.flipCoin(game)) {
if (!player.flipCoin(game, true)) {
return true;
}
}

View file

@ -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);

View file

@ -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)."));