mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
* Removed land set restriction on limited add land dialog (fixes #4373).
This commit is contained in:
parent
75b8a4b165
commit
82defb2ab8
1 changed files with 22 additions and 13 deletions
|
@ -73,26 +73,27 @@ public class AddLandDialog extends MageDialog {
|
|||
public void showDialog(Deck deck, DeckEditorMode mode) {
|
||||
this.deck = deck;
|
||||
SortedSet<String> landSetNames = new TreeSet<>();
|
||||
String defaultSetName = null;
|
||||
if (mode != DeckEditorMode.FREE_BUILDING) {
|
||||
// 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()) {
|
||||
this.landSetCodes.add(expansionInfo.getCode());
|
||||
landSetNames.add(expansionInfo.getName());
|
||||
defaultSetName = expansionInfo.getName();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// if sets have no basic land, take land from block
|
||||
if (this.landSetCodes.isEmpty()) {
|
||||
if (defaultSetName == null) {
|
||||
for (String setCode : deck.getExpansionSetCodes()) {
|
||||
ExpansionInfo expansionInfo = ExpansionRepository.instance.getSetByCode(setCode);
|
||||
if (expansionInfo != null) {
|
||||
List<ExpansionInfo> blockSets = ExpansionRepository.instance.getSetsFromBlock(expansionInfo.getBlockName());
|
||||
for (ExpansionInfo blockSet : blockSets) {
|
||||
if (blockSet.hasBasicLands()) {
|
||||
this.landSetCodes.add(blockSet.getCode());
|
||||
landSetNames.add(blockSet.getName());
|
||||
defaultSetName = expansionInfo.getName();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -100,12 +101,10 @@ public class AddLandDialog extends MageDialog {
|
|||
}
|
||||
}
|
||||
// if still no set with lands found, add list of all available
|
||||
if (this.landSetCodes.isEmpty()) {
|
||||
List<ExpansionInfo> basicLandSets = ExpansionRepository.instance.getSetsWithBasicLandsByReleaseDate();
|
||||
for (ExpansionInfo expansionInfo : basicLandSets) {
|
||||
landSetNames.add(expansionInfo.getName());
|
||||
}
|
||||
}
|
||||
if (landSetNames.isEmpty()) {
|
||||
throw new IllegalArgumentException("No set with basic land was found");
|
||||
}
|
||||
|
@ -113,7 +112,17 @@ public class AddLandDialog extends MageDialog {
|
|||
landSetNames.add("<Random lands>");
|
||||
}
|
||||
cbLandSet.setModel(new DefaultComboBoxModel(landSetNames.toArray()));
|
||||
if (defaultSetName != null) {
|
||||
String item;
|
||||
for (int i = 0; i < cbLandSet.getItemCount(); i++) {
|
||||
item = (String) cbLandSet.getItemAt(i);
|
||||
if (item.equalsIgnoreCase(defaultSetName)) {
|
||||
cbLandSet.setSelectedIndex(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// windows settings
|
||||
if (this.isModal()) {
|
||||
|
|
Loading…
Reference in a new issue