ro_sham_bo 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ce77bcab61a9ae0943e2c524ce9db8549f2f655fe0c94b232459af086332416e
4
- data.tar.gz: '0692f563d97e79eedbf2e52d9d06c5b26cafbe7cb4c8f1472b2325ffe2066f69'
3
+ metadata.gz: 3336e5189ae0b7bc49c4c2f9c6c6fc86744344386eb88ad483aadc48aca2aaed
4
+ data.tar.gz: 9d454268bb69d507d916b5a5c69defa46501bc37e122d2007dc95a9466c2ac75
5
5
  SHA512:
6
- metadata.gz: d777b31737a483305adc350b97a5fd3983b15f1ba64905c667bbe3862c60ef2f72e458b3cccea258b36e904dccbd956fbecbbe1b3f5720fcdb30e1329a837d7f
7
- data.tar.gz: 3598e5ce1fbbbea18391fa235994b7e364eeccdd7780465c0f27386baa60e0953e471b605fe6fa608ccf01477fca70254698fb819e7735584541347e283c29b8
6
+ metadata.gz: 9cf0b5e881f2a0fe2ad59a7d85c4ede8a315457a9cd41c1933927e290e09bfb50d2cdff218bee644055ca4af47ad6dd104107d0609638757460c04815f4d4bb2
7
+ data.tar.gz: 7b80a054800c6daa814485f38e8d1feeee4a5ca0fd747ca6d2e2f1d2ac97004971369d3965c0a5f863c1d6e73bcf10208ad735123e2c2c9308cf77cd71093d00
data/README.md CHANGED
@@ -18,6 +18,7 @@ rake install
18
18
  ```
19
19
 
20
20
  ## Usage
21
+ ### Command Line
21
22
  Just call the `ro_sham_bo` executable, which should now be in your `$PATH`.
22
23
  The default number of rounds is best-of `3`. This can be altered with the
23
24
  `-r [NUMBER OF ROUNDS]` option. The number passed must be an odd number. To see
@@ -34,9 +35,36 @@ game.
34
35
 
35
36
  Cheating is possible, both for the user and the computer. Pass `-c` (or `-c
36
37
  user`) for the user to always win. Pass `-c computer` to make the computer win.
37
- It will still look real; cheating only actually happens when the non-cheater has
38
- one less point than is needed to win. Even then, it can still return a draw for
39
- that round.
38
+ It will still look real; cheating only actually happens when the non-cheater
39
+ only needs one more point to win. Even then, it can still return a draw for that
40
+ round.
41
+
42
+ ### Console
43
+ You can play via an IRB/Pry console via the gem's API.
44
+
45
+ ```ruby
46
+ require 'ro_sham_bo'
47
+
48
+ game = RoShamBo.new
49
+ game.play(:rock)
50
+ # => #<RoShamBo:0x00007fe3011a2070
51
+ # @cheater=nil,
52
+ # @points_to_win=2,
53
+ # @rounds=3,
54
+ # @score={:user=>0, :computer=>0}>
55
+
56
+ game.play(%i[rock paper scissors].sample) until game.over?
57
+ game
58
+ # => #<RoShamBo:0x00007fe3011a2070
59
+ # @cheater=nil,
60
+ # @computer_choice=:paper,
61
+ # @points_to_win=2,
62
+ # @round_winner=:user,
63
+ # @rounds=3,
64
+ # @score={:user=>2, :computer=>1},
65
+ # @user_choice=:scissors,
66
+ # @winner=:user>
67
+ ```
40
68
 
41
69
  ### Rules
42
70
  The rules are standard rock, paper, scissors rules.
data/lib/ro_sham_bo.rb CHANGED
@@ -10,6 +10,7 @@ class RoShamBo
10
10
  attr_reader :cheater
11
11
  attr_reader :rounds
12
12
  attr_reader :score
13
+ attr_reader :draws
13
14
  attr_reader :points_to_win
14
15
  attr_reader :user_choice
15
16
  attr_reader :computer_choice
@@ -26,6 +27,7 @@ class RoShamBo
26
27
  @cheater = cheater
27
28
  @rounds = rounds
28
29
  @score = {user: 0, computer: 0}
30
+ @draws = 0
29
31
  @points_to_win = (rounds.to_f / 2).ceil
30
32
  end
31
33
 
@@ -53,7 +55,7 @@ class RoShamBo
53
55
  when :lose then :computer
54
56
  else :draw
55
57
  end
56
- score[winner] += 1 unless winner == :draw
58
+ winner == :draw ? @draws += 1 : score[winner] += 1
57
59
  winner
58
60
  end
59
61
 
@@ -16,7 +16,7 @@ class RoShamBo
16
16
 
17
17
  ##
18
18
  # Patch version.
19
- PATCH = 0
19
+ PATCH = 1
20
20
 
21
21
  ##
22
22
  # Version as +MAJOR.MINOR.PATCH+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ro_sham_bo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Gray