Exemplo n.º 1
0
def damage_planet(database):
    planet_name = promptUtils.planet_prompt(database)
    amount_to_reduce = int(iq.text("Garrison points lost:").execute())

    if amount_to_reduce is None:
        planetCrud.reduce_garrison_points(database, planet_name)
    else:
        planetCrud.reduce_garrison_points(database, planet_name,
                                          int(amount_to_reduce))
Exemplo n.º 2
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)
Exemplo n.º 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)
Exemplo n.º 4
0
def create_facility(database):

    planet_name = promptUtils.planet_prompt(database)
    facility_type = iq.select(message="Facility type:",
                              choices=all_facility_types).execute()
    is_blockaded = iq.confirm("Blockaded?").execute()

    facility = {'planet': planet_name, 'facility_type': facility_type}

    facilityCrud.create_facility_from_dict(database, facility)

    if not is_blockaded:
        planetCrud.restore_garrison_points(database, planet_name)
        facilityCrud.restore_planet_facilities(database, planet_name)
Exemplo n.º 5
0
def move_ship(database):
    origin_location = promptUtils.planet_prompt(database, "From:")

    ships_on_origin = shipCrud.get_ships_on_planet(database, origin_location)
    ship_ids_on_origin = list(map(lambda ship: f"{ship.id}, modules: {ship.modules}, owner: {ship.owner}", ships_on_origin))

    ship_selection = iq.select(
        message="Ship:",
        choices=ship_ids_on_origin
    ).execute()

    ship_id = ship_selection.split(',')[0]

    origin_connections = planetCrud.get_connection_names(database, origin_location)

    destination = iq.select(
        message="Destination:",
        choices=origin_connections
    ).execute()

    shipCrud.move_ship(database, ship_id, destination)
Exemplo n.º 6
0
def get_facilities(database):
    planet_name = promptUtils.planet_prompt(database)

    facilities = facilityCrud.query_facilities_on_planet(
        database, planet_name).all()

    print(
        dedent(f"""\
                 -------------------------------
                 Facilities on {planet_name}
                 -------------------------------\
                 """))

    for facility in facilities:
        entry = f"""\
                id: {facility.id}
                level: {level_to_str.get(facility.level)}
                type: {type_to_str.get(facility.facility_type)}
                HP: {1 + facility.shields}
                """

        print(dedent(entry))
Exemplo n.º 7
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)
Exemplo n.º 8
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))
Exemplo n.º 9
0
def restore_planet_facilities(database):
    planet_name = promptUtils.planet_prompt(database)

    facilityCrud.restore_planet_facilities(database, planet_name)
Exemplo n.º 10
0
def restore_planet(database):
    planet_name = promptUtils.planet_prompt(database)

    planetCrud.restore_garrison_points(database, planet_name)
Exemplo n.º 11
0
def upgrade_planet(database):
    planet_name = promptUtils.planet_prompt(database)

    planetCrud.upgrade_colony_type(database, planet_name)
Exemplo n.º 12
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)
Exemplo n.º 13
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)