#!/usr/bin/ruby class Attackers attr_accessor :attacks, :s def initialize(s, a) self.s = s.to_i self.attacks = a.to_i end end class Combat def initialize(a) @a = a end def fight dice = (1..@a.attacks).inject([]){|arr, i| arr << (rand(6) + 1)} damdice = dice.map{|d| if(d > 3) rand(6) + 1 + @a.s else 0 end } effectdice = damdice.map{|d| if(d == 10) #glance rand(6) - 1 elsif(d > 10) rand(6) + 1 else -5 end } if effectdice.select{|d| d == 3 || d == 4}.size >= 3 effectdice << 4.5 end effectdice.sort.last end end times = ARGV[0].to_i || 10 if ARGV[1] fighter1 = Attackers.new(*ARGV[1].split(':')) else fighter1 = Attackers.new(4, 21) end cc = Combat.new(fighter1) 1.upto(times) do |i| puts cc.fight end