def do_roll(self, stat=None, skill=None, difficulty=15): """Performs and records a roll for this action.""" from world.roll import Roll roll = Roll(self.character, stat=stat, skill=skill, difficulty=difficulty, quiet=False, flat_modifier=self.state.special_roll_modifier) roll.roll() self.roll = roll
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 _send_quiet_roll_msg(self): """ Notifies all staff and specified player(s) in the room of the result of the roll. """ namelist = [] roll_msg = "|w[Private Roll]|n " + Roll.build_msg( self.caller.ndb.last_roll) if self.rhs.lower() in ( "me", "self", str(self.caller).lower(), str(self.caller.key).lower(), ): namelist.append("self-only") else: # send roll message to each recipient for name in self.rhs.split(","): recipient = self.caller.search(name.strip(), use_nicks=True) if recipient: namelist.append(name.strip()) recipient.msg(roll_msg, options={"roll": True}) roll_msg += " (Shared with: %s)" % ", ".join(namelist) self.caller.msg(roll_msg, options={"roll": True}) # GMs always get to see rolls. staff_list = [ x for x in self.caller.location.contents if x.check_permstring("Builders") ] for gm in staff_list: gm.msg(roll_msg, options={"roll": True})
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
def func(self): """Run the @check command""" caller = self.caller skill = None maximum_difference = 100 flub = "flub" in self.switches if not self.args: caller.msg("Usage: @check <stat>[+<skill>][ at <difficulty number>][=receiver1,receiver2,etc]") return args = self.lhs if self.rhs else self.args args = args.lower() # if args contains ' at ', then we split into halves. otherwise, it's default of 6 diff_list = args.split(' at ') difficulty = stats_and_skills.DIFF_DEFAULT if len(diff_list) > 1: if not diff_list[1].isdigit() or not 0 < int(diff_list[1]) < maximum_difference: caller.msg("Difficulty must be a number between 1 and %s." % maximum_difference) return difficulty = int(diff_list[1]) args = diff_list[0] arg_list = args.split("+") if len(arg_list) > 1: skill = arg_list[1].strip() stat = arg_list[0].strip() matches = stats_and_skills.get_partial_match(stat, "stat") if not matches or len(matches) > 1: caller.msg("There must be one unique match for a character stat. Please check spelling and try again.") return # get unique string that matches stat stat = matches[0] if skill: matches = stats_and_skills.get_partial_match(skill, "skill") if not matches: # check for a skill not in the normal valid list if skill in caller.db.skills: matches = [skill] else: caller.msg("No matches for a skill by that name. Check spelling and try again.") return if len(matches) > 1: caller.msg("There must be one unique match for a character skill. Please check spelling and try again.") return skill = matches[0] quiet = bool(self.rhs) stats_and_skills.do_dice_check(caller, stat, skill, difficulty, quiet=quiet, flub=flub) if quiet: namelist = [name.strip() for name in self.rhs.split(",") if caller.search(name.strip(), use_nicks=True)] roll_msg = Roll.build_msg(caller.ndb.last_roll) + " " + "(Private roll sent to: %s)" % ", ".join(namelist) caller.msg(roll_msg) # they have a recipient list; only tell those people (and GMs) for name in namelist: recipient = caller.search(name, use_nicks=True) recipient.msg(roll_msg, options={'roll':True}) # GMs always get to see rolls. staff_list = [x for x in caller.location.contents if x.check_permstring("Builders")] for GM in staff_list: GM.msg("{w(Private roll) {n" + roll_msg) return