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())
- Low_level = int(Max_health * 0.2)
- end = False
- command = input()
- while command != 'Retire':
- parts = command.split()
- action = parts[0]
- if action == 'Fire':
- index = int(parts[1])
- damage = int(parts[2])
- if 0 <= index < len(warship):
- warship[index] -= damage
- if warship[index] <= 0:
- print('You won! The enemy ship has sunken.')
- break
- elif action == 'Defend':
- start_index = int(parts[1])
- end_index = int(parts[2])
- damage = int(parts[3])
- if 0 <= start_index <= end_index < len(pirate_ship):
- for i in range(start_index, end_index + 1):
- pirate_ship[i] -= damage
- if pirate_ship[i] <= 0:
- print('You lost! The pirate ship has sunken.')
- end = True
- break
- if end:
- break
- elif action == 'Repair':
- index = int(parts[1])
- health = int(parts[2])
- if 0 <= index < len(pirate_ship):
- pirate_ship[index] += health
- if pirate_ship[index] > Max_health:
- pirate_ship[index] = Max_health
- elif action == 'Status':
- count = len([x for x in pirate_ship if x < Low_level])
- print(f'{count} sections need repair.')
- command = input()
- else:
- print(f'Pirate ship status: {sum(i for i in pirate_ship)}')
- print(f'Warship status: {sum(i for i in warship)}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement