mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
Merge pull request #6520 from emerald000/londonMulligan
Streamline London Mulligan UX.
This commit is contained in:
commit
e3b75a445f
3 changed files with 149 additions and 42 deletions
|
@ -91,7 +91,7 @@ public class LondonMulliganTest extends MulliganTestBase {
|
||||||
});
|
});
|
||||||
scenario.discardBottom(count -> {
|
scenario.discardBottom(count -> {
|
||||||
scenario.assertSizes(7, 33);
|
scenario.assertSizes(7, 33);
|
||||||
assertEquals(2, count);
|
assertEquals(1, count);
|
||||||
assertEquals(hand1, new HashSet<>(scenario.getLibraryRangeSize(19, 7)));
|
assertEquals(hand1, new HashSet<>(scenario.getLibraryRangeSize(19, 7)));
|
||||||
assertEquals(discarded, scenario.getLibraryRangeSize(26, 1));
|
assertEquals(discarded, scenario.getLibraryRangeSize(26, 1));
|
||||||
assertEquals(hand2, new HashSet<>(scenario.getLibraryRangeSize(27, 6)));
|
assertEquals(hand2, new HashSet<>(scenario.getLibraryRangeSize(27, 6)));
|
||||||
|
@ -101,11 +101,23 @@ public class LondonMulliganTest extends MulliganTestBase {
|
||||||
remainingHand.addAll(Sets.difference(scenario.getHand(), new HashSet<>(discarded)));
|
remainingHand.addAll(Sets.difference(scenario.getHand(), new HashSet<>(discarded)));
|
||||||
return discarded;
|
return discarded;
|
||||||
});
|
});
|
||||||
|
scenario.discardBottom(count -> {
|
||||||
|
scenario.assertSizes(6, 34);
|
||||||
|
assertEquals(1, count);
|
||||||
|
assertEquals(hand1, new HashSet<>(scenario.getLibraryRangeSize(19, 7)));
|
||||||
|
assertEquals(discarded, scenario.getNBottomOfLibrary(1));
|
||||||
|
assertEquals(hand2, new HashSet<>(scenario.getLibraryRangeSize(27, 6)));
|
||||||
|
discarded.clear();
|
||||||
|
remainingHand.clear();
|
||||||
|
scenario.getHand().stream().limit(count).forEach(discarded::add);
|
||||||
|
remainingHand.addAll(Sets.difference(scenario.getHand(), new HashSet<>(discarded)));
|
||||||
|
return discarded;
|
||||||
|
});
|
||||||
scenario.mulligan(() -> {
|
scenario.mulligan(() -> {
|
||||||
scenario.assertSizes(5, 35);
|
scenario.assertSizes(5, 35);
|
||||||
assertEquals(hand1, new HashSet<>(scenario.getLibraryRangeSize(19, 7)));
|
assertEquals(hand1, new HashSet<>(scenario.getLibraryRangeSize(19, 7)));
|
||||||
assertEquals(hand2, new HashSet<>(scenario.getLibraryRangeSize(27, 6)));
|
assertEquals(hand2, new HashSet<>(scenario.getLibraryRangeSize(27, 6)));
|
||||||
assertEquals(discarded, scenario.getNBottomOfLibrary(2));
|
assertEquals(discarded, scenario.getNBottomOfLibrary(1));
|
||||||
hand3.addAll(scenario.getHand());
|
hand3.addAll(scenario.getHand());
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
@ -115,7 +127,7 @@ public class LondonMulliganTest extends MulliganTestBase {
|
||||||
assertEquals(hand1, new HashSet<>(scenario.getLibraryRangeSize(19, 7)));
|
assertEquals(hand1, new HashSet<>(scenario.getLibraryRangeSize(19, 7)));
|
||||||
assertEquals(hand2, new HashSet<>(scenario.getLibraryRangeSize(27, 6)));
|
assertEquals(hand2, new HashSet<>(scenario.getLibraryRangeSize(27, 6)));
|
||||||
assertEquals(hand3, scenario.getHand());
|
assertEquals(hand3, scenario.getHand());
|
||||||
assertEquals(discarded, scenario.getNBottomOfLibrary(2));
|
assertEquals(discarded, scenario.getNBottomOfLibrary(1));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,7 +233,12 @@ public class LondonMulliganTest extends MulliganTestBase {
|
||||||
});
|
});
|
||||||
scenario.discardBottom(count -> {
|
scenario.discardBottom(count -> {
|
||||||
scenario.assertSizes(7, 33);
|
scenario.assertSizes(7, 33);
|
||||||
assertEquals(2, count);
|
assertEquals(1, count);
|
||||||
|
return scenario.getHand().stream().limit(count).collect(Collectors.toList());
|
||||||
|
});
|
||||||
|
scenario.discardBottom(count -> {
|
||||||
|
scenario.assertSizes(6, 34);
|
||||||
|
assertEquals(1, count);
|
||||||
return scenario.getHand().stream().limit(count).collect(Collectors.toList());
|
return scenario.getHand().stream().limit(count).collect(Collectors.toList());
|
||||||
});
|
});
|
||||||
scenario.mulligan(() -> {
|
scenario.mulligan(() -> {
|
||||||
|
@ -230,7 +247,17 @@ public class LondonMulliganTest extends MulliganTestBase {
|
||||||
});
|
});
|
||||||
scenario.discardBottom(count -> {
|
scenario.discardBottom(count -> {
|
||||||
scenario.assertSizes(7, 33);
|
scenario.assertSizes(7, 33);
|
||||||
assertEquals(3, count);
|
assertEquals(1, count);
|
||||||
|
return scenario.getHand().stream().limit(count).collect(Collectors.toList());
|
||||||
|
});
|
||||||
|
scenario.discardBottom(count -> {
|
||||||
|
scenario.assertSizes(6, 34);
|
||||||
|
assertEquals(1, count);
|
||||||
|
return scenario.getHand().stream().limit(count).collect(Collectors.toList());
|
||||||
|
});
|
||||||
|
scenario.discardBottom(count -> {
|
||||||
|
scenario.assertSizes(5, 35);
|
||||||
|
assertEquals(1, count);
|
||||||
return scenario.getHand().stream().limit(count).collect(Collectors.toList());
|
return scenario.getHand().stream().limit(count).collect(Collectors.toList());
|
||||||
});
|
});
|
||||||
scenario.mulligan(() -> {
|
scenario.mulligan(() -> {
|
||||||
|
@ -239,7 +266,22 @@ public class LondonMulliganTest extends MulliganTestBase {
|
||||||
});
|
});
|
||||||
scenario.discardBottom(count -> {
|
scenario.discardBottom(count -> {
|
||||||
scenario.assertSizes(7, 33);
|
scenario.assertSizes(7, 33);
|
||||||
assertEquals(4, count);
|
assertEquals(1, count);
|
||||||
|
return scenario.getHand().stream().limit(count).collect(Collectors.toList());
|
||||||
|
});
|
||||||
|
scenario.discardBottom(count -> {
|
||||||
|
scenario.assertSizes(6, 34);
|
||||||
|
assertEquals(1, count);
|
||||||
|
return scenario.getHand().stream().limit(count).collect(Collectors.toList());
|
||||||
|
});
|
||||||
|
scenario.discardBottom(count -> {
|
||||||
|
scenario.assertSizes(5, 35);
|
||||||
|
assertEquals(1, count);
|
||||||
|
return scenario.getHand().stream().limit(count).collect(Collectors.toList());
|
||||||
|
});
|
||||||
|
scenario.discardBottom(count -> {
|
||||||
|
scenario.assertSizes(4, 36);
|
||||||
|
assertEquals(1, count);
|
||||||
return scenario.getHand().stream().limit(count).collect(Collectors.toList());
|
return scenario.getHand().stream().limit(count).collect(Collectors.toList());
|
||||||
});
|
});
|
||||||
scenario.mulligan(() -> {
|
scenario.mulligan(() -> {
|
||||||
|
@ -248,7 +290,27 @@ public class LondonMulliganTest extends MulliganTestBase {
|
||||||
});
|
});
|
||||||
scenario.discardBottom(count -> {
|
scenario.discardBottom(count -> {
|
||||||
scenario.assertSizes(7, 33);
|
scenario.assertSizes(7, 33);
|
||||||
assertEquals(5, count);
|
assertEquals(1, count);
|
||||||
|
return scenario.getHand().stream().limit(count).collect(Collectors.toList());
|
||||||
|
});
|
||||||
|
scenario.discardBottom(count -> {
|
||||||
|
scenario.assertSizes(6, 34);
|
||||||
|
assertEquals(1, count);
|
||||||
|
return scenario.getHand().stream().limit(count).collect(Collectors.toList());
|
||||||
|
});
|
||||||
|
scenario.discardBottom(count -> {
|
||||||
|
scenario.assertSizes(5, 35);
|
||||||
|
assertEquals(1, count);
|
||||||
|
return scenario.getHand().stream().limit(count).collect(Collectors.toList());
|
||||||
|
});
|
||||||
|
scenario.discardBottom(count -> {
|
||||||
|
scenario.assertSizes(4, 36);
|
||||||
|
assertEquals(1, count);
|
||||||
|
return scenario.getHand().stream().limit(count).collect(Collectors.toList());
|
||||||
|
});
|
||||||
|
scenario.discardBottom(count -> {
|
||||||
|
scenario.assertSizes(3, 37);
|
||||||
|
assertEquals(1, count);
|
||||||
return scenario.getHand().stream().limit(count).collect(Collectors.toList());
|
return scenario.getHand().stream().limit(count).collect(Collectors.toList());
|
||||||
});
|
});
|
||||||
scenario.mulligan(() -> {
|
scenario.mulligan(() -> {
|
||||||
|
@ -257,7 +319,32 @@ public class LondonMulliganTest extends MulliganTestBase {
|
||||||
});
|
});
|
||||||
scenario.discardBottom(count -> {
|
scenario.discardBottom(count -> {
|
||||||
scenario.assertSizes(7, 33);
|
scenario.assertSizes(7, 33);
|
||||||
assertEquals(6, count);
|
assertEquals(1, count);
|
||||||
|
return scenario.getHand().stream().limit(count).collect(Collectors.toList());
|
||||||
|
});
|
||||||
|
scenario.discardBottom(count -> {
|
||||||
|
scenario.assertSizes(6, 34);
|
||||||
|
assertEquals(1, count);
|
||||||
|
return scenario.getHand().stream().limit(count).collect(Collectors.toList());
|
||||||
|
});
|
||||||
|
scenario.discardBottom(count -> {
|
||||||
|
scenario.assertSizes(5, 35);
|
||||||
|
assertEquals(1, count);
|
||||||
|
return scenario.getHand().stream().limit(count).collect(Collectors.toList());
|
||||||
|
});
|
||||||
|
scenario.discardBottom(count -> {
|
||||||
|
scenario.assertSizes(4, 36);
|
||||||
|
assertEquals(1, count);
|
||||||
|
return scenario.getHand().stream().limit(count).collect(Collectors.toList());
|
||||||
|
});
|
||||||
|
scenario.discardBottom(count -> {
|
||||||
|
scenario.assertSizes(3, 37);
|
||||||
|
assertEquals(1, count);
|
||||||
|
return scenario.getHand().stream().limit(count).collect(Collectors.toList());
|
||||||
|
});
|
||||||
|
scenario.discardBottom(count -> {
|
||||||
|
scenario.assertSizes(2, 38);
|
||||||
|
assertEquals(1, count);
|
||||||
return scenario.getHand().stream().limit(count).collect(Collectors.toList());
|
return scenario.getHand().stream().limit(count).collect(Collectors.toList());
|
||||||
});
|
});
|
||||||
scenario.mulligan(() -> {
|
scenario.mulligan(() -> {
|
||||||
|
@ -266,7 +353,37 @@ public class LondonMulliganTest extends MulliganTestBase {
|
||||||
});
|
});
|
||||||
scenario.discardBottom(count -> {
|
scenario.discardBottom(count -> {
|
||||||
scenario.assertSizes(7, 33);
|
scenario.assertSizes(7, 33);
|
||||||
assertEquals(7, count);
|
assertEquals(1, count);
|
||||||
|
return scenario.getHand().stream().limit(count).collect(Collectors.toList());
|
||||||
|
});
|
||||||
|
scenario.discardBottom(count -> {
|
||||||
|
scenario.assertSizes(6, 34);
|
||||||
|
assertEquals(1, count);
|
||||||
|
return scenario.getHand().stream().limit(count).collect(Collectors.toList());
|
||||||
|
});
|
||||||
|
scenario.discardBottom(count -> {
|
||||||
|
scenario.assertSizes(5, 35);
|
||||||
|
assertEquals(1, count);
|
||||||
|
return scenario.getHand().stream().limit(count).collect(Collectors.toList());
|
||||||
|
});
|
||||||
|
scenario.discardBottom(count -> {
|
||||||
|
scenario.assertSizes(4, 36);
|
||||||
|
assertEquals(1, count);
|
||||||
|
return scenario.getHand().stream().limit(count).collect(Collectors.toList());
|
||||||
|
});
|
||||||
|
scenario.discardBottom(count -> {
|
||||||
|
scenario.assertSizes(3, 37);
|
||||||
|
assertEquals(1, count);
|
||||||
|
return scenario.getHand().stream().limit(count).collect(Collectors.toList());
|
||||||
|
});
|
||||||
|
scenario.discardBottom(count -> {
|
||||||
|
scenario.assertSizes(2, 38);
|
||||||
|
assertEquals(1, count);
|
||||||
|
return scenario.getHand().stream().limit(count).collect(Collectors.toList());
|
||||||
|
});
|
||||||
|
scenario.discardBottom(count -> {
|
||||||
|
scenario.assertSizes(1, 39);
|
||||||
|
assertEquals(1, count);
|
||||||
return scenario.getHand().stream().limit(count).collect(Collectors.toList());
|
return scenario.getHand().stream().limit(count).collect(Collectors.toList());
|
||||||
});
|
});
|
||||||
scenario.run(() -> {
|
scenario.run(() -> {
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
package mage.game.mulligan;
|
package mage.game.mulligan;
|
||||||
|
|
||||||
import mage.cards.Cards;
|
|
||||||
import mage.cards.CardsImpl;
|
import mage.cards.CardsImpl;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.constants.Zone;
|
|
||||||
import mage.filter.FilterCard;
|
import mage.filter.FilterCard;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.target.TargetCard;
|
import mage.target.Target;
|
||||||
|
import mage.target.common.TargetCardInHand;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -15,8 +14,8 @@ import java.util.UUID;
|
||||||
|
|
||||||
public class LondonMulligan extends Mulligan {
|
public class LondonMulligan extends Mulligan {
|
||||||
|
|
||||||
protected Map<UUID, Integer> startingHandSizes = new HashMap<>();
|
private final Map<UUID, Integer> startingHandSizes = new HashMap<>();
|
||||||
protected Map<UUID, Integer> openingHandSizes = new HashMap<>();
|
private final Map<UUID, Integer> openingHandSizes = new HashMap<>();
|
||||||
|
|
||||||
public LondonMulligan(int freeMulligans) {
|
public LondonMulligan(int freeMulligans) {
|
||||||
super(freeMulligans);
|
super(freeMulligans);
|
||||||
|
@ -93,27 +92,20 @@ public class LondonMulligan extends Mulligan {
|
||||||
openingHandSizes.put(playerId, openingHandSizes.get(playerId) - deduction);
|
openingHandSizes.put(playerId, openingHandSizes.get(playerId) - deduction);
|
||||||
int newHandSize = openingHandSizes.get(player.getId());
|
int newHandSize = openingHandSizes.get(player.getId());
|
||||||
if (deduction == 0) {
|
if (deduction == 0) {
|
||||||
game.fireInformEvent(new StringBuilder(player.getLogName())
|
game.fireInformEvent(player.getLogName() +
|
||||||
.append(" mulligans for free.")
|
" mulligans for free.");
|
||||||
.toString());
|
|
||||||
} else {
|
} else {
|
||||||
game.fireInformEvent(new StringBuilder(player.getLogName())
|
game.fireInformEvent(player.getLogName() +
|
||||||
.append(" mulligans")
|
" mulligans down to " +
|
||||||
.append(" down to ")
|
newHandSize +
|
||||||
.append(newHandSize)
|
(newHandSize == 1 ? " card" : " cards"));
|
||||||
.append(newHandSize == 1 ? " card" : " cards").toString());
|
|
||||||
}
|
}
|
||||||
player.drawCards(numCards, null, game);
|
player.drawCards(numCards, null, game);
|
||||||
|
|
||||||
if (player.getHand().size() > newHandSize) {
|
while (player.getHand().size() > newHandSize) {
|
||||||
int cardsToDiscard = player.getHand().size() - newHandSize;
|
Target target = new TargetCardInHand(new FilterCard("card (" + (player.getHand().size() - newHandSize) + " more) to put on the bottom of your library"));
|
||||||
Cards cards = new CardsImpl();
|
player.chooseTarget(Outcome.Discard, target, null, game);
|
||||||
cards.addAll(player.getHand());
|
|
||||||
TargetCard target = new TargetCard(cardsToDiscard, cardsToDiscard, Zone.HAND,
|
|
||||||
new FilterCard("card" + (cardsToDiscard > 1 ? "s" : "") + " to PUT on the BOTTOM of your library (Discard for Mulligan)"));
|
|
||||||
player.chooseTarget(Outcome.Neutral, cards, target, null, game);
|
|
||||||
player.putCardsOnBottomOfLibrary(new CardsImpl(target.getTargets()), game, null, true);
|
player.putCardsOnBottomOfLibrary(new CardsImpl(target.getTargets()), game, null, true);
|
||||||
cards.removeAll(target.getTargets());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,5 +120,4 @@ public class LondonMulligan extends Mulligan {
|
||||||
mulligan.startingHandSizes.putAll(startingHandSizes);
|
mulligan.startingHandSizes.putAll(startingHandSizes);
|
||||||
return mulligan;
|
return mulligan;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ import mage.cards.decks.Deck;
|
||||||
import mage.choices.Choice;
|
import mage.choices.Choice;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.constants.RangeOfInfluence;
|
import mage.constants.RangeOfInfluence;
|
||||||
|
import mage.filter.FilterMana;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.combat.CombatGroup;
|
import mage.game.combat.CombatGroup;
|
||||||
import mage.game.draft.Draft;
|
import mage.game.draft.Draft;
|
||||||
|
@ -25,13 +26,12 @@ import mage.target.TargetCard;
|
||||||
import mage.target.TargetPlayer;
|
import mage.target.TargetPlayer;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import static com.google.common.collect.Iterables.getOnlyElement;
|
import static com.google.common.collect.Iterables.getOnlyElement;
|
||||||
import static java.util.stream.Collectors.toList;
|
|
||||||
import mage.filter.FilterMana;
|
|
||||||
|
|
||||||
public class StubPlayer extends PlayerImpl implements Player {
|
public class StubPlayer extends PlayerImpl implements Player {
|
||||||
|
|
||||||
|
@ -54,15 +54,10 @@ public class StubPlayer extends PlayerImpl implements Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean chooseTarget(Outcome outcome, Cards cards, TargetCard target, Ability source, Game game) {
|
public boolean chooseTarget(Outcome outcome, Cards cards, TargetCard target, Ability source, Game game) {
|
||||||
if (target.getFilter().getMessage() != null && target.getFilter().getMessage().endsWith("(Discard for Mulligan)")) {
|
UUID cardId = getOnlyElement(cards.getCards(game)).getId();
|
||||||
chooseDiscardBottom(game, target.getMinNumberOfTargets(), cards.getCards(game)
|
if (chooseScry(game, cardId)) {
|
||||||
.stream().map(MageItem::getId).collect(toList())).forEach(cardId -> target.add(cardId, game));
|
target.add(cardId, game);
|
||||||
} else {
|
return true;
|
||||||
UUID cardId = getOnlyElement(cards.getCards(game)).getId();
|
|
||||||
if (chooseScry(game, cardId)) {
|
|
||||||
target.add(cardId, game);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -111,6 +106,10 @@ public class StubPlayer extends PlayerImpl implements Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean chooseTarget(Outcome outcome, Target target, Ability source, Game game) {
|
public boolean chooseTarget(Outcome outcome, Target target, Ability source, Game game) {
|
||||||
|
if (target.getFilter().getMessage() != null && target.getFilter().getMessage().endsWith(" more) to put on the bottom of your library")) {
|
||||||
|
chooseDiscardBottom(game, target.getMinNumberOfTargets(), new ArrayList<>(target.possibleTargets(null, null, game)))
|
||||||
|
.forEach(cardId -> target.add(cardId, game));
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue