mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
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:
parent
8cb4c17567
commit
f42bab2b16
5 changed files with 38 additions and 10 deletions
|
@ -103,6 +103,7 @@ public class GameEvent {
|
|||
SHUFFLE_LIBRARY, LIBRARY_SHUFFLED,
|
||||
ENCHANT_PLAYER, ENCHANTED_PLAYER,
|
||||
CAN_TAKE_MULLIGAN,
|
||||
FLIP_COIN,
|
||||
|
||||
//permanent events
|
||||
ENTERS_THE_BATTLEFIELD,
|
||||
|
@ -187,14 +188,19 @@ public class GameEvent {
|
|||
return amount;
|
||||
}
|
||||
|
||||
public void setAmount(int amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public boolean getFlag() {
|
||||
return flag;
|
||||
}
|
||||
|
||||
public void setAmount(int amount) {
|
||||
this.amount = amount;
|
||||
public void setFlag(boolean flag) {
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
|
||||
public String getData() {
|
||||
return data;
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ public class CleanupStep extends Step<CleanupStep> {
|
|||
Player activePlayer = game.getPlayer(activePlayerId);
|
||||
game.getState().setPriorityPlayerId(activePlayer.getId());
|
||||
//20091005 - 514.1
|
||||
if (!activePlayer.hasLeft() && !activePlayer.hasLost()) {
|
||||
if (activePlayer.isInGame()) {
|
||||
activePlayer.discardToMax(game);
|
||||
activePlayer.setGameUnderYourControl(true);
|
||||
}
|
||||
|
|
|
@ -239,7 +239,12 @@ public class Turn implements Serializable {
|
|||
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) {
|
||||
// Exile all spells and abilities on the stack
|
||||
game.getStack().clear();
|
||||
|
|
|
@ -197,6 +197,7 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
boolean canBeTargetedBy(MageObject source, Game game);
|
||||
boolean hasProtectionFrom(MageObject source, Game game);
|
||||
boolean flipCoin(Game game);
|
||||
boolean flipCoin(Game game, ArrayList<UUID> appliedEffects);
|
||||
void discard(int amount, Ability source, Game game);
|
||||
void discardToMax(Game game);
|
||||
boolean discard(Card card, Ability source, Game game);
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
package mage.players;
|
||||
|
||||
import java.awt.Event;
|
||||
import mage.Constants.AsThoughEffectType;
|
||||
import mage.Constants.Outcome;
|
||||
import mage.Constants.RangeOfInfluence;
|
||||
|
@ -461,10 +462,16 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
|
|||
|
||||
@Override
|
||||
public void discardToMax(Game game) {
|
||||
while (hand.size() > this.maxHandSize) {
|
||||
TargetDiscard target = new TargetDiscard(playerId);
|
||||
choose(Outcome.Discard, target, null, game);
|
||||
discard(hand.get(target.getFirstTarget(), game), null, game);
|
||||
int cardsStart = hand.size();
|
||||
if (cardsStart > this.maxHandSize) {
|
||||
while (hand.size() > this.maxHandSize) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean flipCoin(Game game) {
|
||||
return this.flipCoin(game, null);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return true if player won the toss
|
||||
*/
|
||||
@Override
|
||||
public boolean flipCoin(Game game) {
|
||||
public boolean flipCoin(Game game, ArrayList<UUID> appliedEffects) {
|
||||
boolean result = rnd.nextBoolean();
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue