fork download
  1. v=gets.split
  2. def p*a;puts a*' 'end
  3. loop{a,b=v[0],v[6]
  4. w=v.map &:to_i
  5. p a,:attacks,b+?!
  6. w[11]*rand/2>w[4]*rand ? (p b,:dodges!):(h=v[7]=w[7]-=d=[rand(w[2])-rand(w[9])/2,1].max
  7. p a,:hits,b,:for,d,:damage!
  8. p b,:has,h<1?"been slain!":"#{h} health left."
  9. h<1&&exit)
  10. v.rotate!6}
Success #stdin #stdout 0.01s 7412KB
stdin
goblin 50 40 35 3 2 elf 50 35 30 4 5
stdout
goblin attacks elf!
elf dodges!
elf attacks goblin!
elf hits goblin for 7 damage!
goblin has 43 health left.
goblin attacks elf!
goblin hits elf for 29 damage!
elf has 21 health left.
elf attacks goblin!
elf hits goblin for 4 damage!
goblin has 39 health left.
goblin attacks elf!
goblin hits elf for 6 damage!
elf has 15 health left.
elf attacks goblin!
elf hits goblin for 1 damage!
goblin has 38 health left.
goblin attacks elf!
elf dodges!
elf attacks goblin!
goblin dodges!
goblin attacks elf!
goblin hits elf for 10 damage!
elf has 5 health left.
elf attacks goblin!
elf hits goblin for 1 damage!
goblin has 37 health left.
goblin attacks elf!
elf dodges!
elf attacks goblin!
goblin dodges!
goblin attacks elf!
goblin hits elf for 16 damage!
elf has been slain!