Added info how many cards still to discard in discard message of cleanup phase. Added replace effect for coin flipping.

This commit is contained in:
LevelX2 2013-06-05 17:26:02 +02:00
parent 8cb4c17567
commit f42bab2b16
5 changed files with 38 additions and 10 deletions

View file

@ -103,6 +103,7 @@ public class GameEvent {
SHUFFLE_LIBRARY, LIBRARY_SHUFFLED, SHUFFLE_LIBRARY, LIBRARY_SHUFFLED,
ENCHANT_PLAYER, ENCHANTED_PLAYER, ENCHANT_PLAYER, ENCHANTED_PLAYER,
CAN_TAKE_MULLIGAN, CAN_TAKE_MULLIGAN,
FLIP_COIN,
//permanent events //permanent events
ENTERS_THE_BATTLEFIELD, ENTERS_THE_BATTLEFIELD,
@ -187,14 +188,19 @@ public class GameEvent {
return amount; return amount;
} }
public void setAmount(int amount) {
this.amount = amount;
}
public boolean getFlag() { public boolean getFlag() {
return flag; return flag;
} }
public void setAmount(int amount) { public void setFlag(boolean flag) {
this.amount = amount; this.flag = flag;
} }
public String getData() { public String getData() {
return data; return data;
} }

View file

@ -57,7 +57,7 @@ public class CleanupStep extends Step<CleanupStep> {
Player activePlayer = game.getPlayer(activePlayerId); Player activePlayer = game.getPlayer(activePlayerId);
game.getState().setPriorityPlayerId(activePlayer.getId()); game.getState().setPriorityPlayerId(activePlayer.getId());
//20091005 - 514.1 //20091005 - 514.1
if (!activePlayer.hasLeft() && !activePlayer.hasLost()) { if (activePlayer.isInGame()) {
activePlayer.discardToMax(game); activePlayer.discardToMax(game);
activePlayer.setGameUnderYourControl(true); activePlayer.setGameUnderYourControl(true);
} }

View file

@ -239,7 +239,12 @@ public class Turn implements Serializable {
this.play(game, activePlayerId); this.play(game, activePlayerId);
} }
}*/ }*/
/**
* Used for some spells with end turn effect (e.g. Time Stop).
*
* @param game
* @param activePlayerId
*/
public void endTurn(Game game, UUID activePlayerId) { public void endTurn(Game game, UUID activePlayerId) {
// Exile all spells and abilities on the stack // Exile all spells and abilities on the stack
game.getStack().clear(); game.getStack().clear();

View file

@ -197,6 +197,7 @@ public interface Player extends MageItem, Copyable<Player> {
boolean canBeTargetedBy(MageObject source, Game game); boolean canBeTargetedBy(MageObject source, Game game);
boolean hasProtectionFrom(MageObject source, Game game); boolean hasProtectionFrom(MageObject source, Game game);
boolean flipCoin(Game game); boolean flipCoin(Game game);
boolean flipCoin(Game game, ArrayList<UUID> appliedEffects);
void discard(int amount, Ability source, Game game); void discard(int amount, Ability source, Game game);
void discardToMax(Game game); void discardToMax(Game game);
boolean discard(Card card, Ability source, Game game); boolean discard(Card card, Ability source, Game game);

View file

@ -28,6 +28,7 @@
package mage.players; package mage.players;
import java.awt.Event;
import mage.Constants.AsThoughEffectType; import mage.Constants.AsThoughEffectType;
import mage.Constants.Outcome; import mage.Constants.Outcome;
import mage.Constants.RangeOfInfluence; import mage.Constants.RangeOfInfluence;
@ -461,10 +462,16 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
@Override @Override
public void discardToMax(Game game) { public void discardToMax(Game game) {
while (hand.size() > this.maxHandSize) { int cardsStart = hand.size();
TargetDiscard target = new TargetDiscard(playerId); if (cardsStart > this.maxHandSize) {
choose(Outcome.Discard, target, null, game); while (hand.size() > this.maxHandSize) {
discard(hand.get(target.getFirstTarget(), game), null, game); TargetDiscard target = new TargetDiscard(playerId);
target.setTargetName(new StringBuilder(" card to discard (").append(hand.size() - this.maxHandSize).append(" in total)").toString());
choose(Outcome.Discard, target, null, game);
discard(hand.get(target.getFirstTarget(), game), null, game);
}
int discarded =cardsStart - hand.size();
game.informPlayers(new StringBuilder(getName()).append(" discards ").append(discarded).append(discarded == 1?"card":"cards").append(" (cleanup)").toString());
} }
} }
@ -1347,15 +1354,24 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
return false; return false;
} }
@Override
public boolean flipCoin(Game game) {
return this.flipCoin(game, null);
}
/** /**
* *
* @return true if player won the toss * @return true if player won the toss
*/ */
@Override @Override
public boolean flipCoin(Game game) { public boolean flipCoin(Game game, ArrayList<UUID> appliedEffects) {
boolean result = rnd.nextBoolean(); boolean result = rnd.nextBoolean();
game.informPlayers("[Flip a coin] " + getName() + (result ? " won (head)." : " lost (tail).")); game.informPlayers("[Flip a coin] " + getName() + (result ? " won (head)." : " lost (tail)."));
return result; GameEvent event = new GameEvent(GameEvent.EventType.FLIP_COIN, playerId, null, playerId, 0, result);
event.setAppliedEffects(appliedEffects);
game.replaceEvent(event);
return event.getFlag();
} }
@Override @Override