Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.12 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. bot = commands.Bot(command_prefix='rpg.')
  10.  
  11. logging.basicConfig(level='INFO')
  12.  
  13. @bot.command()
  14. async def ping(ctx):
  15. await ctx.send('pong')
  16.  
  17. @bot.command()
  18. async def start(ctx):
  19. def predicate(message):
  20. return (
  21. message.author == ctx.author
  22. and message.channel == ctx.channel
  23. and message.content.isdigit()
  24. )
  25. you=Player(ctx.author)
  26. allTotalNumbers = []
  27. allBaseNumbers = []
  28. for x in range(7):
  29. tempNum1 = random.randint(1, 6)
  30. tempNum2 = random.randint(1, 6)
  31. tempNum3 = random.randint(1, 6)
  32. tempNum4 = random.randint(1, 6)
  33. tempNum5 = random.randint(1, 6)
  34. allBaseNumbers.clear()
  35. allBaseNumbers.append(tempNum1)
  36. allBaseNumbers.append(tempNum2)
  37. allBaseNumbers.append(tempNum3)
  38. allBaseNumbers.append(tempNum4)
  39. allBaseNumbers.append(tempNum5)
  40. smallest=9
  41. for x in allBaseNumbers:
  42. await ctx.send(x)
  43. if allBaseNumbers[x]<smallest:
  44. smallest=allBaseNumbers[x]
  45. totalNum = tempNum1 + tempNum2 + tempNum3 + tempNum4 + tempNum5-smallest
  46. allTotalNumbers.append(totalNum)
  47. await ctx.send(str(tempNum1) + " + " + str(tempNum2) + " + " + str(tempNum3) + " + " + str(tempNum4) + " + " + str(tempNum5) + " - smallest value " + str(smallest) + ", Total = " + str(totalNum))
  48.  
  49. you.strength=allTotalNumbers[0]
  50. you.agility=allTotalNumbers[1]
  51. you.toughness = allTotalNumbers[2]
  52. you.intellect = allTotalNumbers[3]
  53. you.wisdom = allTotalNumbers[4]
  54. you.willpower = allTotalNumbers[5]
  55. you.luck= allTotalNumbers[6]
  56. await ctx.send("Strength : " + str(you.strength) + "\nAgility : " + str(you.agility) + "\nToughness : " + str(you.toughness) + "\nIntellect : " +
  57. str(you.intellect)+ "\nWisdom : " + str(you.wisdom)+ "\nWillpower : " + str(you.willpower)+ "\nLuck : " + str(you.luck))
  58. while you.modifPoints > 0:
  59. await ctx.send("you have " + str(you.modifPoints) + " modifier points, 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")
  60. message=await bot.wait_for('message', timeout=30,check=predicate)
  61. tempAnswer=str(message.content)
  62. ctx.send(tempAnswer)
  63. if tempAnswer == "1":
  64. you.extstrength += 1
  65. elif tempAnswer == "2":
  66. you.extagility += 1
  67. elif tempAnswer == "3":
  68. you.exttoughness += 1
  69. elif tempAnswer == "4":
  70. you.extintellect += 1
  71. elif tempAnswer == "5":
  72. you.extwisdom += 1
  73. elif tempAnswer == "6":
  74. you.extwillpower += 1
  75. elif tempAnswer == "7":
  76. you.extluck += 1
  77. else:
  78. await ctx.send("that was an incorrect answer, please select the stat you want by using the numbers 1 to 7")
  79. you.modifPoints += 1
  80. you.modifPoints -= 1
  81. await ctx.send("that is all your modifiers used up, character creation has finished")
  82. await you.seeMe(ctx)
  83.  
  84.  
  85. @dataclasses.dataclass()
  86. class Player:
  87. user: discord.User
  88. money= 0
  89. treasures= 0
  90. level= 1
  91. exp= 0
  92. expNeeded= 5
  93. modifPoints= 5
  94. strength = 0
  95. agility = 0
  96. toughness = 0
  97. intellect = 0
  98. wisdom = 0
  99. willpower = 0
  100. luck = 0
  101. move1 = 0
  102. move2 = 0
  103. move3 = 0
  104. move4 = 0
  105. weapon = 0
  106. armour = 0
  107. medalion = 0
  108. ring = 0
  109. head = 0
  110. extstrength = 0
  111. extagility = 0
  112. exttoughness = 0
  113. extintellect = 0
  114. extwisdom = 0
  115. extwillpower = 0
  116. extluck = 0
  117.  
  118. async def seeMe(self,ctx):
  119. await ctx.send("Money: " + str(self.money) + "\nTreasures: " + str(self.treasures) + "\nLevel: " + str(self.level) + "\nExp :" + str(self.exp) + "/" +
  120. str(self.expNeeded) + "\n\nSTATS\n Base Bonus"
  121. "\nStrength: " + str(self.strength) + " ("+ str(self.extstrength) + ")"
  122. "\nAgility: " + str(self.agility) + " ("+ str(self.extagility) + ")"
  123. "\nToughness: " + str(self.toughness) + " (" + str(self.exttoughness) + ")"
  124. "\nIntellect: " + str(self.intellect) + " (" + str(self.extintellect) + ")"
  125. "\nWisdom: " + str(self.wisdom) + " (" + str(self.extwisdom) + ")"
  126. "\nWillpower: " + str(self.willpower) + " (" + str(self.extwillpower) + ")"
  127. "\nLuck: " + str(self.luck) + " (" + str(self.extluck) + ")"
  128. )
  129.  
  130.  
  131. class PlayerCollection(typing.Dict[discord.User, Player]):
  132. def get_player(self, user: discord.User) -> Player:
  133. if user not in self:
  134. self[user] = Player(user)
  135.  
  136. return self[user]
  137.  
  138.  
  139. @bot.command()
  140. async def seeme(ctx):
  141. you = player_collection.get_player(ctx.author)
  142. print(you.user)
  143. await you.seeMe(ctx)
  144.  
  145. player_collection = PlayerCollection()
  146.  
  147. class Monster:
  148. def __init__(self):
  149. self.area=0
  150. self.rarity=0
  151. self.moneyGive = 0
  152. self.treasuresGive = 0
  153. self.level = 1
  154. self.expGive = 0
  155. self.strength = 0
  156. self.agility = 0
  157. self.toughness = 0
  158. self.intellect = 0
  159. self.wisdom = 0
  160. self.willpower = 0
  161. self.luck = 0
  162. self.move1 = 0
  163. self.move2 = 0
  164. self.move3 = 0
  165. self.move4 = 0
  166. self.weapon = 0
  167. self.armour = 0
  168. self.medalion = 0
  169. self.ring = 0
  170. self.head = 0
  171.  
  172. class Item:
  173. def __init__(self):
  174. self.rarity=0
  175. self.strength = 0
  176. self.agility = 0
  177. self.toughness = 0
  178. self.intellect = 0
  179. self.wisdom = 0
  180. self.willpower = 0
  181. self.luck = 0
  182. self.place=0
  183.  
  184.  
  185. # event
  186. @bot.listen()
  187. async def on_guild_join(guild):
  188. print('I just joined', guild)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement