def start(self): other_airports = get_other_airports_id() other_airports = filter_airports(other_airports) # TODO mock # other_airports = ['122791'] for airport_id in other_airports: switch_to_airport(airport_id) BotPlayer(self.missions).launch_missions()
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'])
def planes_value(request): response = '' other_airports = get_other_airports_id() for j in other_airports: value_sum = 0 planes_nb = 0 switch_to_airport(j) current_airport = Airport() page = get_request(PLANES_PAGE) ready_planes = build_planes_from_html(page) for i in ready_planes: if i.get_value: if i.get_value(): value_sum += i.get_value() planes_nb += 1 response += '{}({}/{}) <br/><br/>'.format(current_airport.airport_name, planes_nb, current_airport.planes_capacity, format_amount(value_sum)) return HttpResponse(response)