(final SpellAbility sp, SpellAbilityStackInstance si, int id)
| 523 | |
| 524 | // Push should only be used by add. |
| 525 | private SpellAbilityStackInstance push(final SpellAbility sp, SpellAbilityStackInstance si, int id) { |
| 526 | if (null == sp.getActivatingPlayer()) { |
| 527 | sp.setActivatingPlayer(sp.getHostCard().getController()); |
| 528 | System.out.println(sp.getHostCard().getName() + " - activatingPlayer not set before adding to stack."); |
| 529 | } |
| 530 | |
| 531 | if (sp.isSpell() && sp.getMayPlay() != null) { |
| 532 | sp.getMayPlay().incMayPlayTurn(); |
| 533 | if (sp.getMayPlay().hasParam("ReplaceGraveyard")) { |
| 534 | PlayEffect.addReplaceGraveyardEffect(sp.getHostCard(), sp.getMayPlay().getHostCard(), sp, sp, sp.getMayPlay().getParam("ReplaceGraveyard")); |
| 535 | } |
| 536 | } |
| 537 | si = si == null ? new SpellAbilityStackInstance(sp, id) : si; |
| 538 | |
| 539 | stack.addFirst(si); |
| 540 | int stackIndex = stack.size() - 1; |
| 541 | |
| 542 | int distinctSources = 0; |
| 543 | Set<Integer> sources = new TreeSet<>(); |
| 544 | for (SpellAbilityStackInstance s : stack) { |
| 545 | if (s.isSpell()) { |
| 546 | distinctSources++; |
| 547 | } else { |
| 548 | sources.add(s.getSourceCard().getId()); |
| 549 | } |
| 550 | } |
| 551 | distinctSources += sources.size(); |
| 552 | if (distinctSources > maxDistinctSources) maxDistinctSources = distinctSources; |
| 553 | |
| 554 | // 2012-07-21 the following comparison needs to move below the pushes but somehow screws up priority |
| 555 | // When it's down there. That makes absolutely no sense to me, so i'm putting it back for now |
| 556 | if (!(sp.isTrigger() || (sp instanceof AbilityStatic))) { |
| 557 | // when something is added we need to setPriority |
| 558 | game.getPhaseHandler().setPriority(sp.getActivatingPlayer()); |
| 559 | } |
| 560 | |
| 561 | sp.getHostCard().getGame().getAction().checkStaticAbilities(false); |
| 562 | sp.getHostCard().getGame().getTriggerHandler().resetActiveTriggers(); |
| 563 | |
| 564 | game.updateStackForView(); |
| 565 | game.fireEvent(new GameEventSpellAbilityCast(sp, si, stackIndex)); |
| 566 | return si; |
| 567 | } |
| 568 | |
| 569 | public final void resolveStack() { |
| 570 | // freeze the stack while we're in the middle of resolving |
no test coverage detected