Fix price of common choices being inflated

This commit is contained in:
Midgard 2020-02-24 00:58:35 +01:00
parent 13560b04cd
commit 94d4a403cb
Signed by: midgard
GPG key ID: 511C112F1331BBB4

View file

@ -3,6 +3,7 @@
from glob import glob from glob import glob
from os import path from os import path
import itertools import itertools
from copy import deepcopy
from typing import Iterable, List, Union, Tuple from typing import Iterable, List, Union, Tuple
from tatsu import parse as tatsu_parse from tatsu import parse as tatsu_parse
from tatsu.ast import AST from tatsu.ast import AST
@ -28,7 +29,7 @@ class HldsSemanticActions:
for dish in dishes: for dish in dishes:
for i, choice in enumerate(dish.choices): for i, choice in enumerate(dish.choices):
if not isinstance(choice[1], Choice): if not isinstance(choice[1], Choice):
dish.choices[i] = (dish.choices[i][0], choices[choice[1]]) dish.choices[i] = (dish.choices[i][0], deepcopy(choices[choice[1]]))
# Move the base price to the first single choice if there is any # Move the base price to the first single choice if there is any
first_single_choice = first(c[1] for c in dish.choices if c[0] == "single_choice") first_single_choice = first(c[1] for c in dish.choices if c[0] == "single_choice")