def buy_missing_planes(plane_class, missing_units): # if amount_needed(missing_planes) < self.airport.money: # for aircraft_type, missing_units in missing_planes.iteritems(): for _ in range(missing_units): if plane_class == SupersonicPlane: if take_concorde_from_alliance(): return page = get_request(plane_class.buy_url) try: exception_if_not_contains(SHOP_SUCCESSFUL_PLANES, page, 'Could not buy a plane') except: withdraw_from_alliance(plane_class.price)
def fill_all_airports(): other_airports = get_other_airports_id() # switch on all airports for j in other_airports: switch_to_airport(j) current_airport = Airport() capacity = current_airport.get_kerosene_capacity() stock = current_airport.get_kerosene_supply() difference = capacity - stock if difference > 0: page = get_request() available_offers = extract_available_offers(page) # while difference > 0: # the list should be copied so that it's a copy that's altered if available_offers: current_offer = available_offers.pop() if difference < current_offer['quantity']: try: buy_market_kero(difference, current_offer['sell_id']) except: # plus quick refill withdraw_from_alliance(int(current_offer['price'] * difference) + 2500) buy_market_kero(difference, current_offer['sell_id']) quick_refill = get_request(QUICK_REFILL_URL) # exception_if_not_contains('Vous venez de mettre un total de') # exception_if_not_contains("aucun plein n'est possible") current_airport = Airport() capacity = current_airport.get_kerosene_capacity() stock = current_airport.get_kerosene_supply() difference = capacity - stock if difference > 0: page = get_request(SHOP_USED_KEROSENE_URL) available_offers = extract_available_offers(page) # while difference > 0: # the list should be copied so that it's a copy that's altered if available_offers: current_offer = available_offers.pop() if difference < current_offer['quantity']: try: buy_market_kero(difference, current_offer['sell_id']) except: # plus quick refill withdraw_from_alliance(int(current_offer['price'] * difference) + 2500) buy_market_kero(difference, current_offer['sell_id'])