Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pirate_ship = list(map(int, input().split('>')))
- war_ship = list(map(int, input().split('>')))
- max_section_health = int(input())
- while True:
- command = input()
- if command == "Retire":
- break
- elif command == "Status":
- count = len([x for x in pirate_ship if x < max_section_health / 5])
- print(f"{count} sections need repair.")
- continue
- command = command.split(' ')
- index = int(command[1])
- if command[0] == "Fire":
- damage = int(command[2])
- if 0 <= index < len(war_ship):
- war_ship[index] -= damage
- if war_ship[index] <= 0:
- print("You won! The enemy ship has sunken.")
- war_ship.clear()
- break
- elif command[0] == "Defend":
- final_index = int(command[2])
- damage = int(command[3])
- if 0 <= index < len(pirate_ship) and 0 <= final_index < len(pirate_ship):
- for i in range(index, final_index + 1):
- pirate_ship[i] -= damage
- if pirate_ship[i] <= 0:
- print("You lost! The pirate ship has sunken.")
- pirate_ship.clear()
- exit(0)
- elif command[0] == "Repair":
- health = int(command[2])
- if 0 <= index < len(pirate_ship):
- pirate_ship[index] += health
- if pirate_ship[index] > max_section_health:
- pirate_ship[index] = max_section_health
- if len(pirate_ship) > 0 and len(war_ship) > 0:
- print(f"Pirate ship status: {sum(pirate_ship)}\nWarship status: {sum(war_ship)}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement