Refactor: extract card names compare logic (is empty name, is same name)

Fixed last broken tests
This commit is contained in:
Oleg Agafonov 2018-12-07 00:26:50 +04:00
parent 96187ad3c0
commit 02b7e2cf10
63 changed files with 614 additions and 466 deletions

View file

@ -1,7 +1,5 @@
package mage.game.command.emblems;
import java.util.List;
import mage.abilities.Ability;
import mage.abilities.common.LimitedTimesPerTurnActivatedAbility;
import mage.abilities.costs.common.DiscardCardCost;
@ -13,19 +11,16 @@ import mage.cards.Sets;
import mage.cards.repository.CardCriteria;
import mage.cards.repository.CardInfo;
import mage.cards.repository.CardRepository;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SetType;
import mage.constants.TimingRule;
import mage.constants.Zone;
import mage.constants.*;
import mage.game.Game;
import mage.game.command.Emblem;
import mage.game.permanent.token.EmptyToken;
import mage.util.CardUtil;
import mage.util.RandomUtil;
import java.util.List;
/**
*
* @author spjspj
*/
public final class MomirEmblem extends Emblem {
@ -70,7 +65,7 @@ class MomirEffect extends OneShotEffect {
return false;
}
EmptyToken token = new EmptyToken(); // search for a non custom set creature
while (token.getName().isEmpty() && !options.isEmpty()) {
while (!options.isEmpty()) {
int index = RandomUtil.nextInt(options.size());
ExpansionSet expansionSet = Sets.findSet(options.get(index).getSetCode());
if (expansionSet == null || expansionSet.getSetType() == SetType.CUSTOM_SET) {
@ -79,6 +74,7 @@ class MomirEffect extends OneShotEffect {
Card card = options.get(index).getCard();
if (card != null) {
CardUtil.copyTo(token).from(card);
break;
} else {
options.remove(index);
}