Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- list_pirate_ship = list(map(int, input().split(">")))
- list_warship = list(map(int, input().split(">")))
- max_health_capacity = int(input())
- is_over = False
- while True:
- command = input().split()
- if "Retire" in command:
- break
- elif "Fire" in command and 0 <= int(command[1]) < len(list_warship):
- if int(command[2]) - list_warship[int(command[1])] >= 0:
- print("You won! The enemy ship has sunken.")
- is_over = True
- break
- list_warship[int(command[1])] -= int(command[2])
- elif "Defend" in command and 0 <= int(command[1]) < len(list_pirate_ship) and 0 <= int(command[2])\
- < len(list_pirate_ship):
- if int(command[1]) <= int(command[2]):
- for index in range(int(command[1]), int(command[2]) + 1):
- if list_pirate_ship[index] - int(command[3]) <= 0:
- print("You lost! The pirate ship has sunken.")
- is_over = True
- break
- list_pirate_ship[index] -= int(command[3])
- if is_over:
- break
- elif int(command[1]) > int(command[2]):
- for index in range(int(command[2]), int(command[1]) + 1):
- if list_pirate_ship[index] - int(command[3]) <= 0:
- print("You lost! The pirate ship has sunken.")
- is_over = True
- break
- list_pirate_ship[index] -= int(command[3])
- if is_over:
- break
- elif "Repair" in command and (0 <= int(command[1]) < len(list_pirate_ship)):
- if int(command[2]) + list_pirate_ship[int(command[1])] <= max_health_capacity:
- list_pirate_ship[int(command[1])] += int(command[2])
- else:
- list_pirate_ship[int(command[1])] = max_health_capacity
- elif "Status" in command:
- repair_needed = len([n for n in list_pirate_ship if n < (0.2 * max_health_capacity)])
- print(f"{repair_needed} sections need repair.")
- if not is_over:
- print(f"Pirate ship status: {sum(list_pirate_ship)}\nWarship status: {sum(list_warship)}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement