def randomize_damage_modifiers(self): # Generate small random damage modifiers for the mage. These won't make a huge deal for the most part. resistances = {} for magic_type in MagicTypesEnum.choices(): resistances[magic_type] = random.randint(0, 4) - 2 for affinity in self.magical_affinity: resistances[affinity] += 2 self.resistances = resistances
def randomize_affinity(self, rand_count=2): """ Give the mage random affinities. Gives them rand_count total affinities. If they already have some, they will get that many less. :param rand_count: :return: """ magic_types = MagicTypesEnum.choices() magical_affinity = [] for existing_type in self.magical_affinity: magic_types.remove(existing_type) rand_count -= 1 for _ in range(rand_count): magic_type = magic_types[random.randint(0, len(magic_types) - 1)] magical_affinity.append(magic_type) magic_types.remove(magic_type) self.magical_affinity = magical_affinity