def detect(self, robot: Robot, t_now): if (robot.buff_left_time > 0): robot.buff_left_time -= t_now - self.__t_last robot.buff_left_time = max(0, robot.buff_left_time) for buff in self.__buff_area: buff.detect(robot, t_now) self.__t_last = t_now
def detect(self, robot: Robot, t_now): if (robot.buff_left_time > 0): robot.buff_left_time -= t_now - self.__t_last robot.buff_left_time = max(0, robot.buff_left_time) # if robot.buff_left_time == 0: # print("punish pass once") for buff in self.__buff_area: buff.detect(robot, t_now) self.__t_last = t_now
def detect(self, robot: Robot, t_now): # 0, 1, 2min refresh if (int(t_now) % 60 == 0): self.__activated = False self.__t_stay = 0 if self.__activated: return if robot.group != self.__group: return if self._if_in_area(robot.get_pos(), self.__box): self.__t_stay += t_now - self.__t_last if self.__t_stay >= TIME_BUFF_TRIGGER: self.__activated = True robot.buff_left_time = TIME_BUFF_INIT self.__t_stay = 0 else: self.__t_stay = 0 self.__t_last = t_now
def detect(self, robot: Robot, t_now): # 0, 1, 2min refresh bool_t = (t_now > 3.00 - 0.05 and t_now < 3.00 + 0.05) and (t_now > 120.00 - 0.05 and t_now < 120.00 + 0.05) if (int(t_now) % 60 == 0): # if t_now == 5.00 or t_now == 60.00: # if bool_t: self.__activated = False self.__t_stay = 0 self.__type = choice(TYPE) # print(f'time {t_now}') # print(f"buff type - 2 {self.__type}") if self.__activated: return if robot.group != self.__group and self.__type < 1: return if self._if_in_area(robot.get_pos(), self.__box): self.__t_stay += t_now - self.__t_last if self.__t_stay >= TIME_BUFF_TRIGGER: self.__activated = True if self.__type == 0: robot.lose_health(-1000) return if self.__type == 1: robot.supply() return robot.buff_left_time = PUNISH_TIME robot.buff_type = self.__type self.__t_stay = 0 else: self.__t_stay = 0 self.__t_last = t_now