mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
initPlane moved to a better place (after mulligans)
added mulligan rule 103.4b
This commit is contained in:
@@ -1479,6 +1479,9 @@ public class GameAction {
|
|||||||
game.setAge(GameAge.Play);
|
game.setAge(GameAge.Play);
|
||||||
|
|
||||||
// THIS CODE WILL WORK WITH PHASE = NULL {
|
// THIS CODE WILL WORK WITH PHASE = NULL {
|
||||||
|
if(game.getType() == GameType.Planechase)
|
||||||
|
firstPlayer.initPlane();
|
||||||
|
|
||||||
handleLeylinesAndChancellors();
|
handleLeylinesAndChancellors();
|
||||||
// Run Trigger beginning of the game
|
// Run Trigger beginning of the game
|
||||||
final HashMap<String, Object> runParams = new HashMap<String, Object>();
|
final HashMap<String, Object> runParams = new HashMap<String, Object>();
|
||||||
@@ -1497,38 +1500,54 @@ public class GameAction {
|
|||||||
whoCanMulligan.add(whoCanMulligan.remove(0));
|
whoCanMulligan.add(whoCanMulligan.remove(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean[] hasKept = new boolean[whoCanMulligan.size()];
|
||||||
|
int[] handSize = new int[whoCanMulligan.size()];
|
||||||
|
for( int i = 0; i < whoCanMulligan.size(); i++) {
|
||||||
|
hasKept[i] = false;
|
||||||
|
handSize[i] = whoCanMulligan.get(i).getZone(ZoneType.Hand).size();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
MapOfLists<Player, Card> exiledDuringMulligans = new HashMapOfLists<Player, Card>(CollectionSuppliers.<Card>arrayLists());
|
MapOfLists<Player, Card> exiledDuringMulligans = new HashMapOfLists<Player, Card>(CollectionSuppliers.<Card>arrayLists());
|
||||||
|
|
||||||
|
// rule 103.4b
|
||||||
|
boolean isMultiPlayer = game.getPlayers().size() > 2;
|
||||||
|
int mulliganDelta = isMultiPlayer ? 0 : 1;
|
||||||
|
|
||||||
|
boolean allKept;
|
||||||
do {
|
do {
|
||||||
|
allKept = true;
|
||||||
for (int i = 0; i < whoCanMulligan.size(); i++) {
|
for (int i = 0; i < whoCanMulligan.size(); i++) {
|
||||||
|
if( hasKept[i]) continue;
|
||||||
|
|
||||||
Player p = whoCanMulligan.get(i);
|
Player p = whoCanMulligan.get(i);
|
||||||
List<Card> toMulligan = p.canMulligan() ? p.getController().getCardsToMulligan(isCommander, firstPlayer) : null;
|
List<Card> toMulligan = p.canMulligan() ? p.getController().getCardsToMulligan(isCommander, firstPlayer) : null;
|
||||||
if ( toMulligan != null ) {
|
if ( toMulligan != null && !toMulligan.isEmpty()) {
|
||||||
if( !isCommander ) {
|
if( !isCommander ) {
|
||||||
toMulligan = new ArrayList<Card>(p.getCardsIn(ZoneType.Hand));
|
toMulligan = new ArrayList<Card>(p.getCardsIn(ZoneType.Hand));
|
||||||
for (final Card c : toMulligan) {
|
for (final Card c : toMulligan) {
|
||||||
moveToLibrary(c);
|
moveToLibrary(c);
|
||||||
}
|
}
|
||||||
p.shuffle();
|
p.shuffle();
|
||||||
p.drawCards(toMulligan.size() - 1);
|
p.drawCards(handSize[i] - mulliganDelta);
|
||||||
|
} else {
|
||||||
} else if ( !toMulligan.isEmpty() ){
|
|
||||||
List<Card> toExile = Lists.newArrayList(toMulligan);
|
List<Card> toExile = Lists.newArrayList(toMulligan);
|
||||||
for(Card c : toExile) {
|
for(Card c : toExile) {
|
||||||
exile(c);
|
exile(c);
|
||||||
}
|
}
|
||||||
exiledDuringMulligans.addAll(p, toExile);
|
exiledDuringMulligans.addAll(p, toExile);
|
||||||
p.drawCards(toExile.size() - 1);
|
p.drawCards(toExile.size() - 1);
|
||||||
} else
|
}
|
||||||
continue;
|
|
||||||
|
|
||||||
p.onMulliganned();
|
p.onMulliganned();
|
||||||
|
allKept = false;
|
||||||
} else {
|
} else {
|
||||||
game.getGameLog().add(GameEventType.MULLIGAN, p.getName() + " has kept a hand of " + p.getZone(ZoneType.Hand).size() + " cards");
|
game.getGameLog().add(GameEventType.MULLIGAN, p.getName() + " has kept a hand of " + p.getZone(ZoneType.Hand).size() + " cards");
|
||||||
whoCanMulligan.remove(i--);
|
hasKept[i] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while( !whoCanMulligan.isEmpty() );
|
mulliganDelta++;
|
||||||
|
} while( !allKept );
|
||||||
|
|
||||||
if( isCommander )
|
if( isCommander )
|
||||||
for(Entry<Player, Collection<Card>> kv : exiledDuringMulligans.entrySet() ) {
|
for(Entry<Player, Collection<Card>> kv : exiledDuringMulligans.entrySet() ) {
|
||||||
|
|||||||
@@ -132,9 +132,6 @@ public class MatchController {
|
|||||||
currentGame.getInputQueue().invokeGameAction(new Runnable() {
|
currentGame.getInputQueue().invokeGameAction(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if(currentGame.getType() == GameType.Planechase)
|
|
||||||
firstPlayer.initPlane();
|
|
||||||
|
|
||||||
currentGame.getAction().mulligan(firstPlayer);
|
currentGame.getAction().mulligan(firstPlayer);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -488,6 +488,6 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
public List<Card> getCardsToMulligan(boolean isCommander, Player firstPlayer) {
|
public List<Card> getCardsToMulligan(boolean isCommander, Player firstPlayer) {
|
||||||
final InputConfirmMulligan inp = new InputConfirmMulligan(player, firstPlayer, isCommander);
|
final InputConfirmMulligan inp = new InputConfirmMulligan(player, firstPlayer, isCommander);
|
||||||
player.getGame().getInputQueue().setInputAndWait(inp);
|
player.getGame().getInputQueue().setInputAndWait(inp);
|
||||||
return inp.isKeepHand() ? null : inp.getSelectedCards();
|
return inp.isKeepHand() ? null : isCommander ? inp.getSelectedCards() : player.getCardsIn(ZoneType.Hand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user