From 431b363829d7791c2353b356c18ae168271669d2 Mon Sep 17 00:00:00 2001 From: galegosimpatico Date: Wed, 15 Nov 2017 22:04:20 +0100 Subject: [PATCH 1/3] Randomize starter decks presentation. --- data/objects/choose_deck_controller.cfg | 41 +++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/data/objects/choose_deck_controller.cfg b/data/objects/choose_deck_controller.cfg index c240c2b8..d29ee873 100644 --- a/data/objects/choose_deck_controller.cfg +++ b/data/objects/choose_deck_controller.cfg @@ -250,9 +250,14 @@ where selected_deck = lib.citadel.preferences[if(starter, 'selected_starter_deck', 'selected_custom_deck')] ) ] where decks_sorted = if (starter, - // Assume starter decks will always be carefully - // crafted with at least 50 cards each. - sort(values(decks), [a.custom_sort] < [b.custom_sort]), + rotate_decks( + // Assume starter decks will always be + // carefully crafted with at least 50 cards + // each. + sort( + values(decks), + [a.custom_sort] < [b.custom_sort]), + 1d32993 % 9), sort( filter(values(decks), size(value.cards) >= 50), [a.creation_time, a.name] < @@ -265,6 +270,36 @@ ]) ", + // This is a quick and dirty list rotator with no careful + // thinking of performance. Do NOT use it unless for lists + // known to be ALWAYS small. + rotate_decks: "def + ([Deck] decks, int positions) -> [Deck] + if (positions < 1, + decks, + rotate_decks( + single_decks_rotation(decks), + positions - 1)) + ", + + // Helps `rotate_decks(([Deck], int) -> [Deck])`. + single_decks_rotation: "def + ([Deck] decks) -> [Deck] +// dump( +// [ +// 'single_decks_rotation', +// map(decks, value.custom_sort), +// map(returning, value.custom_sort) +// ], returning) +// where returning = + // Clockwise rotation of 9 decks forming a mosaic. + [ + decks[3], decks[0], decks[1], decks[6], + decks[4], decks[2], decks[7], decks[8], + decks[5] + ] asserting size(decks) = 9 + ", + create_objects: "def() ->commands [ spawn('combo_label_controller', { xpos: x + lib.gui.py(int(228*scaling)), From ef73e4f7f2d646d56d7fab92a02296f106be4bb9 Mon Sep 17 00:00:00 2001 From: galegosimpatico Date: Sun, 17 Dec 2017 03:26:01 +0100 Subject: [PATCH 2/3] Rotate decks on a monthly basis. Rotate decks on a monthly basis instead of in a `choose_deck_controller` _creation time_ basis. --- data/objects/choose_deck_controller.cfg | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/data/objects/choose_deck_controller.cfg b/data/objects/choose_deck_controller.cfg index 6cca7322..cd670fc5 100644 --- a/data/objects/choose_deck_controller.cfg +++ b/data/objects/choose_deck_controller.cfg @@ -259,7 +259,18 @@ sort( values(decks), [a.custom_sort] < [b.custom_sort]), - 1d32993 % 9), + // There are nine deck widgets in the panel, + // only eight are rotating because one of them + // always stays in the middle. There are only + // eight rotations. + month_domini % 8) + // This formula guarantees year over year + // continuity until `int` overflow. + where month_domini = year * 12 + month + where month = int(split_date[1]) + where year = int(split_date[0]) + where split_date = split(date, ':') + where date = localdate(), sort( filter(values(decks), size(value.cards) >= 50), [a.creation_time, a.name] < From f34181b78fa09f88c3f8f99278ff355176f33af6 Mon Sep 17 00:00:00 2001 From: galegosimpatico Date: Sun, 14 Jan 2018 19:07:34 +0100 Subject: [PATCH 3/3] Using vanilla Anura. --- data/objects/choose_deck_controller.cfg | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/data/objects/choose_deck_controller.cfg b/data/objects/choose_deck_controller.cfg index cd670fc5..b1f13659 100644 --- a/data/objects/choose_deck_controller.cfg +++ b/data/objects/choose_deck_controller.cfg @@ -263,15 +263,15 @@ // only eight are rotating because one of them // always stays in the middle. There are only // eight rotations. - month_domini % 8) - // This formula guarantees year over year - // continuity until `int` overflow. - where month_domini = year * 12 + month - where month = int(split_date[1]) - where year = int(split_date[0]) - where split_date = split(date, ':') - where date = localdate(), - sort( + mensis_domini % 8 + ) + // This formula guarantees year over year continuity + // until `int` overflow. + where mensis_domini = year * 12 + month + where month = now.month + where year = now.year + where now = time() + , sort( filter(values(decks), size(value.cards) >= 50), [a.creation_time, a.name] < [b.creation_time, b.name])