Fixed LondonMulligan to give mulligan choice after discarding to bottom, which fixes the interaction with Serum Powder.

This commit is contained in:
John Hitchings 2019-03-20 23:23:28 -07:00
parent 47c9aab877
commit 1ca876c2ed
2 changed files with 114 additions and 67 deletions

View file

@ -5,6 +5,7 @@ import mage.game.mulligan.MulliganType;
import org.junit.Test;
import java.util.*;
import java.util.stream.Collectors;
import static org.junit.Assert.assertEquals;
@ -37,25 +38,26 @@ public class LondonMulliganTest extends MulliganTestBase {
hand1.addAll(scenario.getHand());
return true;
});
scenario.mulligan(() -> {
scenario.assertSizes(7, 33);
assertEquals(hand1, new HashSet<>(scenario.getLibraryRangeSize(26, 7)));
hand2.addAll(scenario.getHand());
return false;
});
scenario.discardBottom(count -> {
scenario.assertSizes(7, 33);
assertEquals(1, count);
assertEquals(hand1, new HashSet<>(scenario.getLibraryRangeSize(26, 7)));
assertEquals(hand2, scenario.getHand());
scenario.getHand().stream().limit(count).forEach(discarded::add);
remainingHand.addAll(Sets.difference(scenario.getHand(), new HashSet<>(discarded)));
return discarded;
});
scenario.mulligan(() -> {
scenario.assertSizes(6, 34);
assertEquals(hand1, new HashSet<>(scenario.getLibraryRangeSize(26, 7)));
assertEquals(remainingHand, scenario.getHand());
hand2.addAll(scenario.getHand());
return false;
});
scenario.run(() -> {
scenario.assertSizes(6, 34);
assertEquals(remainingHand, new HashSet<>(scenario.getHand()));
assertEquals(hand1, new HashSet<>(scenario.getLibraryRangeSize(26, 7)));
assertEquals(hand2, scenario.getHand());
assertEquals(discarded, scenario.getNBottomOfLibrary(1));
});
}
@ -73,34 +75,46 @@ public class LondonMulliganTest extends MulliganTestBase {
hand1.addAll(scenario.getHand());
return true;
});
scenario.mulligan(() -> {
scenario.discardBottom(count -> {
scenario.assertSizes(7, 33);
assertEquals(1, count);
assertEquals(hand1, new HashSet<>(scenario.getLibraryRangeSize(26, 7)));
scenario.getHand().stream().limit(count).forEach(discarded::add);
remainingHand.addAll(Sets.difference(scenario.getHand(), new HashSet<>(discarded)));
return discarded;
});
scenario.mulligan(() -> {
scenario.assertSizes(6, 34);
assertEquals(hand1, new HashSet<>(scenario.getLibraryRangeSize(26, 7)));
hand2.addAll(scenario.getHand());
return true;
});
scenario.mulligan(() -> {
scenario.assertSizes(7, 33);
assertEquals(hand1, new HashSet<>(scenario.getLibraryRangeSize(19, 7)));
assertEquals(hand2, new HashSet<>(scenario.getLibraryRangeSize(26, 7)));
hand3.addAll(scenario.getHand());
return false;
});
scenario.discardBottom(count -> {
scenario.assertSizes(7, 33);
assertEquals(2, count);
assertEquals(hand1, new HashSet<>(scenario.getLibraryRangeSize(19, 7)));
assertEquals(hand2, new HashSet<>(scenario.getLibraryRangeSize(26, 7)));
assertEquals(hand3, scenario.getHand());
assertEquals(discarded, scenario.getLibraryRangeSize(26, 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.assertSizes(5, 35);
assertEquals(hand1, new HashSet<>(scenario.getLibraryRangeSize(19, 7)));
assertEquals(hand2, new HashSet<>(scenario.getLibraryRangeSize(27, 6)));
assertEquals(discarded, scenario.getNBottomOfLibrary(2));
hand3.addAll(scenario.getHand());
return false;
});
scenario.run(() -> {
scenario.assertSizes(5, 35);
assertEquals(remainingHand, new HashSet<>(scenario.getHand()));
assertEquals(hand1, new HashSet<>(scenario.getLibraryRangeSize(19, 7)));
assertEquals(hand2, new HashSet<>(scenario.getLibraryRangeSize(26, 7)));
assertEquals(hand2, new HashSet<>(scenario.getLibraryRangeSize(27, 6)));
assertEquals(hand3, scenario.getHand());
assertEquals(discarded, scenario.getNBottomOfLibrary(2));
});
}
@ -162,27 +176,28 @@ public class LondonMulliganTest extends MulliganTestBase {
hand2.addAll(scenario.getHand());
return true;
});
scenario.mulligan(() -> {
scenario.assertSizes(7, 33);
assertEquals(hand1, new HashSet<>(scenario.getLibraryRangeSize(19, 7)));
assertEquals(hand2, new HashSet<>(scenario.getLibraryRangeSize(26, 7)));
hand3.addAll(scenario.getHand());
return false;
});
scenario.discardBottom(count -> {
scenario.assertSizes(7, 33);
assertEquals(1, count);
assertEquals(hand1, new HashSet<>(scenario.getLibraryRangeSize(19, 7)));
assertEquals(hand2, new HashSet<>(scenario.getLibraryRangeSize(26, 7)));
assertEquals(hand3, scenario.getHand());
scenario.getHand().stream().limit(count).forEach(discarded::add);
remainingHand.addAll(Sets.difference(scenario.getHand(), new HashSet<>(discarded)));
return discarded;
});
scenario.mulligan(() -> {
scenario.assertSizes(6, 34);
assertEquals(hand1, new HashSet<>(scenario.getLibraryRangeSize(19, 7)));
assertEquals(hand2, new HashSet<>(scenario.getLibraryRangeSize(26, 7)));
assertEquals(discarded, scenario.getNBottomOfLibrary(1));
hand3.addAll(scenario.getHand());
return false;
});
scenario.run(() -> {
scenario.assertSizes(6, 34);
assertEquals(hand1, new HashSet<>(scenario.getLibraryRangeSize(19, 7)));
assertEquals(hand2, new HashSet<>(scenario.getLibraryRangeSize(26, 7)));
assertEquals(hand3, scenario.getHand());
assertEquals(remainingHand, new HashSet<>(scenario.getHand()));
assertEquals(discarded, scenario.getNBottomOfLibrary(1));
});
@ -195,33 +210,64 @@ public class LondonMulliganTest extends MulliganTestBase {
scenario.assertSizes(7, 33);
return true;
});
scenario.mulligan(() -> {
scenario.discardBottom(count -> {
scenario.assertSizes(7, 33);
return true;
assertEquals(1, count);
return scenario.getHand().stream().limit(count).collect(Collectors.toList());
});
scenario.mulligan(() -> {
scenario.assertSizes(7, 33);
return true;
});
scenario.mulligan(() -> {
scenario.assertSizes(7, 33);
return true;
});
scenario.mulligan(() -> {
scenario.assertSizes(7, 33);
return true;
});
scenario.mulligan(() -> {
scenario.assertSizes(7, 33);
return true;
});
scenario.mulligan(() -> {
scenario.assertSizes(7, 33);
scenario.assertSizes(6, 34);
return true;
});
scenario.discardBottom(count -> {
scenario.assertSizes(7, 33);
assertEquals(2, count);
return scenario.getHand().stream().limit(count).collect(Collectors.toList());
});
scenario.mulligan(() -> {
scenario.assertSizes(5, 35);
return true;
});
scenario.discardBottom(count -> {
scenario.assertSizes(7, 33);
assertEquals(3, count);
return scenario.getHand().stream().limit(count).collect(Collectors.toList());
});
scenario.mulligan(() -> {
scenario.assertSizes(4, 36);
return true;
});
scenario.discardBottom(count -> {
scenario.assertSizes(7, 33);
assertEquals(4, count);
return scenario.getHand().stream().limit(count).collect(Collectors.toList());
});
scenario.mulligan(() -> {
scenario.assertSizes(3, 37);
return true;
});
scenario.discardBottom(count -> {
scenario.assertSizes(7, 33);
assertEquals(5, count);
return scenario.getHand().stream().limit(count).collect(Collectors.toList());
});
scenario.mulligan(() -> {
scenario.assertSizes(2, 38);
return true;
});
scenario.discardBottom(count -> {
scenario.assertSizes(7, 33);
assertEquals(6, count);
return scenario.getHand().stream().limit(count).collect(Collectors.toList());
});
scenario.mulligan(() -> {
scenario.assertSizes(1, 39);
return true;
});
scenario.discardBottom(count -> {
scenario.assertSizes(7, 33);
assertEquals(7, count);
return new ArrayList<>(scenario.getHand());
return scenario.getHand().stream().limit(count).collect(Collectors.toList());
});
scenario.run(() -> {
scenario.assertSizes(0, 40);