From d019180bada751a8b8cbec84b82271700d680143 Mon Sep 17 00:00:00 2001 From: "marcin.sciesinski" Date: Tue, 16 Feb 2021 22:15:22 -0800 Subject: [PATCH] Fixed possible parsing issue --- .../com/gempukku/lotro/game/ImportCards.java | 36 +++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/game/ImportCards.java b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/game/ImportCards.java index 633f54187..67d468fa9 100644 --- a/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/game/ImportCards.java +++ b/gemp-lotr/gemp-lotr-server/src/main/java/com/gempukku/lotro/game/ImportCards.java @@ -62,30 +62,38 @@ public class ImportCards { } private boolean isFromOfficialSet(String id) { - return Integer.parseInt(id.split("_")[0]) < 20; + try { + return Integer.parseInt(id.split("_")[0]) < 20; + } catch (NumberFormatException exp) { + return false; + } } private List getDecklist(String rawDecklist) { + int quantity; + String cardLine; + List result = new ArrayList<>(); for (String line : rawDecklist.split("~")) { if (line.length() == 0) continue; line = line.toLowerCase(); - int quantity; - - String cardLine; - if (Character.isDigit(line.charAt(0))) { - quantity = Character.getNumericValue(line.charAt(0)); - cardLine = line.substring(line.indexOf(" ")); - } else if (Character.isDigit(line.charAt(line.length() - 1))) { - quantity = Character.getNumericValue(line.charAt(line.length() - 1)); - cardLine = line.substring(0, line.indexOf(" ", line.length() - 3)); - } else { - quantity = 1; - cardLine = line; + try { + if (Character.isDigit(line.charAt(0))) { + quantity = Character.getNumericValue(line.charAt(0)); + cardLine = line.substring(line.indexOf(" ")); + } else if (Character.isDigit(line.charAt(line.length() - 1))) { + quantity = Character.getNumericValue(line.charAt(line.length() - 1)); + cardLine = line.substring(0, line.indexOf(" ", line.length() - 3)); + } else { + quantity = 1; + cardLine = line; + } + result.add(new CardCount(SortAndFilterCards.replaceSpecialCharacters(cardLine).trim(), quantity)); + } catch (Exception exp) { + // Ignore the card } - result.add(new CardCount(SortAndFilterCards.replaceSpecialCharacters(cardLine).trim(), quantity)); } return result; }