From aba8301758588b9a2879ec7e6f82c531a4144888 Mon Sep 17 00:00:00 2001 From: Midgard Date: Wed, 4 Mar 2020 22:56:45 +0100 Subject: [PATCH] Better condition for moving price to options There's no point in doing this for Ocean Garden's stuff that has a fixed price. --- app/hlds/parser.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/hlds/parser.py b/app/hlds/parser.py index 7728909..29d8aeb 100644 --- a/app/hlds/parser.py +++ b/app/hlds/parser.py @@ -25,15 +25,16 @@ def filter_instance(cls, iterable): class HldsSemanticActions: def location(self, ast) -> Location: choices = {choice.id: choice for choice in filter_instance(Choice, ast["items_"])} - dishes = filter_instance(Dish, ast["items_"]) + dishes: Iterable[Dish] = filter_instance(Dish, ast["items_"]) for dish in dishes: for i, choice in enumerate(dish.choices): if not isinstance(choice[1], Choice): 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 the dish has a fixed price first_single_choice = first(c[1] for c in dish.choices if c[0] == "single_choice") - if dish.price and first_single_choice: + price_range = dish.price_range() + if dish.price and price_range[0] != price_range[1] and first_single_choice: for option in first_single_choice.options: option.price += dish.price dish.price = 0