예제 #1
0
    def test_init_menus(self):
        api_dict = {
            "TestBar":
            self.MockAPIPlan(
                self.mockAPI,
                ["shit", "shit", "Stone", "Stone", "Founders"]).executor(),
        }
        good_menu1 = Menu("TestBar", [
            MenuSection("1", "Title1",
                        [Beer("name Stone", "style", 8, "brewery")])
        ])
        good_menu2 = Menu("TestBar", [
            MenuSection("1", "Title1",
                        [Beer("name Founders", "style", 8, "brewery")])
        ])

        mm = MenuManager(api_dict=api_dict)
        self.assertEqual({}, mm.find_good_bars())

        mm.update_menus()
        self.assertEqual({}, mm.find_good_bars())

        mm.update_menus()
        self.assertEqual({"TestBar": good_menu1}, mm.find_good_bars())

        mm.update_menus()
        self.assertEqual({}, mm.find_good_bars())

        mm.update_menus()
        self.assertEqual({"TestBar": good_menu2}, mm.find_good_bars())
예제 #2
0
 def test_GetMenu(self):
     bars = {
         "TestBar": 0,
     }
     mr = MenuReader(bars)
     expected = Menu("TestBar")
     expected.load_beers_from_file()
     self.assertEqual(expected, mr.get_menu_of("TestBar"))
예제 #3
0
class TestTelegramBotUtil(unittest.TestCase):

    beer_1 = Beer("Breakfast Stout", "Stout", "8.6", "Founders")
    beer_2 = Beer("Stone IPA", "IPA", "5.6", "Stone")
    section_1 = MenuSection("111", "On Tap (2 bier)", [beer_1, beer_2])
    empty_section = MenuSection("222", "Empty", [])
    menu_1 = Menu("TAP", [section_1, empty_section])
    menu_2 = Menu("FooBar", [section_1, empty_section])

    beer_1_text = "Breakfast Stout\n" \
                    "8.6% ABV\n" \
                    "Stout\n" \
                    "Founders\n"
    beer_2_text = "Stone IPA\n" \
                  "5.6% ABV\n" \
                  "IPA\n" \
                  "Stone\n"
    section_1_text = "_On Tap_ (2 Beers)\n" \
                    "   ---Beer 1---\n" \
                    "{}" \
                    "   ---Beer 2---\n" \
                    "{}".format(beer_1_text, beer_2_text)
    menu_1_text = "*TAP*\n" \
                  "{}".format(section_1_text)

    menu_2_text = "*FooBar*\n" \
                  "{}".format(section_1_text)

    def test_beer_in_markdown(self):
        actual_text = util.beer_to_markdown(self.beer_1)
        self.assertEqual(actual_text, self.beer_1_text)

    def test_menusection_in_markdown(self):
        actual_text = util.section_to_markdown(self.section_1)
        self.assertEqual(actual_text, self.section_1_text)

    def test_menu_in_markdown(self):
        actual_text = util.menu_to_markdown(self.menu_1)
        self.assertEqual(actual_text, self.menu_1_text)

    def test_multiple_menus_in_markdown(self):
        actual_text = util.multiple_menus_to_markdown({
            "TAP": self.menu_1,
            "FooBar": self.menu_2
        })
        self.assertEqual(actual_text,
                         self.menu_1_text + "\n" + self.menu_2_text)
예제 #4
0
 def __init__(self):
     self.name = ""
     self.owner = Owner()
     self.description = ""
     self.clientele = ""
     self.costPerNight = ""
     self.menu = Menu()
     self.lifestyle = Lifestyle.SQUALID
     self.cost = ""
