# Path: magnate/market.py
# class CommodityData:
# class Commodity:
# class SystemData:
# class LocationData:
# class Market:
#     def __init__(self, pubpen, commodity_data):
#     def __getattr__(self, key):
#     def __repr__(self):
#     def __init__(self, magnate, location_data, commodity_data):
#     def __getattr__(self, key):
#     def handle_market_info(self):
#     def handle_movement(self, new_location, *args):
#     def recalculate_prices(self):
#     def _calculate_price(self, commodity):
# 
# Path: magnate/ship.py
# class ManifestEntry:
#     """
#     Associates a given amount of a commodity with sale-related information
#     """
#     #: Name of the commodity this ManifestEntry is for
#     commodity = attr.ib(validator=attr.validators.instance_of(str))
# 
#     #: Amount of the commodity in this ManifestEntry
#     quantity = attr.ib(validator=attr.validators.instance_of(int))
# 
#     #: Average price paid for the commodity.  This may be used to
#     #: automatically show profit and loss
#     price_paid = attr.ib(validator=attr.validators.instance_of(float), convert=float)
# 
#     # When we start using depreciation in price:
#     #average_age = attr.ib(validator.attr.validators.instance_of(float))


from .market import CommodityType
from .ship import ManifestEntry
        if order.location != self.user.ship.location.name:
            fatal_error = True
            self.pubpen.publish('user.order_failure',
                                'Cannot process an order when the player is not at the location')

        current_price = self.markets[order.location].commodities[order.commodity].price
        total_quantity = order.hold_quantity + order.warehouse_quantity
        total_sale = current_price * total_quantity

        if order.buy:
            # Check that the price matches or is better
            if order.price < current_price:
                fatal_error = True
                self.pubpen.publish('user.order_failure',
                                    "Current market price is higher than on the order."
                                    "  Refresh prices and try again")

            # Check that the user has enough cash
            if total_sale > self.user.cash:
                fatal_error = True
                self.pubpen.publish("user.order_failure",
                                    "Total amount of money for this sale exceeds the user's cash")

            if fatal_error:
                return

            # Purchase the commodity
            new_cash = self.user.cash - total_sale
            if CommodityType.cargo in self.markets[order.location].commodities[order.commodity].type:
                # Buy cargo

# Path: magnate/market.py
# class CommodityData:
# class Commodity:
# class SystemData:
# class LocationData:
# class Market:
#     def __init__(self, pubpen, commodity_data):
#     def __getattr__(self, key):
#     def __repr__(self):
#     def __init__(self, magnate, location_data, commodity_data):
#     def __getattr__(self, key):
#     def handle_market_info(self):
#     def handle_movement(self, new_location, *args):
#     def recalculate_prices(self):
#     def _calculate_price(self, commodity):
# 
# Path: magnate/ship.py
# class ManifestEntry:
#     """
#     Associates a given amount of a commodity with sale-related information
#     """
#     #: Name of the commodity this ManifestEntry is for
#     commodity = attr.ib(validator=attr.validators.instance_of(str))
# 
#     #: Amount of the commodity in this ManifestEntry
#     quantity = attr.ib(validator=attr.validators.instance_of(int))
# 
#     #: Average price paid for the commodity.  This may be used to
#     #: automatically show profit and loss
#     price_paid = attr.ib(validator=attr.validators.instance_of(float), convert=float)
# 
#     # When we start using depreciation in price:
#     #average_age = attr.ib(validator.attr.validators.instance_of(float))


# Path: magnate/dispatcher.py
from .market import CommodityType
from .ship import ManifestEntry

        if order.location != self.user.ship.location.name:
            fatal_error = True
            self.pubpen.publish('user.order_failure',
                                'Cannot process an order when the player is not at the location')

        current_price = self.markets[order.location].commodities[order.commodity].price
        total_quantity = order.hold_quantity + order.warehouse_quantity
        total_sale = current_price * total_quantity

        if order.buy:
            # Check that the price matches or is better
            if order.price < current_price:
                fatal_error = True
                self.pubpen.publish('user.order_failure',
                                    "Current market price is higher than on the order."
                                    "  Refresh prices and try again")

            # Check that the user has enough cash
            if total_sale > self.user.cash:
                fatal_error = True
                self.pubpen.publish("user.order_failure",
                                    "Total amount of money for this sale exceeds the user's cash")

            if fatal_error:
                return

            # Purchase the commodity
            new_cash = self.user.cash - total_sale
            if CommodityType.cargo in self.markets[order.location].commodities[order.commodity].type:
                # Buy cargo

                new_cargo = ManifestEntry(order.commodity, order.hold_quantity, order.price)