コード例 #1
0
def run_normal_menu():
    first_price_box.run()
    standard_price_box.run()

    typing.write(typing.retro_8x10, 'Price of a first class ticket:', (renderer.mid_x, renderer.mid_y - 50))
    typing.write(typing.retro_8x10, 'Price of a standard class ticket:', (renderer.mid_x, renderer.mid_y + 50))

    if next_button.run():
        global_data.first_price = first_price_box.run()
        global_data.standard_price = standard_price_box.run()
        return True

    return False
コード例 #2
0
def run():
    typing.write(typing.retro_8x10, 'UK airport:',
                 (renderer.mid_x, renderer.mid_y - 100))
    typing.write(typing.retro_8x10, 'Overseas airport:',
                 (renderer.mid_x, renderer.mid_y))
    if save_button.run():
        if uk_airport_box.correct and overseas_airport_box.correct:
            global_data.uk_airport = uk_airport_box.run()
            global_data.overseas_airport = overseas_airport_box.run()
            return global_data.main_menu

    uk_airport_box.run()
    overseas_airport_box.run()

    return global_data.enter_airport_details
コード例 #3
0
def run():
    typing.write(typing.retro_8x10, 'Route stats:',
                 (renderer.mid_x, renderer.mid_y - 175))

    if main_menu_button.run():
        return global_data.main_menu

    def find_overseas_airport(airport_code):
        for airport in global_data.list_of_airports:
            if airport.code == airport_code:
                return airport

    if global_data.uk_airport == 'LJL':
        airport_dist = find_overseas_airport(
            global_data.overseas_airport).dist_LJL
    else:
        airport_dist = find_overseas_airport(
            global_data.overseas_airport).dist_BI

    try:
        standard_seats = int(
            global_data.airplane_types_data[global_data.airplane_type][
                global_data.max_capacity]) - int(global_data.first_seats) * 2
        cost_per_seat = global_data.airplane_types_data[
            global_data.airplane_type][
                global_data.running_cost] * airport_dist / 100
        cost = float(cost_per_seat) * (float(global_data.first_seats) +
                                       float(standard_seats))
        income = float(global_data.first_seats) * float(
            global_data.first_price) + standard_seats * float(
                global_data.standard_price)
        profit = income - cost

        typing.write(typing.retro_8x10,
                     f'The flight costs {cost_per_seat} per seat',
                     (renderer.mid_x, renderer.mid_y - 100))
        typing.write(typing.retro_8x10, f'The flight costs {cost} in total',
                     (renderer.mid_x, renderer.mid_y - 50))
        typing.write(typing.retro_8x10, f'The total income of {income}',
                     (renderer.mid_x, renderer.mid_y))
        typing.write(typing.retro_8x10, f'The profit is {profit}',
                     (renderer.mid_x, renderer.mid_y + 50))
    except ValueError:
        print(
            f"Bug found: calc_profit_info.run() found a value error. Probably because it is "
            f"trying to float or int a string or something.")

    return global_data.calc_profit_info
コード例 #4
0
def run():

    typing.write(typing.retro_8x10, 'Some data still needs to be entered:',
                 (center_x, center_y))

    if main_menu_button.run():
        return global_data.main_menu

    if global_data.overseas_airport == '' or global_data.uk_airport == '':
        if enter_airport_details.run():
            return global_data.enter_airport_details

    if global_data.first_seats == 0 or global_data.airplane_type == -1:
        if enter_flight_details.run():
            return global_data.enter_flight_details

    return global_data.calc_profit_enter
コード例 #5
0
def run():
    if global_data.airplane_type == -1 or global_data.uk_airport == '' or global_data.overseas_airport == '' or global_data.first_seats == 0:
        return global_data.calc_profit_enter

    elif global_data.first_price != 0 and global_data.standard_price != 0:
        return global_data.calc_profit_info

    else:
        airplane_max = global_data.airplane_types_data[global_data.airplane_type][global_data.max_range]

        if global_data.uk_airport == 'lpl':
            airport_dist = find_overseas_airport().dist_LJL
        else:
            airport_dist = find_overseas_airport().dist_BI

        if airplane_max < int(airport_dist):
            typing.write(typing.retro_8x10, 'The range of the selected', (renderer.mid_x, renderer.mid_y - 50))
            typing.write(typing.retro_8x10, 'airplane is too short for', (renderer.mid_x, renderer.mid_y))
            typing.write(typing.retro_8x10, 'the flight plan', (renderer.mid_x, renderer.mid_y + 50))
            py.display.flip()
            time.sleep(5)
            return global_data.main_menu

        else:
            if run_normal_menu():
                return global_data.calc_profit_info

    return global_data.calc_profit_data
