Guest User

so cool

a guest
Jun 4th, 2014
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.25 KB | None | 0 0
  1. class Map(self, keyboard):
  2. """ View of characted being moved to new location. """
  3.  
  4. class Character():
  5. def Character(object):
  6. C = player(hero)
  7. hero = {'name' : 'Hero',
  8. 'lvl' : 1,
  9. 'xp' : 0,
  10. 'lvlNext' : 25,
  11. 'stats' : {'str' : 1,
  12. 'dex' : 1,
  13. 'int' : 1,
  14. 'hp' : 30,
  15. 'atk' : [5, 12]}}
  16. def update(self, C, map):
  17. """ Move player based on keys pressed. """
  18. if keyboard.is_pressed(K_w, C, map):
  19. self.C
  20. self.map
  21. self.y -= 1
  22. if keyboard.is_pressed(K_s, C, map):
  23. self.C
  24. self.map
  25. self.y += 1
  26. if keyboard.is_pressed(K_a, C, map):
  27. self.C
  28. self.map
  29. self.x -= 1
  30. if keyboard.is_preseed(K_d, C, map):
  31. self.C
  32. self.map
  33. self.x += 1
  34.  
  35. else:
  36. print(" Waiting for your move. ")
  37.  
  38. class Enemy():
  39. def Enemy(object):
  40. f = enemy(fly)
  41. fly = {'name' : 'Fly',
  42. 'lvl' : 1,
  43. 'reward' : 25,
  44. 'xp' : 0,
  45. 'lvlNext' : 25,
  46. 'stats' : {'str': 1,
  47. 'int' : 1,
  48. 'hp' : 30,
  49. 'atk' : [5, 12]}}
  50.  
  51. def move(self, f, map):
  52. """ Mov
  53.  
  54.  
  55. class Wall()
  56. def Wall(object):
  57. P = wall(solid)
  58. solid = ['name' : 'Solid',
  59. 'Function' :
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68. c = chest
  69. d = door
  70. DD = door
  71.  
  72.  
  73.  
  74.  
  75. map = """
  76.  
  77. PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
  78. P|-----------------------------------------------------|P
  79. P| |--------| |-------|------------| |---------------|P
  80. P| | |PPDPPPPPPPP| | | |P
  81. P| C| |P P| f | | |P
  82. P| | |P f P| | | |P
  83. P| | |P P| d d |P
  84. P| | |P P| | | |P
  85. P| | |P P| | | |P
  86. P| | |P P| | | cccc |P
  87. P| | |PPPPPPPPPPP| | | c c |P
  88. P|__d_______|P|_________d___________| |____cccc_______|P
  89. PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPDDPPPPPPPPPPPPPPPPPP
  90.  
  91. """
  92.  
  93.  
  94.  
  95.  
  96. class Keyboard(self, character, map):
  97. """ Key board controls. """
  98. def update(self):
  99. """ Move hero based on keys pressed. """
  100. if keyboard.is_pressed(K_w, p, map):
  101. self.y -= 1
  102. if keyboard.is_pressed(K_s, p, map):
  103. self.y += 1
  104. if keyboard.is_pressed(K_a, p, map):
  105. self.x -= 1
  106. if keyboard.is_preseed(K_d, p, map):
  107. self.x += 1
  108.  
  109. hero = {'name' : 'Hero',
  110. 'lvl' : 1,
  111. 'xp' : 0,
  112. 'lvlNext' : 45,
  113. 'stats' : {'str' : 4,
  114. 'dex' : 2,
  115. 'int' : 10,
  116. 'hp' : 100,
  117. 'atk' : [5, 12]}}
  118.  
  119. fly = {'name' : 'Fly',
  120. 'lvl' : 5,
  121. 'reward' : 25,
  122. 'xp' : 0,
  123. 'lvlNext' : 25,
  124. 'stats' : {'str': 5,
  125. 'int' : 4,
  126. 'hp' : 13,
  127. 'atk' : [5, 12]}}
  128.  
  129. def level(char):
  130. nStr, nDex, nInt = 0, 0, 0
  131. while char['xp'] >= char['lvlNext']:
  132. char['lvl'] += 1
  133. char['xp'] = char['xp'] - char['lvlNext']
  134. char['lvlNext'] = round(char['lvlNext'] * 1.5)
  135. nStr += 1
  136. nDex += 1
  137. nInt += 1
  138.  
  139. print('level:', char['lvl'])
  140.  
  141. print('STR {} +{} DEX {} +{} INT {} +{}'.format(char['stats']['str'], nStr,
  142. char['stats']['dex'], nDex,
  143. char['stats']['int'], nInt))
  144. char['stats']['str'] += nStr
  145. char['stats']['dex'] += nDex
  146. char['stats']['int'] += nInt
  147.  
  148. from random import randint
  149.  
  150. def takeDmg(attacker, defender):
  151. dmg = randint(attacker['stats']['atk'][0], attacker['stats']['atk'][1])
  152. defender['stats']['hp'] = defender['stats']['hp'] - dmg
  153. if defender['stats']['hp'] <= 0:
  154. print('{} has been slain'.format(defender['name']))
  155. hero['xp'] += fly['reward']
  156. level(hero)
  157. input('Press any key to quite.')
  158. exit(0)
  159. else:
  160. print('{} takes {} damage!'.format(defender['name'], dmg))
  161.  
  162. def commands(player, enemy):
  163. while True:
  164. print('----------------------')
  165. cmd = input('Do you want to attack? yes/no: ').lower()
  166. if 'yes' in cmd:
  167. takeDmg(player, enemy)
  168. elif 'no' in cmd:
  169. print('{} takes the opportunity to attack!'.format(enemy['name']))
  170. takeDmg(enemy, player)
  171. else:
  172. pass
  173.  
  174. commands(hero, fly)
Advertisement
Add Comment
Please, Sign In to add comment