Merge branch 'master' into 'master'

minor fixes

See merge request core-developers/forge!4629
This commit is contained in:
Anthony Calosa
2021-04-30 14:37:18 +00:00
3 changed files with 17 additions and 3 deletions

View File

@@ -533,6 +533,8 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
@Override @Override
public int getPrintCount(String cardName, String edition) { public int getPrintCount(String cardName, String edition) {
int cnt = 0; int cnt = 0;
if (edition == null || cardName == null)
return cnt;
for (PaperCard pc : getAllCards(cardName)) { for (PaperCard pc : getAllCards(cardName)) {
if (pc.getEdition().equals(edition)) { if (pc.getEdition().equals(edition)) {
cnt++; cnt++;
@@ -544,6 +546,8 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
@Override @Override
public int getMaxPrintCount(String cardName) { public int getMaxPrintCount(String cardName) {
int max = -1; int max = -1;
if (cardName == null)
return max;
for (PaperCard pc : getAllCards(cardName)) { for (PaperCard pc : getAllCards(cardName)) {
if (max < pc.getArtIndex()) { if (max < pc.getArtIndex()) {
max = pc.getArtIndex(); max = pc.getArtIndex();
@@ -555,6 +559,8 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
@Override @Override
public int getArtCount(String cardName, String setName) { public int getArtCount(String cardName, String setName) {
int cnt = 0; int cnt = 0;
if (cardName == null || setName == null)
return cnt;
Collection<PaperCard> cards = getAllCards(cardName); Collection<PaperCard> cards = getAllCards(cardName);
if (null == cards) { if (null == cards) {
@@ -635,10 +641,12 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
CardEdition edition = null; CardEdition edition = null;
try { try {
edition = editions.getEditionByCodeOrThrow(paperCard.getEdition()); edition = editions.getEditionByCodeOrThrow(paperCard.getEdition());
if (edition.getType() == Type.PROMOS||edition.getType() == Type.REPRINT)
return false;
} catch (Exception ex) { } catch (Exception ex) {
return false; return false;
} }
return edition != null && (edition.getType() != Type.PROMOS||edition.getType() != Type.REPRINT); return true;
} }
})); }));
} }

View File

@@ -256,7 +256,7 @@ public final class CardEdition implements Comparable<CardEdition> { // immutable
date = date + "-01"; date = date + "-01";
try { try {
return formatter.parse(date); return formatter.parse(date);
} catch (ParseException e) { } catch (Exception e) {
return new Date(); return new Date();
} }
} }

View File

@@ -997,6 +997,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
@Override @Override
public CardCollectionView orderMoveToZoneList(final CardCollectionView cards, final ZoneType destinationZone, final SpellAbility source) { public CardCollectionView orderMoveToZoneList(final CardCollectionView cards, final ZoneType destinationZone, final SpellAbility source) {
boolean bottomOfLibrary = false;
if (source == null || source.getApi() != ApiType.ReorderZone) { if (source == null || source.getApi() != ApiType.ReorderZone) {
if (destinationZone == ZoneType.Graveyard) { if (destinationZone == ZoneType.Graveyard) {
switch (FModel.getPreferences().getPref(FPref.UI_ALLOW_ORDER_GRAVEYARD_WHEN_NEEDED)) { switch (FModel.getPreferences().getPref(FPref.UI_ALLOW_ORDER_GRAVEYARD_WHEN_NEEDED)) {
@@ -1019,13 +1020,18 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
} }
} }
if (source != null) {
if (source.hasParam("LibraryPosition")) {
bottomOfLibrary = Integer.parseInt(source.getParam("LibraryPosition")) < 0;
}
}
tempShowCards(cards); tempShowCards(cards);
GameEntityViewMap<Card, CardView> gameCacheMove = GameEntityView.getMap(cards); GameEntityViewMap<Card, CardView> gameCacheMove = GameEntityView.getMap(cards);
List<CardView> choices = gameCacheMove.getTrackableKeys(); List<CardView> choices = gameCacheMove.getTrackableKeys();
switch (destinationZone) { switch (destinationZone) {
case Library: case Library:
choices = getGui().order(localizer.getMessage("lblChooseOrderCardsPutIntoLibrary"), localizer.getMessage("lblClosestToTop"), choices, null); choices = getGui().order(localizer.getMessage("lblChooseOrderCardsPutIntoLibrary"), localizer.getMessage(bottomOfLibrary ? "lblClosestToBottom" : "lblClosestToTop"), choices, null);
break; break;
case Battlefield: case Battlefield:
choices = getGui().order(localizer.getMessage("lblChooseOrderCardsPutOntoBattlefield"), localizer.getMessage("lblPutFirst"), choices, null); choices = getGui().order(localizer.getMessage("lblChooseOrderCardsPutOntoBattlefield"), localizer.getMessage("lblPutFirst"), choices, null);