예제 #1
0
    def __init__(self):
        self.luck = randint(27, 500) / 10000
        self.test_time_interval = randint(160, 1800)
        self.last_test_was = randint(
            randint(1, randint(2, 30)),
            int(self.test_time_interval / randint(1, 3)))
        self.is_already_connected_today = bool(randint(0, 1))
        self.was_infected_today = []
        self.is_connected_with_spin_user = False
        self.is_connected_with_simple_user = False
        self.diseases = []
        self.count_of_doctor_visits_per_year = []
        self.count_of_doctor_visits = 0
        self.__count_of_useful_doctor_visits = 0
        self.is_notified = False
        self.known_diseases = []
        self.__spin_partner_list = []
        self.is_spin_user = decision(get_setting('SPIN_USERS'))
        self.__vaccination = []
        self.__vaccination_try()
        self.__days_before_found_disease = {}
        self.__days_before_found_disease_avg = copy.deepcopy(
            get_setting('DISEASES_DETECT_LIST'))
        self.__count_of_notifications = 0
        self.__count_of_useful_notifications = 0

        for disease in get_setting('DISEASES_LIST'):
            if len(self.diseases) > 14:
                break
            if decision(get_setting('DISEASES_LIST').get(disease)):
                self.diseases.append(disease)

        self.__count_days_before_found()
예제 #2
0
 def __try_to_heal(self, doctor=False):
     for disease_index, disease in enumerate(self.diseases):
         if doctor:
             if disease not in self.known_diseases:
                 self.__clear_days_before_found(disease)
                 self.known_diseases.append(disease)
         if disease not in get_setting('DISEASES_LUCK_HEAL_LIST'):
             self.diseases.pop(disease_index)
         elif doctor and decision(
                 get_setting('DISEASES_LUCK_HEAL_LIST')[disease]):
             self.diseases.pop(disease_index)
             if disease in self.known_diseases:
                 self.known_diseases.pop(self.known_diseases.index(disease))
         elif not doctor and decision(
                 get_setting('DISEASES_DAILY_LUCK_HEAL_LIST')[disease]):
             self.diseases.pop(disease_index)
             if disease in self.known_diseases:
                 self.known_diseases.pop(self.known_diseases.index(disease))
예제 #3
0
 def connect(self, person_to_connect, start_use_spin):
     if person_to_connect.is_spin_user:
         self.is_connected_with_spin_user = True
     else:
         self.is_connected_with_simple_user = True
     if start_use_spin and self.is_spin_user and person_to_connect.is_spin_user:
         self.__spin_partner_list.append(person_to_connect)
     for connect_disease in person_to_connect.diseases:
         if connect_disease in self.diseases:
             continue
         elif len(self.diseases) > 14:
             break
         elif decision(get_setting('DISEASES_LIST').get(connect_disease)):
             if connect_disease not in self.__vaccination and \
                     (connect_disease not in get_setting('DISEASES_LUCK_LIST') or
                      decision(get_setting('DISEASES_LUCK_LIST')[connect_disease])):
                 self.diseases.append(connect_disease)
                 self.was_infected_today.append(connect_disease)
     self.is_already_connected_today = True
예제 #4
0
 def notified(self, from_who):
     self.is_notified = True
     self.__count_of_notifications += 1
     for partner in self.__spin_partner_list:
         if partner != from_who and not partner.is_notified:
             partner.notified(self)
     self.__clear_spin_partner_list()
     if decision(get_setting('REACT_LUCKY')):
         self.__check_is_need_to_start_day_counting()
         self.check_is_need_go_to_doctor(is_spin=True)
예제 #5
0
 def live_a_day(self, person_to_connect, start_use_spin, new_year=False):
     if person_to_connect is not None:
         if not self.is_spin_user or person_to_connect.is_spin_user or decision(
                 get_setting('SPIN_USER_CONNECT_SIMPLE_USER_LUCK')):
             person_to_connect.connect(self, start_use_spin)
             self.connect(person_to_connect, start_use_spin)
     self.__count_days_before_found()
     self.last_test_was -= 1
     self.check_is_need_go_to_doctor()
     if new_year:
         self.count_of_doctor_visits_per_year.append(
             self.count_of_doctor_visits)
         self.count_of_doctor_visits = 0
     if len(self.known_diseases
            ) > 0 and not self.__is_only_unhealable_known_diseases:
         self.__try_to_heal()
예제 #6
0
 def __is_only_unhealable_known_diseases(self) -> bool:
     return all(disease in get_setting('UNHEALABLE_DISEASES')
                for disease in self.known_diseases)
예제 #7
0
 def __vaccination_try(self):
     for disease in get_setting('VACCINATION'):
         if decision(get_setting('VACCINATION')[disease]):
             self.__vaccination.append(disease)