MCPcopy Create free account
hub / github.com/Card-Forge/forge / mill

Method mill

forge-game/src/main/java/forge/game/player/Player.java:1553–1605  ·  view source on GitHub ↗
(int n, final ZoneType destination, SpellAbility sa, Map<AbilityKey, Object> params)

Source from the content-addressed store, hash-verified

1551 }
1552
1553 public final CardCollectionView mill(int n, final ZoneType destination, SpellAbility sa, Map<AbilityKey, Object> params) {
1554 // Replacement effects
1555 final Map<AbilityKey, Object> repRunParams = AbilityKey.mapFromAffected(this);
1556 repRunParams.put(AbilityKey.Number, n);
1557 if (params != null) {
1558 repRunParams.putAll(params);
1559 }
1560
1561 if (destination == ZoneType.Graveyard) {
1562 switch (getGame().getReplacementHandler().run(ReplacementType.Mill, repRunParams)) {
1563 case NotReplaced:
1564 break;
1565 case Updated:
1566 // check if this is still the affected player
1567 if (this.equals(repRunParams.get(AbilityKey.Affected))) {
1568 n = (int) repRunParams.get(AbilityKey.Number);
1569 } else {
1570 return CardCollection.EMPTY;
1571 }
1572 break;
1573 default:
1574 return CardCollection.EMPTY;
1575 }
1576 }
1577
1578 Iterable<Card> milledView = getCardsIn(ZoneType.Library);
1579 // CR 614.13c
1580 if (sa.getRootAbility().getReplacingObject(AbilityKey.SimultaneousETB) != null) {
1581 milledView = IterableUtil.filter(milledView, c -> !((CardCollection) sa.getRootAbility().getReplacingObject(AbilityKey.SimultaneousETB)).contains(c));
1582 }
1583 CardCollectionView milled = new CardCollection(Iterables.limit(milledView, n));
1584
1585 if (destination == ZoneType.Graveyard) {
1586 milled = GameActionUtil.orderCardsByTheirOwners(game, milled, ZoneType.Graveyard, sa);
1587 }
1588
1589 for (Card m : milled) {
1590 Card moved = game.getAction().moveTo(destination, m, sa, params);
1591 moved.setMilled(true);
1592
1593 final Map<AbilityKey, Object> runParams = AbilityKey.mapFromPlayer(this);
1594 runParams.put(AbilityKey.Card, m);
1595 game.getTriggerHandler().runTrigger(TriggerType.Milled, runParams, false);
1596 }
1597
1598 if (!milled.isEmpty()) {
1599 final Map<AbilityKey, Object> runParams = AbilityKey.mapFromPlayer(this);
1600 runParams.put(AbilityKey.Cards, milled);
1601 game.getTriggerHandler().runTrigger(TriggerType.MilledOnce, runParams, false);
1602 }
1603
1604 return milled;
1605 }
1606
1607 public final CardCollection getTopXCardsFromLibrary(int amount) {
1608 final CardCollection topCards = new CardCollection();

Callers 3

payAsDecidedMethod · 0.45
resolveMethod · 0.45
resolveMethod · 0.45

Calls 15

mapFromAffectedMethod · 0.95
getGameMethod · 0.95
getCardsInMethod · 0.95
filterMethod · 0.95
setMilledMethod · 0.95
mapFromPlayerMethod · 0.95
getReplacementHandlerMethod · 0.80
getReplacingObjectMethod · 0.80
getRootAbilityMethod · 0.80
limitMethod · 0.80
runTriggerMethod · 0.80

Tested by

no test coverage detected