Advertisement
Nenogzar

Counter-Strike

Feb 13th, 2024
1,097
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.78 KB | None | 0 0
  1. import sys
  2.  
  3. def check_win_counter(energy, distance_to_enemy, win_counter):
  4.     if distance_to_enemy <= energy:
  5.         energy -= distance_to_enemy
  6.         win_counter += 1
  7.     else:
  8.         print(f"Not enough energy! Game ends with {win_counter} won battles and {energy} energy")
  9.         sys.exit()  # Излизаме от програмата
  10.  
  11.     if win_counter % 3 == 0:
  12.         energy += win_counter
  13.  
  14.     return win_counter, energy
  15.  
  16. energy = int(input())
  17. distance_to_enemy = input()
  18. win_counter = 0
  19.  
  20. while distance_to_enemy != "End of battle":
  21.     distance_to_enemy = int(distance_to_enemy)
  22.  
  23.     win_counter, energy = check_win_counter(energy, distance_to_enemy, win_counter)
  24.  
  25.     distance_to_enemy = input()
  26.  
  27. print(f"Won battles: {win_counter}. Energy left: {energy}")
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement