mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 12:31:59 -08:00
* Game: fixed that Snow-Covered lands can be added to auto-generated or submitted/timeout decks (#7222);
This commit is contained in:
parent
10cf9c4a4e
commit
dd7c1939d3
6 changed files with 71 additions and 51 deletions
|
|
@ -1,12 +1,5 @@
|
|||
package mage.client.deck.generator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import mage.cards.Card;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.cards.repository.CardCriteria;
|
||||
|
|
@ -21,6 +14,8 @@ import mage.constants.Rarity;
|
|||
import mage.util.RandomUtil;
|
||||
import mage.util.TournamentUtil;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Generates random card pool and builds a deck.
|
||||
*
|
||||
|
|
@ -289,6 +284,7 @@ public final class DeckGenerator {
|
|||
if (!landSets.isEmpty()) {
|
||||
criteria.setCodes(landSets.toArray(new String[landSets.size()]));
|
||||
}
|
||||
criteria.ignoreSetsWithSnowLands();
|
||||
|
||||
Map<String, List<CardInfo>> basicLandMap = new HashMap<>();
|
||||
|
||||
|
|
@ -297,7 +293,7 @@ public final class DeckGenerator {
|
|||
criteria.rarities(Rarity.LAND).name(landName);
|
||||
List<CardInfo> cards = CardRepository.instance.findCards(criteria);
|
||||
if (cards.isEmpty()) { // Workaround to get basic lands if lands are not available for the given sets
|
||||
criteria.setCodes("ORI");
|
||||
criteria.setCodes("M15");
|
||||
cards = CardRepository.instance.findCards(criteria);
|
||||
}
|
||||
basicLandMap.put(landName, cards);
|
||||
|
|
|
|||
|
|
@ -37,10 +37,6 @@ public class AddLandDialog extends MageDialog {
|
|||
this.setModal(true);
|
||||
}
|
||||
|
||||
private boolean setHaveSnowLands(ExpansionInfo exp) {
|
||||
return CardRepository.instance.haveSnowLands(exp.getCode());
|
||||
}
|
||||
|
||||
public void showDialog(Deck deck, DeckEditorMode mode) {
|
||||
this.deck = deck;
|
||||
SortedSet<String> landSetNames = new TreeSet<>();
|
||||
|
|
@ -49,7 +45,7 @@ public class AddLandDialog extends MageDialog {
|
|||
// decide from which sets basic lands are taken from
|
||||
for (String setCode : deck.getExpansionSetCodes()) {
|
||||
ExpansionInfo expansionInfo = ExpansionRepository.instance.getSetByCode(setCode);
|
||||
if (expansionInfo != null && expansionInfo.hasBasicLands() && !setHaveSnowLands(expansionInfo)) {
|
||||
if (expansionInfo != null && expansionInfo.hasBasicLands() && !CardRepository.haveSnowLands(expansionInfo.getCode())) {
|
||||
defaultSetName = expansionInfo.getName();
|
||||
break;
|
||||
}
|
||||
|
|
@ -62,7 +58,7 @@ public class AddLandDialog extends MageDialog {
|
|||
if (expansionInfo != null) {
|
||||
List<ExpansionInfo> blockSets = ExpansionRepository.instance.getSetsFromBlock(expansionInfo.getBlockName());
|
||||
for (ExpansionInfo blockSet : blockSets) {
|
||||
if (blockSet.hasBasicLands() && !setHaveSnowLands(expansionInfo)) {
|
||||
if (blockSet.hasBasicLands() && !CardRepository.haveSnowLands(expansionInfo.getCode())) {
|
||||
defaultSetName = expansionInfo.getName();
|
||||
break;
|
||||
}
|
||||
|
|
@ -71,11 +67,12 @@ public class AddLandDialog extends MageDialog {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if still no set with lands found, add list of all available
|
||||
List<ExpansionInfo> basicLandSets = ExpansionRepository.instance.getSetsWithBasicLandsByReleaseDate();
|
||||
for (ExpansionInfo expansionInfo : basicLandSets) {
|
||||
// snow lands only in free mode
|
||||
if (mode != DeckEditorMode.FREE_BUILDING && setHaveSnowLands(expansionInfo)) {
|
||||
if (mode != DeckEditorMode.FREE_BUILDING && CardRepository.haveSnowLands(expansionInfo.getCode())) {
|
||||
continue;
|
||||
}
|
||||
landSetNames.add(expansionInfo.getName());
|
||||
|
|
@ -148,6 +145,8 @@ public class AddLandDialog extends MageDialog {
|
|||
throw new IllegalArgumentException("Code of Set " + landSetName + " not found");
|
||||
}
|
||||
criteria.setCodes(expansionInfo.getCode());
|
||||
} else {
|
||||
criteria.ignoreSetsWithSnowLands();
|
||||
}
|
||||
criteria.rarities(Rarity.LAND).name(landName);
|
||||
List<CardInfo> cards = CardRepository.instance.findCards(criteria);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue