Example #1
0
def buy_engines(engines_nb, engine_type):
    url = {
        '4': SHOP_ENGINE_4_URL,
        '5': SHOP_ENGINE_5_URL,
        '6': SHOP_ENGINE_6_URL,
    }[engine_type]
    page = post_request(url, {'cq': str(engines_nb)})
def move_money_to_alliance(amount=None):
    if not amount:
        page = get_request(ALLIANCE_PAGE)
        amount = get_amount_from_regex(AIRPORT_CASH_REGEX, page)
    if amount > 0:
        result = post_request(ALLIANCE_DEPOSIT_CASH_URL, {'cq': amount})
        exception_if_not_contains(ALLIANCE_DEPOSIT_SUCCESSFUL, result)
 def __change_engines(self):
     result = post_request(CHANGE_ENGINES_URL.format(plane_id=self.plane.plane_id),
                           {'id_moteur': self.plane.replacement_engines_type})
     if not string_contains("L'avion va bien recevoir ses nouveaux moteurs, durée : 2 heures.", result):
         # TODO parse the answer
         logger.warning('Error while changing engines')
     self.__ready = False
Example #4
0
def buy_market_kero(quantity, sale_id):
    body = {
        'cq': quantity,
        'mon_champ': sale_id
     }
    response = post_request(SHOP_BUY_USED_KEROSENE_URL, body)
    exception_if_not_contains(SHOP_SUCCESSFUL_KEROSENE, response)
 def __fill_fuel(self):
     fuel_qty = self.plane.fuel_capacity - self.plane.kerosene
     confirm_page = post_request(FILL_FUEL_URL.format(plane_id=self.plane.plane_id),
                                 {'cq': fuel_qty})
     if not string_contains('Vous avez ajouté .+ litres? de kérosène dans votre avion !',
                            confirm_page):
         logger.warning('Error when filling fuel')
         self.__ready = False
def move_money_to_bank(amount=None):
    if not amount:
        page = get_request(BANK_PAGE)
        amount = get_amount_from_regex(AIRPORT_CASH_REGEX, page)
    else:
        get_request(BANK_PAGE)
    result = post_request(BANK_DEPOSIT_URL, {'cq': amount})
    exception_if_not_contains(BANK_DEPOSIT_SUCCESSFUL, result)
Example #7
0
def list_missions(mission_type, countries_list):
    result = []
    countries_list = countries_list
    for country_id in countries_list:
        page = post_request(GENERIC_MISSION_PAGE.format(mission_type=mission_type), {u'id_pays': country_id})
        countries_missions = parse_all_missions_in_page(page, country_id)
        result += countries_missions
    return result
def __accept_mission(country_id, plane_id, mission_id, mission_type):
    bonus = None
    logger.info('accept mission: {} with plane {}'.format(mission_id, plane_id))
    page = post_request(
        GENERIC_ACCEPT_MISSION.format(mission_type=mission_type, mission_id=mission_id, country_id=country_id),
        {'id_avion': str(plane_id)})
    # Be careful, if re.findall()[0], may introduce list index out of range exception!
    temp_bonus = extract_bonus_from_page(page)
    if len(temp_bonus) == 1:
        bonus = int(temp_bonus[0][0] + temp_bonus[0][1])
    return bonus
Example #9
0
def buy_kerosene(litres):
    page = get_request(SHOP_KEROSENE_URL)
    # TODO check if there is kerosene available
    page = post_request(SHOP_BUY_KEROSENE_URL, {'cq': str(litres)})
Example #10
0
def hire_pilots(pilots_nb):
    post_request(HIRE_PILOTS_URL, {'cq': pilots_nb})
Example #11
0
def hire_mechanics(mechanics_nb):
    post_request(HIRE_MECHANICS_URL, {'cq': mechanics_nb})
Example #12
0
def hire_flight_attendants(flight_attendants_nb):
    post_request(HIRE_FLIGHT_ATTENDANTS_URL, {'cq': flight_attendants_nb})
def withdraw_from_alliance(amount=None):
    if not amount:
        page = get_request(ALLIANCE_PAGE)
        # TODO Put all the amounts regex in a constant
        amount = get_amount_from_regex(ALLIANCE_CASH_REGEX, page)
    post_request(ALLIANCE_WITHDRAW_CASH_URL, {'cq': amount})
def switch_to_airport(airport_id):
    get_request(AIRPORT_MENU_PAGE)
    post_request(SWITCH_TO_AIRPORT_URL, {'id_aeroport': airport_id})