예제 #5
0
def menu():
    form = request.form
    if session['search'] == "Job Openings":
        result = Menu().search_job(form['start'], form['end'],
                                   form['title']).sort_values(
                                       by=['update_date'], ascending=False)
        return render_template('menu/jobs.html', results=result)
    elif session['search'] == "Company":
        result = Menu().search_company(form['location'], form['region'],
                                       form['country'])
        return render_template('menu/company.html', results=result)
    elif session['search'] == "Both":
        df = Menu().search_both(form['start'], form['end'], form['title'],
                                form['location'], form['region'],
                                form['country'])
        result = Menu().group_by(df, 'locality').sort_values(by='count',
                                                             ascending=False)
        return render_template('menu/openings.html', results=result)
예제 #6
0
 def __init__(self, window):
     self.window = window
     self.menu = Menu(window)
     self.pantallaJuego = None
     self.jugadores = []
     self.numeroRonda = 0
     self.dado = Dado(300, 300, 100, 100, self.window)
     self.temporizador = None
     self.mazoPuzzles = []
     self.numeroJugadores = 0
     self.enJuego = False
     self.enMenu = True
     self.enRonda = False
     self.finRonda = False
     self.limiteFilasPorJugadorEnRonda = [0 for _ in range(4)]
     self.numeroGanadores = 0
     self.maximoMovimientosFichas = 0
     self.tiempoAuxiliar = 0
     self.tiempoAleatorio = 0
예제 #7
0
    def post(self):
        from models.role import Role, RoleHasApi, RoleHasMenu
        from models.menu import Menu, MenuHasApi

        from app import db
        try:
            role_id = request.json.get('id')
            if not Role.check_role(self.app_id, role_id):
                return '权限错误', 400
            now_menus = request.json.get('menu_ids')
            old_menus = RoleHasMenu.get_menu(role_id)
            need_delete = list(set(old_menus) - set(now_menus))
            need_add = list(set(now_menus) - set(old_menus))
            for n in need_add:
                if Menu.check_menu(self.app_id, n):
                    m = RoleHasMenu()
                    m.role_id = role_id
                    m.menu_id = n
                    db.session.add(m)
                    # 查询menu_has_api,   menu_id拥有的俄api_id,自动添加到role_has_api中
                    temp = MenuHasApi.get_api(n)
                    for x in temp:
                        rha = RoleHasApi()
                        rha.role_id = role_id
                        rha.api_id = x
                        db.session.add(rha)

            for d in need_delete:
                if Menu.check_menu(self.app_id, d):
                    m = RoleHasMenu.query.filter_by(role_id=role_id,
                                                    menu_id=d).first()
                    # 查询 menu_has_api,  menu_id拥有的api_id,删除role_has_api
                    temp = MenuHasApi.get_api(m.menu_id)
                    for x in temp:
                        c = RoleHasApi.query.filter_by(role_id=role_id,
                                                       api_id=x).first()
                        db.session.delete(c)
                    db.session.delete(m)
            db.session.commit()
        except Exception as e:
            db.session.rollback()
예제 #8
0
def map():
    if request.method == "POST":
        if 'company' in request.form:
            company = request.form['company']
            continent = request.form['continent']
            current_app.logger.info(continent)
            return render_template('menu/map.html', continent=continent)
        if 'title' in request.form:
            form = request.form
            result = Menu().search_job(form['start'], form['end'],
                                       form['title']).sort_values(
                                           by=['update_date'], ascending=False)
            current_app.logger.info("Get the titles")
            return render_template('menu/map.html', results=result)
    return render_template('menu/map.html')
예제 #9
0
 def post(self):
     from models.menu import Menu
     from app import db
     m = Menu()
     m.app_id = self.app_id
     m.name = request.json.get('name')
     m.parent_id = request.json.get('parent_id', None)
     m.refer_path = request.json.get('refer_path', None)
     db.session.add(m)
     db.session.commit()
예제 #10
0
    def build_menu_from_html(self, page):
        tree = html.document_fromstring(page)
        m = Menu(self.bar_name)

        # Get all menu sections
        sections = tree.find_class("menu-section")

        for section in sections:
            # Get section details
            section_id_string = section.get("id")
            section_id = re.search("section_(.+?)$",
                                   section_id_string).group(1)
            title = self.sanitize_markdown_characters(
                section.find_class("menu-section-header")[0].text_content())
            beer_list = section.find_class("menu-section-list")
            beers = beer_list[0].getchildren()
            # If not all beers are loaded
            if len(section.find_class("show-more-section")) > 0:
                logging.debug(
                    "Loading more beers for {}.".format(section_id_string))
                beers += self.load_section(section_id)

            # There are beers in this section
            if len(beers) > 0:
                ms = MenuSection(section_id, title)
                for beer in beers:
                    details = beer.find_class("beer-details")[0]
                    h5, h6 = details.getchildren()
                    name, style = h5.getchildren()
                    abv = h6.getchildren()[0]
                    brewery = h6.getchildren()[0].getchildren()[0]
                    ms.beers.append(
                        Beer(
                            self.sanitize_markdown_characters(
                                name.text_content()),
                            self.sanitize_markdown_characters(
                                style.text_content()),
                            self.sanitize_markdown_characters(
                                self.get_abv_from_span(abv.text_content())),
                            self.sanitize_markdown_characters(
                                brewery.text_content())))
                m.sections.append(ms)
        return m
예제 #11
0
    def post(self):
        from models.menu import MenuHasApi, Menu
        from models.api import Api
        from models.role import RoleHasApi, RoleHasMenu

        from app import db
        try:
            menu_id = request.json.get('id')
            if not Menu.check_menu(self.app_id, menu_id):
                return '权限错误', 400
            now_apis = request.json.get('api_ids')
            old_apis = MenuHasApi.get_api(menu_id)
            need_delete = list(set(old_apis) - set(now_apis))
            need_add = list(set(now_apis) - set(old_apis))
            # 根据menu_id 查询roles
            roles = RoleHasMenu.get_role(menu_id)
            for n in need_add:
                if Api.check_api(self.app_id, n):
                    m = MenuHasApi()
                    m.menu_id = menu_id
                    m.api_id = n
                    db.session.add(m)
                    # 将role_id,n写入role_has_api
                    for r in roles:
                        rha = RoleHasApi()
                        rha.role_id = r
                        rha.api_id = n
                        db.session.add(rha)
            for d in need_delete:
                if Api.check_api(self.app_id, d):
                    m = MenuHasApi.query.filter_by(menu_id=menu_id,
                                                   api_id=d).first()
                    # 删除role_has_api中角色对应的api
                    temp = RoleHasApi.query.filter(
                        RoleHasApi.api_id == d,
                        RoleHasApi.role_id.in_(roles)).all()
                    for t in temp:
                        db.session.delete(t)
                    db.session.delete(m)
            db.session.commit()
        except Exception as e:
            db.session.rollback()
예제 #12
0
    def post(self):
        op = request.form.get("op")
        if op == "search":
            keyword = request.form.get("keyword")
            return redirect(url_for("search_result") + "?keyword=" + keyword)
        elif op == "review":
            restid = request.form.get("restid")
            rating = request.form.get("rating")
            content = request.form.get("review_content")
            country = request.form.get("country")

            revid = Review.insert(restid, float(rating), content, country)
            menuid = Menu.insert_menu(int(restid), int(revid))

            for i in request.form:
                if i.startswith("menu"):
                    course = request.form.get(i).split(":")
                    Course.insert_course(menuid, course[0], course[1])

            return redirect(url_for("rest_index") + "?id=" + restid)
예제 #13
0
    def get(self):
        # 根据menu_id查询对应的api_id。
        # 需返回已分配的,和未分配的API
        from models.menu import MenuHasApi, Menu
        from models.api import Api
        returnObj = {}
        assigned_apis = []
        not_assigned_apis = []
        menu_id = request.args.get('id')
        if not Menu.check_menu(self.app_id, menu_id):
            return '权限错误', 400

        assigned_apis_in_db = MenuHasApi.query.filter_by(menu_id=menu_id).all()
        all_apis_in_db = Api.query.filter_by(app_id=self.app_id).all()

        assigned_api_ids = []
        for a in assigned_apis_in_db:
            assigned_api_ids.append(a.api_id)
            assigned_apis.append({
                'id': a.api_id,
                'path': a.api.path,
                'method': a.api.method,
                'remark': a.api.remark
            })
        assigned_api_ids = set(assigned_api_ids)

        for a in all_apis_in_db:
            if a.id not in assigned_api_ids:
                not_assigned_apis.append({
                    'id': a.id,
                    'path': a.path,
                    'method': a.method,
                    'remark': a.remark
                })

        returnObj['not_assigned_apis'] = not_assigned_apis
        returnObj['assigned_apis'] = assigned_apis

        return returnObj
예제 #14
0
def get_taverns():
    menu = Menu()
    menu.breakfast = "poached eggs and potatoes and cup of fruit"
    menu.lunch = "chicken noodle soup"
    menu.dinner = "steak and green beans"
    menu.lifestyle = Lifestyle.WEALTHY
    owner = Owner()
    owner.name = "Gentlemen Johnny"
    owner.description = "A well dressed copper dragonborn full of mirth"
    tavern = Tavern()
    tavern.name = "Countryside Palace"
    tavern.clientele = "A single young man sipping a cup of tea."
    tavern.description = "A victorian style house with a cozy hearth and colorful fabrics"
    tavern.lifestyle = Lifestyle.WEALTHY
    tavern.menu = menu
    tavern.owner = owner
    tavern_list = list()
    tavern_list.append(tavern)
    return tavern_list
예제 #15
0
def set_menu():
    """
    Set Menu 
    BOOK-A-MEAL API
    Set menu for the day
    ---
    tags:
      - meals
    parameters:
      - in: body
        name: body
        schema:
          id: set_menu
          required:
            - meal_ids
            - user_id
          properties:
            meal_ids:
              type: string
              description: meal name
              default: [1,3,5]
            user_id:
              type: integer
              description: user id
              default: 3 
    responses:
      400:
        description: 
      201:
        description: Order Made
        schema:
          id: menu
          properties:
            id:
              type: integer
              description: price for meal
              default: 3
            meal_ids:
              type: string
              description: meal ids
              default: [1,3,5]
            user_ids:
              type: integer
              description: user id
              default: 3 
            created_at:
              type: string
              description: time created menu
              default: Fri, 04 May 2018 00:10:06 GMT
            updated_at:
              type: string
              description: time updated menu
              default: Fri, 04 May 2018 00:10:06 GMT   

    """
    """ Setting menu 
       We need to cocatenate the items in the lsit with a special character into a string
       And when retrieving it we return it into a string

    """

    if not request.get_json() or 'meal_ids' not in request.get_json()\
    or 'user_id' not in request.get_json():
        abort(400)
    """ We need to check if the id exist in the meals"""

    meal_ids = request.get_json().get('meal_ids')
    user_id = request.get_json().get('user_id')

    if len(meal_ids) == 0:
        return jsonify({'message': 'No meals sent for menu'}), 400

    caterer = Menu.query.filter_by(user_id=user_id).first()
    if caterer is not None:
        return jsonify({'message':
                        'Caterer Already Set Menu For the Day'}), 400

    meal_ids_string = ""
    for ids in meal_ids:
        meal_ids_string += ';%s' % ids

    menu = Menu(user_id=user_id, meal_ids=meal_ids_string)
    db.session.add(menu)
    db.session.commit()

    menu_info = {}
    menu_info['id'] = menu.id
    menu_info['user_id'] = menu.user_id
    """ Converting the meal ids into a list again """
    converted_meal_ids = []
    for idx in menu.meal_ids.split(';'):
        if idx != "":
            converted_meal_ids.append(int(idx))

    menu_info['meal_ids'] = converted_meal_ids
    menu_info['created_at'] = menu.created_at
    menu_info['updated_at'] = menu.updated_at

    return jsonify({'message':'Menu Successfully Created',\
      'menu': menu_info}), 201
예제 #16
0
class Juego():

    def __init__(self, window):
        self.window = window
        self.menu = Menu(window)
        self.pantallaJuego = None
        self.jugadores = []
        self.numeroRonda = 0
        self.dado = Dado(300, 300, 100, 100, self.window)
        self.temporizador = None
        self.mazoPuzzles = []
        self.numeroJugadores = 0
        self.enJuego = False
        self.enMenu = True
        self.enRonda = False
        self.finRonda = False
        self.limiteFilasPorJugadorEnRonda = [0 for _ in range(4)]
        self.numeroGanadores = 0
        self.maximoMovimientosFichas = 0
        self.tiempoAuxiliar = 0
        self.tiempoAleatorio = 0

    def crearJugadores(self):
        for id in range(self.numeroJugadores):
            if id != self.numeroJugadores - 1:
                self.jugadores.append(Jugador(id, definirMovimientosJugador(id), definirMovimientosFichas(id)))
            else:
                self.jugadores.append(JugadorComputadora(id, definirMovimientosJugador(id), definirMovimientosFichas(id)))
        self.pantallaJuego = PantallaJuego(self.window, self.jugadores)

    def asignarPuzzles(self, dificultad):
        idPuzzle = 0
        x = 0
        y = 650
        espaciado = 0
        if self.numeroJugadores == 2:
            x = 350
            espaciado = 850
        elif self.numeroJugadores == 3:
            x = 200
            espaciado = 600
        elif self.numeroJugadores == 4:
            x = 155
            espaciado = 450
        for i in range(self.numeroJugadores):
            if i != 0:
                x += espaciado
            for _ in range(9):
                if dificultad == "Normal":
                   idPuzzle = random.randint(1,8)
                elif dificultad == "Difícil":
                   idPuzzle = random.randint(1,34)
                puzzleGenerado = PuzzleFactory.crearPuzzle(x, y, idPuzzle, self.window, dificultad)
                self.jugadores[i].puzzles.append(puzzleGenerado)
            
            #####
            # self.jugadores[i].puzzleSeleccionado = copy.copy(self.jugadores[i].puzzles[0])
            # self.jugadores[i]._puzzleSeleccionadoForma = copy.deepcopy(self.jugadores[i].puzzleSeleccionado.forma)


    def asignarFichas(self):
        x = 482
        y = 282
        diameter = 30
        switcher = {
            "color1": (196, 255, 14),
            "color2": (140, 255, 251),
            "color3": (140, 125, 251),
            "color4": (140, 255, 125)
        }

        for i in range(self.numeroJugadores):
            self.jugadores[i].ficha = Ficha(x, y, diameter, self.window, switcher.get("color" + str(i + 1)), i, i)
            x += diameter
            y += diameter+5

    def dibujarFichas(self):
        for i in range(self.numeroJugadores):
            self.jugadores[i].ficha.dibujarFicha()

    def dibujarPuzzles(self):
        for i in range(self.numeroJugadores):
            self.jugadores[i].puzzleSeleccionado.dibujarPuzzle()

    def asignarPiezas(self):
        pieza = None

        for i in range(self.numeroJugadores):

            jugador = self.jugadores[i]
            jugador.piezas = []
            x = jugador.puzzleSeleccionado.x
            codigosPiezas = jugador.puzzleSeleccionado.piezas[self.dado.posicion]
            y = jugador.puzzleSeleccionado.y + jugador.puzzleSeleccionado.height + 35

            for j in range(len(codigosPiezas)):
                if j > 0 and pieza != None:
                    x += pieza.width
                pieza = PiezaFactory.crearPieza(x, y, codigosPiezas[j], self.window)
                jugador.piezas.append(pieza)

            self.jugadores[i].piezaSeleccionada = self.jugadores[i].piezas[0]

    def dibujarPiezas(self):
        for i in range(self.numeroJugadores):
            for j in range(len(self.jugadores[i].piezas)):
                self.jugadores[i].piezas[j].dibujarPieza()

    def dibujarMenu(self):
        if self.enMenu:
            self.menu.dibujarMenu()
            self.menu.dibujarBotones()

    def hoverBotonesMenu(self, pos):
        self.menu.hoverBotonesMenu(pos)

    #aqui esta el monstruo
    def transicionarMenu(self, posicionMouse):
        if self.menu.enPantallaInicio:
            if self.menu.botonIniciar.isOver(posicionMouse):
                self.menu.enPantallaInicio = False
                self.menu.enJugadores = True
            elif self.menu.botonDificultad.isOver(posicionMouse):
                self.menu.enPantallaInicio = False
                self.menu.enDificultad = True

        elif self.menu.enJugadores:
            if self.dificultad != "":

                if self.menu.botonUnJugador.isOver(posicionMouse):
                    self.numeroJugadores = 2
                    self.maximoMovimientosFichas = 2
                elif self.menu.botonDosJugadores.isOver(posicionMouse):
                    self.numeroJugadores = 3
                    self.maximoMovimientosFichas = 3
                elif self.menu.botonTresJugadores.isOver(posicionMouse):
                    self.numeroJugadores = 4
                    self.maximoMovimientosFichas = 4
                if self.menu.botonUnJugador.isOver(posicionMouse) or self.menu.botonDosJugadores.isOver(posicionMouse) or self.menu.botonTresJugadores.isOver(posicionMouse):
                    self.menu.enJugadores = False
                    self.crearJugadores()
                    self.asignarFichas()
                    self.asignarPuzzles(self.dificultad)
                    self.enMenu = False
                    self.numeroRonda += 1
                    self.enJuego = True
                    self.iniciarRonda()

            if self.menu.botonRegresar.isOver(posicionMouse):
                self.menu.enPantallaInicio = True
                self.menu.enJugadores = False
        elif self.menu.enDificultad:
            if self.menu.botonDificultadNormal.isOver(posicionMouse):
                self.menu.enDificultad = False
                self.menu.enPantallaInicio = True
                self.dificultad = "Normal"
            elif self.menu.botonRegresar.isOver(posicionMouse):
                self.menu.enPantallaInicio = True


    def dibujarJuego(self):
        if self.enRonda:
            self.tiempoAuxiliar += 1
            if self.tiempoAuxiliar == 7:
                self.tiempoAuxiliar = 0
                self.pantallaJuego.barraJuego.temporizador.correrTiempo()
            if self.pantallaJuego.barraJuego.temporizador.segundos == 0:
                self.enRonda = False
                self.tiempoAuxiliar = 0
        else:
            self.numeroRonda += 1
            self.iniciarRonda()

        self.pantallaJuego.dibujarTablero()
        self.dibujarPuzzles()
        self.dibujarPiezas()
        self.dibujarFichas()



    def tirarDado(self):
        self.pantallaJuego.dado.tirarDado()

    #en realidad lo que hace es ejecutar una accion disparada con alguna tecla  
    def ejecutarAccion(self, movimiento):
        
        #debo verificar que tecla es, para saber que accion se realizara

        #la ronda no esta iniciada y se presiono la tecla de iniciar?:
        #  iniciarRonda
        if self.pantallaJuego.barraJuego.temporizador.segundos > 0:

            for i in range(self.numeroJugadores - 1):

                if self.jugadores[i].movimientoFicha == False:
                    #si ningun jugador ha presionado una tecla, continuar
                    if not self.jugadores[i].moverPieza(movimiento):
                        continue
                    if self.jugadores[i].validarSolucionPuzzle():
                        #Límite de acuerdo al jugador conforme van ganando
                        self.limiteFilasPorJugadorEnRonda[i] = self.maximoMovimientosFichas - self.numeroGanadores
                        self.numeroGanadores += 1
                    #supongo que aqui tambien tengo que ver lo del movimiento de los peones
                else:
                    self.jugadores[i].moverFicha(movimiento, self.limiteFilasPorJugadorEnRonda[i], self.pantallaJuego.tablero)

            if self.pantallaJuego.barraJuego.temporizador.segundos == self.tiempoAleatorio:
                self.jugadores[-1].resolverPuzzle()



    def iniciarRonda(self):
        self.pantallaJuego.barraJuego.temporizador.reiniciarTiempo()
        self.enRonda = True
        #       tirar dado
        self.tirarDado()
        self.tiempoAleatorio = random.randint(40, 50)
        #       obtener el puzzle de encima del monticulo

        for i in range(self.numeroJugadores):
            self.jugadores[i].puzzleSeleccionado = copy.copy(self.jugadores[i].puzzles[self.numeroRonda - 1])
            self.jugadores[i]._puzzleSeleccionadoForma = copy.deepcopy(self.jugadores[i].puzzleSeleccionado.forma)

        #       obtener las piezas de la cartilla segun el dado
        self.asignarPiezas()


        #       resolver (con tiempo)
        #       el que ya haya completado su puzzle, podrá mover su ficha X espacios
        #       mover fichaJugador
        #       comenzar nueva ronda
        return
예제 #17
0
 def __init__(self, bars):
     for api in bars.keys():
         self.menus[api] = Menu(api)
         self.menus[api].load_beers_from_file()
     logging.info("MenuReader Initialized")
예제 #18
0
from models.menu import Menu

Menu()
예제 #19
0
import pygame
from models.menu import Menu
from models.Juego import Juego

mesa = pygame.image.load('assets/Fondos/fondo mesa.png')
pygame.init()


window = pygame.display.set_mode((1920, 1080))
#window = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)

pygame.display.set_caption("Prueba")
run = True
menu = Menu(window)
ubongo = Juego(window)


#kejestooo?
paraTirarDado = 0

while run:
    window.fill((0, 0, 0))
    window.blit(mesa, (0, 0))

    if ubongo.enMenu:
        ubongo.dibujarMenu()
    elif ubongo.enJuego:
        ubongo.dibujarJuego()

    pygame.display.update()
예제 #20
0
# Game variables
gameOver = False
gameStarted = False
score = 0
highscore = 0

pygame.init()

pygame.display.set_caption("Snake Game")
window = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))

grid = Grid(window, SCREEN_WIDTH, SCREEN_HEIGHT, SQUARE_SIZE)
snake = Snake(snake_pos_x, snake_pos_y, snake_dir, SQUARE_SIZE)
food = Food(15, 15, SCREEN_WIDTH / SQUARE_SIZE, SCREEN_HEIGHT / SQUARE_SIZE,
            SQUARE_SIZE)
menu = Menu(window, SCREEN_WIDTH, SCREEN_HEIGHT)

clock = pygame.time.Clock()

while True:
    pygame.time.delay(40)
    clock.tick(10)

    if gameStarted == False:
        menu.draw(score, highscore)

    if gameOver == False and gameStarted:
        grid.draw(snake, food)

        snake.move()
def create_menu():
    """Method to create a menu for that day"""
    meal_ids = str(request.get_json().get('meal_ids'))
    return Menu.create_menu_item(meal_ids)
예제 #22
0
파일: app.py 프로젝트: AdamF42/acmEat
import json

from models.menu import Menu
from models.order import Order
from flask import jsonify, request, abort
from models.status import Status
from repo.menu_repository import menu
from utils.app_creator import create_app

app = create_app('RestaurantService')

my_menu = Menu(menu)


# ======== Routing =========================================================== #
# -------- PlaceOrder _------------------------------------------------------- #
@app.route('/restaurant/order', methods=['PUT'])
def place_order():
    if 'id' not in request.json:
        abort(400)
    order = json.dumps(request.json)
    order = json.loads(order)
    order = Order.get_order_by_id(order['id'])
    if order.get("status", None) is None:
        order['status'] = Status.NOT_AVAILABLE.name
        return jsonify(order)

    if order['status'] == Status.AVAILABLE.name:
        order['status'] = Status.ACCEPTED.name

    return jsonify(order)
