Advertisement
Raggie

Python - How do you make a random() variable in a loop?

May 1st, 2014
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.72 KB | None | 0 0
  1. # Combat System -------
  2.  
  3. def battle_menu():
  4.     print("BATTLE MENU:")
  5.     print("\n(1) ATTACK")
  6.     print("(2) SPECIAL ATTACK")
  7.  
  8. def recall_last(func):
  9.     def _inner(*args, **kwargs):
  10.         if args:
  11.             func.last_dealt = func(*args,**kwargs)
  12.         else:
  13.             func.last_dealt = getattr(func,'last_dealt',0)
  14.         return func.last_dealt
  15.     return _inner
  16.  
  17. @recall_last
  18. def rand_damage(*values):
  19.     return random.randrange(*values)
  20.  
  21. jack_health = 300
  22. jack_damage = random.randrange(1, 10)
  23. jack_defense = random.randrange(1, 5)
  24.  
  25. boss_health = 700
  26. boss_damage = random.randrange(10, 15)
  27. boss_defense = random.randrange(15, 20)
  28. def boss_specialattack(my_defense):
  29.     my_defense = my_defense - 10
  30. boss_killed = False
  31.  
  32. # ---------------------
  33.  
  34. #'my_damage' values
  35.         deskemon_selection_input = input("> ")
  36.     if deskemon_selection_input == "1":
  37.         deskemon = "TIMOSHA"
  38.         my_health = 500
  39.         my_damage = (25, 30)
  40.         my_defense = (10, 15)
  41.         my_specialattack = 0
  42.         print("You have selected TIMOSHA as your Deskemon")
  43.         deskemon_selection_loop = False
  44.     elif deskemon_selection_input == "2":
  45.         deskemon = "PICKAPOO"
  46.         my_health = 750
  47.         my_min = 20
  48.         my_max = 25
  49.         my_damage = lambda: random.randrange(my_min, my_max)
  50.         my_defense = random.randrange(20, 25)
  51.         my_specialattack = 0
  52.         print("You have selected PICKAPOO as your Deskemon")
  53.         deskemon_selection_loop = False
  54.     elif deskemon_selection_input == "3":
  55.         deskemon = "LILWILLY"
  56.         my_health = 1000
  57.         my_damage = random.randrange(40, 45)
  58.         my_defense = random.randrange(10, 15)
  59.         def my_specialattack():
  60.             boss_killed = True
  61.         print("You have selected LILWILLY as your Deskemon")
  62.         deskemon_selection_loop = False
  63.     elif deskemon_selection_input == "4":
  64.         deskemon = "BIGGBOI"
  65.         my_health = 2000
  66.         my_damage = random.randrange(10, 15)
  67.         my_defense = random.randrange(50, 60)
  68.         my_specialattack = 0
  69.         print("You have selected BIGGBOI as your Deskemon")
  70.         deskemon_selection_loop = False
  71.     elif deskemon_selection_input == "":
  72.         deskemon_selection_loop = True
  73.     else:
  74.         deskemon_selection_loop = True
  75.  
  76. #combat system
  77.             print("LET'S GO BATTLE!")
  78.         jack_battle_loop = True
  79.         while jack_battle_loop:
  80.             battle_menu()
  81.             choise = input("> ")
  82.             if choise == "1":
  83.                 #(jack_health + jack_defense) - my_damage = jack_health
  84.                 jack_health = (jack_health + jack_defense) - rand_damage(*my_damage)
  85.                 print(deskemon + " HAS INFLICTED " + str(rand_damage()) + " TO CHIPHEAD")
  86.                 if jack_health <= 0:
  87.                     jack_battle_loop = False
  88.                     break
  89.                 print("CHIPHEAD HAS " + str(jack_health) + " HITPOINTS LEFT!")
  90.                 time.sleep(1)
  91.                 print("...")
  92.                 time.sleep(1)
  93.                 print("...")
  94.                 time.sleep(1)
  95.                 print("...")
  96.                 time.sleep(1)
  97.                 #(my_health + my_defense) - jack_damage = my_health
  98.                 my_health = (my_health + my_defense) - jack_damage
  99.                 print("CHIPHEAD HAVE INFLICTED " + str(jack_damage) + " TO " + deskemon)
  100.                 if my_health <= 0:
  101.                     jack_battle_loop = False
  102.                     break
  103.                 print(deskemon + " HAS " + str(jack_health) + " HITPOINTS LEFT!")
  104.                 jack_battle_loop = True
  105.             elif choise == "":
  106.                 jack_battle_loop = True
  107.             else:
  108.                 jack_battle_loop = True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement