Example #1
0
def app_main():
    action = sys.argv[1] if sys.argv[1:] else None

    if action == "load":
        savename = sys.argv[2]
        save.load_game(savename)
    elif action == "connect":
        host, port, username = sys.argv[2:]
        save.connect(host, int(port), username)
    elif action == "eval":
        exec sys.argv[2] in globals()
    elif action == "loadmeet":
        savename = sys.argv[2]
        ident = int(sys.argv[3])

        def callback():
            client.freeciv.func.py_init_meeting(ident)

        save.load_game(savename, callback)
    elif action == "help":
        import help

        help.show()
    else:
        if action:
            print "unknown action %r, see lib/main.py for actions" % action
        menus.main_menu()
Example #2
0
def app_main():
    action = features.get('app.action')
    arg = features.get('app.action_arg')

    if action == 'load_remote':
        from freeciv import dropbox
        dropbox.load_dropbox_save(arg)
    else:
        menus.main_menu()
Example #3
0
def resume():
    name = get_resume_data()
    if name:
        remove_pause_file()
        try:
            menus.main_menu()
            ui.set(ui.Label('dummy'))
            save.load_game(name)
        except IOError:
            # loading save failed
            return False
        return True
    else:
        return False
Example #4
0
def offer_ride(db_connection, cursor, member_email):
    print_logo("Offer Ride")

    driver = str(member_email)
    cursor.execute("SELECT MAX(rno) FROM rides")
    rno = str(int(cursor.fetchone()[0]) + 1)

    trueDate = False
    trueNoSeats = False
    truePricePerSeat = False
    trueLuggage = False
    trueSRC = False
    trueDST = False
    trueCar = False
    trueEnroutes = False

    enrouteStops = []

    # validates date entered by the user; does not let past dates be selected
    while trueDate == False:
        now = datetime.now()
        date = input("   {DATE} Enter ride date (ex. YYYY-MM-DD): ")
        if (len(date) != 10) or (date[4] != "-") or (
                date[7] != '-') or not (date[0:4].isdigit()) or not (
                    date[5:7].isdigit()) or not (date[8:10].isdigit()):
            print(
                "***\n*** Incorrect date format. Try again (ex. YYYY-MM-DD)\n***"
            )
            continue
        else:
            year = int(date[0:4])
            month = int(date[5:7])
            day = int(date[8:10])
            todaysDATE = now.strftime(
                "%Y-%m-%d"
            )  # check if less than today's date... the date today https://www.saltycrane.com/blog/2008/06/how-to-get-current-date-and-time-in/

            if date < todaysDATE:
                print(
                    "***\n*** Incorrect date. Cannot offer rides in the past.\n*** Today's date is: {}\n***"
                    .format(todaysDATE))
                continue
            if (month > 12) or (month < 1) or (day < 1) or (day > 31):
                print(
                    "***\n*** Incorrect date. Try again (ex. YYYY-MM-DD)\n***")
                continue
            if (month == 4) or (month == 6) or (month == 9) or (month == 11):
                if day > 30:
                    print(
                        "***\n*** Incorrect date. There are not that many days in the month. Try again (ex. YYYY-MM-DD)\n***"
                    )
                    continue
            if (month == 2):
                if (year % 4 == 0):
                    if day > 29:
                        print(
                            "***\n*** Incorrect date format. Remember it's February... (ex. YYYY-MM-DD)\n***"
                        )
                        continue
                elif day > 28:
                    print(
                        "***\n*** Incorrect date. Remember it's February... (ex. YYYY-MM-DD)\n***"
                    )
                    continue
            trueDate = True

    # checks if number of seats are related to the cno; does not let a member offer 0 seats
    while trueNoSeats == False:
        noSeats = input("   {SEATS} Enter the number of seats: ")
        if noSeats.isdigit():
            if noSeats != '0':
                trueNoSeats = True
            else:
                print(
                    "***\n*** Incorrect input. You can't offer a ride with 0 seats. Try again\n***"
                )
            continue
        else:
            print("\n*** Incorrect input format. Try again\n***")
            continue
    #enter price per seat
    while truePricePerSeat == False:
        pricePerSeat = input("   {PRICE} Enter a price per seat ($): ")
        if pricePerSeat.isdigit():
            truePricePerSeat = True
        else:
            print("***\n*** Incorrect input format. Try again\n***")
            continue

    # enter luggage description
    while trueLuggage == False:
        luggage = input("   {LUGGAGE} Enter a luggage description: ")
        if len(luggage) > 10:
            print(
                "***\n***Too long of a description (10 characters max). Try again\n***"
            )
            continue
        if len(luggage) == 0:
            print(
                "***\n***You need to enter something for the description. Try again\n***"
            )
            continue
        trueLuggage = True

    #pick up location: add and select
    while trueSRC == False:
        SRCnum = input("\n   {PICKUP} Enter a pickup location: ")
        if len(SRCnum) > 16 or len(SRCnum) == 0:
            print("***\n*** Incorrect input format. Try again\n***")
            continue

        cursor.execute("SELECT * FROM locations WHERE lcode LIKE \"%" +
                       SRCnum + "%\"  OR city LIKE \"%" + SRCnum +
                       "%\" OR prov LIKE \"%" + SRCnum +
                       "%\" OR address LIKE \"%" + SRCnum + "%\"")
        srcOptions = cursor.fetchall()
        x = 0

        if (len(srcOptions) > 1):
            clear_screen()
            print(
                "\n   Select a pickup location by the listed number option \n   <press ENTER for more options>"
            )
            while x < len(srcOptions):
                try:
                    print(str(x + 1) + ". " + str(srcOptions[x]))
                    x = x + 1
                except:
                    continue
                if x // 5 > 0:
                    choice = input("")
                    if choice.isdigit():
                        src = srcOptions[int(choice) - 1][0]
                        trueSRC = True
                        break
                    elif choice == "":
                        if x + 1 > len(srcOptions):
                            x = 0
                        continue
                    else:
                        print("***\n*** Incorrect choice. Try again\n***")
                        x = 0
                        continue
        elif (len(srcOptions) == 1):
            src = srcOptions[0][0]
            print(srcOptions)
            trueSRC = True
        else:
            print(
                "***\n*** Something is MIA. We couldn't find any lcode, city, province or address with that query\n***"
            )
            continue

    # destination location: add and select
    while trueDST == False:
        DSTnum = input("\n   {DROPOFF} Enter a destination location: ")
        if len(DSTnum) > 16 or len(DSTnum) == 0:
            print("***\n*** Incorrect input format. Try again\n***")
            continue

        cursor.execute("SELECT * FROM locations WHERE lcode LIKE \"%" +
                       DSTnum + "%\"  OR city LIKE \"%" + DSTnum +
                       "%\" OR prov LIKE \"%" + DSTnum +
                       "%\" OR address LIKE \"%" + DSTnum + "%\"")
        dstOptions = cursor.fetchall()

        x = 0
        if (len(dstOptions) > 1):
            clear_screen()
            print(
                "\n   Select a destination location by the listed number option \n   <press ENTER for more options>"
            )
            while x < len(dstOptions):
                try:
                    print(str(x + 1) + ". " + str(dstOptions[x]))
                    x = x + 1
                except:
                    continue
                if x // 5 > 0:
                    choice = input("")
                    if choice.isdigit():
                        dst = dstOptions[int(choice) - 1][0]
                        trueDST = True
                        break
                    elif choice == "":
                        if x + 1 > len(dstOptions):
                            x = 0
                        continue
                    else:
                        print("***\n*** Incorrect choice. Try again\n***")
                        x = 0
                        continue

        elif (len(dstOptions) == 1):
            dst = dstOptions[0][0]
            print(dstOptions)
            trueDST = True
        else:
            print(
                "\n*** Something is MIA. We couldn't find any lcode, city, province or address with that query\n***"
            )

    # add enroutes
    while trueEnroutes == False:
        stop = input(
            "\n   {ENROUTE} Enter an enroute location \n < press ENTER to skip > "
        )
        if len(stop) > 16:
            print("***\n***Incorrect input format. Try again\n***")
            continue

        if stop == "":
            trueEnroutes = True
            continue

        cursor.execute("SELECT * FROM locations  WHERE lcode LIKE \"%" + stop +
                       "%\"  OR city LIKE \"%" + stop +
                       "%\" OR prov LIKE \"%" + stop +
                       "%\" OR address LIKE \"%" + stop + "%\"")
        stopOptions = cursor.fetchall()

        x = 0

        if (len(stopOptions) > 1):
            print(
                "\n   {ENROUTE} Choose an enroute location by the listed number\n < press ENTER for all options >"
            )
            while x < len(stopOptions):
                try:
                    print(str(x + 1) + ". " + str(stopOptions[x]))
                    x = x + 1
                except:
                    continue
                if x // 5 > 0:
                    choice = input("")
                    if choice.isdigit():
                        stop = stopOptions[int(choice) - 1]
                        enrouteStops.append(stop)
                        break
                    elif choice == "":
                        if x + 1 > len(stopOptions):
                            x = 0
                        continue
                    else:
                        print("\n*** Incorrect choice. Try again ***")
                        x = 0
                        continue
        elif (len(stopOptions) == 1):
            enrouteStops.append(stopOptions[0])
            print(stopOptions)
        else:
            print(
                "\n*** Something is MIA. We couldn't find any lcode, city, province or address with that query\n***"
            )

    # valid car number
    while trueCar == False:
        cno = input(
            "\n   {CARNUMBER} Enter a car number\n < Press ENTER to skip > ")
        if cno.isdigit():
            cursor.execute("SELECT cno FROM cars WHERE cno = ? AND owner = ?;",
                           [cno, member_email])
            cars = cursor.fetchall()
            if len(cars) == 0:
                print("***\n*** Invalid car. Try again\n*** ")
                continue
            elif len(cars) == 1:
                trueCar = True
            else:
                print("***\n*** Something went wrong. Try again\n*** ")
                continue
        elif cno == "":
            trueCar = True
            cno = None
        else:
            print("***\n*** Something went wrong. Try again\n***")
            continue

        #enter ride into database with all inputted info
        cursor.execute(
            "INSERT INTO rides VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);",
            [rno, pricePerSeat, date, noSeats, luggage, src, dst, driver, cno])
        for item in enrouteStops:
            cursor.execute("INSERT INTO enroute VALUES (?, ?);",
                           [rno, item[0]])
    db_connection.commit()

    print("\n   . . .. . Ride successfully posted!")  #validation
    sleep(1.5)

    menus.main_menu(db_connection, cursor, member_email)
Example #5
0
def main():
	constants = get_constants()

	libtcod.console_set_custom_font('arial10x10.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)

	libtcod.console_init_root(constants['screen_width'], constants['screen_height'], constants['window_title'], False)

	con = libtcod.console_new(constants['screen_width'], constants['screen_height'])
	panel = libtcod.console_new(constants['screen_width'], constants['panel_height'])

	player = None
	entities = []
	game_map = None
	message_log = None
	game_state = None

	show_main_menu = True
	show_load_error_message = False

	main_menu_background_image = libtcod.image_load('menu_background1.png')

	key = libtcod.Key()
	mouse = libtcod.Mouse()

	while not libtcod.console_is_window_closed():
		libtcod.sys_check_for_event(libtcod.EVENT_KEY_PRESS | libtcod.EVENT_MOUSE, key, mouse)

		if show_main_menu:
			main_menu(con, main_menu_background_image, constants['screen_width'],
					  constants['screen_height'])

			if show_load_error_message:
				message_box(con, 'No save game to load', 50, constants['screen_width'], constants['screen_height'])

			libtcod.console_flush()

			action = handle_main_menu(key)

			new_game = action.get('new_game')
			load_saved_game = action.get('load_game')
			exit_game = action.get('exit')

			if show_load_error_message and (new_game or load_saved_game or exit_game):
				show_load_error_message = False
			elif new_game:
				player, entities, game_map, message_log, game_state = get_game_variables(constants)
				game_state = GameStates.PLAYERS_TURN

				show_main_menu = False
			elif load_saved_game:
				try:
					player, entities, game_map, message_log, game_state = load_game()
					show_main_menu = False
				except FileNotFoundError:
					show_load_error_message = True
			elif exit_game:
				break

		else:
			libtcod.console_clear(con)
			play_game(player, entities, game_map, message_log, game_state, con, panel, constants)

			show_main_menu = True
Example #6
0
    def main(self):

        # Set font
        libtcod.console_set_custom_font(
            'dejavu_wide16x16_gs_tc.png',
            libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
        # Create game window
        libtcod.console_init_root(self.constants['screen_width'],
                                  self.constants['screen_height'],
                                  self.constants['window_title'], False)

        # Create a console (Drawing Layer?)
        con = libtcod.console_new(self.constants['screen_width'],
                                  self.constants['screen_height'])
        panel = libtcod.console_new(self.constants['screen_width'],
                                    self.constants['panel_height'])

        players = []
        entity = []
        game_map = None
        message_log = None
        self.game_state = None
        self.active_player = 0

        show_main_menu = True
        show_load_error_message = False

        main_menu_background_image = libtcod.image_load('menu_background.png')

        # Holds keyboard and mouse input
        key = libtcod.Key()
        mouse = libtcod.Mouse()

        # Menu loop
        while not libtcod.console_is_window_closed():
            libtcod.sys_check_for_event(
                libtcod.EVENT_KEY_PRESS | libtcod.EVENT_MOUSE, key, mouse)

            if show_main_menu:
                main_menu(con, main_menu_background_image,
                          self.constants['screen_width'],
                          self.constants['screen_height'])

                if show_load_error_message:
                    message_box(con, 'No save game to load', 50,
                                self.constants['screen_width'],
                                self.constants['screen_height'])

                libtcod.console_flush()

                action = handle_main_menu(key)

                new_game = action.get('new_game')
                load_saved_game = action.get('load_game')
                exit_game = action.get('exit')

                if show_load_error_message and (new_game or load_saved_game
                                                or exit_game):
                    show_load_error_message = False
                elif new_game:
                    players, entities, game_map, message_log, self.game_state = get_game_variables(
                        self.constants)
                    self.game_state = GameStates.PLAYERS_TURN

                    show_main_menu = False
                elif load_saved_game:
                    try:
                        players, entities, game_map, message_log, self.game_state, self.active_player = load_game(
                            self.constants['player_count'])
                        self.game_state = GameStates.PLAYERS_TURN

                        show_main_menu = False
                    except FileNotFoundError:
                        show_load_error_message = True
                elif exit_game:
                    break
            else:
                libtcod.console_clear(con)
                self.play_game(players, entities, game_map, message_log,
                               self.game_state, con, panel, self.constants)

                show_main_menu = True
Example #7
0
def main():

    constants = get_constants()
    names_list = get_unidentified_names()
    colors_list = get_render_colors()
    load_customfont()

    libtcod.console_set_custom_font(
        'fontplus.png',
        libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_ASCII_INROW, 16, 30)

    libtcod.console_init_root(constants['screen_width'],
                              constants['screen_height'],
                              constants['window_title'], False)

    con = libtcod.console.Console(constants['screen_width'],
                                  constants['screen_height'])
    panel = libtcod.console.Console(constants['screen_width'],
                                    constants['panel_height'])

    player = None
    entities = []
    game_map = None
    message_log = None
    game_state = None

    show_main_menu = True
    show_load_error_message = False

    main_menu_background_image = libtcod.image_load('menu_background.png')

    key = libtcod.Key()
    mouse = libtcod.Mouse()

    while not libtcod.console_is_window_closed():
        libtcod.sys_check_for_event(
            libtcod.EVENT_KEY_PRESS | libtcod.EVENT_MOUSE, key, mouse)

        if show_main_menu:
            main_menu(con, main_menu_background_image,
                      constants['screen_width'], constants['screen_height'])

            if show_load_error_message:
                message_box(con, 'No save game to load', 50,
                            constants['screen_width'],
                            constants['screen_height'])

            libtcod.console_flush()

            action = handle_main_menu(key)

            new_game = action.get('new_game')
            load_saved_game = action.get('load_game')
            exit_game = action.get('exit')

            if show_load_error_message and (new_game or load_saved_game
                                            or exit_game):
                show_load_error_message = False
            elif new_game:
                constants = get_constants()
                names_list = get_unidentified_names()
                colors_list = get_render_colors()

                if intro(constants):
                    if not game_options(constants) == "nah":
                        if not origin_options(constants) == "nah":
                            if not character_name(constants) == 'nah':
                                player, entities, game_map, message_log, game_state = get_game_variables(
                                    constants, names_list, colors_list)
                                game_state = GameStates.PLAYERS_TURN

                                show_main_menu = False
            elif load_saved_game:
                try:
                    player, entities, game_map, message_log, game_state, constants = load_game(
                    )
                    show_main_menu = False
                except FileNotFoundError:
                    show_load_error_message = True

            elif exit_game:
                break

        else:
            libtcod.console_clear(con)
            play_game(player, entities, game_map, message_log, game_state, con,
                      panel, constants, names_list, colors_list)

            show_main_menu = True
Example #8
0
import utils
import globals
import menus

globals.init()

while menus.main_menu(): pass

utils.clear_screen()
Example #9
0
def post_ride_request(db_connection, cursor, member_email):
    # The member can post a ride request by providing a date, a pick up location code,
    # a drop off location code, and the amount willing to pay per seat.
    # The request id is set to a unique number automatically
    # Can return by pressing enter at any time (except for when entering amount)

    print_logo("Post Ride Requests")

    # Generate request id
    try:
        cursor.execute("SELECT MAX(rid) FROM requests;")
        rid = cursor.fetchone()[0] + 1
    except:
        rid = 1  # in case there are no ride requests in the database yet

    # Validate date
    # Date must match format YYYY-MM-DD and be in the future
    date = input("  Date (YYYY-MM-DD): ")
    if len(date) == 0:
        menus.main_menu(db_connection, cursor, member_email)
    while not will_validate_date(date):
        print("  Please enter a valid date.")
        date = input("  Date (YYYY-MM-DD): ")
        if len(date) == 0:
            menus.main_menu(db_connection, cursor, member_email)

    # Get list of location codes
    location_codes = []
    cursor.execute("SELECT DISTINCT lcode FROM locations;")
    for row in cursor:
        location_codes.append(row[0])

    # Print all location codes
    print("\n  Location codes:")
    for i in range(len(location_codes)):
        if i == 0:
            print("  ", end="")
        if i % 7 == 0 and i // 7 > 0:
            print("{}".format(location_codes[i]), end="\n  ")
        else:
            print("{}".format(location_codes[i]), end=" ")
    print()

    # Validate pickup location
    pickup = input("  Pickup location: ").lower()
    while pickup not in location_codes:
        print("Please enter a valid pickup location.")
        pickup = input("  Pickup location: ").lower()

    # Validate dropoff location (can't be the same as pickup)
    dropoff = input("  Dropoff location: ").lower()
    while dropoff not in location_codes:
        print("Please enter a valid dropoff location.")
        dropoff = input("\n  Dropoff location: ").lower()

    # Validate amount (non-negative integer)
    amount = -1
    while amount < 0:
        try:
            amount = int(input("  Amount per seat: "))
        except:
            continue

    # print(rid, member_email, date, pickup, dropoff, amount)
    # Insert ride request into database
    cursor.execute("INSERT INTO requests VALUES (?, ?, ?, ?, ?, ?);",
                   [rid, member_email, date, pickup, dropoff, amount])
    db_connection.commit()

    print("\n. .. . .. Request successfully posted!.")
    sleep(1.5)

    menus.main_menu(db_connection, cursor, member_email)
Example #10
0
def main():
    constants = get_constants()

    libtcod.console_set_custom_font(
        'arial10x10.png',
        libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)

    libtcod.console_init_root(
        constants['screen_width'], constants['screen_height'],
        constants['window_title'], False)

    con = libtcod.console_new(
        constants['screen_width'], constants['screen_height'])
    panel = libtcod.console_new(
        constants['screen_width'], constants['panel_height'])

    player = None
    entities = []
    game_map = None
    message_log = None
    game_state = None

    show_main_menu = True
    get_weapon = False
    show_load_error_message = False

    key = libtcod.Key()
    mouse = libtcod.Mouse()

    while not libtcod.console_is_window_closed():
        libtcod.sys_check_for_event(
            libtcod.EVENT_KEY_PRESS | libtcod.EVENT_MOUSE, key, mouse)

        if show_main_menu:
            main_menu(
                con, None, constants['screen_width'],
                constants['screen_height'])

            if show_load_error_message:
                message_box(
                    con, 'No save game to load', 50,
                    constants['screen_width'], constants['screen_height'])

            libtcod.console_flush()

            action = handle_main_menu(key)

            new_game = action.get('new_game')
            load_saved_game = action.get('load_game')
            exit_game = action.get('exit')

            if show_load_error_message and (
                    new_game or load_saved_game or exit_game):
                show_load_error_message = False
            elif new_game:
                player, entities, game_map, message_log, game_state = (
                    get_game_variables(constants))
                get_weapon = True
                game_state = GameStates.PLAYERS_TURN

                show_main_menu = False
            elif load_saved_game:
                try:
                    player, entities, game_map, message_log, game_state = (
                        load_game())
                    show_main_menu = False
                except FileNotFoundError:
                    show_load_error_message = True
            elif exit_game:
                break

        elif get_weapon:
            menu(
                con, 'Choose Weapon',
                ['Sword and Board (Chance to block when fighting straight on)',
                 'Daggers (Gets a sneaky stab in and can dodge when moving)',
                 'Pike (Attacks twice as far as other weapons)'],
                64, constants['screen_width'], constants['screen_height'])
            libtcod.console_flush()

            action = handle_weapon_menu(key)
            exit = action.get('exit')
            sword = action.get('sword')
            daggers = action.get('daggers')
            pike = action.get('pike')

            if exit:
                libtcod.console_clear(0)
                show_main_menu = True
                get_weapon = False
            elif sword:
                get_weapon = False
                constants['weapon'] = 'sword'
            elif daggers:
                get_weapon = False
                constants['weapon'] = 'daggers'
            elif pike:
                get_weapon = False
                constants['weapon'] = 'pike'

        else:
            libtcod.console_clear(con)
            play_game(player, entities, game_map, message_log,
                      game_state, con, panel, constants)

            libtcod.console_clear(0)
            libtcod.console_flush()
            show_main_menu = True
Example #11
0
def main():
    tdl.set_font('arial12x12.png', greyscale=True, altLayout=True)
    display = Display()  # missing game_map, has an empty log

    show_main_menu = True
    show_load_error = False
    player = None
    entities = []
    state = GameStates.PLAYER_TURN
    game_map = None

    main_menu_background_image = image_load('a.png')

    while not tdl.event.is_window_closed():

        for event in tdl.event.get():
            if event.type == 'KEYDOWN':
                user_input = event
                break
        else:
            user_input = None

        if show_main_menu:
            main_menu(display, main_menu_background_image)

            if show_load_error:
                message_box(display, 'No save game to load', 50)

            tdl.flush()

            action = handle_main_menu(user_input)

            new = action.get('new')
            load = action.get('load')
            exit = action.get('exit')
            fullscreen = action.get('fullscreen')

            if fullscreen:
                tdl.set_fullscreen(not tdl.get_fullscreen())
            if show_load_error and (new or load or exit):
                show_load_error = False
            elif new:
                player_name = player_name_select(display)
                if not player_name:
                    continue
                player, entities, game_map, state = initialize(
                    display, player_name)
                display.write(Message('Chop wood, carry water.'))
                show_main_menu = False
            elif load:
                try:
                    player, entities, game_map, log, state = load_game()
                    display.gmap = game_map
                    display.log = log
                    display.write(Message(
                        'Ah, {0} returns. Welcome back.'.format(player.name)))
                    show_main_menu = False
                except FileNotFoundError:
                    show_load_error = True
            elif exit:
                break

        else:
            play(player, entities, game_map, display, state)

            display.root_console.clear()
            display.con.clear()
            display.panel.clear()

            # need to reset message log, player inventory, etc
            # if exiting and returning to main menu
            show_main_menu = True
            show_load_error = False
            display = Display()
            player = None
            game_map = None
            entities = []
Example #12
0
def main():
    constants = get_constants()

    libtcod.console_set_custom_font(
        'dejavu_wide16x16_gs_tc.png',
        libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)

    libtcod.console_init_root(constants['screen_width'],
                              constants['screen_height'],
                              constants['window_title'], False)

    con = libtcod.console_new(constants['screen_width'],
                              constants['screen_height'])

    # Debugging info: at this point con is a big integer. Later on we find that it is something
    # else. What is going on?
    # Hopefully fixed. Most likely an error in libtcod engine. Fixed when moving to more python
    # specific engine. Python-tcod

    panel = libtcod.console_new(constants['screen_width'],
                                constants['panel_height'])

    player = None
    entities = []
    game_map = None
    message_log = None
    game_state = None
    ggender = None

    show_main_menu = True
    show_load_error_message = False

    main_menu_background_image = libtcod.image_load('menu_background.png')

    key = libtcod.Key()
    mouse = libtcod.Mouse()

    while not libtcod.console_is_window_closed():
        libtcod.sys_check_for_event(
            libtcod.EVENT_KEY_PRESS | libtcod.EVENT_MOUSE, key, mouse)

        if show_main_menu:
            main_menu(con, main_menu_background_image,
                      constants['screen_width'], constants['screen_height'])

            if show_load_error_message:
                message_box(con, 'No save game to load', 50,
                            constants['screen_width'],
                            constants['screen_height'])

            libtcod.console_flush()

            action = handle_main_menu(
                key,
                player,
            )

            new_game = action.get('new_game')
            load_saved_game = action.get('load_game')
            exit_game = action.get('exit')

            if show_load_error_message and (new_game or load_saved_game
                                            or exit_game):
                show_load_error_message = False
            elif new_game:
                player, entities, game_map, message_log, game_state, ggender = get_game_variables(
                    constants)
                game_state = GameStates.PLAYERS_TURN

                show_main_menu = False
            elif load_saved_game:
                try:
                    player, entities, game_map, message_log, game_state, ggender = load_game(
                    )
                    show_main_menu = False
                except FileNotFoundError:
                    show_load_error_message = True
            elif exit_game:
                break

        else:
            libtcod.console_flush()
            libtcod.console_clear(con)
            play_game(player, entities, game_map, message_log, game_state, con,
                      panel, constants)
            show_main_menu = True
Example #13
0
def main():
    constants = get_constants()

    # Initialize console stuff
    libtcod.console_set_custom_font('arial10x10.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD) # The font.
    libtcod.console_init_root(constants['screen_width'], constants['screen_height'], constants['window_title'], False) #The size of the root console.
    con = libtcod.console_new(constants['screen_width'], constants['screen_height']) # The main console of the game.
    panel = libtcod.console_new(constants['screen_width'], constants['panel_height']) # A UI panel for the game.

    # Declare these variables here, but fill them later
    player = None   
    entities = []
    game_map = None
    message_log = None
    game_state = None
    priority_queue = []
    global_variables = None

    show_main_menu = True
    show_load_error_message = False

    main_menu_background_image = libtcod.image_load('menu_background.png')

    key = libtcod.Key()
    mouse = libtcod.Mouse()

    while not libtcod.console_is_window_closed():
        libtcod.sys_check_for_event(libtcod.EVENT_KEY_PRESS | libtcod.EVENT_MOUSE, key, mouse)

        if show_main_menu:
            main_menu(con, main_menu_background_image, constants['screen_width'], constants['screen_height'])

            if show_load_error_message:
                message_box(con, 'No save game to load', 50, constants['screen_width'], constants['screen_height'])

            libtcod.console_flush()

            action = handle_main_menu(key)

            new_game = action.get('new_game')
            load_saved_game = action.get('load_game')
            exit_game = action.get('exit')

            if show_load_error_message and (new_game or load_saved_game or exit_game):
                show_load_error_message = False
            elif new_game:
                player, entities, game_map, message_log, game_state, priority_queue, global_variables, world = get_game_variables(constants)
                show_main_menu = False
            elif load_saved_game:
                try:
                    player, entities, game_map, message_log, game_state, priority_queue, global_variables, world = load_game()
                    show_main_menu = False
                except FileNotFoundError:
                    show_load_error_message = True
            elif exit_game:
                break

        else:
            libtcod.console_clear(con)
            play_game(player, entities, game_map, message_log, game_state, con, panel, constants, priority_queue, global_variables, world)

            show_main_menu = True # When play_game() is done, the menu reappears.
Example #14
0
def add_booking(db_connection, cursor, member_email):
    # list all rides offered by the user then select a ride to book a member
    # on
    #
    # username is the only match, and only show future rides

    print_logo("Add Booking")

    user = (member_email, )
    ride_numbers = []
    # retrieve all FUTURE rides offered by the user
    cursor.execute(
        "SELECT distinct r.rno, r.price, r.rdate, r.seats, r.lugDesc,r.src, r.dst, r.driver, r.cno FROM rides r WHERE driver = ? and rdate > date('now')",
        user)

    # fetch the ride matches
    ride_matches = cursor.fetchall()

    #  if there are none, tell the user, and ask if they want to offer a ride
    if not ride_matches:
        prompt = input(
            "\nYou Have Not Offered Any Rides\nDo You Want To Offer A Ride?\nYes/No: "
        ).strip()
        if prompt.strip() == 'yes':
            offer_ride(db_connection, cursor, member_email)
        elif prompt.strip() == 'no':
            return False

    # Print all the ride matches
    # make a list of ride_numbers for easier reference
    else:

        # print the rides one at a time
        ride_matches = list(ride_matches)
        for each, ride in enumerate(ride_matches):
            ride = list(ride)
            ride_matches[each] = ride
            for each, value in enumerate(ride):
                if value is None:
                    ride[each] = ""

        stop_list = False
        print("\nHere Are Your Future Rides: \n")
        global num_rides
        num_rides = (len(ride_matches) - 1)

        #make a list of just the ride numbers
        for each in ride_matches:
            ride_numbers.append(each[0])
        while stop_list == False:

            #print the data max 5 times at a time
            print("\n{:^5}{:^7}{:^12}{:^5}{:^15}{:^5}{:^5}{:^20}{:^5}".format(
                'rno', 'price', 'date', 'seats', 'lugDesc', 'src', 'dst',
                'driver', 'cno'))
            for count, ride in enumerate(ride_matches):
                print("\n{:^5}{:^7}{:^12}{:^5}{:^15}{:^5}{:^5}{:^20}{:^5}".
                      format(ride[0], ride[1], ride[2], ride[3], ride[4],
                             ride[5], ride[6], ride[7], ride[8]))

                #5 at a time
                if (count == num_rides) or count > 0 and (count % 4) == 0:

                    # get the input for a ride number
                    prompt = input(
                        "\nEnter a ride number or return to see more: ").strip(
                        )
                    if prompt == "":
                        print(
                            "\n{:^5}{:^7}{:^12}{:^5}{:^15}{:^5}{:^5}{:^20}{:^5}"
                            .format(ride[0], ride[1], ride[2], ride[3],
                                    ride[4], ride[5], ride[6], ride[7],
                                    ride[8]))
                        continue
                    elif prompt == 'exit':
                        stop_list = True
                        exit()
                    elif prompt.isdigit():
                        stop_list = True
                        break

        # User picks a ride they want to book on
        rno = prompt

    #Check if the ride_number belongs to one of the users
    for each in ride_matches:
        while not rno.isdigit() or int(rno) not in ride_numbers:
            rno = input("\nInvalid ride number, try again: ")

    rno = int(rno)

    #Check if the chosen ride is out of seats
    cursor.execute("SELECT seats FROM rides where rno = ? ", (rno, ))
    seats_available = cursor.fetchone()[0]
    print("\nRide Number: ", rno)
    print("\nSeats Available: ", seats_available)

    # if it is full, return a message asking to proceed
    if seats_available == 0:
        proceed = input("\nThis ride is full! Proceed?\n(yes/no)").strip()
        while proceed.lower not in ["no", "yes"]:
            proceed = input("\nPlease enter yes or no: ").strip()
        if proceed.lower() == 'no':
            add_booking(db_connection, cursor, member_email)
        elif proceed.lower() == 'yes':
            pass

    #If there are available seats, create new bookings number
    # and start collecting booking data
    elif seats_available > 0:
        cursor.execute("SELECT MAX(bno) from bookings")
        old_bno = cursor.fetchone()[0]
        new_bno = old_bno + 1

        #to check for a valid user
        member_to_book = input("\nEnter member's email to book: ").strip()
        cursor = db_connection.cursor()
        while not valid_user(member_to_book, cursor):
            member_to_book = input(
                "\nInvalid Email, Enter another email: ").strip()

        #Get how many seats to book for the member
        #Check that they input an int only
        while True:
            seats_to_book = input(
                "\nEnter the number of seats being booked: ").strip()

            try:
                # If we are over the seat limit
                if int(seats_to_book) > seats_available:
                    prompt = input(
                        "\nAttempting to overbook! Proceed?\n(yes/no): "
                    ).strip()
                    while prompt not in ('no', 'yes'):
                        prompt = input("\nPlease enter yes or no: ").strip()
                    if prompt.lower() == 'no':
                        add_booking(db_connection, cursor, member_email)
                    elif prompt.lower() == 'yes':
                        seats_to_book = int(seats_to_book)

                elif int(seats_to_book) == 0:
                    print("Can't book 0 seats.")

                elif int(seats_to_book) < 0:
                    print("Invalid number.")

                else:
                    seats_to_book = int(seats_to_book)
                    break
            except:
                continue

        #recieve the cost per seat and make sure a digit is put in
        # then change it into a float before putting in db
        valid_cost = False
        while valid_cost == False:
            try:
                cost_per_seat = input("\nEnter the cost per seat: ").strip()
                float(cost_per_seat)
                valid_cost = True
            except ValueError:
                cost_per_seat = print("\nInvalid Price!! Numbers only")

        #recieve the pickup code, then check for validity
        pickup = input("\nEnter the pickup location code: ").strip()
        while not valid_lcode(pickup, cursor):
            pickup = input("\nInvalid location code, try again: ").strip()

        # Recieve the dropff code, then check for validity
        dropoff = input("\nEnter the dropoff location code: ").strip()
        while not valid_lcode(dropoff, cursor):
            dropoff = input("\nInvalid location code, try again: ").strip()

        #The list of the new booking info
        new_booking = (
            new_bno,
            member_to_book,
            rno,
            cost_per_seat,
            seats_to_book,
            pickup,
            dropoff,
        )

        # GEt final prompt from user
        prompt = input("\nConfirm Booking? (yes/no):   ").strip()
        while prompt not in ["yes", "no"]:
            prompt = input("\nPlease enter yes or no: ").strip()
        if prompt == "yes":
            # Insert the new bookings into the table
            cursor.execute("INSERT INTO BOOKINGS VALUES(?,?,?,?,?,?,?)",
                           new_booking)
            seats_left = (int(seats_available) - int(seats_to_book))

            # Then update the rides table and message the booked member
            updated_ride = (
                seats_left,
                rno,
            )
            cursor.execute("UPDATE rides SET seats = ? where rno = ?",
                           updated_ride)

            message = "You have been booked on ride " + str(rno) + "."
            sender = member_email
            recipient = member_to_book
            message_member(db_connection, cursor, recipient, sender, message,
                           rno)
            db_connection.commit()
            # after booking, prompt to make another one
            prompt = input(
                "\nBooking Confirmed. Would you like to make another one?\n(yes/no): "
            ).strip()

            while prompt not in ["yes", "no"]:
                prompt = input("\nPlease enter yes or no: ").strip()
            if prompt == "yes":
                add_booking(db_connection, cursor, member_email)
            elif prompt == "no":
                menus.main_menu(db_connection, cursor, member_email)
            elif prompt == "exit":
                menus.main_menu(db_connection, cursor, member_email)
        elif prompt == "no":
            add_booking(db_connection, cursor, member_email)

    return True
Example #15
0
def ride_search(db_connection, cursor, member_email):
    # Searches for a ride
    # Keyword can match either the location code or substring of the city, province
    # or the address fields of the location
    # display all ride details and car details

    print_logo("Search Rides")

    # recieve input from user and split using blankspace
    prompt = input("\nEnter keywords or 'exit': ")
    if prompt.lower() == "exit":
        menus.main_menu(db_connection, cursor, member_email)
    else:
        # for each keyword given, make a sequence ins SQLite
        match_list = []
        master_list = []
        for keyword in prompt.split(" "):
            print("KEYWORD:" + keyword)
            keyword = "%" + keyword + "%"

            # a list of sequences for each possible match

            keywords = [
                keyword, keyword, keyword, keyword, keyword, keyword, keyword,
                keyword, keyword, keyword, keyword
            ]

            # execute query for each keyword
            cursor.execute(
                "SELECT distinct r.rno, r.price, r.rdate, r.seats, r.lugDesc,r.src, r.dst, r.driver, r.cno, c.make, c.model, c.year, c.seats FROM rides AS r LEFT OUTER JOIN enroute e on r.rno = e.rno LEFT OUTER JOIN locations l1 on r.src = l1.lcode LEFT OUTER JOIN locations l2 on r.dst = l2.lcode LEFT OUTER JOIN cars c on r.cno = c.cno WHERE r.src LIKE ? COLLATE NOCASE or r.dst LIKE ? COLLATE NOCASE or e.lcode LIKE ? COLLATE NOCASE or l1.lcode LIKE ? COLLATE NOCASE or l1.city LIKE ? COLLATE NOCASE or l1.prov LIKE ? COLLATE NOCASE or l1.address LIKE ? COLLATE NOCASE or l2.lcode LIKE ? COLLATE NOCASE or l2.city LIKE ? COLLATE NOCASE or l2.prov LIKE ? COLLATE NOCASE or l2.address LIKE ? COLLATE NOCASE GROUP BY r.rno;",
                keywords)

            # fetch all the matches for each keyword
            ride_matches = cursor.fetchall()

            if len(master_list) == 0:
                for each in ride_matches:
                    master_list.append(each)
            else:
                master_list[:] = [
                    each for each in ride_matches if each in master_list
                ]

        # the masterlist contains only matches all keywords
        # gets fetched as immutable tuples so must be converted into a list
        # for manipulation

        master_list = list(master_list)

        # Iterate through the list looking for none types and turn them
        # into empty strings
        for each, ride in enumerate(master_list):

            # gets fetched as immutable tuples so must be converted into a list
            # for manipulation
            ride = list(ride)
            master_list[each] = ride

            # if value is none type then replace with an empty string
            for each, value in enumerate(ride):
                if value is None:
                    ride[each] = ""

        # boolean to help listing
        stop_list = False

        print_logo("Search Rides")

        # print the labels
        print(
            "\n {:<5}{:<7}{:<12}{:<7}{:<15}{:<6}{:<6}{:<20}{:<5}{:<12}{:<10}{:<6}{:<10}"
            .format("rno", "price", "date", "seats", "LugDesc", "src", "dst",
                    "driver", "cno", "make", "model", "year", "seats"))

        # stop_list is only true if the the input is a ride number or exit
        while stop_list == False:

            #print matches maximum 5 at a time
            for count, each in enumerate(master_list):
                print(
                    "\n {:<5}{:<7}{:<12}{:<7}{:<15}{:<6}{:<6}{:<20}{:<5}{:<12}{:<10}{:<6}{:<10}"
                    .format(each[0], each[1], each[2], each[3], each[4],
                            each[5], each[6], each[7], each[8], each[9],
                            each[10], each[11], each[12]))

                # if we are at the last ride or the the 5th value, ask for an input

                if (count == len(master_list) - 1) or (count > 0 and
                                                       ((count + 1) % 5) == 0):
                    prompt = input(
                        "\n Enter a ride number or return to see more: "
                    ).strip()

                    #if the prompt is empty then keep listing
                    if prompt == "":

                        print_logo("Search Rides")

                        print(
                            "\n {:<5}{:<7}{:<12}{:<7}{:<15}{:<6}{:<6}{:<20}{:<5}{:<12}{:<10}{:<6}{:<10}"
                            .format("rno", "price", "date", "seats", "LugDesc",
                                    "src", "dst", "driver", "cno", "make",
                                    "model", "year", "seats"))

                        continue
                    #if the input is a digit then get the email of the driver who is offering the ride from the table
                    # the user will send a message to the driver
                    elif prompt.isdigit():
                        prompt = int(prompt)
                        cursor.execute(
                            "SELECT driver FROM rides WHERE rno = ?;",
                            (prompt, ))
                        driver = cursor.fetchone()[0]
                        stop_list == True
                        message = input(" Enter message: ")
                        message_member(db_connection, cursor, driver,
                                       member_email, message, int(prompt))
                    elif prompt == 'exit':
                        stop_list == True
                        menus.main_menu(db_connection, cursor, member_email)
    return True
def main():
    constants = get_constants()

    libtcod.console_set_custom_font('img/Tocky-square-10x10.png',
                                    libtcod.FONT_LAYOUT_ASCII_INROW)

    libtcod.console_init_root(constants['screen_width'],
                              constants['screen_height'],
                              constants['window_title'], False)

    con = libtcod.console_new(constants['screen_width'],
                              constants['screen_height'])
    panel = libtcod.console_new(constants['screen_width'],
                                constants['panel_height'])
    panel_bg = libtcod.console_new(constants['screen_width'],
                                   constants['panel_height'])
    info = libtcod.console_new(constants['info_width'],
                               constants['screen_height'])
    info_bg = libtcod.console_new(constants['info_width'],
                                  constants['screen_height'])
    player_con = libtcod.console_new(constants['player_con_width'],
                                     constants['player_con_x'])
    player_con_bg = libtcod.console_new(constants['player_con_width'],
                                        constants['player_con_x'])

    player = None
    entities = []
    game_map = None
    message_log = None
    game_state = None

    show_main_menu = True
    show_character_select = False

    show_load_error_message = False

    main_menu_background_image = libtcod.image_load('img/castle.png')
    character_select_background_image = libtcod.image_load('img/castle.png')

    key = libtcod.Key()
    mouse = libtcod.Mouse()

    while not libtcod.console_is_window_closed():
        libtcod.sys_check_for_event(
            libtcod.EVENT_KEY_PRESS | libtcod.EVENT_MOUSE, key, mouse)

        if show_main_menu and not show_character_select:

            main_menu(con, main_menu_background_image,
                      constants['screen_width'], constants['screen_height'])

            if show_load_error_message:
                message_box(con, 'No Save Game to Load', 50,
                            constants['screen_width'],
                            constants['screen_height'])

            libtcod.console_flush()

            action = handle_main_menu(key)

            new_game = action.get('new_game')
            load_saved_game = action.get('load_game')
            exit_game = action.get('exit')

            if show_load_error_message and (new_game or load_saved_game
                                            or exit_game):
                show_load_error_message = False

            elif new_game:
                show_character_select = True
                show_main_menu = False

            elif load_saved_game:
                try:
                    player, entities, game_map, message_log, game_state, permanent_cooldown_counter = load_game(
                    )
                    show_main_menu = False
                except FileNotFoundError:
                    show_load_error_message = True
            elif exit_game:
                break

        elif show_character_select and not show_main_menu:

            character_select_menu(con, character_select_background_image,
                                  constants['screen_width'],
                                  constants['screen_height'])

            libtcod.console_flush()

            action = handle_character_select(key)

            thief = action.get('thief')
            brute = action.get('brute')
            occultist = action.get('occultist')

            if thief:
                player, entities, game_map, message_log, game_state, permanent_cooldown_counter = initialize_game(
                    constants, "thief")
                game_state = GameStates.PLAYERS_TURN
                show_character_select = False

            elif brute:
                player, entities, game_map, message_log, game_state, permanent_cooldown_counter = initialize_game(
                    constants, "brute")
                player.fighter.heal(
                    player.inventory.items[0][0].equippable.max_hp_bonus)
                game_state = GameStates.PLAYERS_TURN
                show_character_select = False

            elif occultist:
                player, entities, game_map, message_log, game_state, permanent_cooldown_counter = initialize_game(
                    constants, "occultist")
                game_state = GameStates.PLAYERS_TURN
                show_character_select = False

        elif not (show_main_menu and show_character_select):
            libtcod.console_clear(con)
            play_game(player, entities, game_map, message_log, game_state, con,
                      panel, panel_bg, info, info_bg, player_con,
                      player_con_bg, constants, permanent_cooldown_counter)

            show_main_menu = True
Example #17
0
def main():
    constants = get_constants()

    # Instantiate main window
    libtcod.console_set_custom_font(
        "arial10x10.png",
        libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)
    libtcod.console_init_root(constants["screen_width"],
                              constants["screen_height"],
                              constants["window_title"], False)

    # Instantiate offscreen window for drawing
    window_main = libtcod.console_new(constants["screen_width"],
                                      constants["screen_height"])

    # Instantiate UI window
    ui_panel = libtcod.console_new(constants["screen_width"],
                                   constants["ui_panel_height"])

    player = None
    entities = []
    game_map = None
    message_log = None
    game_state = None

    show_main_menu = True
    show_load_error_message = False

    main_menu_background_image = libtcod.image_load(
        "ainsley.png")  #("menu_background.png")

    key = libtcod.Key()
    mouse = libtcod.Mouse()

    while not libtcod.console_is_window_closed():
        libtcod.sys_check_for_event(
            libtcod.EVENT_KEY_PRESS | libtcod.EVENT_MOUSE, key, mouse)

        if show_main_menu:
            action_keyboard = handle_main_menu_keys(key)

            # .get() returns None if not found
            new_game = bool(action_keyboard.get("new_game"))
            load_saved_game = bool(action_keyboard.get("load_game"))
            exit_game = bool(action_keyboard.get("exit"))

            menu_click_results = main_menu(window_main,
                                           main_menu_background_image,
                                           constants["screen_width"],
                                           constants["screen_height"], mouse)

            # Handle results of mouse click on menu item
            for result in menu_click_results:
                item_clicked = chr(result.get("item_clicked"))

                if item_clicked:
                    action_mouse = get_main_menu_option_from_index(
                        item_clicked)

                    new_game |= bool(action_mouse.get("new_game"))
                    load_saved_game |= bool(action_mouse.get("load_game"))
                    exit_game |= bool(action_mouse.get("exit"))

            if show_load_error_message:
                message_box(window_main, "No save game to load", 50,
                            constants["screen_width"],
                            constants["screen_height"])

            libtcod.console_flush()

            if show_load_error_message and (new_game or load_saved_game
                                            or exit_game):
                show_load_error_message = False
            elif new_game:
                player, entities, game_map, message_log, game_state = get_game_variables(
                    constants)
                game_state = GameStates.PLAYER_TURN

                show_main_menu = False
            elif load_saved_game:
                try:
                    player, entities, game_map, message_log, game_state = load_game(
                    )
                    show_main_menu = False
                except FileNotFoundError:
                    show_load_error_message = True
            elif exit_game:
                break

        else:
            libtcod.console_clear(window_main)
            play_game(player, entities, game_map, message_log, game_state,
                      window_main, ui_panel, constants, key, mouse)
            show_main_menu = True
Example #18
0
def main():

    constants = get_constants()

    font_path = 'arial12x12.png'  # this will look in the same folder as this script
    font_flags = libt.FONT_TYPE_GREYSCALE | libt.FONT_LAYOUT_TCOD  # the layout may need to change with a different font
    libt.console_set_custom_font(font_path, font_flags)

    fullscreen = False

    libt.console_init_root(constants['screen_width'],
                           constants['screen_height'],
                           constants['window_title'], fullscreen)

    con = libt.console_new(constants['screen_width'],
                           constants['screen_height'])
    panel = libt.console_new(constants['screen_width'],
                             constants['panel_height'])

    player = None
    entities = []
    game_map = None
    message_log = None
    game_state = None

    show_main_menu = True
    show_load_error_message = False

    main_menu_background_image = libt.image_load('menu_background.png')

    key = libt.Key()
    mouse = libt.Mouse()

    while not libt.console_is_window_closed():
        libt.sys_check_for_event(libt.EVENT_KEY_PRESS | libt.EVENT_MOUSE, key,
                                 mouse)

        if show_main_menu:
            main_menu(con, main_menu_background_image,
                      constants['screen_width'], constants['screen_height'])

            if show_load_error_message:
                message_box(con, 'No save game to load', 50,
                            constants['screen_width'],
                            constants['screen_height'])

            libt.console_flush()

            action = handle_main_menu(key)

            new_game = action.get('new_game')
            load_save_game = action.get('load_game')
            exit_game = action.get('exit')

            if show_load_error_message and (new_game or load_save_game
                                            or exit_game):
                show_load_error_message = False
            elif new_game:
                player, entities, game_map, message_log, game_state = get_game_variables(
                    constants)
                game_state = GameStates.PLAYERS_TURN

                show_main_menu = False
            elif load_save_game:
                try:
                    player, entities, game_map, message_log, game_state = load_game(
                    )
                    show_main_menu = False
                except FileNotFoundError:
                    show_load_error_message = True
            elif exit_game:
                break

        else:
            libt.console_clear(con)
            play_game(player, entities, game_map, message_log, game_state, con,
                      panel, constants)
            show_main_menu = True
Example #19
0
def main():
    constants = get_constants()

    tdl.set_font('arial12x12.png', greyscale=True, altLayout=True)

    root_console = tdl.init(constants['screen_width'],
                            constants['screen_height'],
                            title=constants['window_title'])
    con = tdl.Console(constants['screen_width'], constants['screen_height'])
    panel = tdl.Console(constants['screen_width'], constants['panel_height'])
    mouse_console = tdl.Console(1, 1)

    player = None
    entities = []
    game_map = None
    message_log = None
    game_state = None

    show_main_menu = True
    show_load_error_message = False

    main_menu_background_image = image_load('menu_background.png')

    while not tdl.event.is_window_closed():
        for event in tdl.event.get():
            if event.type == 'KEYDOWN':
                user_input = event
                break
        else:
            user_input = None

        if show_main_menu:
            main_menu(con, root_console, main_menu_background_image,
                      constants['screen_width'], constants['screen_height'])

            if show_load_error_message:
                message_box(con, root_console, 'No save game', 50,
                            constants['screen_width'],
                            constants['screen_height'])

            tdl.flush()

            action = handle_main_menu(user_input)

            new_game = action.get('new_game')
            load_saved_game = action.get('load_game')
            exit_game = action.get('exit')

            if show_load_error_message and (new_game or load_saved_game
                                            or exit_game):
                show_load_error_message = False
            elif new_game:
                player, entities, game_map, message_log, game_state = get_game_variables(
                    constants)
                game_state = GameStates.PLAYERS_TURN

                show_main_menu = False
            elif load_saved_game:
                try:
                    player, entities, game_map, message_log, game_state = load_game(
                    )
                    show_main_menu = False
                except FileNotFoundError:
                    show_load_error_message = True
            elif exit_game:
                break

        else:
            root_console.clear()
            con.clear()
            panel.clear()
            play_game(player, entities, game_map, message_log, game_state,
                      root_console, con, panel, mouse_console, constants)

            show_main_menu = True
Example #20
0
def main():
    constants = get_constants()

    #sets the font of the console to arial10x10.png
    tcod.console_set_custom_font('arial10x10.png', tcod.FONT_TYPE_GREYSCALE
        | tcod.FONT_LAYOUT_TCOD)

    #creates a non-fullscreen window with the width and height defined earlier
    #and the title of "Tutorial"
    tcod.console_init_root(constants['screen_width'], constants['screen_height'],
        constants['window_title'], False)

    con = tcod.console_new(constants['screen_width'], constants['screen_height'])
    panel = tcod.console_new(constants['screen_width'], constants['panel_height'])

    player = None
    entities = []
    world_map = None
    message_log = None
    game_state = None

    show_main_menu = True
    show_load_error_message = False

    main_menu_background_image = tcod.image_load('menu_background.png')

    key = tcod.Key()
    mouse = tcod.Mouse()

    while not tcod.console_is_window_closed():
        tcod.sys_check_for_event(tcod.EVENT_KEY_PRESS, key, mouse)

        if show_main_menu:
            main_menu(con, main_menu_background_image, constants['screen_width'], constants['screen_height'])

            if show_load_error_message:
                message_box(con, 'No save game to load', 50, constants['screen_width'], constants['screen_height'])

            tcod.console_flush()

            action = handle_main_menu(key)

            new_game = action.get('new_game')
            load_saved_game = action.get('load_game')
            exit_game = action.get('exit_game')

            #get better method for main menu item selection

            if show_load_error_message and (new_game or load_saved_game or exit_game):
                show_load_error_message = False
            elif new_game:
                player, entities, world_map, message_log, game_state = get_game_variables(constants)
                game_state = GameStates.PLAYER_TURN
                current_enemy = None

                show_main_menu = False
            elif load_saved_game:
                try:
                    player, entities, world_map, message_log, game_state, current_enemy = load_game()
                    show_main_menu = False
                except FileNotFoundError:
                    show_load_error_message = True
            elif exit_game:
                break

        else:
            tcod.console_clear(con)
            play_game(player, entities, world_map, message_log, game_state, current_enemy, con, panel, constants)

            show_main_menu = True
def main():
    constants = get_constants()

    terminal.open()
    terminal.set(f'window: size={constants["screen_width"]}x{constants["screen_height"]}, title="{constants["window_title"]}"; input: filter=[keyboard, mouse+]')

    player: Entity = None
    entities: List[Entity] = []
    game_map: GameMap = None
    message_log: MessageLog = None
    game_state: GameStates = None

    show_main_menu: bool = True
    show_load_error_message: bool = False

    while True:
        if show_main_menu:
            main_menu(screen_width=constants['screen_width'], screen_height=constants['screen_height'])

            if show_load_error_message:
                message_box(
                    header='No saved game to load.',
                    width=50,
                    screen_width=constants['screen_width'],
                    screen_height=constants['screen_height']
                )

            if terminal.has_input():
                terminal_input: int = terminal.read()

                action = handle_main_menu(key=terminal_input)

                new_game = action.get('new_game')
                load_saved_game = action.get('load_saved_game')
                exit_game = action.get('exit_game')

                if show_load_error_message and (new_game or load_saved_game or exit_game):
                    show_load_error_message = False
                elif new_game:
                    player, entities, game_map, message_log, game_state = get_game_variables(constants)
                    game_state = GameStates.PLAYERS_TURN

                    show_main_menu = False
                elif load_saved_game:
                    try:
                        player, entities, game_map, message_log, game_state = load_game()
                        show_main_menu = False
                    except FileNotFoundError:
                        show_load_error_message = True
                elif exit_game:
                    break

            terminal.refresh()

        else:
            play_game(
                player=player,
                entities=entities,
                game_map=game_map,
                message_log=message_log,
                game_state=game_state,
                constants=constants
            )

            show_main_menu = True

        terminal.clear()
    terminal.close()
Example #22
0
def terminate():
    pygame.quit()
    sys.exit()


def resource_path(relative):
    if hasattr(sys, "_MEIPASS"):
        return os.path.join(sys._MEIPASS, relative)
    return os.path.join(relative)


if __name__ == '__main__':
    import menus
    import gameplay

    pygame.init()
    fps_clock = pygame.time.Clock()
    display_surf = pygame.display.set_mode((WINDOWWIDTH, WINDOWHEIGHT))
    pygame.display.set_caption('Asteroids')

    while True:
        choice = menus.main_menu(display_surf, fps_clock)
        if choice == 0:
            score = gameplay.playgame(display_surf, fps_clock)
            menus.high_scores(display_surf, fps_clock, score)
        elif choice == 1:
            menus.high_scores(display_surf, fps_clock)
        elif choice == 2:
            terminate()
Example #23
0
def main():
    # 定数を読み込む
    constants = get_constants()

    # フォントの指定と(libtcod.FONT_TYPE_GRAYSCALE | libtcod.FONT_LAYOUT_TCOD)でどのタイプのファイルを読み取るのかを伝える
    libtcod.console_set_custom_font("arial10x10.png", libtcod.FONT_TYPE_GRAYSCALE | libtcod.FONT_LAYOUT_TCOD)

    # ここで実際に画面を作成する、画面サイズとタイトルとフルスクリーンとレンダラーと画面の垂直同期を指定している
    libtcod.console_init_root(constants["screen_width"], constants["screen_height"], constants["window_title"], False)

    con = libtcod.console.Console(constants["screen_width"], constants["screen_height"])
    panel = libtcod.console.Console(constants["screen_width"], constants["panel_height"])

    player = None

    entities = []
    game_map = None
    message_log = None
    game_state = None

    show_main_menu = True
    show_load_error_message = False

    main_menu_background_image = libtcod.image_load("menu_background.png")

    main_window = libtcod.console_is_window_closed()

    

    while True:
        if show_main_menu:
            main_menu(con, main_menu_background_image, constants["screen_width"],
                      constants["screen_height"])

            if show_load_error_message:
                message_box(con, "No save game to load", 50, constants["screen_width"], constants["screen_height"])

            libtcod.console_flush()
            for events in libtcod.event.get():
                if events.type == "KEYDOWN":
                    action = handle_main_menu(events)

                    new_game = action.get("new_game")
                    load_saved_game = action.get("load_game")
                    exit_game = action.get("exit")

                    if show_load_error_message and (new_game or load_saved_game or exit_game):
                        show_load_error_message = False
                    elif new_game:
                        player, entities, game_map, message_log, game_state = get_game_variables(constants)
                        game_state = GameStates.PLAYERS_TURN

                        show_main_menu = False
                    elif load_saved_game:
                        try:
                            player, entities, game_map, message_log, game_state = load_game()
                            show_main_menu = False
                        except FileNotFoundError:
                            show_load_error_message = True
                    elif exit_game:
                        return False


        else:
            libtcod.console_clear(con)
            play_game(player, entities, game_map, message_log, game_state, con, panel, constants)

            show_main_menu = True
Example #24
0
def main():
    constants = get_constants()

    tdl.set_font("arial10x10.png", greyscale=True, altLayout=True)

    root_console = tdl.init(constants["screen_width"],
                            constants["screen_height"],
                            constants["window_title"])
    con = tdl.Console(constants["screen_width"], constants["screen_height"])
    panel = tdl.Console(constants["screen_width"], constants["panel_height"])

    player = None
    entities = []
    game_map = None
    message_log = None
    game_state = None

    show_main_menu = True
    show_load_error_message = False

    # image for the main menu, change this to something unique later
    main_menu_background_image = image_load("menu_background.png")

    while not tdl.event.is_window_closed():
        for event in tdl.event.get():
            if event.type == "KEYDOWN":
                user_input = event
                break
        else:
            user_input = None

        if show_main_menu:
            main_menu(con, root_console, main_menu_background_image,
                      constants["screen_width"], constants["screen_height"],
                      constants["colors"])

            if show_load_error_message:
                message_box(con, root_console, "No save game to load", 50,
                            constants["screen_width"],
                            constants["screen_height"])

            tdl.flush()

            action = handle_main_menu(user_input)

            new_game = action.get("new_game")
            load_saved_game = action.get("load_game")
            exit_game = action.get("exit")

            if show_load_error_message and (new_game or load_saved_game
                                            or exit_game):
                show_load_error_message = False
            elif new_game:
                player, entities, game_map, message_log, game_state = get_game_variables(
                    constants)
                game_state = GameStates.PLAYERS_TURN

                show_main_menu = False
            elif load_saved_game:
                try:
                    player, entities, game_map, message_log, game_state = load_game(
                    )
                    show_main_menu = False
                except FileNotFoundError:
                    show_load_error_message = True
            elif exit_game:
                break

        else:
            root_console.clear()
            con.clear()
            panel.clear()
            play_game(player, entities, game_map, message_log, game_state,
                      root_console, con, panel, constants)

            show_main_menu = True
Example #25
0
def main():
    constants = get_constants()

    libtcod.console_set_custom_font(
        'arial10x10.png',
        libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)

    libtcod.console_init_root(constants['screen_width'],
                              constants['screen_height'],
                              constants['window_title'], False)

    con = libtcod.console_new(constants['screen_width'],
                              constants['screen_height'])
    panel = libtcod.console_new(constants['screen_width'],
                                constants['panel_height'])

    player = None
    entities = []
    game_map = None
    message_log = None
    game_state = None

    show_main_menu = True
    show_load_error_message = False

    main_menu_background_image = libtcod.image_load('menu_background.png')

    key = libtcod.Key()
    mouse = libtcod.Mouse()

    while not libtcod.console_is_window_closed():
        libtcod.sys_check_for_event(
            libtcod.EVENT_KEY_PRESS | libtcod.EVENT_MOUSE, key, mouse)

        if show_main_menu:
            main_menu(con, main_menu_background_image,
                      constants['screen_width'], constants['screen_height'])

            if show_load_error_message:
                message_box(con, 'No save game to load', 50,
                            constants['screen_width'],
                            constants['screen_height'])

            libtcod.console_flush()

            action = handle_main_menu(key)

            new_game = action.get('new_game')
            load_saved_game = action.get('load_game')
            exit_game = action.get('exit')

            if show_load_error_message and (new_game or load_saved_game
                                            or exit_game):
                show_load_error_message = False
            elif new_game:
                player, entities, game_map, message_log, game_state = get_game_variables(
                    constants)
                game_state = GameStates.PLAYERS_TURN

                show_main_menu = False
            elif load_saved_game:
                try:
                    player, entities, game_map, message_log, game_state = load_game(
                    )
                    show_main_menu = False
                except FileNotFoundError:
                    show_load_error_message = True
            elif exit_game:
                break

        else:
            libtcod.console_clear(con)
            play_game(player, entities, game_map, message_log, game_state, con,
                      panel, constants)

            show_main_menu = True
def main():
    libtcod.sys_set_fps(30)
    constants = get_constants()

    player = None
    entities = []
    game_map = None
    message_log = None
    show_main_menu = True
    show_load_error_message = False

    key = libtcod.Key()
    mouse = libtcod.Mouse()

    libtcod.console_set_custom_font(
        'Fonts/terminal8x8_gs_ro.png',
        libtcod.FONT_TYPE_GRAYSCALE | libtcod.FONT_LAYOUT_ASCII_INROW)
    hp_bar = libtcod.console.Console(constants['stat_bar_width'],
                                     constants['stat_bar_height'])
    xp_bar = libtcod.console.Console(constants['stat_bar_width'],
                                     constants['stat_bar_height'])
    panel = libtcod.console.Console(constants['panel_width'],
                                    constants['panel_height'])
    main_menu_background_image = libtcod.image_load('sludge2.png')

    with libtcod.console_init_root(constants['root_width'],
                                   constants['root_height'],
                                   constants['window_title'],
                                   True,
                                   libtcod.RENDERER_SDL2,
                                   vsync=True) as root_console:
        while True:
            libtcod.sys_check_for_event(
                libtcod.EVENT_KEY_PRESS | libtcod.EVENT_MOUSE, key, mouse)

            if show_main_menu:
                main_menu(root_console, main_menu_background_image,
                          constants['root_width'], constants['root_height'])

                if show_load_error_message:
                    message_box(root_console, 'No save game to load', 50,
                                constants['root_width'],
                                constants['root_height'])

                custrender.clear((0, 0, 0))
                custrender.accumulate(
                    root_console,
                    custrender.get_viewport(root_console, True, True))
                custrender.present()
                root_console.clear(fg=(255, 255, 255))

                action = handle_main_menu(key)

                new_game = action.get('new_game')
                load_saved_game = action.get('load_game')
                exit_game = action.get('exit')

                if show_load_error_message and (new_game or load_saved_game
                                                or exit_game):
                    show_load_error_message = False
                elif new_game:
                    player, entities, game_map, message_log, game_state = get_game_variables(
                        constants)
                    game_state = GameStates.PLAYERS_TURN

                    show_main_menu = False
                elif load_saved_game:
                    try:
                        player, entities, game_map, message_log, game_state = load_game(
                        )
                        show_main_menu = False
                    except FileNotFoundError:
                        show_load_error_message = True
                elif exit_game:
                    raise SystemExit()

            else:
                play_game(player, entities, game_map, message_log,
                          root_console, panel, hp_bar, xp_bar, constants)

                show_main_menu = True
Example #27
0
def main():
    """main() starts the app and displays the main menu"""
    main_menu()

    # This is where user input is read and assigned to a variable
    # In Python 3, raw_input() has been replaced by input()
    # The = operator assigns a value to a variable
    choice = raw_input("Enter Your Selection: ")  # the argument is the prompt that will show in terminal

    # Try blocks allow the code to handle errors instead of exiting prematurely
    try:

        # Call functions based on user input
        # if means if. The == operator means 'is equal to'. other operators are !=, <=, >=
        if int(choice) == 1:

            # this code will be executed if the user inputs the number 1 in the terminal
            # this function comes from the menu module that we imported at the top of the file
            os.system('cls' if os.name == 'nt' else 'clear')
            add_menu()

            # this should look familiar. Same as before.
            choice = raw_input("Enter your selection: ")

            try:
                if int(choice) == 1:
                    # add new directive
                    os.system('cls' if os.name == 'nt' else 'clear')
                    directive = raw_input("Type new directive: ")
                    add_field('directives', 'directive', directive)
                    three_prints()
                    print "Directive added"
                    three_prints()
                    time.sleep(2)
                    main()

                elif int(choice) == 2:
                    # add new adjective
                    os.system('cls' if os.name == 'nt' else 'clear')
                    adjective = raw_input("Type new adjective: ")
                    add_field('adjectives', 'adjective', adjective)
                    three_prints()
                    print "Adjective added"
                    three_prints()
                    time.sleep(2)
                    main()

                elif int(choice) == 3:
                    # add new name
                    os.system('cls' if os.name == 'nt' else 'clear')
                    name = raw_input("Type new name: ")
                    add_field('names', 'name', name)
                    three_prints()
                    print "Name added"
                    three_prints()
                    time.sleep(2)
                    main()

                elif int(choice) == 4:
                    # main menu
                    os.system('cls' if os.name == 'nt' else 'clear')
                    main()

                elif int(choice) == 5:
                    # exit
                    os.system('cls' if os.name == 'nt' else 'clear')
                    three_prints()
                    print "See you in hell, asshole!"
                    three_prints()
                    exit()

                else:
                    print
                    print "Sorry, I didn't understand you. Maybe you fat fingered your choice."
                    print

                    time.sleep(2)
                    main()

            except ValueError:
                os.system('cls' if os.name == 'nt' else 'clear')
                three_prints()
                print "You f****d up. What are you, retarded?"
                three_prints()
                time.sleep(2)
                main()

        # elif (else if) code will be executed if the user inputs 2.
        # the int(function) transforms the choice variable into an integer
        elif int(choice) == 2:

            # this comes from the addwords module that we created
            # functions should be lower case and underscore separated
            os.system('cls' if os.name == 'nt' else 'clear')
            three_prints()
            print generate_insult()
            three_prints()
            time.sleep(2)
            main()

        # another "else if" conditional with another block of code indented underneath
        elif int(choice) == 3:

            # In Python 3, the print statement has been replaced by the print() function
            # this would be 'print("well f**k off then")'
            os.system('cls' if os.name == 'nt' else 'clear')
            three_prints()
            print "Well f**k off then"
            three_prints()

            # sleep puts code execution on hold, takes number of seconds as an argument
            time.sleep(2)

            # exit() terminates the program
            exit()

        # else covers every conditional not previously covered in an if or elif block
        else:
            os.system('cls' if os.name == 'nt' else 'clear')
            print
            print "Sorry, I didn't understand you. Maybe you fat fingered your choice."
            print
            time.sleep(2)

            # You can call a function inside of itself. This is called recursion.
            # Recursion can be much more useful than this simple example. We will get to that.
            os.system('cls' if os.name == 'nt' else 'clear')
            main()

    # this except block will handle all ValueError exceptions that can occur. In this instance, that would apply
    # to the user inputting anything other than a number when making a menu selection
    except ValueError:

        # here we tell the user to stop being a f*****g dipshit
        os.system('cls' if os.name == 'nt' else 'clear')
        three_prints()
        print "You f****d up. What are you, retarded?"
        three_prints()
        time.sleep(2)
        main()
Example #28
0
)
menus.prompt()
Characters.add_equipment(equipment.cursed_ring, 1)
print("\n\nLet's take a look at your party!")
menus.prompt()
print()
Characters.check_members()
while True:
    answer = input(
        "\nWould you like me to help you equip your characters? Yes (y), No (n): "
    )
    if answer.lower() == "y":
        print()
        char1.full_equip(
            [equipment.broad_sword, equipment.chain_mail, equipment.gauntlet])
        char2.full_equip(
            [equipment.wood_staff, equipment.magic_robe, equipment.magic_ring])
        char3.full_equip(
            [equipment.cat_claws, equipment.cat_fur, equipment.cat_ears])
        print("\nLet's take another look at your party members.")
        menus.prompt()
        print()
        Characters.check_members()
        break
    elif answer.lower() == "n":
        break
    else:
        continue
menus.main_menu()
print("\n\nAnd the characters set off on their adventure!")
print("\nThanks for playing! More coming soon.\n")
Example #29
0
#!/usr/bin/env python3
"""
Author   : Evan Elias Young
Date     : 2020-03-14
Revision : 2020-03-14
"""

from menus import main_menu

if __name__ == '__main__':
    main_menu()
Example #30
0
def main_screen(constants):
    con = libtcod.console_new(constants['screen_width'], constants['screen_height'])
    panel = libtcod.console_new(constants['screen_width'], constants['panel_height'])

    print('DEBUG : MAIN SCREEN')
    player = None
    entities = []
    game_map = None
    message_log = None
    game_state = None

    show_main_menu = True
    show_load_error_message = False
    show_score_bill = False
    show_creation_menu = False
    show_load_menu = False

    character_name = str("")
    main_menu_background_image = libtcod.image_load('menu_background.png')

    key = libtcod.Key()
    mouse = libtcod.Mouse()

    while not libtcod.console_is_window_closed():
        libtcod.sys_check_for_event(libtcod.EVENT_KEY_PRESS | libtcod.EVENT_MOUSE, key, mouse)

        if show_main_menu:
            main_menu(con, main_menu_background_image, constants['screen_width'], constants['screen_height'],
                      constants['version'])

            if show_load_error_message:
                message_box(con, 'No save game to load', 50, constants['screen_width'], constants['screen_height'])

            libtcod.console_flush()

            action = handle_main_menu(key)

            new_game = action.get('new_game')
            load_saved_game = action.get('load_game')
            score_bill = action.get('score_bill')
            exit_game = action.get('exit')
            fullscreen = action.get('fullscreen')

            if fullscreen:
                libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen())

            if show_load_error_message and (new_game or load_saved_game or exit_game):
                show_load_error_message = False

            elif new_game:
                # v14.
                show_main_menu = False
                show_creation_menu = True

            elif load_saved_game:
                # v15
                if show_load_menu == False:
                    number_of_games = get_saved_games()
                    if number_of_games == []:
                        show_load_error_message = True
                    else:
                        show_main_menu = False
                        show_load_menu = True

                    '''
                    try:
                        player, entities, game_map, message_log, game_state = load_game()
                        show_main_menu = False
                    except FileNotFoundError:
                        show_load_error_message = True
                    '''

            # v14
            elif score_bill:
                show_main_menu = False
                show_score_bill = True

            elif exit_game:
                break

        # v15
        elif show_load_menu:
            number_of_games = get_saved_games()
            print('INFO : number of games : ', number_of_games)
            header = 'Choose your save :'
            menu(con, header, number_of_games, int(constants['screen_width'] / 2), constants['screen_width'],
                 constants['screen_height'])

            libtcod.console_flush()

            action = handle_load_menu(key)

            load_chosen = None
            load_chosen = action.get('load_chosen')
            load_exit = action.get('load_exit')

            if load_exit:
                show_main_menu = True
                show_load_menu = False

            if load_chosen != None:
                try:
                    save_to_load = number_of_games[load_chosen]
                    player, entities, game_map, message_log, game_state = load_game(save_to_load)
                    show_main_menu = False
                    show_creation_menu = False
                    show_score_bill = False
                    show_load_menu = False

                except FileNotFoundError:
                    show_load_error_message = True

        # v14
        elif show_creation_menu:
            character_creation_menu(main_menu_background_image, constants['screen_width'],
                                      constants['screen_height'], character_name)

            libtcod.console_flush()

            action = handle_character_creation_menu(key)

            exit_creation = action.get('exit_creation')
            validate_creation = action.get('validate_creation')
            letter = action.get('letter')

            if letter == 'backspace':
                if len(character_name) > 0:
                    character_name = character_name[:-1]

            if letter in ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '-']:
                if len(character_name) < 10:
                    character_name += str(letter)

            if validate_creation:
                if len(character_name) == 0:
                    character_name = 'Player'

                show_creation_menu = False
                player, entities, game_map, message_log, game_state = get_game_variables(constants)
                player.name = character_name
                game_state = GameStates.PLAYERS_TURN

            if exit_creation:
                show_creation_menu = False
                show_main_menu = True

        # v14
        elif show_score_bill:
            # show score bill.
            score_bill_menu(main_menu_background_image, constants['screen_width'],
                            constants['screen_height'])

            libtcod.console_flush()

            action = handle_score_bill_menu(key)
            exit_score_bill = action.get('score_exit')

            if exit_score_bill:
                show_score_bill = False
                show_main_menu = True

        else:
            libtcod.console_clear(con)
            play_game(player, entities, game_map, message_log, game_state, con, panel, constants)

            show_main_menu = True