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(">")))
- maximum_health_capacity = int(input())
- warning_sections = maximum_health_capacity * 0.2
- stalemate = True
- commands = input()
- while commands != "Retire":
- current_command = commands.split()[0]
- if current_command == "Fire":
- index_for_fire = int(commands.split()[1])
- damage_of_fire = int(commands.split()[2])
- if 0 <= index_for_fire < len(warship):
- warship[index_for_fire] -= damage_of_fire
- if warship[index_for_fire] <= 0:
- print("You won! The enemy ship has sunken.")
- stalemate = False
- break
- elif current_command == "Defend":
- starting_index = int(commands.split()[1])
- ending_index = int(commands.split()[2])
- defend_damage = int(commands.split()[3])
- if 0 <= starting_index and ending_index < len(pirate_ship):
- for making_damage in range(starting_index, ending_index+1):
- pirate_ship[making_damage] -= defend_damage
- if pirate_ship[making_damage] <= 0:
- print("You lost! The pirate ship has sunken.")
- stalemate = False
- break
- elif current_command == "Repair":
- index_for_repair = int(commands.split()[1])
- health_gained = int(commands.split()[2])
- if 0 <= index_for_repair < len(pirate_ship):
- pirate_ship[index_for_repair] += health_gained
- if pirate_ship[index_for_repair] > maximum_health_capacity:
- pirate_ship[index_for_repair] = maximum_health_capacity
- elif current_command == "Status":
- sections_in_danger = [x for x in pirate_ship if x < warning_sections]
- print(f"{len(sections_in_danger)} sections need repair.")
- commands = input()
- if stalemate:
- print(f"Pirate ship status: {sum(pirate_ship)}")
- print(f"Warship status: {sum(warship)}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement