diff --git a/client.png b/client.png new file mode 100644 index 0000000..3c74d02 Binary files /dev/null and b/client.png differ diff --git a/dishes.json b/dishes.json new file mode 100644 index 0000000..dbcb916 --- /dev/null +++ b/dishes.json @@ -0,0 +1,293 @@ +[ + { + "name": "margherita", + "price": 20, + "spiciness": false, + "vege": true, + "size": 30, + "allergens": "", + "ingridients": [ "cheese" ], + "drink_in": true + }, + { + "name": "hawajska", + "price": 22, + "spiciness": false, + "vege": false, + "size": 50, + "allergens": "", + "ingridients": [ "cheese", "ham", "pineapple" ], + "drink_in": true + }, + { + "name": "funghi", + "price": 22, + "spiciness": false, + "vege": true, + "size": 30, + "allergens": "", + "ingridients": [ "cheese", "mushrooms" ], + "drink_in": true + }, + { + "name": "light", + "price": 24, + "spiciness": false, + "vege": true, + "size": 30, + "allergens": "tomato", + "ingridients": [ "cheese", "tomato", "oregano", "pineapple" ], + "drink_in": false + }, + { + "name": "4 sery", + "price": 24, + "spiciness": false, + "vege": true, + "size": 50, + "allergens": "", + "ingridients": [ "cheese", "mozzarella", "parmesan", "gorgonzola" ], + "drink_in": true + }, + { + "name": "pepperoni", + "price": 25, + "spiciness": true, + "vege": false, + "size": 50, + "allergens": "", + "ingridients": [ "cheese", "onion", "pepperoni" ], + "drink_in": true + }, + { + "name": "salami", + "price": 25, + "spiciness": false, + "vege": false, + "size": 30, + "allergens": "", + "ingridients": [ "cheese", "salami" ], + "drink_in": true + }, + { + "name": "wegetarianska", + "price": 25, + "spiciness": false, + "vege": true, + "size": 50, + "allergens": "olives", + "ingridients": [ "cheese", "mushorooms", "onion", "corn", "pepper", "tomato", "olives", "shrimps" ], + "drink_in": false + }, + { + "name": "barbecue", + "price": 26, + "spiciness": false, + "vege": false, + "size": 30, + "allergens": "tomato", + "ingridients": [ "cheese", "bacon", "chicken", "onion", "Barbecue sauce", "tomato" ], + "drink_in": false + }, + { + "name": "miesna", + "price": 27, + "spiciness": false, + "vege": false, + "size": 30, + "allergens": "", + "ingridients": [ "cheese", "ham", "salami", "sausage", "bacon" ], + "drink_in": false + }, + { + "name": "paprykowa", + "price": 27, + "spiciness": true, + "vege": true, + "size": 30, + "allergens": "olives", + "ingridients": [ "cheese", "papper", "broccoli", "mushrooms", "olives", "pineapple" ], + "drink_in": true + }, + { + "name": "jalapeno", + "price": 27, + "spiciness": true, + "vege": false, + "size": 50, + "allergens": "", + "ingridients": [ "cheese", "bacon", "pepper", "onion", "jalapeno" ], + "drink_in": false + }, + { + "name": "barbecue wege", + "price": 27, + "spiciness": true, + "vege": true, + "size": 30, + "allergens": "feta", + "ingridients": [ "cheese", "pepper", "corn", "onion", "jalapeno", "feta" ], + "drink_in": false + }, + { + "name": "kebab", + "price": 32, + "spiciness": false, + "vege": false, + "size": 30, + "allergens": "feta", + "ingridients": [ "cheese", "kebab", "onion", "bacon", "mushrooms", "feta" ], + "drink_in": false + }, + { + "name": "grecka", + "price": 34, + "spiciness": false, + "vege": true, + "size": 50, + "allergens": "tomato", + "ingridients": [ "cheese", "olives", "shripms", "arugula", "tomato" ], + "drink_in": true + }, + { + "name": "piekielna", + "price": 37, + "spiciness": true, + "vege": false, + "size": 50, + "allergens": "olives", + "ingridients": [ "cheese", "chicken", "onion", "jalapeno", "olives", "pepperoni", "salami" ], + "drink_in": true + }, + { + "name": "drwala", + "price": 37, + "spiciness": true, + "vege": false, + "size": 30, + "allergens": "tomato", + "ingridients": [ "cheese", "cranberries", "onion", "bacon", "tomato", "salami", "sausage" ], + "drink_in": false + }, + { + "name": "grzybowa", + "price": 37, + "spiciness": false, + "vege": true, + "size": 50, + "allergens": "olives", + "ingridients": [ "cheese", "mushrooms", "broccoli", "olives", "corn", "arugula" ], + "drink_in": true + }, + { + "name": "staropolska", + "price": 40, + "spiciness": false, + "vege": false, + "size": 30, + "allergens": "", + "ingridients": [ "cheese", "chicken", "mushrooms", "sausage", "ham" ], + "drink_in": true + }, + { + "name": "goralska", + "price": 42, + "spiciness": false, + "vege": false, + "size": 30, + "allergens": "tomato", + "ingridients": [ "cheese", "sausage", "cranberries", "onion", "tomato", "ham" ], + "drink_in": true + }, + { + "name": "prosciutto", + "price": 43, + "spiciness": false, + "vege": false, + "size": 30, + "allergens": "olives", + "ingridients": [ "cheese", "ham", "arugula", "olives", "mushrooms" ], + "drink_in": true + }, + { + "name": "broccoli", + "price": 44, + "spiciness": false, + "vege": true, + "size": 50, + "allergens": "feta", + "ingridients": [ "cheese", "corn", "broccoli", "papper", "mushrooms", "feta" ], + "drink_in": true + }, + { + "name": "americana", + "price": 45, + "spiciness": true, + "vege": false, + "size": 50, + "allergens": "", + "ingridients": [ "cheese", "salami", "papperoni", "onion", "corn" ], + "drink_in": false + }, + { + "name": "farmerska", + "price": 47, + "spiciness": true, + "vege": false, + "size": 30, + "allergens": "", + "ingridients": [ "cheese", "sausage", "ham", "salami", "chicken", "pepperoni" ], + "drink_in": false + }, + { + "name": "nachos", + "price": 48, + "spiciness": true, + "vege": false, + "size": 30, + "allergens": "feta", + "ingridients": [ "cheese", "pepper", "nachos", "shrimps", "feta" ], + "drink_in": false + }, + { + "name": "texas", + "price": 48, + "spiciness": true, + "vege": false, + "size": 50, + "allergens": "tomato", + "ingridients": [ "cheese", "salami", "pepperoni", "jalapeno", "Barbecue sauce", "papper", "tomato" ], + "drink_in": true + }, + { + "name": "kurczak", + "price": 49, + "spiciness": false, + "vege": false, + "size": 50, + "allergens": "tomato", + "ingridients": [ "cheese", "chicken", "onion", "corn", "toamto" ], + "drink_in": false + }, + { + "name": "zielona", + "price": 50, + "spiciness": false, + "vege": true, + "size": 30, + "allergens": "olives", + "ingridients": [ "cheese", "broccoli", "papper", "olives", "mushrooms" ], + "drink_in": true + }, + { + "name": "mix", + "price": 50, + "spiciness": true, + "vege": false, + "size": 50, + "allergens": "feta", + "ingridients": [ "cheese", "ham", "salami", "papperoni", "sausage", "mushrooms", "corn", "broccoli", "pineapple", "feta" ], + "drink_in": false + } + +] \ No newline at end of file diff --git a/tiles.py b/tiles.py index 122d976..92f114a 100644 --- a/tiles.py +++ b/tiles.py @@ -1,3 +1,4 @@ +import random import time import numpy as np import pygame @@ -16,15 +17,7 @@ waiterImgL = pygame.image.load("waiterL.png") waiterImgR = pygame.image.load("waiterR.png") tableImg = pygame.image.load('table.png') chairImg = pygame.image.load('chair.png') - - -def pos_of_chair(table_cor, k): - pos = ((table_cor[0], table_cor[1] - 32), - (table_cor[0], table_cor[1] + 32), - (table_cor[0] - 32, table_cor[1]), - (table_cor[0] + 32, table_cor[1])) - return pos[k] - +clientImg = pygame.image.load('client.png') class Waiter: def __init__(self, loc): @@ -56,6 +49,22 @@ class Waiter: def right(self): self.loc[0] += 32 +class Client: + def __init__(self, loc): + self.loc = loc + + def render(self, surface): + surface.blit(clientImg, (self.loc[0], self.loc[1])) + +def generate_client(): + loc_for_client = [] + for i in chairs: + for j in i: + loc_for_client.append(j.loc) + + loc = (random.randint(0, len(loc_for_client))) + client_coordinates = (loc_for_client[loc]) + return client_coordinates class Table: def __init__(self, loc, num): @@ -72,6 +81,15 @@ class Table: def get_number_of_chairs(self): return self.num_of_chairs +def check_collision_with_table(x,y): + answer = False + for i in tables_coordinates: + if i[0] <= x <= i[0] + 32 and i[1] <= y <= i[1] + 32: + answer = True + else: + continue + return answer + class Chair: def __init__(self, loc): @@ -80,16 +98,38 @@ class Chair: def render(self, surface): surface.blit(chairImg, (self.loc[0], self.loc[1])) +def pos_of_chair(table_cor, k): + pos = ((table_cor[0], table_cor[1] - 32), + (table_cor[0], table_cor[1] + 32), + (table_cor[0] - 32, table_cor[1]), + (table_cor[0] + 32, table_cor[1])) + return pos[k] + +def check_collision_with_chair(x,y): + answer = False + for i in chairs: + for j in i: + if j.loc[0] <= x <= j.loc[0] + 32 and j.loc[1] <= y <= j.loc[1] + 32: + answer = True + else: + continue + return answer + class Food: - def __init__(self, name, price): + def __init__(self, name, price, spiciness, vege, size, allergens, ingridients, drink_in): self.name = name self.price = price + self.spiciness = spiciness + self.vege = vege + self.size = size + self.allergens = allergens + self.ingridients = ingridients + self.drink_in = drink_in def get_food(self): return self.name, self.price - class Menu: def __init__(self, card={}): self.card = card @@ -100,7 +140,6 @@ class Menu: def add_to_card(self, dish): self.card[str(len(self.card) + 1)] = dish - class Order(Table): def __init__(self, status=False, table=0, dishes=[]): self.table = table @@ -114,7 +153,6 @@ class Order(Table): def deliver(self): self.status = True - class Graph: def __init__(self, num_of_nodes, directed=True): self.m_num_of_nodes = num_of_nodes @@ -158,7 +196,6 @@ class Graph: path.reverse() return path - def pathFromTo(start, dest): tab2 = [42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57] tab4 = [41, 58] @@ -200,7 +237,6 @@ def pathFromTo(start, dest): path = graph.bfs(start, dest) return path - def numToX(num): digits = [int(a) for a in str(num)] if num >= 100: @@ -216,17 +252,14 @@ def numToX(num): x = x * 32 return x - def numToY(num): y = (math.floor(num / 20)) * 32 return y - def coordsToNum(coords): num = ((coords[1] // 32) * 20) + (coords[0] // 32) return int(num) - def waiterGo(dest): print("Path: ", (pathFromTo(coordsToNum(waiter.loc), dest))) go = [] @@ -259,7 +292,6 @@ def waiterGo(dest): pygame.display.update() time.sleep(0.2) - def mouseToNum(): x = pygame.mouse.get_pos()[0] y = pygame.mouse.get_pos()[1] @@ -267,7 +299,6 @@ def mouseToNum(): squareNum = coordsToNum(cordTab) return squareNum - class Map: def __init__(self): self.arr = np.zeros((20, 20)) @@ -282,7 +313,6 @@ class Map: def get_arr(self): return self.arr.transpose() - class Tile(): def __init__(self, parent=None, loc=None): self.parent = parent @@ -294,7 +324,6 @@ class Tile(): def __eq__(self, other): return self.position == other.position - def astar(map, start, end): start_tile = Tile(None, start) start_tile.g = start_tile.h = start_tile.f = 0 @@ -344,15 +373,39 @@ def astar(map, start, end): continue open_list.append(child) +def tell_preferences(): + possibilities = [[30, 40 ,50, None], + [True, False, None], + [True, False, None], + ["high", "low", None], + ["tomato", "olives", "feta", None], + ["sausage", "pineapple", "mushrooms", "shrimps", "salami", None], + [True, False, None]] + choices = [] + for i in possibilities: + choices.append(random.choice(i)) + preferences = { + "budget": choices[0], + "spiciness": choices[1], + "vege": choices[2], + "level_of_hunger": choices[3], + "allergy": choices[4], + "favorite_ingridient": choices[5], + "drink_in": choices[6] + } + return preferences + map = Map() waiter = Waiter([32, 32]) + tables = [] -chairs = [] tables_coordinates = ((32 * 3, 32 * 2), (32 * 7, 32 * 2), (32 * 12, 32 * 2), (32 * 16, 32 * 2), (32 * 3, 32 * 6), (32 * 7, 32 * 6), (32 * 12, 32 * 6), (32 * 16, 32 * 6), (32 * 3, 32 * 13), (32 * 7, 32 * 13), (32 * 12, 32 * 13), (32 * 16, 32 * 13), (32 * 3, 32 * 17), (32 * 7, 32 * 17), (32 * 12, 32 * 17), (32 * 16, 32 * 17)) + +chairs = [] for i in range(16): tables.append(Table(tables_coordinates[i], i)) arr = [] @@ -363,24 +416,7 @@ for i in range(16): for table in tables: map.add_table(table.loc) -def check_collision_with_table(x,y): - answer = False - for i in tables_coordinates: - if i[0] <= x <= i[0] + 32 and i[1] <= y <= i[1] + 32: - answer = True - else: - continue - return answer - -def check_collision_with_chair(x,y): - answer = False - for i in chairs: - for j in i: - if j.loc[0] <= x <= j.loc[0] + 32 and j.loc[1] <= y <= j.loc[1] + 32: - answer = True - else: - continue - return answer +client = Client(generate_client()) def main(): direction = [] @@ -418,16 +454,33 @@ def main(): if y > 608 or y < 32 or x > 608 or x < 32 or check_collision_with_table(y,x) or check_collision_with_chair(y, x): print("I can't go there") break + print(x,y) goal = (x // 32, y // 32) route = astar(map.get_arr(), (waiter.loc[1] // 32, waiter.loc[0] // 32), goal) direction = [(x[1] - y[1], x[0] - y[0]) for x, y in zip(route[1:], route)] + print(waiter.loc) break elif middle: - x = pygame.mouse.get_pos()[1] - y = pygame.mouse.get_pos()[0] - goal = (18,18) - route = astar(map.get_arr(), (waiter.loc[1] // 32, waiter.loc[0] // 32), goal) - direction = [(x[1] - y[1], x[0] - y[0]) for x, y in zip(route[1:], route)] + if client.loc[0] in [64, 128, 192, 256, 352, 416, 480, 544]: + while True: + x = client.loc[1] - 32 + y = client.loc[0] + goal = (x // 32, y // 32) + route = astar(map.get_arr(), (waiter.loc[1] // 32, waiter.loc[0] // 32), goal) + direction = [(x[1] - y[1], x[0] - y[0]) for x, y in zip(route[1:], route)] + break + elif client.loc[0] in [96, 224, 384, 512]: + while True: + x = client.loc[1] + y = client.loc[0] - 32 + goal = (x // 32, y // 32) + route = astar(map.get_arr(), (waiter.loc[1] // 32, waiter.loc[0] // 32), goal) + direction = [(x[1] - y[1], x[0] - y[0]) for x, y in zip(route[1:], route)] + break + print("Hello Sir, tell me yours preferences") + print("Here is my list of preferences") + print(tell_preferences()) + if len(direction) > 0: d = direction.pop(0) if d[0] == 1: @@ -443,6 +496,7 @@ def main(): if key[pygame.K_p]: pass waiter.render(display) + client.render(display) pygame.display.update()