Advertisement
Guest User

Untitled

a guest
Feb 28th, 2020
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.34 KB | None | 0 0
  1. pirate_ship = list(map(int, input().split(">")))
  2. warship = list(map(int, input().split(">")))
  3.  
  4. max_health = int(input())
  5.  
  6. lost = False
  7.  
  8. while True:
  9.     if lost:
  10.         break
  11.  
  12.     command = input().split()
  13.     if command[0] == "Fire":
  14.         index, damage = int(command[1]), int(command[2])
  15.         if 0 <= index < len(warship):
  16.             warship[index] -= damage
  17.             if warship[index] <= 0:
  18.                 print("You won! The enemy ship has sunken.")
  19.                 break
  20.  
  21.     elif command[0] == "Defend":
  22.         start, end, damage = int(command[1]), int(command[2]), int(command[3])
  23.         if 0 <= start < end < len(pirate_ship):
  24.             for index in range(start, end + 1):
  25.                 pirate_ship[index] -= damage
  26.                 if pirate_ship[index] <= 0:
  27.                     print("You lost! The pirate ship has sunken.")
  28.                     lost = True
  29.                     break
  30.  
  31.     elif command[0] == "Repair":
  32.         index, health = int(command[1]), int(command[2])
  33.         if 0 <= index < len(pirate_ship):
  34.             pirate_ship[index] += health
  35.             if pirate_ship[index] >= max_health:
  36.                 pirate_ship[index] = max_health
  37.  
  38.     elif command[0] == "Status":
  39.         minimum_status = max_health * 0.2
  40.         len([x for x in pirate_ship if x < minimum_status])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement