Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pirate_ship = list(map(int, input().split(">")))
- warship = list(map(int, input().split(">")))
- max_health = int(input())
- lost = False
- while True:
- if lost:
- break
- command = input().split()
- if command[0] == "Fire":
- index, damage = int(command[1]), int(command[2])
- if 0 <= index < len(warship):
- warship[index] -= damage
- if warship[index] <= 0:
- print("You won! The enemy ship has sunken.")
- break
- elif command[0] == "Defend":
- start, end, damage = int(command[1]), int(command[2]), int(command[3])
- if 0 <= start < end < len(pirate_ship):
- for index in range(start, end + 1):
- pirate_ship[index] -= damage
- if pirate_ship[index] <= 0:
- print("You lost! The pirate ship has sunken.")
- lost = True
- break
- elif command[0] == "Repair":
- index, health = int(command[1]), int(command[2])
- if 0 <= index < len(pirate_ship):
- pirate_ship[index] += health
- if pirate_ship[index] >= max_health:
- pirate_ship[index] = max_health
- elif command[0] == "Status":
- minimum_status = max_health * 0.2
- len([x for x in pirate_ship if x < minimum_status])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement