From e541e4cc31f63ba548f668f09a8d379075dd8390 Mon Sep 17 00:00:00 2001 From: Ross Date: Sat, 6 Dec 2025 22:54:55 +0000 Subject: [PATCH] . --- .../templates/cards/_card_inner_design4.html | 78 ++++++++++-------- cards/views.py | 25 ++++++ db.sqlite3 | Bin 151552 -> 151552 bytes 3 files changed, 67 insertions(+), 36 deletions(-) diff --git a/cards/templates/cards/_card_inner_design4.html b/cards/templates/cards/_card_inner_design4.html index 4341bce..aca1c89 100644 --- a/cards/templates/cards/_card_inner_design4.html +++ b/cards/templates/cards/_card_inner_design4.html @@ -48,50 +48,56 @@
-
-
Speed
-
-
{{ card.speed_display }}
- -
-
Weight
-
-
{{ card.weight_display }}
- -
-
Intelligence
-
-
{{ card.intelligence_display }}
- -
-
Height
-
-
{{ card.height_display }}
- + {% endwith %} + {% if card.facts_list %}
Fun facts diff --git a/cards/views.py b/cards/views.py index 7ea1914..4f10f61 100644 --- a/cards/views.py +++ b/cards/views.py @@ -456,6 +456,31 @@ def print_preview(request): for i in range(0, len(ordered), 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 columns = 1 if per_page == 1 else 2 diff --git a/db.sqlite3 b/db.sqlite3 index b93ff934238b5b6ae601f1b13cf5f6ebc1abed6d..a685a3fcad31d44ecef0581096b75f2998eb1273 100644 GIT binary patch delta 304 zcmW;FKS%;`90l;-_v@X1kn`E#;GZ&y1|d2p2`TNkGiYpV>HI9$3pIM7c9Qz%DU^NfOlP-RQ! ztRjS$hC1iN|2@YiEBT{yhBn<)jth~PU(7pp6e62RYh_|GoN9pNPLWSZ>wdJ?$S0Re z{16Y;#guqbf_s5Ba{hbuEwZkRwW^YE6RUjb;qK62Nhqfv=BCqHY4Wupw@faO+BG^c pd1rE#H2Gq3F;*9fvmJ-XcCOhA-b%Kho+)yrdYM8nzg?^`p8N*7?%Re^C;R z5NJa$6rZv7P`~|B+{y3@uK!e)v-A9 zuaU+1C=uzJ3BxK&lNxgfTBmF}#%wmGAo kZ7$7+cStAc))F8o%~(;0N!tvO$~xRpBZnP->@Y`v0k+;td;kCd