mechanism.py 561B

1234567891011121314151617
  1. # coding: utf-8
  2. import typing
  3. from opencc.const import SIDE, COLLECTION_ALIVE
  4. from synergine2_xyz.subjects import XYZSubject
  5. from synergine2_xyz.visible.simulation import VisibleMechanism
  6. class OpponentVisibleMechanism(VisibleMechanism):
  7. from_collection = COLLECTION_ALIVE
  8. def reduce_subjects(self, subjects: typing.List[XYZSubject]) -> typing.Iterator[XYZSubject]:
  9. def filter_subject(subject: XYZSubject) -> bool:
  10. return self.subject.properties[SIDE] != subject.properties[SIDE]
  11. return filter(filter_subject, subjects)