TIY-ATL-ROR-2016-Feb / planeswalkr

A Magic the Gathering deckbuilder
0 stars 7 forks source link

Add Deck methods for statistical work #36

Open kingcons opened 8 years ago

kingcons commented 8 years ago

Add the following the methods to the deck model:

sample_hand that returns an array of 7 cards picked at random from the deck. mana_curve that returns a hash where the key is the converted_mana_cost and the value is the number of cards in the deck with that cost. card_type_curve that return a hash where the key is the card_type and the value is the number of cards in the deck with that card type

Testing for this will have be done by adding cards to a deck manually which is very easy now that the data model with rails c. For example,

deck = Deck.find(7)
cards = Card.first(20)
deck.cards << Card.find_by(name: "Forest")
deck.cards << Card.find_by(name: "Bad Moon")
deck.cards.push(Card.find_by(name: "Bad Moon"))
deck.cards = deck.cards + cards
kingcons commented 8 years ago

Jen is helping out.

kingcons commented 8 years ago

(See the graphs here: http://deckbox.org/sets/1392609 and sample hand functionality here: http://deckbox.org/sets/1392609/tools for an idea of what kind of data these methods should return.)

Note that these are just methods on the model! No view or controller level work needed for this ticket. :)