Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pirates = list(map(lambda x: int(x), input().split(">")))
- warship = list(map(lambda x: int(x), input().split(">")))
- max_health = int(input())
- check = True
- win_check = False
- while True:
- commands = input()
- if commands == "Retire":
- break
- if win_check:
- break
- actions = commands.split(" ")
- if actions[0] == "Fire":
- index = int(actions[1])
- damage = int(actions[2])
- if index < len(warship) and warship[index] >= 0:
- warship[index] -= damage
- if warship[index] <= 0:
- print("You won! The enemy ship has sunken.")
- check = False
- win_check = True
- break
- elif actions[0] == "Defend":
- start_index = int(actions[1])
- end_index = int(actions[2])
- damage = int(actions[3])
- if start_index > len(pirates) or end_index > len(pirates):
- continue
- if start_index < len(pirates) and end_index < len(pirates):
- for j in range(0, len(pirates)):
- if start_index >= j or end_index >= j:
- pirates[j] -= damage
- if pirates[j] <= 0:
- print("You lost! The pirate ship has sunken.")
- check = False
- win_check = True
- break
- elif actions[0] == "Repair":
- index = int(actions[1])
- health_gain = int(actions[2])
- if index < len(pirates) and index >= 0:
- pirates[index] += health_gain
- if pirates[index] > max_health:
- pirates[index] = max_health
- elif actions[0] == "Status":
- repairs_ships = 0
- for k in range(0, len(pirates)):
- current_health = pirates[k]
- if current_health < max_health * 0.2:
- repairs_ships += 1
- print(f"{repairs_ships} sections need repair.")
- if check:
- print(f"Pirate ship status: {sum(pirates)}")
- print(f"Warship status: {sum(warship)}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement