async def roll(ctx, dice): if dice in customs: dice = customs[dice] dice_set = dice.split(";") output = "```" try: for d in range(len(dice_set)): dice = dice_set[d] output += "\n[{}]:\n".format(dice) dice_mult = dice.split("*") multi = 1 if len(dice_mult) > 1: multi = int(dice_mult[1]) dice = dice_mult[0] dice_split = dice.split("+") for i in range(multi): if len(dice_split) > 1: result = tools.roll(dice_split[0], int(dice_split[1])) else: result = tools.roll(dice) output += "\tRoll {}: {}\n".format(i + 1, result) await ctx.send(output + "```") except Exception as e: print("Something went terribly wrong.") print(e)
def in_view(self, pos, pt, view, left_view, vert, horz): #verify not out of range dist = tools.pts_dist(pt, pos) if dist > self.view: return False p, r, y = view lp, lr, ly = left_view vect = tools.pitch([0, 0, 1], p, do_round=self.do_round) vect = tools.roll(vect, r, do_round=self.do_round) vect = tools.yaw(vect, y, do_round=self.do_round) #parallel to top and bottom of view frame, runs from right to left horz = tools.pitch([-1, 0, 0], lp, do_round=self.do_round) horz = tools.roll(horz, lr, do_round=self.do_round) horz = tools.yaw(horz, ly, do_round=self.do_round) #parallel to left and right of view frame, runs from bottom to top vert = tools.ortho(vect, horz) #verify not too far left/right/high/low pt_vector = (pos[0] - pt[0], pos[1] - pt[1], pos[2] - pt[2]) angle = tools.angle_2_vectors(pt_vector, vect) vert_proj = tools.projection_vector(pt_vector, vert) horz_proj = tools.projection_vector(pt_vector, horz) vert_angle = tools.angle_2_vectors(vert_proj, vect) horz_angle = tools.angle_2_vectors(horz_proj, vect) if vert_angle > self.hr / 2 or horz_angle > self.wr / 2: return False else: return True
def convert(self, pos, projection, view, left_view): p, r, y = view lp, lr, ly = left_view wp = len(projection) hp = len(projection[0]) i_mid = wp/2 j_mid = hp/2 #direction of camera's view vect = tools.pitch([0,0,1], p, do_round=self.do_round) vect = tools.roll(vect, r, do_round=self.do_round) vect = tools.yaw(vect, y, do_round=self.do_round) #parallel to top and bottom of view frame, runs from right to left horz = tools.pitch([-1,0,0], lp, do_round=self.do_round) horz = tools.roll(horz, lr, do_round=self.do_round) horz = tools.yaw(horz, ly, do_round=self.do_round) #parallel to left and right of view frame, runs from bottom to top vert = tools.ortho(vect, horz) new_pts = set() i_temp = np.zeros((8, 8)) j_temp = np.zeros((8, 8)) #j = all the rows, i = all the columns for j in range(len(projection)): for i in range(len(projection[j])): #get radians difference from center i_rad = -(i + 0.5 - i_mid)/wp * self.wr j_rad = (j + 0.5 - j_mid)/hp * self.hr #get rotation m_i = tools.rmatrix_to_vector(tools.invert(tools.make_unit_vector(vert)), j_rad) m_j = tools.rmatrix_to_vector(tools.invert(tools.make_unit_vector(horz)), i_rad) max_vect = tools.normalize(vect, tools.len_vector(vect)) max_vect = tools.vector_multiplier(max_vect, self.darkest) #get vector from camera to pixel, with vector in objective 3D space pix_dist = self.darkest - float(projection[i][j]) / 255 * self.darkest pv = [tools.dot_product(vect, m_i[0]), tools.dot_product(vect, m_i[1]), tools.dot_product(vect, m_i[2])] pv = [tools.dot_product(pv, m_j[0]), tools.dot_product(pv, m_j[1]), tools.dot_product(pv, m_j[2])] pv = tools.make_unit_vector(pv) pix_vect = tools.vector_multiplier(pv, pix_dist) #get position of this point in 3D space pix_pt = tools.sum_vectors(pos, pix_vect) if self.do_round: new_pts.add(tuple(tools.make_ints(pix_pt))) else: new_pts.add(tuple(pix_pt)) return list(new_pts), vert, horz
def setVals(self): self.stats['STR'] = tools.roll(3,6) self.stats['DEX'] = tools.roll(3,6) self.stats['CON'] = tools.roll(3,6) self.stats['INT'] = tools.roll(3,6) self.stats['WIS'] = tools.roll(3,6) self.stats['CHA'] = tools.roll(3,6) print "\nYour current stat rolls are:\n" print "\tSTR:", self.stats['STR'], "\tDEX:", self.stats['DEX'], "\tCON:", self.stats['CON'] print "\tINT:", self.stats['INT'], "\tWIS:", self.stats['WIS'], "\tCHA:", self.stats['CHA'] extraPoints=tools.roll(4,6) while extraPoints > 0 or choice < 1 or choice > 6: print "\nYou have", extraPoints,"to spend on increasing stats." print "Which stat would you like to increase? (You cannot increase higher than 18)\n" print "\n\t1) STR:",self.stats['STR'],"\t2) DEX:",self.stats['DEX'],"\t3) CON:",self.stats['CON'] print "\t4) INT:",self.stats['INT'],"\t5) WIS:",self.stats['WIS'],"\t6) CHA:",self.stats['CHA'],"\n" choice = input("\n>> ") if choice == 1: if self.stats['STR'] < 18: self.stats['STR'] +=1 extraPoints-=1 else: print "That stat is maxed out..." elif choice ==2: if self.stats['DEX'] < 18: self.stats['DEX'] +=1 extraPoints-=1 else: print "That stat is maxed out..." elif choice ==3: if self.stats['CON'] < 18: self.stats['CON'] +=1 extraPoints-=1 else: print "That stat is maxed out..." elif choice ==4: if self.stats['INT'] < 18: self.stats['INT'] +=1 extraPoints-=1 else: print "That stat is maxed out..." elif choice ==5: if self.stats['WIS'] < 18: self.stats['WIS'] +=1 extraPoints-=1 else: print "That stat is maxed out..." elif choice ==6: if self.stats['CHA'] < 18: self.stats['CHA'] +=1 extraPoints-=1 else: print "That stat is maxed out..." else: print"\nI am sorry, that is not a valid choice. Please try again..."
def setMP(self): if self.stats['WIS'] >18: dice=14 elif self.stats['WIS'] >16: dice=13 elif self.stats['WIS'] >14: dice=12 elif self.stats['WIS'] >12: dice=11 elif self.stats['WIS'] >10: dice=10 elif self.stats['WIS'] >8: dice=9 elif self.stats['WIS'] >6: dice=8 elif self.stats['WIS'] >4: dice=7 elif self.stats['WIS'] >1: dice=6 self.maxMP=tools.roll(dice,6) self.currentMP=self.maxMP
def setHP(self): if self.stats['CON'] >18: dice=16 elif self.stats['CON'] >16: dice=15 elif self.stats['CON'] >14: dice=14 elif self.stats['CON'] >12: dice=13 elif self.stats['CON'] >10: dice=12 elif self.stats['CON'] >8: dice=11 elif self.stats['CON'] >6: dice=10 elif self.stats['CON'] >4: dice=9 elif self.stats['CON'] >2: dice=8 self.maxHP=tools.roll(dice,6) self.currentHP=self.maxHP
async def rollout(ctx, *, pilot): await ctx.send(tools.roll(pilot))
def setGold(self): self.gold=tools.roll(100,5)
def setGold(gold): goldAmt = tools.roll(gold, 6) return goldAmt
def setHealth(hitdice): hp = tools.roll(hitdice, 6) return hp