from italianfood.dough import PizzaDough
from italianfood.ovens import bake_pizza

STANDARD_FLOUR_WEIGHT = 180  # grams per pizza
STANDARD_WATER_WEIGHT = 126  # grams per pizza
STANDARD_SALT_WEIGHT = 2  # grams per pizza
STANDARD_YEAST_WEIGHT = 1  # grams per pizza

MARGARITA_TOPPINGS = ["tomato sauce", "mozzarella cheese", "fresh basil"]
MUSHROOM_TOPPINGS = ["tomato sauce", "mozzarella cheese", "mushrooms"]


class Pizza:
    dough: PizzaDough
    num_pizzas: int = 1
    is_ready: bool = False

    def __init__(self, dough, num_pizza_balls):
        if num_pizza_balls < 1:
            raise ValueError("Number of pizza balls must be at least 1.")
        self.num_pizzas = num_pizza_balls
        self.dough = dough
        self.make_pizza_balls()

    def make_pizza_balls(self):
        self.weight_per_pizza_ball = self.dough.total_weight / self.num_pizzas
        print(
            f"Each Pizza will be made out of {self.weight_per_pizza_ball} g dough.\n..."
        )
        print("Now imagine expert pizza tossing skills!\n...")
        return self

    def add_toppings(self, toppings):
        self.toppings = toppings
        print(f"Adding {self.toppings} to pizza(s).\n...")
        return self


def make_margarita_pizza_more_readable(num_pizzas: int = 1):
    dough = make_pizza_dough(num_pizzas)
    baked_pizza = make_and_bake_pizza(dough, num_pizzas, MARGARITA_TOPPINGS)
    return baked_pizza


def make_pizza_dough(num_pizzas: int = 1):
    dough = PizzaDough(
        flour_weight=STANDARD_FLOUR_WEIGHT * num_pizzas,
        water_weight=STANDARD_WATER_WEIGHT * num_pizzas,
        salt_weight=STANDARD_SALT_WEIGHT * num_pizzas,
        yeast_weight=STANDARD_YEAST_WEIGHT * num_pizzas,
    )
    return dough


def make_and_bake_pizza(dough, num_pizzas, toppings):
    pizza = Pizza(dough=dough, num_pizza_balls=num_pizzas)
    pizza.add_toppings(toppings)
    baked_pizza = bake_pizza(pizza)
    return baked_pizza


def make_pizza_reusable(num_pizzas, toppings):
    dough = make_pizza_dough(num_pizzas)
    baked_pizza = make_and_bake_pizza(dough, num_pizzas, toppings)
    return baked_pizza


def pizza_tasting_menu():
    all_pizzas = []

    margarita_pizza = make_pizza_reusable(num_pizzas=1, toppings=MARGARITA_TOPPINGS)
    all_pizzas.append(margarita_pizza)

    mushroom_pizza = make_pizza_reusable(num_pizzas=2, toppings=MUSHROOM_TOPPINGS)
    all_pizzas.append(mushroom_pizza)

    return all_pizzas
