示例#1
0
    def mutate(self):
        oldstats = {}
        for key in self.mutate_attributes:
            oldstats[key] = getattr(self, key)
        super(MonsterObject, self).mutate()
        if self.is_boss:
            for (attr, oldval) in oldstats.items():
                if getattr(self, attr) < oldval:
                    setattr(self, attr, oldval)

        if self.is_boss:
            while True:
                chance = random.randint(0, 3)
                if chance == 0:
                    break
                if chance == 1:
                    self.resistances |= (1 << random.randint(4, 7))
                elif chance == 2:
                    self.immunities |= (1 << random.randint(0, 3))
                elif chance == 3:
                    weak = (1 << random.randint(4, 7))
                    if self.weaknesses_approach & weak:
                        self.weaknesses_approach ^= weak
        else:
            resistances = shuffle_bits(self.resistances >> 4, size=4)
            self.resistances = resistances << 4
            self.immunities = shuffle_bits(self.immunities, size=4)
            weak = shuffle_bits(self.weaknesses_approach >> 4, size=4)
            self.weaknesses_approach &= 0x0F
            self.weaknesses_approach |= (weak << 4)
            if random.randint(1, 3) == 3:
                self.hit_special_defense ^= 0x2
            self.hit_special_defense ^= (random.randint(0, 3) << 2)
示例#2
0
    def mutate(self):
        super(ArmorObject, self).mutate()
        if random.randint(1, 4) == 4:
            self.element = shuffle_bits(self.element)
        else:
            value = shuffle_bits(self.element >> 3, size=5)
            value = value << 3
            self.element = self.element & 0x7
            self.element |= value

        if self.index + self.first_name_index not in UNDESIRABLE_ITEMS:
            if self.status & 0x80 and random.randint(1, 10) == 10:
                return
            self.status &= 0x7F
示例#3
0
    def mutate(self):
        super(ArmorObject, self).mutate()
        if random.randint(1, 4) == 4:
            self.element = shuffle_bits(self.element)
        else:
            value = shuffle_bits(self.element >> 3, size=5)
            value = value << 3
            self.element = self.element & 0x7
            self.element |= value

        if self.index + self.first_name_index not in UNDESIRABLE_ITEMS:
            if self.status & 0x80 and random.randint(1, 10) == 10:
                return
            self.status &= 0x7F
示例#4
0
 def mutate(self):
     if self.index == 0x42:
         # Behemoth
         return
     oldstats = {}
     for key in self.mutate_attributes:
         oldstats[key] = getattr(self, key)
     super(MonsterObject, self).mutate()
     if self.is_boss:
         for (attr, oldval) in oldstats.items():
             if getattr(self, attr) < oldval:
                 setattr(self, attr, oldval)
     for attr in ["resistances", "weaknesses", "immunities"]:
         if self.is_boss and attr == "immunities":
             continue
         value = getattr(self, attr) >> 4
         value = shuffle_bits(value, size=4) << 4
     while random.choice([True, False]):
         attr = random.choice(["resistances", "weaknesses", "immunities"])
         value = getattr(self, attr)
         if attr != "immunities" and bin(value).count("1") > 6:
             continue
         flag = (1 << random.randint(0, 7))
         if ((attr == "weaknesses" or not self.is_boss) and
                 random.randint(1, 10) == 10):
             value ^= flag
         else:
             if attr != "immunities" and bin(value).count("1") > 4:
                 continue
             value |= flag
         setattr(self, attr, value)
     self.resistances = self.resistances & 0xF0
     if self.hp < 200 or self.index in [0x43, 0x4a]:
         return
     if random.randint(1, 4) == 4:
         self.counter &= 0x0F
         newcounter = random.choice([0, 0, 0x10, 0x20, 0x40, 0x80, 0x80])
         self.counter |= newcounter
示例#5
0
 def mutate(self):
     if self.index == 0x42:
         # Behemoth
         return
     oldstats = {}
     for key in self.mutate_attributes:
         oldstats[key] = getattr(self, key)
     super(MonsterObject, self).mutate()
     if self.is_boss:
         for (attr, oldval) in oldstats.items():
             if getattr(self, attr) < oldval:
                 setattr(self, attr, oldval)
     for attr in ["resistances", "weaknesses", "immunities"]:
         if self.is_boss and attr == "immunities":
             continue
         value = getattr(self, attr) >> 4
         value = shuffle_bits(value, size=4) << 4
     while random.choice([True, False]):
         attr = random.choice(["resistances", "weaknesses", "immunities"])
         value = getattr(self, attr)
         if attr != "immunities" and bin(value).count("1") > 6:
             continue
         flag = (1 << random.randint(0, 7))
         if ((attr == "weaknesses" or not self.is_boss)
                 and random.randint(1, 10) == 10):
             value ^= flag
         else:
             if attr != "immunities" and bin(value).count("1") > 4:
                 continue
             value |= flag
         setattr(self, attr, value)
     self.resistances = self.resistances & 0xF0
     if self.hp < 200 or self.index in [0x43, 0x4a]:
         return
     if random.randint(1, 4) == 4:
         self.counter &= 0x0F
         newcounter = random.choice([0, 0, 0x10, 0x20, 0x40, 0x80, 0x80])
         self.counter |= newcounter
示例#6
0
 def mutate(self):
     self.known_magic = shuffle_bits(self.known_magic)
     known_wizard = self.known_wizard >> 4
     self.known_wizard = shuffle_bits(known_wizard, size=4) << 4
     super(CharacterObject, self).mutate()
示例#7
0
 def mutate(self):
     super(CombatObject, self).mutate()
     self.status = shuffle_bits(self.status)
示例#8
0
 def bit_shuffle(self, attr):
     shuffled = shuffle_bits(getattr(self, attr),
                             size=self.get_bit_width(attr))
     setattr(self, attr, shuffled)
示例#9
0
 def mutate(self):
     self.known_magic = shuffle_bits(self.known_magic)
     known_wizard = self.known_wizard >> 4
     self.known_wizard = shuffle_bits(known_wizard, size=4) << 4
     super(CharacterObject, self).mutate()
示例#10
0
 def mutate(self):
     super(CombatObject, self).mutate()
     self.status = shuffle_bits(self.status)