def _add_flight(self, plane_id, date_time, passengers, cargo): Plane.flight(plane_id=plane_id, date_time=date_time, passengers=passengers, cargo=cargo) payment = self.PASSENGER_PAYMENT * passengers + self.CARGO_TON_PAYMENT * cargo self._get_money(payment, "flight of plane # {}".format(plane_id))
def init_planes(number_of_planes): """ Make sure that the planes do not start in the same position. :return: """ planes_list = [] while number_of_planes > 0: plane = Plane(0, 0, rand=True) x_plane, y_plane = plane.get_position() print(len(planes_list)) if not plane.check_for_collisions( planes_list, x_coor=x_plane, y_coor=y_plane): planes_list.append(plane) number_of_planes -= 1 return planes_list
def buy_plane(self, plane_id): if self.can_buy_plane(plane_id): price = Plane.price_market_plane(plane_id) self._pay_money(price, "purchase plane # {}".format(plane_id)) self._add_plane(plane_id) else: raise ValueError("No money - no honey")
def __init__(self, args): super().__init__(args.NUM_PLANES) self.grid = generateGrid(args.GRID_SIZE[0], args.GRID_SIZE[1], args.LOCATION) self.args = args self.map = [] self.complete = Queue(args.NUM_PLANES) for id in range(args.NUM_PLANES): newplane = Plane(id, args) self.map.append(newplane.telemetry()) assert (self.map[-1] != None) self.put(newplane) self.run() self.report()
def plane(self, correct_pos=None, *args): """ args: [correct_pos] - creates a plane with\ correct position set to correct_pos """ try: position = float(correct_pos) except TypeError: position = 0 self.namespace['plane'] = Plane(position)
def simulator(self, *args): """ creates new simulator """ self.namespace['simulator'] = PlaneSimulator( self.namespace.setdefault('plane', Plane()))
def planes_stat(self): return Plane.planes_stat(airline_id=self.airline_id)
def market_planes(self): return Plane.market_planes()
def cargo_planes(self): return Plane.cargo_planes(airline_id=self.airline_id)
def passenger_planes(self): return Plane.passenger_planes(airline_id=self.airline_id)
def planes(self): return Plane.planes(airline_id=self.airline_id)
def flights(self): return Plane.flights(airline_id=self.airline_id)
def sell_plane(self, plane_id): price = Plane.price_own_plane(plane_id) self._del_plane(plane_id) self._get_money(price, "sold plane # {}".format(plane_id))
def can_buy_plane(self, plane_id): settings.logger.info( "Request for allowing to buy plane #{}".format(plane_id)) return self.balance >= Plane.price_market_plane(plane_id)
def market_available_planes(self): return Plane.market_available_planes(airline_id=self.airline_id)