Skip to content

Instantly share code, notes, and snippets.

@epidemian
Created March 31, 2014 03:37
Show Gist options
  • Save epidemian/9884803 to your computer and use it in GitHub Desktop.
Save epidemian/9884803 to your computer and use it in GitHub Desktop.
v=$*
def p*a;puts a*' 'end
loop{a,b=v[0],v[6]
w=v.map &:to_i
p a,:attacks,b+?!
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
p a,:hits,b,:for,d,:damage!
p b,:has,h<1?"been slain!":"#{h} health left."
h<1&&exit)
v.rotate!6}
@epidemian
Copy link
Author

Usage:

ruby battle.rb <creature> <creature>

Where

<creature> = <name> <health> <strength> <defense> <accuracy> <agility>

Example:

ruby battle.rb goblin 50 40 35 3 2 elf 50 35 30 4 5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment