From 774dbda97d84507a7573c847e6737e0426a6d8fc Mon Sep 17 00:00:00 2001 From: Correl Roush Date: Tue, 21 Sep 2010 21:37:00 -0400 Subject: [PATCH] Deck colors --- analyzer/models.py | 11 +++++++++++ templates/decks/index.html | 10 +++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) 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 %}

Decks

{% endblock %}