I wanted to make a DnD style attack command, where one user can attack another user with a d20 die roll.
Example
$(user) `is a formidable` $(z) `whos rolling` $(y) `to hit` $(touser) `armor class of` $(x) `with a` $(a) , $(touser)
if y > x user has died dead
else if y < x user is still alive
This code works but i am wondering if theres more cleaner way to write it and compare z to y, depending on the number if higher or lower to have different string output?
$(user) is a formidable $(eval z=["warrior", "evil mage", "new challenger", "poor pleb"];z[Math.floor(Math.random()*z.length)]) whos rolling $(eval y=Math.floor((Math.random() * 20) + 1)) to hit $(touser) armor class of $(eval x=Math.floor((Math.random() * 20) + 1)) with $(eval a=["a sword", "an axe", "a staff", "a rock", "a bow", "a pin", "a puppy", "a hug", "a gentle touch", "a burp", "a spit", "a catapulted animal"];a[Math.floor(Math.random()*a.length)])