def roll_attack(self, target, penalty=0): """ Returns our roll to hit with an attack. Half of our roll is randomized. """ autohit = self.damage is not None diff = 2 # base difficulty before mods penalty -= self.atk_modifiers diff += penalty diff += self.difficulty_mod if not autohit: roll = do_dice_check( self.attacker, stat=self.attack_stat, skill=self.attack_skill, difficulty=diff, ) else: roll_object = Roll() roll_object.character_name = self.attacker_name if self.attack_skill: roll_object.skills = { self.attack_skill: self.attack_skill_value } else: roll_object.stat_keep = True roll_object.skill_keep = False roll_object.stats = {self.attack_stat: self.attack_stat_value} roll = roll_object.roll() if self.attacker_is_npc: roll = self.modify_difficulty_by_risk(roll) if roll > 2: roll = (roll // 2) + randint(0, (roll // 2)) if not autohit: roll += self.get_modifier(target, RollModifier.ATTACK) return roll
def func(self): maximum_difference = 100 crit = "can_crit" in self.switches flub = "flub" in self.switches roll = Roll( can_crit=crit, quiet=False, announce_room=self.caller.location, announce_values=True, flub=flub, ) try: # rest of the command here. PS, I love you. <3 # checks to see if difficulty exists. PPS Love you too! args_list = self.args.lower().split(" at ") if len(args_list) > 1: if (not args_list[1].isdigit() or not 0 < int(args_list[1]) < maximum_difference): self.msg("Difficulty must be a number between 1 and %s." % maximum_difference) return difficulty = int(args_list[1]) roll.difficulty = difficulty # 'args' here is the remainder after difficulty was split away. # it is not self.args args = args_list[0] other_list = args.split("+") if len(other_list) > 1: skilltup = self.get_value_pair(other_list[1]) if not skilltup: return roll.skills = {skilltup[0]: skilltup[1]} else: roll.stat_keep = True roll.skill_keep = False stattup = self.get_value_pair(other_list[0]) if not stattup: return roll.stats = {stattup[0]: stattup[1]} roll.character_name = "%s GM Roll" % self.caller # Just so you know, you are beautiful and I love you. <3 roll.roll() except IndexError: self.msg( "usage: @gmcheck <stat>/<value>[+<skill>/<value>] at <difficulty number>" ) return