Пример #1
0
 def on_activate(self, reader=None):
     super().on_activate(reader=reader)
     pet = self.owner.get_pet()
     wait_stat = pet.commodity_tracker.get_statistic(
         self.wait_stat_and_value.stat, add=True)
     wait_stat.set_value(self.wait_stat_and_value.initial_value)
     op = operator.le if wait_stat.get_decay_rate() <= 0 else operator.ge
     threshold = Threshold(wait_stat.convergence_value, op)
     if threshold.compare(wait_stat.get_value()):
         self.on_wait_stat_zero(wait_stat)
     else:
         self.wait_listener = wait_stat.create_and_add_callback_listener(
             threshold, self.on_wait_stat_zero)
Пример #2
0
 def passes_threshold(cls, resolver: Resolver, threshold: Threshold) -> bool:
     """ True if the threshold is passed. """
     if resolver is not None:
         cls.get_verbose_log().format(
             resolver_type=type(resolver),
             resolver_class=resolver.__class__,
             resolver_class_name=resolver.__class__.__name__
         )
     if threshold is not None:
         cls.get_verbose_log().format(
             threshold_type=type(threshold),
             threshold_class=threshold.__class__
         )
     return threshold.compare(cls.get_score(resolver))