-3

Okay so my code is PDMG = round(Mage['stats']['PStrength'] * .50) so what I want to do is have the .50 as the minimum value and then have it multiply the same thing by .75, what do I do? Basically what I want is a minimum damage and a maximum damage, its for a a battle system

  • 4
    It is not clear what you actually want. You should elaborate your question a bit. – Randrian Dec 13 '15 at 21:07
  • It's not to me clear either. Are you looking for two values? If it is necessarily in one line, you might use lambda which returns tuple: `PDMG = (lambda x: (x*0.50, x*0.75))(Mage['stats']['PStrength'])`. It's a more functional way, I am not sure if I would prefer that over defining a proper function... – kotrfa Dec 13 '15 at 21:09
  • ternary operators are especially easy in Python: http://stackoverflow.com/questions/394809/does-python-have-a-ternary-conditional-operator – Trilarion Dec 13 '15 at 21:11
  • @kortfa I'll try your idea and see if it works out how im hoping for – user5675699 Dec 13 '15 at 21:12
  • @kotrfa your way worked how I wanted it to, but is there anyway I can get it to round the numbers? – user5675699 Dec 13 '15 at 21:17
  • @user5675699 `PDMG = (lambda x: (round(x*0.50), round(x*0.75)))(Mage['stats']['PStrength'])` – kotrfa Dec 13 '15 at 21:18
  • @kortfa Thanks for the help, it worked – user5675699 Dec 13 '15 at 21:21

1 Answers1

0

You can make two separate variables for it:

minPDMG = round(Mage['stats']['PStrength'] * .50)
maxPDMG = round(Mage['stats']['PStrength'] * .75)
mmghu
  • 557
  • 4
  • 14