mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
* Fixed that wrongly custom set cards were used for Mormir random card selection (fixes #2809).
This commit is contained in:
parent
05940aa481
commit
e6b5c0aef6
1 changed files with 21 additions and 6 deletions
|
@ -39,6 +39,8 @@ import mage.abilities.costs.mana.VariableManaCost;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
import mage.abilities.effects.common.InfoEffect;
|
import mage.abilities.effects.common.InfoEffect;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
|
import mage.cards.ExpansionSet;
|
||||||
|
import mage.cards.Sets;
|
||||||
import mage.cards.repository.CardCriteria;
|
import mage.cards.repository.CardCriteria;
|
||||||
import mage.cards.repository.CardInfo;
|
import mage.cards.repository.CardInfo;
|
||||||
import mage.cards.repository.CardRepository;
|
import mage.cards.repository.CardRepository;
|
||||||
|
@ -47,6 +49,7 @@ import mage.constants.MultiplayerAttackOption;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.constants.PhaseStep;
|
import mage.constants.PhaseStep;
|
||||||
import mage.constants.RangeOfInfluence;
|
import mage.constants.RangeOfInfluence;
|
||||||
|
import mage.constants.SetType;
|
||||||
import mage.constants.TimingRule;
|
import mage.constants.TimingRule;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.game.command.Emblem;
|
import mage.game.command.Emblem;
|
||||||
|
@ -156,14 +159,26 @@ class MomirEffect extends OneShotEffect {
|
||||||
// should this be random across card names, or card printings?
|
// should this be random across card names, or card printings?
|
||||||
CardCriteria criteria = new CardCriteria().types(CardType.CREATURE).convertedManaCost(value);
|
CardCriteria criteria = new CardCriteria().types(CardType.CREATURE).convertedManaCost(value);
|
||||||
List<CardInfo> options = CardRepository.instance.findCards(criteria);
|
List<CardInfo> options = CardRepository.instance.findCards(criteria);
|
||||||
if (options != null && !options.isEmpty()) {
|
if (options == null || options.isEmpty()) {
|
||||||
Card card = options.get(RandomUtil.nextInt(options.size())).getCard();
|
|
||||||
EmptyToken token = new EmptyToken();
|
|
||||||
CardUtil.copyTo(token).from(card);
|
|
||||||
token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId(), false, false);
|
|
||||||
} else {
|
|
||||||
game.informPlayers("No random creature card with converted mana cost of " + value + " was found.");
|
game.informPlayers("No random creature card with converted mana cost of " + value + " was found.");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
EmptyToken token = new EmptyToken(); // search for a non custom set creature
|
||||||
|
while (token.getName().isEmpty() && !options.isEmpty()) {
|
||||||
|
int index = RandomUtil.nextInt(options.size());
|
||||||
|
ExpansionSet expansionSet = Sets.findSet(options.get(index).getSetCode());
|
||||||
|
if (expansionSet == null || expansionSet.getSetType().equals(SetType.CUSTOM_SET)) {
|
||||||
|
options.remove(index);
|
||||||
|
} else {
|
||||||
|
Card card = options.get(index).getCard();
|
||||||
|
if (card != null) {
|
||||||
|
CardUtil.copyTo(token).from(card);
|
||||||
|
} else {
|
||||||
|
options.remove(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId(), false, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue