'''
Austin Richards 2/20/21

sandwich-maker.py uses pyinputplus to validate user input for sandwich preferences
'''
import pyinputplus as ip

def get_cost(food_name):
    '''gets the cost of items in sandwich_builder'''
    food_dict = {
        'sourdough':1.75, 
        'rye':2.0, 
        'wheat':1.50, 
        'white':1.25, 
        'chicken':2.0, 
        'turkey':1.50,
        'ham':2.0,
        'tofu':1.25,
        'cheddar':2.0,
        'swiss':2.5,
        'mozzarella':2.5,
        'yes':0.25, # toppings return 'yes' in sandwich_builder(), so I made them all cost 0.25
        'no':0      # saying no to a topping costs nothing
    }

    return food_dict[food_name]

def sandwich_builder():

    print('Enter your sandwich preferences below:\n')

    bread_prompt = 'What bread type would you like? (sourdough, rye, wheat, or white)\n'
    bread_type   = ip.inputChoice(['sourdough', 'rye', 'wheat', 'white'], prompt=bread_prompt)

    protein_prompt = 'What type of protein would you like? (chicken, turkey, ham, or tofu)\n'
    protein_type   = ip.inputChoice(['chicken', 'turkey', 'ham', 'tofu'], prompt=protein_prompt)

    mayo    = ip.inputYesNo(prompt='Would you like mayo?\n')
    mustard = ip.inputYesNo(prompt='Would you like mustard?\n')
    tomato  = ip.inputYesNo(prompt='Would you like tomato?\n')
    lettuce = ip.inputYesNo(prompt='Would you like lettuce?\n')
    
    like_cheese = ip.inputYesNo(prompt='Do you like cheese on your sandwich?\n')

    if like_cheese is 'yes':
        cheese_prompt = 'What kind of cheese would you like? (cheddar, swiss, mozzarella)\n'
        cheese_type   = ip.inputChoice(['cheddar', 'swiss', 'mozzarella'], prompt=cheese_prompt)

        sandwich = []
        cost = 0
        sandwich.extend([bread_type, protein_type, cheese_type, mayo, mustard, tomato, lettuce])
        
        for item in sandwich:
            cost += get_cost(item)

    else:
        sandwich = []
        cost = 0
        sandwich.extend([bread_type, protein_type, mayo, mustard, tomato, lettuce])
        
        for item in sandwich:
            cost += get_cost(item)


    how_many_prompt = 'How many sandwiches would you like?\n'
    how_many = ip.inputInt(min=1, prompt=how_many_prompt)

    print('\nFinal cost: ${}'.format(round(cost * how_many * 1.06, 2)))

sandwich_builder()
[((871, 946), 'pyinputplus.inputChoice', 'ip.inputChoice', (["['sourdough', 'rye', 'wheat', 'white']"], {'prompt': 'bread_prompt'}), "(['sourdough', 'rye', 'wheat', 'white'], prompt=bread_prompt)\n", (885, 946), True, 'import pyinputplus as ip\n'), ((1063, 1138), 'pyinputplus.inputChoice', 'ip.inputChoice', (["['chicken', 'turkey', 'ham', 'tofu']"], {'prompt': 'protein_prompt'}), "(['chicken', 'turkey', 'ham', 'tofu'], prompt=protein_prompt)\n", (1077, 1138), True, 'import pyinputplus as ip\n'), ((1154, 1200), 'pyinputplus.inputYesNo', 'ip.inputYesNo', ([], {'prompt': '"""Would you like mayo?\n"""'}), "(prompt='Would you like mayo?\\n')\n", (1167, 1200), True, 'import pyinputplus as ip\n'), ((1215, 1264), 'pyinputplus.inputYesNo', 'ip.inputYesNo', ([], {'prompt': '"""Would you like mustard?\n"""'}), "(prompt='Would you like mustard?\\n')\n", (1228, 1264), True, 'import pyinputplus as ip\n'), ((1279, 1327), 'pyinputplus.inputYesNo', 'ip.inputYesNo', ([], {'prompt': '"""Would you like tomato?\n"""'}), "(prompt='Would you like tomato?\\n')\n", (1292, 1327), True, 'import pyinputplus as ip\n'), ((1342, 1391), 'pyinputplus.inputYesNo', 'ip.inputYesNo', ([], {'prompt': '"""Would you like lettuce?\n"""'}), "(prompt='Would you like lettuce?\\n')\n", (1355, 1391), True, 'import pyinputplus as ip\n'), ((1415, 1477), 'pyinputplus.inputYesNo', 'ip.inputYesNo', ([], {'prompt': '"""Do you like cheese on your sandwich?\n"""'}), "(prompt='Do you like cheese on your sandwich?\\n')\n", (1428, 1477), True, 'import pyinputplus as ip\n'), ((2196, 2238), 'pyinputplus.inputInt', 'ip.inputInt', ([], {'min': '(1)', 'prompt': 'how_many_prompt'}), '(min=1, prompt=how_many_prompt)\n', (2207, 2238), True, 'import pyinputplus as ip\n'), ((1625, 1697), 'pyinputplus.inputChoice', 'ip.inputChoice', (["['cheddar', 'swiss', 'mozzarella']"], {'prompt': 'cheese_prompt'}), "(['cheddar', 'swiss', 'mozzarella'], prompt=cheese_prompt)\n", (1639, 1697), True, 'import pyinputplus as ip\n')]