.
This commit is contained in:
@@ -48,7 +48,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<div style="padding:8px 10px; border-top:1px solid rgba(0,0,0,0.04); background:#fafafa;">
|
<div style="padding:8px 10px; border-top:1px solid rgba(0,0,0,0.04); background:#fafafa;">
|
||||||
<div style="display:flex; flex-direction:column; gap:6px;">
|
<div style="display:flex; flex-direction:column; gap:6px;">
|
||||||
<div style="display:flex; justify-content:space-between; align-items:center;">
|
{% with s=card.speed_percent w=card.weight_percent it=card.intelligence_percent h=card.height_percent %}
|
||||||
|
<div style="display:flex; justify-content:space-between; align-items:center; {% if card.is_top_trump and 'speed' in card.best_stats %}box-shadow:inset 6px 0 0 #1abc9c; border-radius:4px;{% endif %}">
|
||||||
<div style="font-size:0.9rem; font-weight:700">Speed</div>
|
<div style="font-size:0.9rem; font-weight:700">Speed</div>
|
||||||
<div style="display:flex; align-items:center; gap:8px;">
|
<div style="display:flex; align-items:center; gap:8px;">
|
||||||
<div style="font-weight:800">{{ card.speed_display }}</div>
|
<div style="font-weight:800">{{ card.speed_display }}</div>
|
||||||
@@ -59,7 +60,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div style="display:flex; justify-content:space-between; align-items:center;">
|
|
||||||
|
<div style="display:flex; justify-content:space-between; align-items:center; {% if card.is_top_trump and 'weight' in card.best_stats %}box-shadow:inset 6px 0 0 #d35400; border-radius:4px;{% endif %}">
|
||||||
<div style="font-size:0.9rem; font-weight:700">Weight</div>
|
<div style="font-size:0.9rem; font-weight:700">Weight</div>
|
||||||
<div style="display:flex; align-items:center; gap:8px;">
|
<div style="display:flex; align-items:center; gap:8px;">
|
||||||
<div style="font-weight:800">{{ card.weight_display }}</div>
|
<div style="font-weight:800">{{ card.weight_display }}</div>
|
||||||
@@ -70,7 +72,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div style="display:flex; justify-content:space-between; align-items:center;">
|
|
||||||
|
<div style="display:flex; justify-content:space-between; align-items:center; {% if card.is_top_trump and 'intelligence' in card.best_stats %}box-shadow:inset 6px 0 0 #8e44ad; border-radius:4px;{% endif %}">
|
||||||
<div style="font-size:0.9rem; font-weight:700">Intelligence</div>
|
<div style="font-size:0.9rem; font-weight:700">Intelligence</div>
|
||||||
<div style="display:flex; align-items:center; gap:8px;">
|
<div style="display:flex; align-items:center; gap:8px;">
|
||||||
<div style="font-weight:800">{{ card.intelligence_display }}</div>
|
<div style="font-weight:800">{{ card.intelligence_display }}</div>
|
||||||
@@ -81,7 +84,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div style="display:flex; justify-content:space-between; align-items:center;">
|
|
||||||
|
<div style="display:flex; justify-content:space-between; align-items:center; {% if card.is_top_trump and 'height' in card.best_stats %}box-shadow:inset 6px 0 0 #27ae60; border-radius:4px;{% endif %}">
|
||||||
<div style="font-size:0.9rem; font-weight:700">Height</div>
|
<div style="font-size:0.9rem; font-weight:700">Height</div>
|
||||||
<div style="display:flex; align-items:center; gap:8px;">
|
<div style="display:flex; align-items:center; gap:8px;">
|
||||||
<div style="font-weight:800">{{ card.height_display }}</div>
|
<div style="font-weight:800">{{ card.height_display }}</div>
|
||||||
@@ -92,6 +96,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% endwith %}
|
||||||
|
|
||||||
{% if card.facts_list %}
|
{% if card.facts_list %}
|
||||||
<div style="margin-top:6px; border-top:1px solid rgba(0,0,0,0.03); padding-top:6px; font-size:0.85rem; color:#333;">
|
<div style="margin-top:6px; border-top:1px solid rgba(0,0,0,0.03); padding-top:6px; font-size:0.85rem; color:#333;">
|
||||||
<strong style="display:block; margin-bottom:4px;">Fun facts</strong>
|
<strong style="display:block; margin-bottom:4px;">Fun facts</strong>
|
||||||
|
|||||||
@@ -456,6 +456,31 @@ def print_preview(request):
|
|||||||
for i in range(0, len(ordered), per_page):
|
for i in range(0, len(ordered), per_page):
|
||||||
pages.append(ordered[i:i+per_page])
|
pages.append(ordered[i:i+per_page])
|
||||||
|
|
||||||
|
# -- Top-trump calculation across the full selection -----------------
|
||||||
|
# For each card compute its best stat percent (0-100) and the stat(s)
|
||||||
|
# that achieve that percent. Then find the global maximum best-value and
|
||||||
|
# mark any card whose best-value equals that maximum as a top-trump.
|
||||||
|
all_best_values = []
|
||||||
|
for c in ordered:
|
||||||
|
# compute percents using model helpers
|
||||||
|
s = c.speed_percent()
|
||||||
|
w = c.weight_percent()
|
||||||
|
it = c.intelligence_percent()
|
||||||
|
h = c.height_percent()
|
||||||
|
# map names to values
|
||||||
|
stats = {'speed': s, 'weight': w, 'intelligence': it, 'height': h}
|
||||||
|
max_val = max(stats.values())
|
||||||
|
best_stats = [name for name, val in stats.items() if val == max_val]
|
||||||
|
# attach computed attributes so templates can read them
|
||||||
|
setattr(c, 'best_value', max_val)
|
||||||
|
setattr(c, 'best_stats', best_stats)
|
||||||
|
all_best_values.append(max_val)
|
||||||
|
# determine global maximum and mark cards as top-trump if they match
|
||||||
|
global_max = max(all_best_values) if all_best_values else 0
|
||||||
|
for c in ordered:
|
||||||
|
setattr(c, 'is_top_trump', getattr(c, 'best_value', 0) == global_max)
|
||||||
|
# ---------------------------------------------------------------------
|
||||||
|
|
||||||
# Determine grid columns for layout: use 1 column for 1-up, 2 columns for 2/4-up
|
# Determine grid columns for layout: use 1 column for 1-up, 2 columns for 2/4-up
|
||||||
columns = 1 if per_page == 1 else 2
|
columns = 1 if per_page == 1 else 2
|
||||||
|
|
||||||
|
|||||||
BIN
Binary file not shown.
Reference in New Issue
Block a user