[F] Fix choice saving

This commit is contained in:
Azalea (on HyDEV-Daisy) 2022-07-29 10:45:51 -04:00
parent 4835bbba40
commit de0d381ee2

View file

@ -186,9 +186,9 @@ def create_config() -> Config:
asc = get_distro_ascii() asc = get_distro_ascii()
asc_width = ascii_size(asc)[0] asc_width = ascii_size(asc)[0]
fore_back = get_fore_back() fore_back = get_fore_back()
asciis = [ arrangements = [
[*ColorAlignment('horizontal', fore_back=fore_back).recolor_ascii(asc, _prs).split('\n'), 'Horizontal'.center(asc_width)], ('Horizontal', ColorAlignment('horizontal', fore_back=fore_back)),
[*ColorAlignment('vertical').recolor_ascii(asc, _prs).split('\n'), 'Vertical'.center(asc_width)], ('Vertical', ColorAlignment('vertical'))
] ]
ascii_per_row = TERM_LEN // (asc_width + 2) ascii_per_row = TERM_LEN // (asc_width + 2)
@ -204,8 +204,8 @@ def create_config() -> Config:
else: else:
choices = random.sample(perm, random_count) choices = random.sample(perm, random_count)
choices = [{i + 1: n for i, n in enumerate(c)} for c in choices] choices = [{i + 1: n for i, n in enumerate(c)} for c in choices]
asciis += [[*ColorAlignment('custom', r).recolor_ascii(asc, _prs).split('\n'), f'random{i}'.center(asc_width)] arrangements += [(f'random{i}', ColorAlignment('custom', r)) for i, r in enumerate(choices)]
for i, r in enumerate(choices)] asciis = [[*ca.recolor_ascii(asc, _prs).split('\n'), k.center(asc_width)] for k, ca in arrangements]
while asciis: while asciis:
current = asciis[:ascii_per_row] current = asciis[:ascii_per_row]
@ -224,12 +224,13 @@ def create_config() -> Config:
if choice == 'roll': if choice == 'roll':
continue continue
if choice in ['horizontal', 'vertical']: # Save choice
color_alignment = ColorAlignment(choice) arrangement_index = {k.lower(): ca for k, ca in arrangements}
elif choice.startswith('random'): if choice in arrangement_index:
color_alignment = ColorAlignment('custom', choices[int(choice[6])]) color_alignment = arrangement_index[choice]
else: else:
raise NotImplementedError() print('Invalid choice.')
continue
break break