def sort_inits(self): self._inits.sort( ) #sorting a list of tuples sorts on the first element of each tuple self._inits.reverse() dupes = self.get_duplicates() if dupes: for dupe_group in dupes: for roll, entity in dupe_group: self._inits.remove((roll, entity)) new_roll = float(int(roll)) + float( (entity.stats.dex)) / 100 + float(utils.roll( 1, 100)) / (100 * 100) self._inits.append((new_roll, entity)) self._inits.sort() self._inits.reverse()
def roll(self, what, type='d20'): value = getattr(self.stats, what) if type == 'd20': return utils.roll(number=1, sides=20, addition=value)
def sort_inits(self): self._inits.sort() #sorting a list of tuples sorts on the first element of each tuple self._inits.reverse() dupes = self.get_duplicates() if dupes: for dupe_group in dupes: for roll, entity in dupe_group: self._inits.remove((roll, entity)) new_roll = float(int(roll)) + float((entity.stats.dex))/100 + float(utils.roll(1, 100))/(100*100) self._inits.append((new_roll, entity)) self._inits.sort() self._inits.reverse()