fork download
  1. def make_combat_modifiers(player1_attributes, player2_attributes):
  2. def vs(hero, foe):
  3. return {
  4. 'health': hero['endurance'],
  5. 'damage': max(1, hero['strength'] // foe['strength']),
  6. 'action': max(1, hero['speed'] // foe['speed']),
  7. 'dodging': max(1, hero['agility'] // foe['agility'])
  8. }
  9.  
  10. player1_combat_modifiers = vs(player1_attributes, player2_attributes)
  11. player2_combat_modifiers = vs(player2_attributes, player1_attributes)
  12. return player1_combat_modifiers, player2_combat_modifiers
  13.  
  14. print(make_combat_modifiers(
  15. {'endurance': 10, 'strength': 1, 'speed': 3, 'agility': 6},
  16. {'endurance': 11, 'strength': 4, 'speed': 3, 'agility': 2}))
Success #stdin #stdout 0.01s 27712KB
stdin
Standard input is empty
stdout
({'dodging': 3, 'action': 1, 'damage': 1, 'health': 10}, {'dodging': 1, 'action': 1, 'damage': 4, 'health': 11})