Advertisement
Guest User

Untitled

a guest
Apr 21st, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. import json
  2.  
  3. max_v = dict()
  4. max_v['Sorceress'] = 50
  5. max_v['Knight'] = 100
  6. max_v['Barbarian'] = 120
  7. max_v['Warlock'] = 70
  8.  
  9.  
  10. class Unit:
  11. def __init__(self, args):
  12. self.race = args[0]
  13. self.lord = args[1]
  14. self.health = args[2]
  15. self.attack = args[3]
  16. self.defence = args[4]
  17. self.experience = args[5]
  18. self.mana = 0
  19. if (len(args) > 6):
  20. self.mana = args[6]
  21. self.maxhealth = max_v[self.race]
  22.  
  23.  
  24. s = input()
  25. d = json.loads(s)
  26. d_w = dict()
  27. for i in d['armies'].keys():
  28. d_w[i] = Unit(list(d['armies'][i].values()))
  29.  
  30. for action in d['battle_steps']:
  31. if action['id_to'] in d_w and action['id_from'] in d_w:
  32. d_w[action['id_from']].experience += 1
  33. if action['action'] != 'cast_health_spell':
  34. if action['action'] == 'attack':
  35. d_w[action['id_from']].attack -= action['power']
  36. else:
  37. d_w[action['id_from']].mana -= action['power']
  38. d_w[action['id_to']].defence -= action['power']
  39. d_w[action['id_to']].experience += 1
  40. if d_w[action['id_to']].defence < 0:
  41. d_w[action['id_to']].health += d_w[action['id_to']].defence
  42. d_w[action['id_to']].defence = 0
  43. if d_w[action['id_to']].health <= 0:
  44. d_w[action['id_from']].experience += 4
  45. del(d_w[action['id_to']])
  46. else:
  47. d_w[action['id_from']].mana -= action['power']
  48. d_w[action['id_to']].health += min(action['power'],
  49. d_w[action['id_to']].maxhealth -
  50. d_w[action['id_to']].health)
  51.  
  52. balance = 0
  53. a = 0
  54. r = 0
  55. for i in d_w.values():
  56. if i.lord == 'Ronald':
  57. r += 1
  58. else:
  59. a += 1
  60. for i in d_w.values():
  61. val = i.experience + i.defence*2 + i.attack*3 + i.mana*10
  62. if i.lord == 'Archibald':
  63. balance += val
  64. else:
  65. balance -= val
  66. if balance > 0:
  67. print('Archibald')
  68. elif balance < 0:
  69. print('Ronald')
  70. elif a == 0 and r != 0:
  71. print('Ronald')
  72. elif a != 0 and r == 0:
  73. print('Archibald')
  74. else:
  75. print('unknown')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement