Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import json
- max_v = dict()
- max_v['Sorceress'] = 50
- max_v['Knight'] = 100
- max_v['Barbarian'] = 120
- max_v['Warlock'] = 70
- class Unit:
- def __init__(self, args):
- self.race = args[0]
- self.lord = args[1]
- self.health = args[2]
- self.attack = args[3]
- self.defence = args[4]
- self.experience = args[5]
- self.mana = 0
- if (len(args) > 6):
- self.mana = args[6]
- self.maxhealth = max_v[self.race]
- s = input()
- d = json.loads(s)
- d_w = dict()
- for i in d['armies'].keys():
- d_w[i] = Unit(list(d['armies'][i].values()))
- for action in d['battle_steps']:
- if action['id_to'] in d_w and action['id_from'] in d_w:
- d_w[action['id_from']].experience += 1
- if action['action'] != 'cast_health_spell':
- if action['action'] == 'attack':
- d_w[action['id_from']].attack -= action['power']
- else:
- d_w[action['id_from']].mana -= action['power']
- d_w[action['id_to']].defence -= action['power']
- d_w[action['id_to']].experience += 1
- if d_w[action['id_to']].defence < 0:
- d_w[action['id_to']].health += d_w[action['id_to']].defence
- d_w[action['id_to']].defence = 0
- if d_w[action['id_to']].health <= 0:
- d_w[action['id_from']].experience += 4
- del(d_w[action['id_to']])
- else:
- d_w[action['id_from']].mana -= action['power']
- d_w[action['id_to']].health += min(action['power'],
- d_w[action['id_to']].maxhealth -
- d_w[action['id_to']].health)
- balance = 0
- a = 0
- r = 0
- for i in d_w.values():
- if i.lord == 'Ronald':
- r += 1
- else:
- a += 1
- for i in d_w.values():
- val = i.experience + i.defence*2 + i.attack*3 + i.mana*10
- if i.lord == 'Archibald':
- balance += val
- else:
- balance -= val
- if balance > 0:
- print('Archibald')
- elif balance < 0:
- print('Ronald')
- elif a == 0 and r != 0:
- print('Ronald')
- elif a != 0 and r == 0:
- print('Archibald')
- else:
- print('unknown')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement