# Path: intelligine/synergy/event/CycleEvent.py
# class CycleEvent(Event):
# 
#     _concern = COL_TRANSPORTER
# 
#     def _prepare(self, object_id, context, parameters):
#         return parameters
# 
# Path: intelligine/cst.py
# CANT_CARRY_STILL = IncrementedNamedInt.get('intelligine.cantcarry.still')
# 
# CANT_PUT_STILL = IncrementedNamedInt.get('intelligine.cantput.still')


from synergine.synergy.event.Action import Action
from intelligine.synergy.event.CycleEvent import CycleEvent
from intelligine.cst import CANT_CARRY_STILL, CANT_PUT_STILL


class CycleAction(Action):

    _listen = CycleEvent

    def run(self, obj, context, synergy_manager):
        cant_carry_still = context.metas.value.get(CANT_CARRY_STILL, obj.get_id(), allow_empty=True, empty_value=0)
        if cant_carry_still > 0:
            context.metas.value.set(CANT_CARRY_STILL, obj.get_id(), cant_carry_still-1)

        cant_put_still = context.metas.value.get(CANT_PUT_STILL, obj.get_id(), allow_empty=True, empty_value=0)
        if cant_put_still > 0:

# Path: intelligine/synergy/event/CycleEvent.py
# class CycleEvent(Event):
# 
#     _concern = COL_TRANSPORTER
# 
#     def _prepare(self, object_id, context, parameters):
#         return parameters
# 
# Path: intelligine/cst.py
# CANT_CARRY_STILL = IncrementedNamedInt.get('intelligine.cantcarry.still')
# 
# CANT_PUT_STILL = IncrementedNamedInt.get('intelligine.cantput.still')


# Path: intelligine/synergy/event/CycleAction.py
from synergine.synergy.event.Action import Action
from intelligine.synergy.event.CycleEvent import CycleEvent
from intelligine.cst import CANT_CARRY_STILL, CANT_PUT_STILL



class CycleAction(Action):

    _listen = CycleEvent

    def run(self, obj, context, synergy_manager):
        cant_carry_still = context.metas.value.get(CANT_CARRY_STILL, obj.get_id(), allow_empty=True, empty_value=0)
        if cant_carry_still > 0:
            context.metas.value.set(CANT_CARRY_STILL, obj.get_id(), cant_carry_still-1)

        cant_put_still = context.metas.value.get(CANT_PUT_STILL, obj.get_id(), allow_empty=True, empty_value=0)
        if cant_put_still > 0:

            context.metas.value.set(CANT_PUT_STILL, obj.get_id(), cant_put_still-1)