Advertisement
MatiGe

D&D System

Jan 13th, 2023
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.96 KB | None | 0 0
  1. import sys
  2. import keyboard
  3. import random
  4. i = 0
  5. print(f"Press Space to play or Esc to exit.")
  6. while i < 5:
  7. if keyboard.is_pressed('Space'):
  8. name = input('Enter your name: ')
  9. print(f'Greetings {name}!')
  10. print(f'Welcome to Dungeons & Dragons!')
  11. character = input(f'Choose your character! Fighter, Wizard or Rogue.')
  12. Start = False
  13. if character == 'Fighter':
  14. st = 18
  15. de = 10
  16. co = 16
  17. i = 8
  18. wi = 11
  19. ch = 12
  20.  
  21. stMod = 4
  22. deMod = 0
  23. coMod = 3
  24. iMod = -1
  25. wiMod = 0
  26. chMod = 2
  27.  
  28. HP = 15
  29. AC = 13
  30.  
  31. att = ('Melee')
  32. Att = random.randint(1, 20) + stMod
  33. dmg = random.randint(2, 6) + stMod
  34.  
  35. initiative = random.randint(1, 20) + deMod
  36.  
  37. exp = 0
  38.  
  39. print(f'STR ', st, ' ', 'MOD ', stMod)
  40. print(f'DEX ', de, ' ', 'MOD ', deMod)
  41. print(f'CON ', co, ' ', 'MOD ', coMod)
  42. print(f'INT ', i, ' ', 'MOD ', iMod)
  43. print(f'WIS ', wi, ' ', 'MOD ', wiMod)
  44. print(f'CHA ', ch, ' ', 'MOD ', chMod)
  45. print(f'HP ', HP)
  46. print(f'AC ', AC)
  47. print(f'Attack ', att)
  48. print(f'Experience: ', exp)
  49. Start = True
  50. elif character == 'Wizard':
  51. st = 8
  52. de = 10
  53. co = 9
  54. i = 18
  55. wi = 16
  56. ch = 11
  57.  
  58. stMod = -1
  59. deMod = 0
  60. coMod = -1
  61. iMod = +4
  62. wiMod = +3
  63. chMod = 0
  64.  
  65. HP = 12
  66. AC = 9
  67.  
  68. att = ('Burning Hands')
  69. Att = random.randint(1, 20) + iMod
  70. dmg = random.randint(3, 6) + iMod
  71.  
  72. initiative = random.randint(1, 20) + deMod
  73.  
  74. exp = 0
  75.  
  76. print(f'STR ', st, ' ', 'MOD ', stMod)
  77. print(f'DEX ', de, ' ', 'MOD ', deMod)
  78. print(f'CON ', co, ' ', 'MOD ', coMod)
  79. print(f'INT ', i, ' ', 'MOD ', iMod)
  80. print(f'WIS ', wi, ' ', 'MOD ', wiMod)
  81. print(f'CHA ', ch, ' ', 'MOD ', chMod)
  82. print(f'HP ', HP)
  83. print(f'AC ', AC)
  84. print(f'Attack ', att)
  85. print(f'Experience: ', exp)
  86.  
  87. Start = True
  88. elif character == 'Rogue':
  89. st = 11
  90. de = 18
  91. co = 10
  92. i = 15
  93. wi = 8
  94. ch = 16
  95.  
  96.  
  97. stMod = 0
  98. deMod = +4
  99. coMod = 0
  100. iMod = +2
  101. wiMod = -1
  102. chMod = +3
  103.  
  104. HP = 13
  105. AC = 10
  106.  
  107. att = ('Crossbow')
  108. Att = random.randint(1, 20) + deMod
  109. dmg = random.randint(1, 4) + deMod
  110.  
  111. initiative = random.randint(1, 20) + deMod
  112.  
  113. exp = 0
  114.  
  115. print(f'STR ', st, ' ', 'MOD ', stMod)
  116. print(f'DEX ', de, ' ', 'MOD ', deMod)
  117. print(f'CON ', co, ' ', 'MOD ', coMod)
  118. print(f'INT ', i, ' ', 'MOD ', iMod)
  119. print(f'WIS ', wi, ' ', 'MOD ', wiMod)
  120. print(f'CHA ', ch, ' ', 'MOD ', chMod)
  121. print(f'HP ', HP)
  122. print(f'AC ', AC)
  123. print(f'Attack ', att)
  124. print(f'Experience: ', exp)
  125.  
  126. Start = True
  127. else:
  128. print(f'Choose Again!')
  129. i = 0
  130. while Start == True:
  131. lev1 = False
  132. option1 = input('You find yourself in a cell of a dungeon, then, from a wall, a key slips underneath. What will you do? Stay or Go?')
  133. if option1 == 'Stay':
  134. print(f'Hours later, rats will come to your cell and will start to eat you. Game Over.')
  135. sys.exit(0)
  136. elif option1 == 'Go':
  137. lev1 = True
  138. else:
  139. print(f'Choose Again!')
  140. Start = True
  141. while lev1 == True:
  142. Level2 = False
  143. option2 = input('You are outside the cell and find a dead guard. Take his sword or No?')
  144. if option2 == 'Take':
  145. print(f'You have taken the sword with you.')
  146. stMod + 2
  147. Level2 = True
  148. elif option2 == 'No':
  149. print(f'You leave the sword there.')
  150. Level2 = True
  151. else:
  152. print(f'Choose Again!')
  153. lev1 = True
  154. while Level2 == True:
  155.  
  156. Fight = False
  157.  
  158.  
  159. level3 = False
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166. what = input(f"On the way you find a goblin, he didn't notice you and you can make a stealth check to pass without being unnoticed or fight him. Fight or Pass? You can sneak kill him too.")
  167. if what == 'Fight':
  168. Fight = True
  169.  
  170.  
  171.  
  172. elif what == 'Pass':
  173. print(f'You try to sneak and walk unnoticed. Can you succeed?')
  174. input(f"Press Enter to Roll 1d20")
  175. d20 = random.randint(1, 20) + deMod
  176. print(d20)
  177. if d20 >= 12:
  178. print(f"You sneaked away from him!")
  179. level3 = True
  180. elif d20 < 12:
  181. print(f"You failed! Now, battle!")
  182. Fight = True
  183.  
  184. elif what == 'Kill':
  185. print(f'Will you kill him easily or will you be noticed?')
  186. input(f"Press Enter to Roll 1d20")
  187. d20 = random.randint(1, 20) + deMod
  188. print(d20)
  189. if d20 >= 15:
  190. print(f"You killed him!")
  191. level3 = True
  192. elif d20 < 15:
  193. print(f"You failed! Now, battle!")
  194. Fight = True
  195.  
  196. else:
  197. print(f'Choose Again!')
  198. Level2 = True
  199.  
  200.  
  201.  
  202. while Fight == True:
  203. print(f'The goblin notices you. Fight!')
  204.  
  205. YTurn = False
  206. GTurn = False
  207.  
  208. initiative
  209.  
  210. gDeMod = 1
  211.  
  212. gStMod = 1
  213.  
  214. gAC = 11
  215.  
  216. gInit = random.randint(1, 20) + gDeMod
  217.  
  218. gAtt = random.randint(1, 20) + gStMod
  219.  
  220. gDMG = random.randint(1, 20) + gStMod
  221.  
  222. gHP = 8
  223.  
  224. initiative
  225.  
  226. gInit
  227.  
  228. if initiative > gInit:
  229. print(initiative, gInit)
  230.  
  231. print(f'You go first!')
  232.  
  233. YTurn = True
  234.  
  235. elif initiative < gInit:
  236.  
  237. print(initiative, gInit)
  238.  
  239. print(f'Goblin goes first!')
  240.  
  241. GTurn = True
  242.  
  243. elif initiative == gInit:
  244.  
  245. print(initiative, gInit)
  246. print(f'Roll again!')
  247. Fight = True
  248.  
  249. while YTurn == True:
  250. GTurn = False
  251. Att
  252.  
  253. if Att >= gAC:
  254.  
  255. print(f'You hit your oponent!')
  256.  
  257. dmg
  258.  
  259. gHP = gHP - dmg
  260.  
  261. if gHP <= 0:
  262.  
  263. print(f'You slained the goblin!')
  264. exp = exp + 100
  265. print(f'Now your experience is ', exp)
  266.  
  267. level3 = True
  268.  
  269. else:
  270. print(f"Goblin's turn!")
  271. YTurn = False
  272. GTurn = True
  273. else:
  274. print(f"You missed! Goblin's turn!")
  275. YTurn = False
  276. GTurn = True
  277.  
  278. while GTurn == True:
  279. YTurn = False
  280. gAtt
  281.  
  282. if gAtt >= AC:
  283. print(gAtt, AC)
  284. print(f'The goblin hits you!')
  285.  
  286. gDMG
  287.  
  288. HP = HP - gDMG
  289.  
  290. if HP <= 0:
  291.  
  292. print(f"You died!, It's Game Over, man!")
  293. sys.exit(0)
  294. else:
  295. print(
  296. f'You take ', gDMG, ' damage, and now you have ', HP, ' left!')
  297. print(f'Your turn!')
  298. GTurn = False
  299. YTurn = True
  300. else :
  301.  
  302. print(gAtt, AC)
  303. print(f'Goblin misses you!')
  304. GTurn = False
  305. YTurn = True
  306.  
  307.  
  308.  
  309. while level3 == True:
  310. print(f'You find a bridge.')
  311.  
  312.  
  313. if keyboard.is_pressed('Esc'):
  314. sys.exit(0)
  315.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement