nicho92 / MtgDesktopCompanion

Cards manager for magic the gathering
Apache License 2.0
165 stars 35 forks source link

Draw probabilities need no card split by Edition #233

Closed shithead closed 2 years ago

shithead commented 2 years ago

merge cards with same name to one probability.

E.g. Mountains from different editions can merge his draw probabilities.

nicho92 commented 2 years ago

can you show me a screencap of the error ? You mean mountain from differents sets are are not merged ? image

nicho92 commented 2 years ago

ok i see

shithead commented 2 years ago

Hi I want to help in this issue.

My Idea to do it is to create an extra MagicDeck var in class DrawProbabilityPanel, which hold unique cardnames without edition information and merged counter.

Do you think that's a good strategy?

nicho92 commented 2 years ago

We should update DrawProbabilityPanel.initDeck() function, and build a "dynamic" model with correct cards count... i'm working on it ;)

shithead commented 2 years ago

okay i work on some code like this.

public class MagicDeck implements MTGStorable {

 public MagicDeck getMergedDeck() {
   // found double named cards
   // get count of cards
   // int getCardCountByName(cardName);
   // set new Deck without edition information

   List<MagicCard> mergeCardList = new ArrayList<MagicCard>();
   List<String> cardNames = new ArrayList<String>();
   getMainAsList().forEach(mc -> {

     if (! cardNames.contains(mc.getName())) {
        getMainAsList().stream().filter(k->k.getName().equalsIgnoreCase(mc.getName())).forEach(k->mergeCardList.add(mc));
       cardNames.add(mc.getName());
     }
   });

   MagicDeck mergedDeck = toDeck(mergeCardList);
   mergedDeck.setName("merged cards deck");
   return mergedDeck;
 }

but i get an outofbound. sorry im not good in java.

shithead commented 2 years ago

so this code get the right cards back, but i still get a java.lang.ArrayIndexOutOfBoundsException

shithead commented 2 years ago

now its work, here my diff draw_probability.diff.txt