Deck colors
This commit is contained in:
parent
7015655663
commit
774dbda97d
2 changed files with 20 additions and 1 deletions
|
@ -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)
|
||||
|
|
|
@ -1,10 +1,18 @@
|
|||
{% extends "main.html" %}
|
||||
{% load math %}
|
||||
|
||||
{% block content %}
|
||||
<h2>Decks</h2>
|
||||
<ul>
|
||||
{% for deck in decks %}
|
||||
<li><a href="{% url mtgweb.decks.views.detail deck.id %}">{{ deck }}</a></li>
|
||||
<li>
|
||||
<a href="{% url mtgweb.decks.views.detail deck.id %}">{{ deck }}</a>
|
||||
{% for color, count in deck.colors.items %}
|
||||
{% if count > 0 %}
|
||||
<span class="mana {{ color }}"></span>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endblock %}
|
||||
|
|
Loading…
Reference in a new issue