Class: MeChallenge

Inherits:
Object
  • Object
show all
Defined in:
lib/me_challenge.rb

Constant Summary collapse

VERSION =
'1.0.1'

Class Method Summary collapse

Class Method Details

.run(args) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/me_challenge.rb', line 8

def self.run(args)
  unless args.size == 5
    puts "\nUSAGE:\n\tme_challenge rank1 health1 rank2 health2 rounds\n"
    puts "EXAMPLE:\n\tme_challenge 50 100 30 100 10000"
    return -1
  end
  
  c1 = Character.new("Character #1", args.shift.to_i, args.shift.to_i)
  c2 = Character.new("Character #2", args.shift.to_i, args.shift.to_i)
  rounds = args.shift.to_i
  
  puts "Simulating #{rounds} rounds of combat between #{c1} and #{c2}\n"
  
  mec = MiddleEarthChallengeSimulator.new(c1, c2, rounds)
  mec.simulate
  
  puts "#{mec.character1} won #{mec.character1_wins}"
  puts "#{mec.character2} won #{mec.character2_wins}"        
      
end