コード例 #1
0
def display_out_of_stock():
    """ Display out of catalog """
    cls()
    header("Out of stock")
    for p in CATALOG:
        if p.Stock == 0:
            product_info(p)
    input("Press Enter to continue...")
コード例 #2
0
def display_catalog(wait=True):
    """ Display catalog in screen """
    cls()
    header("Cataglog")
    for p in CATALOG:
        product_info(p)

    if wait:
        input("Press Enter to continue...")
コード例 #3
0
def unique_categories():
    # """ Converts the array of categories to set (manually) """
    """ Prints unique categories """

    cats = list(map(lambda p: p.Category, CATALOG))

    cls()
    print('Unique categories:')
    for i, cat in enumerate(cats):
        if cat not in cats[:i]:
            print('\t%s' % cat)

    input('\nPress Enter to continue')
コード例 #4
0
def searchvaluefunc():
    searchvalue = input()
    response = bot.get_response(searchvalue)
    print(response, "\n")
    while True:
        try:
            searchvaluefuncmenu = int(input("Type 1 to search again or press enter to go back."))
        except ValueError:
            menu.cls()
            menu.mainMenu()
        else:
            break
    if searchvaluefuncmenu == 1:
        menu.cls()
        print("Type something to search.")
        searchvaluefunc()
コード例 #5
0
def register_product():
    """ Register product """
    global NEXT_ID
    cls()
    header("Register")
    title = input("Provide the title: ")
    category = input("Provide the category: ")

    try:
        stock = int(input("Provide the stock: "))
        price = float(input("Provide the price: "))

        product = Product(NEXT_ID, title, category, stock, price)
        NEXT_ID += 1
        CATALOG.append(product)
    except Exception:
        print('*** Unexpected format :/\n')
        input('Press Enter to continue ...')
コード例 #6
0
ファイル: game_loop.py プロジェクト: Faustrox/POO-Project
def pieceSelected():

    print("It's the turn for the ", team[turn], " team")
    board_functions.board_function.show()
    print("Select the position of the piece that you want to move: ")
    piece_select = input()

    if piece_select[
            0] in minus:  # Si incertas una letra en minuscula esta se convierte en mayuscula
        piece_select = chr(ord(piece_select[0]) - 32) + piece_select[1]

    if is_it_possible(
            piece_select
    ) is False:  # Si la posicion que entraste es imposible en la matriz retornara False
        menu.cls()
        return False

    return piece_select
コード例 #7
0
def get_most_expensive(arr):
    """ Return the 3 more expensive products """
    res = arr[:3]
    if len(res) >= len(arr):
        return res

    prd_sort(res)

    for obj in arr[3:]:
        if res[0].Price < obj.Price:
            res[0] = obj
            prd_sort(res)

    cls()

    for p in res:
        product_info(p)

    input('\nPress Enter to continue ...')
コード例 #8
0
ファイル: game_loop.py プロジェクト: Faustrox/POO-Project
def isPiece(piece):

    position_name = piece
    piece = board.board.game_board[int(piece[1])][board.board.positionY[piece[
        0]]]  # Convierte la variable piece de un string al objeto que indicaste mediante posiciones

    if isinstance(
            piece, menu.pieces.piece
    ) is False:  # Si la posicion que entraste no es una pieza entonces volvera atras para volver a elegir

        menu.cls()
        return "That isn't a piece, please select a valid piece"

    if piece.team != team[
            turn]:  # Si la posicion que seleccionaste es una pieza del otro enemigo, volveras a elegir otra posicion
        menu.cls()
        return "This piece is of the other team, please select one that you can take"

    menu.cls()
    return piece, position_name
コード例 #9
0
ファイル: game_loop.py プロジェクト: Faustrox/POO-Project
            string = colum_string + row_string

            if pos == string:
                return True

    return False


while True:  # BASE LOOP (GAME LOOP)

    if turn == 2:  # Si la variable turno se pasa de 1 entonces vuelve a 0
        turn = 0

    if check(team[turn]) == "checkmate":  # La condicion del jaquemate

        menu.cls()
        print("The ", team[turn], " is checkmate, you lose")
        board_functions.board_function.show()
        break

    elif check(team[turn]) == "check":  # La condicion del jaque

        print("The ", team[turn], " is in check")
    check_var, first, third = False, False, False

    piece_select = pieceSelected()

    if piece_select == False:  # Si la posicion que escribiste no esta en la matriz entonces se repetira la seleccion de alguna pieza

        print("That position doesn't exist or you put the position wrong")
        continue