Action.run()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
c 2
b 0
f 0
dl 0
loc 11
rs 9.4285
1
class Action():
2
    """
3
    ``Action`` own the code intended for modify synergies objects.
4
    """
5
6
    _listen = None
7
    """The ``Event`` class to listen."""
8
    _depend = []
9
    """List of ``Action`` who need to be executed before this."""
10
11
    @classmethod
12
    def get_listened_class(cls):
13
        """
14
15
        :return: The listened ``Event`` class.
16
        :rtype: synergine.synergy.Event.Event
17
        """
18
        return cls._listen
19
20
    @classmethod
21
    def get_dependencies(cls):
22
        """
23
24
        :return: List of ``Action`` who need to be executed before this.
25
        :rtype: list (of ``Action``)
26
        """
27
        return cls._depend
28
29
    def __init__(self, object_id, parameters):
30
        self._object_id = object_id
31
        self._parameters = parameters
32
33
    def get_object_id(self):
34
        """
35
36
        :return: The concerned synergy object id
37
        :rtype: int
38
        """
39
        return self._object_id
40
41
    @classmethod
42
    def cycle_pre_run(cls, context, synergy_manager):
43
        """
44
45
        This class method will be executed each cycle, one time by action class.
46
        Useful fo apply some tricks before this synergies objects action.
47
48
        :param context:
49
        :param synergy_manager:
50
        :return:
51
        """
52
        pass
53
54
    def run(self, obj, context, synergy_manager):
55
        """
56
57
        The execution code of ``Action`` have to be write in ``run`` method.
58
59
        :param obj: The synergy concerned object
60
        :param context: The Context
61
        :param synergy_manager: SynergyObjectManager
62
        :return:
63
        """
64
        raise NotImplementedError