예제 #23
0
파일: app.py 프로젝트: jcromerohdz/FlaskDev
from models.post import Post
from models.database import Database
from models.blog import Blog
from models.menu import Menu

__author__ = 'jcrh'

Database.initialize()

menu = Menu()
menu.run_menu()

# blog = Blog(author='Christian',
#             title='My title',
#             description='Sample description')
#
# blog.new_post()
#
# print(blog.id)
#
# from_database = Blog.get_from_mongo(blog.id)
#
# print(blog.get_posts())

# Insert to mongo
# post = Post(blog_id='12345',
#             title='Super post',
#             content='This the content we send by the app',
#             author='Christian')

#post.save_to_mongo()
def get_menu():
    """A Method to return the menu for the day"""
    return Menu.get_today_menu()
예제 #25
0
 def mockAPI(self, beername=""):
     return Menu("TestBar", [
         MenuSection("1", "Title1",
                     [Beer("name " + beername, "style", 8, "brewery")])
     ])
예제 #26
0
 def parse_menu(cls) -> Menu:
     content = cls.get_page_content()
     main_dishes = cls.parse_main_dishes(content)
     soups = cls.parse_soups(content)
     return Menu(main_dishes, soups)
예제 #27
0
__author__ = "mohsin"

from database import Database
from models.post import Post
from models.blog import Blog
from models.menu import Menu

Database.initialize()

main_menu = Menu()

# my_blog = Blog(author="Mohsin", title="My Adventures", description="Some musings about my travels")
# my_blog.save_to_mongo()
# my_blog.new_post()

#my_blog = Blog.get_from_mongo("4a24cb4444334ab78a63013f1306ab85")
#post_cursor = my_blog.get_posts()

#for post in post_cursor:
#    print(post)

# new_blog = Blog(author="Mac", title="Shiba Summers", description="The summer of a shiba")
# new_blog.save_to_mongo()
# new_blog.new_post()

#new_blog = Blog.get_from_mongo("e79d9b9bab9b4a25b0685f20067f6a0d")
#new_blog_cursor = new_blog.get_posts()

#for post_document in new_blog_cursor:
#    print(post_document)
예제 #28
0
from models.menu import Menu
from database import Database

"""
    Date:       09/03/2016
    Program:    A small command line blog using mongoDB
"""

__author__ = "Seamus de Cleir"

# Starts the Database IMPORTANT
Database.initialize()

menu = Menu()

menu.run_menu()

예제 #29
0
파일: forcook.py 프로젝트: Moai-Team/cook
            record = Time(**{'id': i[0], 'minutes': i[1]})
            session3.add(record)

        data4 = Load_Data_1("csv/1categories.csv")
        for i in data4:
            record = Categories(**{'id': i[0], 'category_name': i[1]})
            session3.add(record)

        data5 = Load_Data_1("csv/1cuisine.csv")
        for i in data5:
            record = Cuisine(**{'id': i[0], 'cuisine_name': i[1]})
            session3.add(record)

        data6 = Load_Data_1("csv/1menu.csv")
        for i in data6:
            record = Menu(**{'id': i[0], 'menu_name': i[1]})
            session3.add(record)

        data7 = Load_Data_3("csv/1recipe_has_ingredients.csv")
        for i in data7:
            record = Recipe_has_ingredients(**{
                'recipe_id': i[0],
                'ingredients_id': i[1]
            })
            session3.add(record)

        data8 = Load_Data_3("csv/1recipe_has_categories.csv")
        for i in data8:
            record = Recipe_has_categories(**{
                'recipe_id': i[0],
                'categories_id': i[1]