Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Randomize starter decks presentation #167

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 50 additions & 4 deletions data/objects/choose_deck_controller.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,26 @@
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]),
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]),
// 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.
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])
Expand All @@ -267,6 +283,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)),
Expand Down