Skip to content

Commit

Permalink
fix 3 cards
Browse files Browse the repository at this point in the history
  • Loading branch information
Ali-Abbasi-Vadeghani committed Jun 26, 2021
1 parent a20de27 commit b187725
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/main/java/model/Deck.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,28 @@ public static ArrayList<CardData> getCardDataArrayFromIdArray(ArrayList<Integer>
CardData temp;
for (Integer id : cardIds) {
temp = CardData.getAllCardData().stream().filter(c -> c.getCardId() == id).findFirst().orElse(null);
if(temp != null) result.add(temp);
if (temp != null) result.add(temp);
}
return result;
}

public int numberOfThisCardInMainDeck(String nameOfCard, String nameOfDeck) {
Deck deck = getDeckWithName(nameOfDeck);
if (deck == null) return 0;
return Collections.frequency(deck.mainDeck, nameOfCard);
try {
return Collections.frequency(deck.mainDeck, Card.getCardIdByName(nameOfCard));
} catch (Exception e) {
return 0;
}
}

public int numberOfThisCardInSideDeck(String nameOfCard, String nameOfDeck) {
Deck deck = getDeckWithName(nameOfDeck);
return Collections.frequency(deck.sideDeck, nameOfCard);
try {
return Collections.frequency(deck.sideDeck, Card.getCardIdByName(nameOfCard));
} catch (Exception e) {
return 0;
}
}

public static void addCard(String nameOfCard, String nameOfDeck, String mainOrSide) {
Expand Down Expand Up @@ -120,8 +128,7 @@ public static boolean isThereThisCardInMainDeckOfThisDeck(String nameOfCard, Str
try {
if (deck == null) return false;
else return deck.mainDeck.contains(Card.getCardIdByName(nameOfCard));
}
catch (Exception e){
} catch (Exception e) {
return false;
}
}
Expand Down

0 comments on commit b187725

Please sign in to comment.