fafranco82 / swdestinydb

Star Wars Destiny Deckbuilder
51 stars 26 forks source link

Feature Request: search / filter for decks that I already have all the cards and dice for #63

Open golike opened 7 years ago

golike commented 7 years ago

Subject line says it all. I'd love to be able to easily see a list of decks that I can make now with the cards and dice I currently own.

stopfstedt commented 7 years ago

this seems rather complicated to implement and problematic from a performance-perspective. great idea tho!

fafranco82 commented 7 years ago

Yes, a great idea that I've already thoguh, but as stopfstedt said, I need to think a way to this without harming performance.

stopfstedt commented 7 years ago

So i looked into this some more, and I believe player decks can be compared using bitmasks and bitwise operators. This would require some database denormalization - bitmask values would for collections and decks would have to be calculated and stored in columns on their respective tables.

See here for a formatted braindump on the subject https://gist.github.com/stopfstedt/6f094b9c9d03702754ed56cff6141553

The same approach, simplified, could be applied for battlefields and player-deck dice.

Now, this will not work for character cards that are selected for each deck, because the rule of two max does not apply.

Perhaps this could be a possible compromise:

Instead of "show me all decks that can be build from my collection" a search feature "show me all decks that i can build with character/dice X" can be added. Another take on this would be a "show me similar decks that I can build" on published decks (assuming that the user has all the characters-cards/dice for a given deck, which would have to be checked beforehand).

CAVEAT The approach outlined above has some issues regarding scalability - as new sets are added, more bitmask columns will have to be added. the SQL query for retrieving them will also have to grow. Performance will degrade over time.

@fafranco82 if there's any interest then I would have a stab at this over the holidays.

fafranco82 commented 7 years ago

Commented on Gist (I've read gist doen't notify you whe someone comments :S)

stopfstedt commented 7 years ago

@fafranco82 thanks for the feedback. i'll try the separate table approach first, seems more manageable. query performance remains to be seen...

thecoolestguy commented 7 years ago

👍

golike commented 7 years ago

For posterity, another approach I was thinking of would be to pull the barebones decklist (deck id, deck name, card id, card quantity, dice quantity) and user card collection (card id, card quantity, dice quantity) down to the client, and then process the filter in javascript. Would likely be easier on backend performance, though at the cost of some increased bandwidth. Also, it shouldn't require any db denormalization.

Just a thought. Thanks for jumping on this idea, guys!