roshambo 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- roshambo (0.0.1)
4
+ roshambo (0.0.2)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
data/bin/roshambo ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'roshambo'
4
+
5
+ puts Roshambo.new.winner.name
data/lib/roshambo/game.rb CHANGED
@@ -4,6 +4,9 @@ class Roshambo::Game
4
4
 
5
5
  def initialize(players)
6
6
  @players = players
7
+
8
+ # NOTE: The wins and loses are arrays, so the Lizard/Spock extension is obvious here.
9
+ # - Danny
7
10
  @moves = {
8
11
  rock: {
9
12
  wins: [:scissors],
@@ -27,12 +30,11 @@ class Roshambo::Game
27
30
  def run_game
28
31
  winner = false
29
32
  @players.each do |player|
33
+ player.move = random_move
34
+
30
35
  if !winner
31
- player.move = random_move
32
36
  winner = player
33
- else
34
- player.move = random_move
35
-
37
+ else
36
38
  if @moves[player.move][:wins].include?(winner.move)
37
39
  winner = player
38
40
  end
@@ -43,6 +45,8 @@ class Roshambo::Game
43
45
  end
44
46
 
45
47
  def random_move
48
+ # NOTE: Don't forget to add Lizard and Spock if you are doing the extension.
49
+ # - Danny
46
50
  [:rock, :paper, :scissors].sort_by{rand}.first
47
51
  end
48
52
 
data/roshambo.gemspec CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path('../lib', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = 'roshambo'
6
- s.version = '0.0.2'
6
+ s.version = '0.0.3'
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ['Daniel Owen van Dommelen']
9
9
  s.email = ['bunny.rabbit@igotish.com']
@@ -37,6 +37,12 @@ describe Roshambo do
37
37
  it 'should have a winner' do
38
38
  @roshambo = Roshambo.new(1)
39
39
  @roshambo.winner.name.should_not be_empty
40
+
41
+ @roshambo = Roshambo.new(2)
42
+ @roshambo.winner.name.should_not be_empty
43
+
44
+ @roshambo = Roshambo.new(3, ['Kermit', 'Animal'])
45
+ @roshambo.winner.name.should_not be_empty
40
46
  end
41
47
 
42
48
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roshambo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,13 +14,15 @@ dependencies: []
14
14
  description: ''
15
15
  email:
16
16
  - bunny.rabbit@igotish.com
17
- executables: []
17
+ executables:
18
+ - roshambo
18
19
  extensions: []
19
20
  extra_rdoc_files: []
20
21
  files:
21
22
  - Gemfile
22
23
  - Gemfile.lock
23
24
  - README.md
25
+ - bin/roshambo
24
26
  - lib/roshambo.rb
25
27
  - lib/roshambo/game.rb
26
28
  - lib/roshambo/player.rb