| Total Complexity | 6 |
| Total Lines | 17 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | from synergine.core.exceptions import NotConcernedEvent |
||
| 7 | class LonelinessSuicideEvent(TestEvent): |
||
| 8 | |||
| 9 | def _prepare(self, object_id, context, parameters={}): |
||
| 10 | if self._has_friends_with_beans(context): |
||
| 11 | raise NotConcernedEvent() |
||
| 12 | return parameters |
||
| 13 | |||
| 14 | @staticmethod |
||
| 15 | def _has_friends_with_beans(context): |
||
| 16 | friends_with_beans_count = 0 |
||
| 17 | for friend_id in context.metas.list.get(TestSimulation.STATE, COMPUTABLE): |
||
| 18 | friend_beans = context.metas.value.get(BEANS, friend_id) |
||
| 19 | if friend_beans > 1: |
||
| 20 | friends_with_beans_count += 1 |
||
| 21 | if friends_with_beans_count == 0: |
||
| 22 | return False |
||
| 23 | return True |
||
| 24 |