Merge origin/master

This commit is contained in:
LevelX2 2017-03-12 21:00:26 +01:00
commit bfa9d17182

View file

@ -142,56 +142,66 @@ class EyeOfTheStormEffect1 extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Spell spell = game.getStack().getSpell(targetPointer.getFirst(game, source));
boolean noLongerOnStack = false;// spell was exiled already by another effect, for example NivMagus Elemental
if (spell == null) {
spell = ((Spell) game.getLastKnownInformation(targetPointer.getFirst(game, source), Zone.STACK));
noLongerOnStack = true;
}
Permanent eyeOfTheStorm = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (spell != null && eyeOfTheStorm != null) {
Player spellController = game.getPlayer(spell.getControllerId());
Card card = spell.getCard();
if (spellController == null || card == null || !instantOrSorceryfilter.match(card, game)) {
if (spellController == null
|| card == null
|| !instantOrSorceryfilter.match(card, game)) {
return false;
}
if (!noLongerOnStack) {// the spell is still on the stack, so exile it
UUID exileZoneId = CardUtil.getExileZoneId(game, source.getSourceId(), eyeOfTheStorm.getZoneChangeCounter(game));
spellController.moveCardsToExile(spell, source, game, true, exileZoneId, eyeOfTheStorm.getIdName());
}
UUID exileZoneId = CardUtil.getExileZoneId(game, source.getSourceId(), eyeOfTheStorm.getZoneChangeCounter(game));
if (spellController.moveCardsToExile(spell, source, game, true, exileZoneId, eyeOfTheStorm.getIdName())) {
eyeOfTheStorm.imprint(card.getId(), game);
eyeOfTheStorm.imprint(card.getId(), game);// technically, using the imprint functionality here is not correct.
if (eyeOfTheStorm.getImprinted() != null && !eyeOfTheStorm.getImprinted().isEmpty()) {
CardsImpl copiedCards = new CardsImpl();
for (UUID uuid : eyeOfTheStorm.getImprinted()) {
card = game.getCard(uuid);
if (eyeOfTheStorm.getImprinted() != null
&& !eyeOfTheStorm.getImprinted().isEmpty()) {
CardsImpl copiedCards = new CardsImpl();
for (UUID uuid : eyeOfTheStorm.getImprinted()) {
card = game.getCard(uuid);
// Check if owner of card is still in game
if (card != null && game.getPlayer(card.getOwnerId()) != null) {
if (card.isSplitCard()) {
copiedCards.add(((SplitCard) card).getLeftHalfCard());
copiedCards.add(((SplitCard) card).getRightHalfCard());
} else {
copiedCards.add(card);
}
}
}
boolean continueCasting = true;
while (continueCasting) {
continueCasting = copiedCards.size() > 1 && spellController.chooseUse(outcome, "Cast one of the copied cards without paying its mana cost?", source, game);
Card cardToCopy;
if (copiedCards.size() == 1) {
cardToCopy = copiedCards.getCards(game).iterator().next();
// Check if owner of card is still in game
if (card != null
&& game.getPlayer(card.getOwnerId()) != null) {
if (card.isSplitCard()) {
copiedCards.add(((SplitCard) card).getLeftHalfCard());
copiedCards.add(((SplitCard) card).getRightHalfCard());
} else {
TargetCard target = new TargetCard(1, Zone.EXILED, new FilterCard("card to copy"));
spellController.choose(Outcome.Copy, copiedCards, target, game);
cardToCopy = copiedCards.get(target.getFirstTarget(), game);
copiedCards.remove(cardToCopy);
}
if (cardToCopy != null) {
Card copy = game.copyCard(cardToCopy, source, source.getControllerId());
if (spellController.chooseUse(outcome, "Cast the copied card without paying mana cost?", source, game)) {
spellController.cast(copy.getSpellAbility(), game, true);
}
copiedCards.add(card);
}
}
return true;
}
boolean continueCasting = true;
while (continueCasting) {
continueCasting = copiedCards.size() > 1 && spellController.chooseUse(outcome, "Cast one of the copied cards without paying its mana cost?", source, game);
Card cardToCopy;
if (copiedCards.size() == 1) {
cardToCopy = copiedCards.getCards(game).iterator().next();
} else {
TargetCard target = new TargetCard(1, Zone.EXILED, new FilterCard("card to copy"));
spellController.choose(Outcome.Copy, copiedCards, target, game);
cardToCopy = copiedCards.get(target.getFirstTarget(), game);
copiedCards.remove(cardToCopy);
}
if (cardToCopy != null) {
Card copy = game.copyCard(cardToCopy, source, source.getControllerId());
if (spellController.chooseUse(outcome, "Cast the copied card without paying mana cost?", source, game)) {
spellController.cast(copy.getSpellAbility(), game, true);
}
}
}
return true;
}
}
return false;