예제 #1
0
def main():

    # creation variables
    cook = Cook(COOK_SURNAME, COOK_NAME)
    government = Government()
    food = []
    panhandle_counter = 0

    # greeting
    print(GREETING_MESSAGE + cook.surname + " " + cook.name + "\n")

    # cooking food
    for i in range(AMOUNT_OF_DISHES):
        food.append(cook.cook_food())
    # the main action
    for i in range(AMOUNT_OF_CUSTOMERS):
        customer = Customer(random.choice(CUSTOMERS_SURNAMES), random.choice(CUSTOMERS_NAMES))
        print(str(customer) + "\n")


        while(customer.calorie_requirement > 0):

            print_menu(food)

            print(PURCHASE_CHOICE_MESSAGE)
            food_choice = input_num()
            if (check_element(food_choice)):
                continue

            if(customer.money >= food[food_choice - 1].cost):
                sell_food(food, food_choice, customer, cook)
                if(customer.health == 0):
                    customer.die()
                    break
            else:
                print(NOT_ENOUGH_MONEY)
                no_money_choice = input_num()
                if(no_money_choice == 1):
                    continue
                elif(no_money_choice == 21):
                    panhandle_action(panhandle_counter, customer, food)
                    if customer.health == 0 or customer.calorie_requirement > 0:
                        customer.die()
                        break
                else:
                    print("You have entered the invalid element!")
                    continue

        if not (customer.health == 0):
            print(THANKS_MESSAGE)

        if random.randint(1, 3) == 1:
            amount_of_seized = government.check_canteen(food, cook)
            if (amount_of_seized > 0):
                for i in range(amount_of_seized):
                    food.append(cook.cook_food())
            if cook.isBankrupt():
                break
    print("Amount of created food: " + str(Food.counter_food()))