diff --git a/analyzer/models.py b/analyzer/models.py index c464b0e..edcff37 100755 --- a/analyzer/models.py +++ b/analyzer/models.py @@ -28,6 +28,17 @@ class Deck(models.Model): cards = models.ManyToManyField(Card, through='Included') def __unicode__(self): return self.name + def colors(self): + mana = {} + symbols = 0 + for card in self.cards.all(): + cost = mtg.ManaCost(card.cost) + for color, count in cost.mana.mana.iteritems(): + if not color in mana.keys(): + mana[color] = 0 + mana[color] += count + symbols += count + return mana class Included(models.Model): card = models.ForeignKey(Card) deck = models.ForeignKey(Deck) diff --git a/templates/decks/index.html b/templates/decks/index.html index a2eeabf..fe0e0ec 100755 --- a/templates/decks/index.html +++ b/templates/decks/index.html @@ -1,10 +1,18 @@ {% extends "main.html" %} +{% load math %} {% block content %}