コード例 #1
0
def claim_planet(database):
    confirmation = iq.confirm(
        "This method should only be used for game setup. Otherwise, use 'colonize' or 'reassign'. Continue?"
    ).execute()
    if not confirmation:
        return

    planet_name = promptUtils.planet_prompt(database)
    faction_name = promptUtils.faction_prompt(database)

    planetCrud.claim_planet(database, planet_name, faction_name)
コード例 #2
0
def print_planets(database):
    print_for_faction = iq.confirm("Print for specific faction?").execute()

    if print_for_faction:
        faction_name = promptUtils.faction_prompt(database)
    else:
        faction_name = None

    planet_info = planetCrud.get_planets(database)

    for p in planet_info:
        print_planet(database, p, faction_name)
コード例 #3
0
def print_single_planet(database):
    planet_name = promptUtils.planet_prompt(database)

    print_for_faction = iq.confirm("Print for specific faction?").execute()

    if print_for_faction:
        faction_name = promptUtils.faction_prompt(database)
    else:
        faction_name = None

    planet_info = planetCrud.get_planet_by_name(database, planet_name)
    print_planet(database, planet_info, faction_name)
コード例 #4
0
def create_ship(database):
    planet_name = promptUtils.planet_prompt(database)
    faction_name = faction_prompt(database)

    ship_size = iq.select(
        message="Class:",
        choices=[
            {"name": "Colony ship", "value": "COLONY"},
            {"name": "Class 1", "value": 1},
            {"name": "Class 2", "value": 2},
            {"name": "Class 3", "value": 3},
            {"name": "Class 4", "value": 4},
            {"name": "Class 5", "value": 5},
            {"name": "Class 6", "value": 6},
            {"name": "Class 7", "value": 7},
            {"name": "Class 8", "value": 8},
            {"name": "Class 9", "value": 9},
            {"name": "Class 10", "value": 10}
        ]
    ).execute()

    if ship_size == "COLONY":
        return shipCrud.create_ship_from_dict(database, {
            'owner': faction_name,
            'modules': ship_size,
            'location': planet_name
        })

    modules = choose_modules(database, ship_size, faction_name)

    ship = {
        'owner': faction_name,
        'modules': modules,
        'location': planet_name
    }

    shipCrud.create_ship_from_dict(database, ship)
コード例 #5
0
def get_all(database):
    query_filters = {}

    do_filter_by_planet = iq.confirm("Filter by planet?").execute()
    if do_filter_by_planet:
        query_filters['location'] = promptUtils.planet_prompt(database)

    do_filter_by_faction = iq.confirm("Filter by faction?").execute()
    if do_filter_by_faction:
        query_filters['owner'] = promptUtils.faction_prompt(database)

    all_ships = shipCrud.query_ships_filtered(database, query_filters).all()
    for ship in all_ships:
        display = f"""\
                id: {ship.id}
                owner: {ship.owner}
                modules: {ship.modules}
                location: {ship.location}
                stealth level: {ship.stealth_level}
                detection level: {ship.detection_level}
                hit points: {ship.hit_points}
                
                """
        print(dedent(display))
コード例 #6
0
def reassign_planet(database):
    planet_name = promptUtils.planet_prompt(database)
    faction_name = promptUtils.faction_prompt(database)

    planetCrud.reassign_planet(database, planet_name, faction_name)
コード例 #7
0
def colonize_planet(database):
    planet_name = promptUtils.planet_prompt(database)
    faction_name = promptUtils.faction_prompt(database)

    planetCrud.colonize_planet(database, planet_name, faction_name)