Transportable   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 11
c 3
b 0
f 0
dl 0
loc 35
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A set_is_carried() 0 6 2
A is_carried() 0 4 2
A get_what_carry() 0 2 1
A set_carried_by() 0 9 4
A __init__() 0 5 1
A is_takable() 0 2 1
1
from intelligine.cst import TRANSPORTABLE, CARRIED_BY, CARRY
2
from intelligine.synergy.object.SynergyObject import SynergyObject
3
4
5
class Transportable(SynergyObject):
6
7
    def __init__(self, collection, context):
8
        super().__init__(collection, context)
9
        self._carried_by = None
10
        context.metas.states.add(self.get_id(), TRANSPORTABLE)
11
        self._is_carried = False
12
13
    def set_carried_by(self, obj):
14
        if obj is not None:
15
            assert self._carried_by is None
16
            self._carried_by = obj
17
            self._context.metas.states.remove(self.get_id(), TRANSPORTABLE)
18
        else:
19
            assert self._carried_by is not None
20
            self._carried_by = None
21
            self._context.metas.states.add(self.get_id(), TRANSPORTABLE)
22
23
    def is_carried(self):
24
        if self._carried_by:
25
            return True
26
        return False
27
28
    def get_what_carry(self):
29
        return self
30
31
    def is_takable(self):
32
        return not self.is_carried()
33
34
    def set_is_carried(self, is_carried, by_obj):
35
        self._is_carried = bool(is_carried)
36
        if self._is_carried:
37
            self._context.metas.value.set(CARRIED_BY, self.get_id(), by_obj.get_id())
38
        else:
39
            self._context.metas.value.unset(CARRIED_BY, self.get_id())
40