コード例 #6
0
def run():
    if medium_narrow_button.run():
        global_data.airplane_type = global_data.medium_narrow
    if large_narrow_button.run():
        global_data.airplane_type = global_data.large_narrow
    if medium_wide_button.run():
        global_data.airplane_type = global_data.medium_wide

    typing.write(typing.retro_8x10, 'Number of first class seats:',
                 (renderer.mid_x, renderer.mid_y))
    if save_button.run():
        if first_seats_box.correct and global_data.airplane_type != -1:
            global_data.first_seats = first_seats_box.run()
            return global_data.main_menu

    first_seats_box.run()

    if global_data.airplane_type == -1:
        message = 'n/a'
    elif global_data.airplane_type == 0:
        message = 'medium narrow'
    elif global_data.airplane_type == 1:
        message = 'large narrow'
    elif global_data.airplane_type == 2:
        message = 'medium wide'
    else:
        message = f'Error: airplane type is {global_data.airplane_type}'

    typing.write(typing.retro_8x10, 'Airplane type: ' + message,
                 (renderer.mid_x, renderer.mid_y - 200))

    if global_data.airplane_type != -1:
        if get_info_button.run():
            return global_data.get_info

    return global_data.enter_flight_details
コード例 #7
0
ファイル: get_info.py プロジェクト: revers3ntropy/Compsci_NEA
def run():
    info = global_data.airplane_types_data[global_data.airplane_type]

    message = 'running cost: ' + str(info[global_data.running_cost])
    typing.write(typing.retro_8x10, message,
                 (renderer.mid_x, renderer.mid_y - 100))
    message = 'maximum range: ' + str(info[global_data.max_range])
    typing.write(typing.retro_8x10, message,
                 (renderer.mid_x, renderer.mid_y - 50))
    message = 'maximum capacity: ' + str(info[global_data.max_capacity])
    typing.write(typing.retro_8x10, message, (renderer.mid_x, renderer.mid_y))
    message = 'minimum first class seats: ' + str(
        info[global_data.min_first_class])
    typing.write(typing.retro_8x10, message,
                 (renderer.mid_x, renderer.mid_y + 50))

    if back_button.run():
        return global_data.enter_flight_details

    return global_data.get_info
コード例 #8
0
def tick_stats():
    # UK airport
    if global_data.uk_airport != '':
        message = f'UK airport: {global_data.uk_airport}'
    else:
        message = 'Uk airport: N/A'
    typing.write(typing.retro_8x10, message,
                 (renderer.mid_x, renderer.mid_y - 50))

    # Overseas airport
    if global_data.overseas_airport != '':
        message = f'Overseas airport: {global_data.overseas_airport}'
    else:
        message = 'Overseas airport: N/A'
    typing.write(typing.retro_8x10, message,
                 (renderer.mid_x, renderer.mid_y - 20))

    # Airplane type
    if global_data.airplane_type != -1:
        message = f'Airplane type: {global_data.airplane_type}'
    else:
        message = 'Airplane type: N/A'
    typing.write(typing.retro_8x10, message,
                 (renderer.mid_x, renderer.mid_y + 10))

    # Number of first class seats
    message = f'Number of First class seats: {global_data.first_seats}'
    typing.write(typing.retro_8x10, message,
                 (renderer.mid_x, renderer.mid_y + 40))

    # First class seat price
    message = f'Price of first class seats: {global_data.first_price}'
    typing.write(typing.retro_8x10, message,
                 (renderer.mid_x, renderer.mid_y + 70))

    # Standard class seat price
    message = f'standard class seat price: {global_data.standard_price}'
    typing.write(typing.retro_8x10, message,
                 (renderer.mid_x, renderer.mid_y + 100))
コード例 #9
0
ファイル: renderer.py プロジェクト: revers3ntropy/Compsci_NEA
# ================================================================================================
"""
                                         Joseph Coppin
                                  Computer Science GSCE Coursework

Description of file

Global Functions:

Imports:                                                                                         """

screen_x = 1000
screen_y = 600
mid_x = screen_x / 2
mid_y = screen_y / 2

background_colour = (255, 255, 255)
# how fast the program should run ideally
run_FPS = 60

# initialises pygame
py.init()
screen = py.display.set_mode((screen_x, screen_y))
clock = py.time.Clock()

# puts starting message on the screen
screen.fill((255, 255, 255))
typing.write(typing.retro_8x10, 'Please look at the console', (mid_x, mid_y))
typing.write(typing.retro_8x10, 'for options', (mid_x, mid_y + 40))
py.display.update()
コード例 #10
0
 def display(self, message):
     typing.write(self.font, message, (self.x, self.y))