mirror of
https://github.com/correl/mage.git
synced 2024-11-28 19:19:55 +00:00
Game: fixed mulligan's copy code (can potentially fix empty hands or loses on game start in rare use cases, e.g. with AI);
This commit is contained in:
parent
fa8c0259d0
commit
bb4f36fddf
6 changed files with 35 additions and 14 deletions
|
@ -390,5 +390,4 @@ public class LondonMulliganTest extends MulliganTestBase {
|
|||
scenario.assertSizes(0, 40);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,9 +15,10 @@ public class CanadianHighlanderMulligan extends VancouverMulligan {
|
|||
super(freeMulligans);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CanadianHighlanderMulligan copy() {
|
||||
return new CanadianHighlanderMulligan(getFreeMulligans());
|
||||
CanadianHighlanderMulligan(final CanadianHighlanderMulligan mulligan) {
|
||||
super(mulligan);
|
||||
|
||||
this.usedMulligans.putAll(mulligan.usedMulligans);
|
||||
}
|
||||
|
||||
private String getNextMulligan(String mulligan) {
|
||||
|
@ -116,9 +117,13 @@ public class CanadianHighlanderMulligan extends VancouverMulligan {
|
|||
}
|
||||
game.fireInformEvent(new StringBuilder(player.getLogName())
|
||||
.append(" mulligans to ")
|
||||
.append(Integer.toString(numToMulliganTo))
|
||||
.append(numToMulliganTo)
|
||||
.append(numToMulliganTo == 1 ? " card" : " cards").toString());
|
||||
player.drawCards(numToMulliganTo, null, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CanadianHighlanderMulligan copy() {
|
||||
return new CanadianHighlanderMulligan(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,13 @@ public class LondonMulligan extends Mulligan {
|
|||
super(freeMulligans);
|
||||
}
|
||||
|
||||
LondonMulligan(final LondonMulligan mulligan) {
|
||||
super(mulligan);
|
||||
|
||||
this.startingHandSizes.putAll(mulligan.startingHandSizes);
|
||||
this.openingHandSizes.putAll(mulligan.openingHandSizes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeMulliganPhase(Game game, int startingHandSize) {
|
||||
/*
|
||||
|
@ -115,9 +122,6 @@ public class LondonMulligan extends Mulligan {
|
|||
|
||||
@Override
|
||||
public LondonMulligan copy() {
|
||||
LondonMulligan mulligan = new LondonMulligan(getFreeMulligans());
|
||||
mulligan.openingHandSizes.putAll(openingHandSizes);
|
||||
mulligan.startingHandSizes.putAll(startingHandSizes);
|
||||
return mulligan;
|
||||
return new LondonMulligan(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,12 @@ public abstract class Mulligan implements Serializable {
|
|||
this.freeMulligans = freeMulligans;
|
||||
}
|
||||
|
||||
Mulligan(final Mulligan mulligan) {
|
||||
super();
|
||||
this.freeMulligans = mulligan.freeMulligans;
|
||||
this.usedFreeMulligans.putAll(mulligan.usedFreeMulligans);
|
||||
}
|
||||
|
||||
public void executeMulliganPhase(Game game, int startingHandSize) {
|
||||
/*
|
||||
* 103.4. Each player draws a number of cards equal to their starting hand size,
|
||||
|
|
|
@ -11,6 +11,10 @@ public class ParisMulligan extends Mulligan {
|
|||
super(freeMulligans);
|
||||
}
|
||||
|
||||
ParisMulligan(final ParisMulligan mulligan) {
|
||||
super(mulligan);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int mulliganDownTo(Game game, UUID playerId) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
|
@ -57,11 +61,11 @@ public class ParisMulligan extends Mulligan {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void endMulligan(Game game, UUID playerId) {}
|
||||
public void endMulligan(Game game, UUID playerId) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParisMulligan copy() {
|
||||
return new ParisMulligan(getFreeMulligans());
|
||||
return new ParisMulligan(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,6 +11,10 @@ public class VancouverMulligan extends ParisMulligan {
|
|||
super(freeMulligans);
|
||||
}
|
||||
|
||||
VancouverMulligan(final VancouverMulligan mulligan) {
|
||||
super(mulligan);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeMulliganPhase(Game game, int startingHandSize) {
|
||||
super.executeMulliganPhase(game, startingHandSize);
|
||||
|
@ -30,7 +34,6 @@ public class VancouverMulligan extends ParisMulligan {
|
|||
|
||||
@Override
|
||||
public VancouverMulligan copy() {
|
||||
return new VancouverMulligan(getFreeMulligans());
|
||||
return new VancouverMulligan(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue