Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.54 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. from discord.ext import commands
  4. import logging
  5. import random
  6. import discord
  7. import dataclasses
  8. import typing
  9. from motor.motor_asyncio import AsyncIOMotorClient
  10.  
  11. client = AsyncIOMotorClient(
  12. "mongodb+srv://DrakeNorr:<password>@rpgbot-atziq.mongodb.net/test?retryWrites=true&w=majority")
  13.  
  14. bot = commands.Bot(command_prefix='rpg.')
  15.  
  16. logging.basicConfig(level='INFO')
  17.  
  18.  
  19. @bot.command()
  20. async def ping(ctx):
  21. await ctx.send('pong')
  22.  
  23.  
  24. @bot.command()
  25. async def start(ctx):
  26. def predicate(message):
  27. return (
  28. message.author == ctx.author
  29. and message.channel == ctx.channel
  30. and message.content.isdigit()
  31. )
  32.  
  33. you = player_collection.get_player(ctx.author)
  34. if you.created:
  35. await ctx.send("you have already made a character")
  36. return
  37. await statsRoll(you, ctx)
  38. await ctx.send("Strength : " + str(you.strength) + "\nAgility : " + str(you.agility) + "\nToughness : " + str(
  39. you.toughness) + "\nIntellect : " +
  40. str(you.intellect) + "\nWisdom : " + str(you.wisdom) + "\nWillpower : " + str(
  41. you.willpower) + "\nLuck : " + str(you.luck))
  42. await ctx.send(
  43. "Please select a race using the numbers beside the races\n1.Human\n+Strength +Agility +Toughness +willpower\n2.Elf\n++Agility ++intellect\n3.Dwarf \n++Toughness ++Strength\n4.Lizardman\n++Wisdom +willpower +luck")
  44. message = await bot.wait_for('message', timeout=60, check=predicate)
  45. tempAnswer = str(message.content)
  46. if tempAnswer == "1":
  47. you.race = "Human"
  48. you.strength += 5
  49. you.agility += 5
  50. you.toughness += 5
  51. you.willpower += 5
  52. elif tempAnswer == "2":
  53. you.race = "Elf"
  54. you.agility += 10
  55. you.intellect += 10
  56. elif tempAnswer == "3":
  57. you.race = "Dwarf"
  58. you.strength += 10
  59. you.toughness += 10
  60. elif tempAnswer == "4":
  61. you.race = "Lizardmen"
  62. you.wisdom += 10
  63. you.willpower += 5
  64. you.luck += 5
  65. await you.seeMe(ctx)
  66. while you.modifPoints > 0:
  67. await ctx.send("you have " + str(
  68. you.modifPoints) + " modifier points, one modifier point gives you a +3 to your chosen stat, select what you want to use them on using the numbers\n1.Strength\n2.Agility\n3.Toughness\n4.Intellect\n5.Wisdom\n6.Willpower\n7.Luck\n")
  69. message = await bot.wait_for('message', timeout=30, check=predicate)
  70. tempAnswer = str(message.content)
  71. ctx.send(tempAnswer)
  72. if tempAnswer == "1":
  73. you.extstrength += 3
  74. elif tempAnswer == "2":
  75. you.extagility += 3
  76. elif tempAnswer == "3":
  77. you.exttoughness += 3
  78. elif tempAnswer == "4":
  79. you.extintellect += 3
  80. elif tempAnswer == "5":
  81. you.extwisdom += 3
  82. elif tempAnswer == "6":
  83. you.extwillpower += 3
  84. elif tempAnswer == "7":
  85. you.extluck += 3
  86. else:
  87. await ctx.send("that was an incorrect answer, please select the stat you want by using the numbers 1 to 7")
  88. you.modifPoints += 1
  89. you.modifPoints -= 1
  90. await ctx.send("that is all your modifiers used up, character creation has finished")
  91. you.created = True
  92. await you.seeMe(ctx)
  93.  
  94.  
  95. @dataclasses.dataclass()
  96. class Player:
  97. user: discord.User
  98. created = False
  99. race = ""
  100. rerolls = 4
  101. money = 0
  102. treasures = 0
  103. level = 1
  104. exp = 0
  105. expNeeded = 5
  106. modifPoints = 5
  107. strength = 0
  108. agility = 0
  109. toughness = 0
  110. intellect = 0
  111. wisdom = 0
  112. willpower = 0
  113. luck = 0
  114. move1 = 0
  115. move2 = 0
  116. move3 = 0
  117. move4 = 0
  118. weapon = 0
  119. armour = 0
  120. medalion = 0
  121. ring = 0
  122. head = 0
  123. extstrength = 0
  124. extagility = 0
  125. exttoughness = 0
  126. extintellect = 0
  127. extwisdom = 0
  128. extwillpower = 0
  129. extluck = 0
  130.  
  131. async def seeMe(self, ctx):
  132. await ctx.send("User: " + str(self.user) + "\nRace: " + str(self.race) + "\nMoney: " + str(
  133. self.money) + "\nTreasures: " + str(self.treasures) + "\nLevel: " + str(self.level) + "\nExp :" + str(
  134. self.exp) + "/" +
  135. str(self.expNeeded) + "\n\nSTATS\n Base Bonus Total"
  136. "\nStrength: " + str(self.strength) + " (" + str(
  137. self.extstrength) + ") = " + str(self.strength + self.extstrength) +
  138. "\nAgility: " + str(self.agility) + " (" + str(self.extagility) + ") = " + str(
  139. self.agility + self.extagility) +
  140. "\nToughness: " + str(self.toughness) + " (" + str(self.exttoughness) + ") = " + str(
  141. self.toughness + self.exttoughness) +
  142. "\nIntellect: " + str(self.intellect) + " (" + str(self.extintellect) + ") = " + str(
  143. self.intellect + self.extintellect) +
  144. "\nWisdom: " + str(self.wisdom) + " (" + str(self.extwisdom) + ") = " + str(
  145. self.wisdom + self.extwisdom) +
  146. "\nWillpower: " + str(self.willpower) + " (" + str(self.extwillpower) + ") = " + str(
  147. self.willpower + self.extwillpower) +
  148. "\nLuck: " + str(self.luck) + " (" + str(self.extluck) + ") = " + str(
  149. self.luck + self.extluck)
  150. )
  151.  
  152.  
  153. class PlayerCollection(typing.Dict[discord.User, Player]):
  154. def get_player(self, user: discord.User) -> Player:
  155. if user not in self:
  156. self[user] = Player(user)
  157.  
  158. return self[user]
  159.  
  160.  
  161. @bot.command()
  162. async def seeme(ctx):
  163. you = player_collection.get_player(ctx.author)
  164. print(you.user)
  165. await you.seeMe(ctx)
  166.  
  167.  
  168. player_collection = PlayerCollection()
  169.  
  170.  
  171. class Monster:
  172. def __init__(self):
  173. self.area = 0
  174. self.rarity = 0
  175. self.moneyGive = 0
  176. self.treasuresGive = 0
  177. self.level = 1
  178. self.expGive = 0
  179. self.strength = 0
  180. self.agility = 0
  181. self.toughness = 0
  182. self.intellect = 0
  183. self.wisdom = 0
  184. self.willpower = 0
  185. self.luck = 0
  186. self.move1 = 0
  187. self.move2 = 0
  188. self.move3 = 0
  189. self.move4 = 0
  190. self.weapon = 0
  191. self.armour = 0
  192. self.medalion = 0
  193. self.ring = 0
  194. self.head = 0
  195.  
  196.  
  197. class Item:
  198. def __init__(self):
  199. self.rarity = 0
  200. self.strength = 0
  201. self.agility = 0
  202. self.toughness = 0
  203. self.intellect = 0
  204. self.wisdom = 0
  205. self.willpower = 0
  206. self.luck = 0
  207. self.place = 0
  208.  
  209.  
  210. # event
  211. @bot.listen()
  212. async def on_guild_join(guild):
  213. print('I just joined', guild)
  214.  
  215.  
  216. async def statsRoll(you, ctx):
  217. def predicate(message):
  218. return (
  219. message.author == ctx.author
  220. and message.channel == ctx.channel
  221. and message.content.isdigit()
  222. )
  223.  
  224. tempAnswer = "1"
  225. while tempAnswer != "2":
  226. if (you.rerolls > 0):
  227. you.rerolls -= 1
  228. allTotalNumbers = []
  229. allBaseNumbers = []
  230. for x in range(7):
  231. tempNum1 = random.randint(1, 6)
  232. tempNum2 = random.randint(1, 6)
  233. tempNum3 = random.randint(1, 6)
  234. tempNum4 = random.randint(1, 6)
  235. tempNum5 = random.randint(1, 6)
  236. allBaseNumbers.clear()
  237. allBaseNumbers.append(tempNum1)
  238. allBaseNumbers.append(tempNum2)
  239. allBaseNumbers.append(tempNum3)
  240. allBaseNumbers.append(tempNum4)
  241. allBaseNumbers.append(tempNum5)
  242. smallest = 9
  243. for x in allBaseNumbers:
  244. if x < smallest:
  245. smallest = x
  246. totalNum = tempNum1 + tempNum2 + tempNum3 + tempNum4 + tempNum5 - smallest
  247. allTotalNumbers.append(totalNum)
  248. await ctx.send(
  249. str(tempNum1) + " + " + str(tempNum2) + " + " + str(tempNum3) + " + " + str(tempNum4) + " + " + str(
  250. tempNum5) + " - smallest value " + str(smallest) + ", Total = " + str(totalNum))
  251. you.strength = allTotalNumbers[0]
  252. you.agility = allTotalNumbers[1]
  253. you.toughness = allTotalNumbers[2]
  254. you.intellect = allTotalNumbers[3]
  255. you.wisdom = allTotalNumbers[4]
  256. you.willpower = allTotalNumbers[5]
  257. you.luck = allTotalNumbers[6]
  258. await ctx.send("\nStrength: " + str(you.strength) + "\nAgility: " + str(you.agility) + "\nToughness: " + str(
  259. you.toughness) + "\nIntellect: " + str(you.intellect) +
  260. "\nWisdom: " + str(you.wisdom) + "\nWillpower: " + str(you.willpower) + "\nLuck: " + str(
  261. you.luck))
  262. await ctx.send(
  263. "Would you like to reroll these stats? you have " + str(
  264. you.rerolls) + " rerolls left\n1.Reroll\n2.Continue")
  265. message = await bot.wait_for('message', timeout=60, check=predicate)
  266. tempAnswer = str(message.content)
  267. if you.rerolls > 0 and tempAnswer == "1":
  268. await ctx.send("Rerolling...")
  269. elif tempAnswer == "1":
  270. await ctx.send("you cannot reroll anymore")
  271. elif tempAnswer == "2":
  272. await ctx.send("lets move on")
  273. else:
  274. await ctx.send("invalid entry, please try again")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement