super(SetSettlementUpgradePermissions, self).__init__(settlement, 'set_upgrade_permissions', level, allowed) GenericCommand.allow_network(SetSettlementUpgradePermissions) class SetTradeSlot(GenericComponentCommand): """Set status of a trade post's buy/sell slot.""" def __init__(self, trade_post, slot_id, resource_id, selling, limit): super(SetTradeSlot, self).__init__(trade_post, 'set_slot', slot_id, resource_id, selling, limit) GenericComponentCommand.allow_network(SetTradeSlot) class ClearTradeSlot(GenericComponentCommand): """Clear a trade post's buy/sell slot.""" def __init__(self, trade_post, slot_id): super(ClearTradeSlot, self).__init__(trade_post, 'clear_slot', slot_id, True) GenericComponentCommand.allow_network(ClearTradeSlot) class TransferResource(GenericCommand): """Transfers an amount of a resource from one Storage to another""" def __init__(self,
super(ToggleActive, self).__init__(producer, "toggle_active") self._production = None if production is None else production.prod_id def __call__(self, issuer): # NOTE: special call method, cause production must be saved as id, not as Production obj obj = self._get_object().get_component_by_name(self.component_name) if self._production is not None: production = obj._get_production(self._production) assert production is not None, "%s does not have a production %s" % (obj, self._production) else: production = None return getattr(obj, self.method)( production ) GenericComponentCommand.allow_network(ToggleActive) class AddProduction(GenericComponentCommand): """Add a production to a producer""" def __init__(self, producer, production_line_id): super(AddProduction, self).__init__(producer, "add_production_by_id", production_line_id) GenericComponentCommand.allow_network(AddProduction) class RemoveFromQueue(GenericComponentCommand): """Remove a production line id from a queueproducer's queue""" def __init__(self, producer, production_line_id): super(RemoveFromQueue, self).__init__(producer, "remove_from_queue", production_line_id)
def __init__(self, settlement, level, allowed): super(SetSettlementUpgradePermissions, self).__init__(settlement, "set_upgrade_permissions", level, allowed) GenericCommand.allow_network(SetSettlementUpgradePermissions) class AddToBuyList(GenericComponentCommand): """Adds a Resource to buy_list of TradePost""" def __init__(self, tradepost, res_id, limit): super(AddToBuyList, self).__init__(tradepost, "add_to_buy_list", res_id, limit) GenericComponentCommand.allow_network(AddToBuyList) class RemoveFromBuyList(GenericComponentCommand): """Removes a Resource from buy_list of TradePost""" def __init__(self, tradepost, res_id): super(RemoveFromBuyList, self).__init__(tradepost, "remove_from_buy_list", res_id) GenericComponentCommand.allow_network(RemoveFromBuyList) class AddToSellList(GenericComponentCommand): """Adds a Resource to sell_list of TradePost"""
class SetSettlementUpgradePermissions(GenericCommand): """Sets the new upgrade permissions for a level in a settlement.""" def __init__(self, settlement, level, allowed): super().__init__(settlement, 'set_upgrade_permissions', level, allowed) GenericCommand.allow_network(SetSettlementUpgradePermissions) class SetTradeSlot(GenericComponentCommand): """Set status of a trade post's buy/sell slot.""" def __init__(self, trade_post, slot_id, resource_id, selling, limit): super().__init__(trade_post, 'set_slot', slot_id, resource_id, selling, limit) GenericComponentCommand.allow_network(SetTradeSlot) class ClearTradeSlot(GenericComponentCommand): """Clear a trade post's buy/sell slot.""" def __init__(self, trade_post, slot_id): super().__init__(trade_post, 'clear_slot', slot_id, True) GenericComponentCommand.allow_network(ClearTradeSlot) class TransferResource(GenericCommand): """Transfers an amount of a resource from one Storage to another""" def __init__(self, amount, res_id, transfer_from, transfer_to, signal_errors=False): super().__init__(transfer_from, 'transfer_to_storageholder', amount, res_id, transfer_to.worldid, signal_errors=signal_errors)
def __call__(self, issuer): # NOTE: special call method, cause production must be saved as id, not as Production obj obj = self._get_object().get_component_by_name(self.component_name) if self._production is not None: production = obj._get_production(self._production) assert production is not None, "%s does not have a production %s" % ( obj, self._production) else: production = None return getattr(obj, self.method)(production) GenericComponentCommand.allow_network(ToggleActive) class AddProduction(GenericComponentCommand): """Add a production to a producer""" def __init__(self, producer, production_line_id): super(AddProduction, self).__init__(producer, "add_production_by_id", production_line_id) GenericComponentCommand.allow_network(AddProduction) class RemoveFromQueue(GenericComponentCommand): """Remove a production line id from a queueproducer's queue""" def __init__(self, producer, production_line_id):