Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- settlements = {}
- while True:
- command = input()
- if command == 'Sail':
- while True:
- new_command = input()
- if new_command == 'End':
- sorted_settlements = dict(sorted(settlements.items(), key=lambda x: (-x[1][1], x[0])))
- print(f'Ahoy, Captain! There are {len(sorted_settlements)} wealthy settlements to go to:')
- for k, v in sorted_settlements.items():
- print(f'{k} -> Population: {v[0]} citizens, Gold: {v[1]} kg')
- break
- tokens = new_command.split('=>')
- if tokens[0] == 'Plunder':
- settlements[tokens[1]][0] -= int(tokens[2])
- settlements[tokens[1]][1] -= int(tokens[3])
- print(f'{tokens[1]} plundered! {tokens[3]} gold stolen, {tokens[2]} citizens killed.')
- if settlements[tokens[1]][0] <= 0 or settlements[tokens[1]][1] <= 0:
- print(f'{tokens[1]} has been wiped off the map!')
- del settlements[tokens[1]]
- elif tokens[0] == 'Prosper':
- if int(tokens[2]) < 0: #### VAJEN BORDER, AKO CHUPI MAHAM =
- print(f'Gold added cannot be a negative number!')
- else:
- settlements[tokens[1]][1] += int(tokens[2])
- print(f'{tokens[2]} gold added to the city treasury. {tokens[1]} now has {settlements[tokens[1]][1]} gold.')
- break
- else:
- city, population, gold = command.split('||')
- if city in settlements:
- settlements[city][0] += int(population)
- settlements[city][1] += int(gold)
- else:
- settlements[city] = [int(population), int(gold)]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement