Example #1
0
def selection_process(input):
    # Load up player file
    file_path = "./Players/" + __builtin__.active_user + ".data"
    with open(file_path) as player_data:
        player_json = json.load(player_data)
    player_ship_list = player_json[__builtin__.active_user]["ship_list"]
    if input == "info":
        id = raw_input("\nPlease enter the ID number of the ship:\n")
        if int(id) in player_ship_list:
            info_generator(id)
            sys.stdout.write("\n")
            selection = raw_input("Info | Back | Exit".center(80) + "\n\n" + prompt(__builtin__.active_user))
            if selection.lower() == "back":
                os.system('clear')
                roster_view(__builtin__.active_user)
            else:
                selection_process(selection)
        else:
            if id in ship_json:
                print "You do not command that ship.\n"
                selection_process(input)
            else:
                print "That vessel does not exist.\n"
                selection_process(input)
    elif input == "back":
        ship_hanger.ship_hanger()
    else:
        command_process(input)
        print "Invalid Selection."
        selection = raw_input("Info | Back | Exit".center(80) + "\n\n" + prompt(__builtin__.active_user))
        selection_process(selection)
Example #2
0
def levels_view(sector_id, wormhole):
    view_creator(sector_id)
    sector_view_file = open('./Data/levels_view.txt', 'r')
    for line in sector_view_file:
        sys.stdout.write(line)
    selection = raw_input("Level | Back | Exit".center(80) + "\n\n" + prompt(__builtin__.active_user))
    command_process(selection)
    selection_process(selection, wormhole)
Example #3
0
def selection_process(selection):
    if selection.lower() == "applied research":
        applied_research()
    else:
        print "\n Invalid selection.  Please try again.\n"
        selection = raw_input("Applied Research".center(80) + "\n\n" + prompt(__builtin__.active_user))
        command_process(selection)
        selection_process(selection)
Example #4
0
def roster_view(user):
    result = view_generator(user)
    if result:
        roster_view_file = open('./Data/roster.txt')
    for line in roster_view_file:
        sys.stdout.write(line)
    sys.stdout.write("\n")
    selection = raw_input("Info | Back | Exit".center(80) + "\n\n" + prompt(__builtin__.active_user))
    selection_process(selection)
Example #5
0
def science_view():
    view_creator()
    science_file = open('./Data/science.txt', 'r')
    os.system('clear')
    for line in science_file:
        sys.stdout.write(line)
    sys.stdout.write("\n")
    selection = raw_input("Applied Research".center(80) + "\n\n" + prompt(__builtin__.active_user))
    command_process(selection)
    selection_process(selection)
Example #6
0
def get_selection():
    user = __builtin__.active_user
    #Print prompt and wait for input
    user_select = raw_input("Engineering | Roster | Salvage | Science | Galactic Market | Exit".center(80) + "\n\n" + 
        prompt(user))
    #Check command to see if it was a special case i.e. exit
    result = command_process(user_select)
    if result == "null":
        print "Invalid Selection.  Please try again.\n"
        get_selection()
    else:
        return str(user_select)
def selection_process():
	selection = raw_input(prompt(__builtin__.active_user))
	# Check for exit/back commands
	command_process(selection)
	selection = selection.lower()
	if selection == "ship hanger":
		f = open('./Data/ship_hanger.txt', 'w')
		f.close()
		ship_hanger()
	elif selection == "wormholes":
		wormholes_view()
	elif selection == "salvage missions":
		salvage_missions()
	elif selection == "communications":
		communications()
	else:
		print "Invalid Selection"
		selection_process()
def salvage_missions():
    user = __builtin__.active_user
    with open("./Players/" + user + ".data") as player_data:
        player_json = json.load(player_data)
    os.system('clear')
    sys.stdout.write(full_line*3)
    sys.stdout.write(empty_line)
    sys.stdout.write(beginning_line + "Salvage Missions".center(50) + end_line)
    sys.stdout.write(empty_line)
    sys.stdout.write(beginning_line + " "*5 + "Available Agents:" + " "*28 + end_line)
    sys.stdout.write(empty_line)
    for agent in current_agents:
        sys.stdout.write(beginning_line + " "*5 + agent.upper() + " "*(45 - len(str(agent))) + end_line)
    tech_string = "Available Tech: %s" % player_json[user]["tech"]
    sys.stdout.write(beginning_line + tech_string.center(50) + end_line)
    sys.stdout.write(empty_line)
    sys.stdout.write(full_line*3)
    sys.stdout.write("\n")
    selection = raw_input("Agent | Back | Help | Exit".center(80) + "\n\n" + prompt(user))
    selection = selection.lower()
    command_process(selection)
    selector(selection)
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()
Example #10
0
def sectors_view(wormhole):
    view_creator(wormhole)
    os.system('clear')
    sub_view = open("./Data/sectors.txt", 'r')
    for line in sub_view:
        sys.stdout.write(line)
    selection = raw_input("Please select a level:".center(80) + "\n\n" + "Level | Back | Exit".center(80) + "\n\n" + prompt(__builtin__.active_user))
    selection = selection.lower()
    selection_process(selection, wormhole)
Example #11
0
def agent_view_creator(selection):
    # Set variables and open files
    counter = 1
    priority_dict = {}

    with open("./Data/ships.json") as ships_json:
        ship_data = json.load(ships_json)
    user = __builtin__.active_user

    # Begin generating race-specific agent view
    os.system('clear')
    sys.stdout.write(full_line*3)
    sys.stdout.write(empty_line)
    sys.stdout.write(beginning_line + (selection.upper() + " Agent").center(50) + end_line)
    sys.stdout.write(empty_line)
    sys.stdout.write(beginning_line + " Current ships with x2 salvage rate:" + " "*14 + end_line)
    # Check to see what agent/race we should be displaying.
    for item in bonus_list:
        string = ship_data[str(item)]["name"]
        sys.stdout.write(beginning_line + "     " + string + " "*(45 - len(string)) + end_line)
    sys.stdout.write(empty_line)
    sys.stdout.write(full_line*3)
    sys.stdout.write("\n")
    sys.stdout.write("Back | Exit".center(80) + "\n\n")
    # Ask the player how much tech he is going to spend
    sub_selection = raw_input("Please enter the amount of tech to spend:".center(80) + "\n\n" + prompt(user))
    sub_selection = sub_selection.lower()
    command_process(sub_selection)
    # Check for "back"
    if sub_selection == "back":
        salvage_missions.salvage_missions()
    else:
        # Check to see if the player input can be converted to an integer
        try:
            tech_spend = number_check(sub_selection)
            sys.stdout.write("\n")
            # If input is an integer and less than or equal to 5, ask player how many ships for priority list
            if tech_spend <= 5:
                sys.stdout.write("You can select up to %d ships for your priority target list.\n" % tech_spend)
                target_number = raw_input("How many priority targets do you wish to select?\n")
                # Check to make sure player entered an integer
                target_number = number_check(target_number)
                # Start handling exception cases
                if target_number > tech_spend:
                    print "Error: You can only select up to %d priority targets.\n" % tech_spend
                    sleep(2)
                    agent_view_creator(selection)
                # If no exception, iterate through number of targets specified and collect each target id
                while counter <= target_number:
                    ship = raw_input("Please enter the identificiation number of priority target %s:\n" % counter)
                    ship_id = number_check(ship)
                    # If the target ID is valid, check to make sure the player hasn't already added it
                    if str(ship_id) in priority_dict.items():
                        print "Error: You may only select each ship one time."
                        agent_view_creator(selection)
                    else:
                        if str(ship_id) in ship_data:
                            priority_dict[counter] = ship_id
                    # If the target ID is invalid, notify player and go back to agent_view
                        else:
                            print "That identifier is not valid."
                            sleep(2)
                            agent_view_creator(selection)
                    counter += 1
            # If input is between 5 and 10, ask player how many ships for priority list
            elif tech_spend > 5 and tech_spend <= 10:
                sys.stdout.write("You can select up to 5 ships for your priority target list.\n")
                target_number = raw_input("How many priority targets do you wish to select?\n")
                # Make sure input is an integer
                target_number = number_check(target_number)
                # If player is trying to set more than 5 priority targets, error
                if target_number > 5:
                    print "Error: You can only select up to 5 priority targets.\n"
                    sleep(2)
                    agent_view_creator(selection)
                while counter <= target_number:
                    # Collect identification numbers for priority targets
                    ship = raw_input("Please enter the identificiation number of priority target %s:\n" % counter)
                    ship_id = number_check(ship)
                    # If target ID is valid, enter it into priority dict
                    if str(ship_id) in ship_data:
                        priority_dict[counter] = ship_id
                    # If target is invalid, notify player and return to agent_view
                    else:
                        print "That identifier is not valid."
                        sleep(2)
                        agent_view_creator(selection)
                    counter += 1
            # Raise error if player tries to spend more than 10 tech on one mission.
            else:
                print "Error: You can only spend a maximum of 10 tech per mission."
                sleep(2)
                agent_view_creator(selection)

        except:
            print "Invalid Selection"
            sleep(2)
            agent_view_creator(selection)
    final_pull_list = pull_generator(tech_spend, selection)
    result = priority_assign(final_pull_list, priority_dict)