示例#1
0
def ship_hanger():
    #Set user variable for simplicity
    user = __builtin__.active_user
    #Clear the screen
    os.system('clear')
    #Generate the view file
    result = view_generator()
    #Check to see that it completed successfully.  If it didn't, exit gracefully.  If it did, show view.
    if result:
        hanger_screen = open("./Data/ship_hanger.txt", 'r')
        for line in hanger_screen:
            sys.stdout.write(line)
        sys.stdout.write("\n")
        os.remove("./Data/ship_hanger.txt")
    else:
        print "Error creating ship hanger view.  Exiting."
        sys.exit(1)
    #Print player ship list with names
    file_path = "./Players/" + user + ".data"
    # Import player.json data
    with open(file_path) as player_data:
        player_json = json.load(player_data)
    selection = get_selection()
    #Check command, and if "back" return to previous screen
    if selection.lower() == "back":
        selection_screen.selection_screen()
    elif selection.lower() == "roster":
        os.system('clear')
        roster_view(user)
    elif selection.lower() == "science":
        science_view()
		
def selector(selection):
    user = __builtin__.active_user
    if selection == "back":
        selection_screen.selection_screen()
    elif selection == "help":
        helpfile = open('./Data/salvage_agents.help', 'r')
        os.system('clear')
        sys.stdout.write("\n")
        for line in helpfile:
            sys.stdout.write(line)
        sys.stdout.write("\n")
        sub_selection = raw_input("Back | Exit".center(80) + "\n\n" + prompt(user))
        command_process(sub_selection)
        if sub_selection == "back":
            salvage_missions()
    else:
        if selection in current_agents:
            agent_view(selection)            
        else:
            print "Invalid Selection."
            sleep(2)
            salvage_missions()