99_game 2.0.2 → 2.0.3.pre.68

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.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 26b9fc53fa03cb556e8f5e44049e41f4e480deba
4
- data.tar.gz: b402031b2eaf54b55e27ab010b3af1e37ce47507
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MWIwMTQzYmNiMjYwMzc2OTFmYWNiYzI4NzgzMmQ1ZTBmYTY1ODMxNg==
5
+ data.tar.gz: !binary |-
6
+ N2E0NGE1Zjk0ZWVmNTlmYTUyODE3OTc1YWU1MGRjNDg5YjM1ZWFjMw==
5
7
  SHA512:
6
- metadata.gz: 170c29409a9386f5dfae7763b291925787c69001a9de31fb0a9f283854178722843926aaacb812856786ebaf6d25030d16abcff9555725d2d447ae57094653dc
7
- data.tar.gz: 074cbf99c32c5fac68219f201e82aec5a297abbe5b49d00134e978fa6655cc88caf30906a81ede193de902bd51438ff628f64ce81ac2f18b91b11a7200244477
8
+ metadata.gz: !binary |-
9
+ ZDI1N2EyM2UxMzQ5MTk0N2IyOWI1NmE1ZjVjOGE2YmFhNzQ4MzFlYWUxMzE3
10
+ MWFhMzQ2YzRjMWE4M2M3MDU2Zjc3M2ZmNGU4NTk3MWVmN2I1Mzc3Zjc4NGI2
11
+ OGIxNDQ2Mzk0NDg4NWIyNGI0MjQzNjU2MmQxN2RkYjE3YTBjZjk=
12
+ data.tar.gz: !binary |-
13
+ NjZlZDQzMjYxMjcxZWNlMDQwYmJlZmFiZjk1Mjg3YWFmYjY2NzhjZDBmMzVm
14
+ NWJmZWU4ZWQ3MWFiOTcyZmE5MGQ3OWJhOGVmMDI3NjM2NzNjYzIxZTk4YTZj
15
+ ODhhNWNhOTdkZGZmYTU4NDZkZjNmM2Y4ZDJkOTgyNWRjNDM4Mjc=
data/.rspec CHANGED
@@ -1,4 +1,4 @@
1
- --color
2
- --require spec_helper.rb
3
- --warnings
4
- --format doc
1
+ --color
2
+ --require spec_helper.rb
3
+ --warnings
4
+ --format doc
@@ -1,21 +1,21 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) {{{2014}}} {{{Zachary Roth Perlmutter}}}
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) {{{2014}}} {{{Zachary Roth Perlmutter}}}
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -1,14 +1,14 @@
1
-
2
- # 99_game
3
-
4
- To install: `gem install 99_game`
5
-
6
- For the rules and arguments: `99_game -h`
7
-
8
- ## Badges
9
- [![Gem Version](https://badge.fury.io/rb/99_game.png)](http://badge.fury.io/rb/99_game)
10
- [![Build Status](https://travis-ci.org/Zrp200/99_game.svg?branch=master)](https://travis-ci.org/Zrp200/99_game)
11
- [![Code Climate](https://codeclimate.com/github/Zrp200/99_game.png)](https://codeclimate.com/github/Zrp200/99_game)
12
- [![Dependency Status](https://gemnasium.com/Zrp200/99_game.svg)](https://gemnasium.com/Zrp200/99_game)
13
- [![Inline docs](http://inch-ci.org/github/Zrp200/99_game.png?branch=master)](http://inch-ci.org/github/Zrp200/99_game)
14
- [![Test Coverage](https://codeclimate.com/github/Zrp200/99_game/coverage.png)](https://codeclimate.com/github/Zrp200/99_game)
1
+
2
+ # 99_game
3
+
4
+ To install: `gem install 99_game`
5
+
6
+ For the rules and arguments: `99_game -h`
7
+
8
+ ## Badges
9
+ [![Gem Version](https://badge.fury.io/rb/99_game.png)](http://badge.fury.io/rb/99_game)
10
+ [![Build Status](https://travis-ci.org/Zrp200/99_game.svg?branch=master)](https://travis-ci.org/Zrp200/99_game)
11
+ [![Code Climate](https://codeclimate.com/github/Zrp200/99_game.png)](https://codeclimate.com/github/Zrp200/99_game)
12
+ [![Dependency Status](https://gemnasium.com/Zrp200/99_game.svg)](https://gemnasium.com/Zrp200/99_game)
13
+ [![Inline docs](http://inch-ci.org/github/Zrp200/99_game.png?branch=master)](http://inch-ci.org/github/Zrp200/99_game)
14
+ [![Test Coverage](https://codeclimate.com/github/Zrp200/99_game/coverage.png)](https://codeclimate.com/github/Zrp200/99_game)
@@ -1,94 +1,93 @@
1
- #!/usr/bin/env ruby
2
- require '99_game'
3
- deck = Deck.new
4
- BEGIN { # Looks at its arguements
5
- ARGV[0] = "-h" if ARGV[0] == "--help"
6
- ARGV[0] = "-v" if ARGV[0] == "--version"
7
- case ARGV[0]
8
- when "-v"
9
- puts "2.0.1"
10
- exit
11
- when "-h"
12
- puts "\u00B7 Commands"
13
- puts "\t\u00b7 -v/--version - display version"
14
- puts "\t\u00B7 -h/--help - shows this message\n"
15
- puts "\u00B7 Abbrevations"
16
- puts "\t\u00B7 J -> Jack"
17
- puts "\t\u00b7 Q -> Queen"
18
- puts "\t\u00b7 K -> King"
19
- puts "\t\u00b7 A -> Ace"
20
- puts "\t\u00b7 $ -> Joker"
21
- puts "\u00B7 Gameplay"
22
- puts "\t\u00B7 Your goal is to get your opponent to bring the value over 99 by playing 1 of your 3 cards."
23
- puts "\t\u00B7 A card will usually increase the value by itself, but there are a few exceptions:"
24
- puts "\t\t\u00B7 Aces are worth 1"
25
- puts "\t\t\u00B7 1 - 10 are worth themselves, with the exception of 4 and 9"
26
- puts "\t\t\u00B7 4, 9, and Jacks are worth 0"
27
- puts "\t\t\u00B7 Queens decrease the value by 10"
28
- puts "\t\t\u00B7 Kings set the value to 99"
29
- puts "\t\t\u00B7 Jokers set the value to 0"
30
- exit
31
- end
32
- }
33
- END { # Thanks for playing
34
- sleep(1.5)
35
- puts "\n\tThanks for playing 99!"
36
- sleep(2.5)
37
- }
38
- $value, value1, value2, value3, dealer, user = 0,0,0,0, Hand.new(deck), Hand.new(deck)
39
- loop do
40
- puts
41
- puts "\tIt is the dealer's turn!"
42
- i = 1
43
- for card in dealer.hand
44
- case i
45
- when 1 then test card, $value, value1
46
- when 2 then test card, $value, value2
47
- when 3 then test card, $value, value3
48
- end
49
- i += 1
50
- end
51
- if value1 >= value2 and value1 >= value3
52
- $card = dealer.hand[0].num
53
- dealer.play(dealer.hand[0])
54
- elsif value2 >= value3
55
- $card = dealer.hand[1].num
56
- dealer.play(dealer.hand[1])
57
- else
58
- $card = dealer.hand[2].num
59
- dealer.play(dealer.hand[2])
60
- end
61
- pause(1.5)
62
- puts "\tThe dealer played a(n) #{$card}"
63
- pause(0.5)
64
- puts "\tThe value is now #{$value}"
65
- puts
66
- pause(1.5)
67
- if $value > 99 # Runs when you win and exits loop
68
- puts "\tYou win!"
69
- break
70
- end
71
- puts "\tIt's your turn!"
72
- pause(1)
73
- user.view
74
- pause(0.5)
75
- print "\tPick a card to play by typing in the name of the card => "
76
- input, turn = gets.chomp, true
77
- for card in user.hand
78
- if card.num == converter(input) && turn
79
- user.play(card)
80
- turn = false
81
- end
82
- end
83
- pause(1)
84
- puts "\tYou drew a(n) #{user.hand[2].num}"
85
- pause(0.5)
86
- puts "\tThe value is now #{$value}"
87
- pause(1.5)
88
- if $value > 99 # Runs when dealer wins and exits loop
89
- puts "\tYou lose"
90
- break
91
- end
92
- end
93
- __END__
94
- Programmed by: Zachary Perlmutter
1
+ #!/usr/bin/env ruby
2
+ require '99_game'
3
+ deck = Deck.new
4
+ BEGIN { # Looks at its arguements
5
+ ARGV[0] = "-h" if ARGV[0] == "--help"
6
+ ARGV[0] = "-v" if ARGV[0] == "--version"
7
+ case ARGV[0]
8
+ when "-v"
9
+ puts "2.0.1"
10
+ exit
11
+ when "-h"
12
+ puts "\u00B7 Commands"
13
+ puts "\t\u00b7 -v/--version - display version"
14
+ puts "\t\u00B7 -h/--help - shows this message\n"
15
+ puts "\u00B7 Abbrevations"
16
+ puts "\t\u00B7 J -> Jack"
17
+ puts "\t\u00b7 Q -> Queen"
18
+ puts "\t\u00b7 K -> King"
19
+ puts "\t\u00b7 A -> Ace"
20
+ puts "\t\u00b7 $ -> Joker"
21
+ puts "\u00B7 Gameplay"
22
+ puts "\t\u00B7 Your goal is to get your opponent to bring the value over 99 by playing 1 of your 3 cards."
23
+ puts "\t\u00B7 A card will usually increase the value by itself, but there are a few exceptions:"
24
+ puts "\t\t\u00B7 Aces are worth 1"
25
+ puts "\t\t\u00B7 1 - 10 are worth themselves, with the exception of 4 and 9"
26
+ puts "\t\t\u00B7 4, 9, and Jacks are worth 0"
27
+ puts "\t\t\u00B7 Queens decrease the value by 10"
28
+ puts "\t\t\u00B7 Kings set the value to 99"
29
+ puts "\t\t\u00B7 Jokers set the value to 0"
30
+ exit
31
+ end
32
+ }
33
+ END { # Thanks for playing
34
+ sleep(1.5)
35
+ puts "\n\tThanks for playing 99!"
36
+ sleep(2.5)
37
+ }
38
+ $value, value1, value2, value3, dealer, user = 0,0,0,0, Hand.new(deck), Hand.new(deck)
39
+ loop do
40
+ puts "\n\tIt is the dealer's turn!"
41
+ i = 1
42
+ for card in dealer.hand
43
+ case i
44
+ when 1 then test card, $value, value1
45
+ when 2 then test card, $value, value2
46
+ when 3 then test card, $value, value3
47
+ end
48
+ i += 1
49
+ end
50
+ if value1 >= value2 && value1 >= value3
51
+ $card = dealer.hand[0].num
52
+ dealer.play dealer.hand[0]
53
+ elsif value1 <= value2 && value2 >= value3
54
+ $card = dealer.hand[1].num
55
+ dealer.play dealer.hand[1]
56
+ else
57
+ $card = dealer.hand[2].num
58
+ dealer.play(dealer.hand[2])
59
+ end
60
+ pause(1.5)
61
+ puts "\tThe dealer played a(n) #{$card}"
62
+ pause(0.5)
63
+ puts "\tThe value is now #{$value}"
64
+ puts
65
+ pause(1.5)
66
+ if $value > 99 # Runs when you win and exits loop
67
+ puts "\tYou win!"
68
+ break
69
+ end
70
+ puts "\tIt's your turn!"
71
+ pause 1
72
+ user.view
73
+ pause 0.5
74
+ print "\tPick a card to play by typing in the name of the card => "
75
+ input, turn = gets.chomp, true
76
+ for card in user.hand
77
+ if card.num == converter(input) && turn
78
+ user.play(card)
79
+ turn = false
80
+ end
81
+ end
82
+ pause 1
83
+ puts "\tYou drew a(n) #{user.hand[2].num}"
84
+ pause(0.5)
85
+ puts "\tThe value is now #{$value}"
86
+ pause(1.5)
87
+ if $value > 99 # Runs when dealer wins and exits loop
88
+ puts "\tYou lose"
89
+ break
90
+ end
91
+ end
92
+ __END__
93
+ Programmed by: Zachary Perlmutter
@@ -1,136 +1,137 @@
1
- # Used by the CPU to determine which card to play. Parameter card needs to be an instance of Card.
2
- def test(card, actual_value, test_value)
3
- if card.num == "King"
4
- test_value = 99
5
- elsif card.num == "Joker"
6
- test_value = 0
7
- else; test_value = actual_value + card.value
8
- end
9
- test_value = -100 if test_value > 99
10
- end
11
- # Tests if obj is not nil.
12
- def not_nil?(obj)
13
- if obj.nil?
14
- return false
15
- else
16
- return true
17
- end
18
- end
19
- # Converts input to an integer if String#capitalize does something. If parameter input is an abbreviation, _input_ is converted to what it stands for. Otherwise, it simply returns a capitalized version of _input_. If _input_ is nil or an emtpy string, raises a CardError
20
- def converter(input)
21
- abbrev = {"$" => "Joker", "K" => "King", "J" => "Jack", "Q" => "Queen", "A" => "Ace"}
22
- raise(CardError, "Input cannot be blank") if input == String.new
23
- if input.to_i == 0
24
- case input.capitalize
25
- when "$" then "Joker"
26
- when "K" then "King"
27
- when "J" then "Jack"
28
- when "Q" then "Queen"
29
- when "A" then "Ace"
30
- end
31
- else
32
- input.to_i
33
- end
34
- end
35
- # Expected errors
36
- class CardError < Exception; end
37
- class Card # Represents a card in the deck
38
- # Gives the number on the card
39
- attr_reader :num
40
- # Gives the Card's value
41
- attr_reader :value
42
- # Backup method for Card#value
43
- def _value
44
- return case @num
45
- when "Ace" then 1
46
- when 2..3 then @num
47
- when 4 then 0
48
- when 5..8 then @num
49
- when 9 then 0
50
- when 10 then 10
51
- when "Jack" then 0
52
- when "Queen" then -10
53
- when "King" then 99
54
- when "Joker" then 0
55
- end
56
- end
57
- # Creates a new card with num as the attribute :num
58
- def initialize(num)
59
- @num, @value = num, case num
60
- when "Ace" then 1
61
- when 4 then 0
62
- when 9 then 0
63
- when "Jack" then 0
64
- when "Joker" then 0
65
- when "King" then 99
66
- when "Queen" then -10
67
- else
68
- num.to_i
69
- end
70
- end
71
- end
72
- class Hand # Creates an object that holds and can play cards. Interacts with Deck objects.
73
- # The actual hand
74
- attr_reader :hand
75
- # Creates a new Hand. The deck argument tells the object which deck to use in Hand#play
76
- def initialize(deck_in_use)
77
- @hand, @deck = [deck_in_use.draw, deck_in_use.draw, deck_in_use.draw], deck_in_use
78
- end
79
- # Gameplay method. The parameter 'card' is the card being played.
80
- def play(card)
81
- if card.num == "King"; $value = 99
82
- elsif card.num == "Joker"; $value = 0
83
- else; $value += card.value
84
- end
85
- i, done = 0, false
86
- for index in @hand
87
- if index.num == card.num and not done
88
- discard = @hand[ i ]
89
- @hand.delete_at i
90
- @hand.push @deck.draw
91
- @deck.discard discard
92
- done = true
93
- end
94
- i += 1
95
- end
96
- end
97
- # Allows you to see your cards.
98
- def view
99
- print "\tThese are your cards: "
100
- @hand.each {|card| print "\t#{card.num}"}
101
- end
102
- end
103
- # Combines sleep and a newline. 'p' is the amount of time waited.
104
- def pause(p)
105
- sleep p
106
- puts
107
- end
108
- class Deck # Cards are stored in these objects
109
- # The contents of the deck
110
- attr_reader :cards
111
- def initialize # Creates a new deck that can now be used for playing the game
112
- @cards = Array.new
113
- 4.times do # Add the cards to the deck
114
- @cards.push Card.new("Ace")
115
- @cards.push Card.new("King")
116
- @cards.push Card.new("Queen")
117
- @cards.push Card.new("Jack")
118
- @cards.push Card.new(10)
119
- @cards.push Card.new(9)
120
- @cards.push Card.new(8)
121
- @cards.push Card.new(7)
122
- @cards.push Card.new(6)
123
- @cards.push Card.new(5)
124
- @cards.push Card.new(4)
125
- @cards.push Card.new(3)
126
- @cards.push Card.new(2)
127
- end
128
- 2.times {@cards.push Card.new("Joker")}
129
- 50.times {@cards.shuffle!}
130
- end
131
- # Draw from the deck
132
- def draw; @cards.shift; end
133
- # Adds 'card' to the deck. Used with Hand#play.
134
- def discard(card); @cards.push card; end
135
- end
136
-
1
+ # Used by the CPU to determine which card to play. Parameter card needs to be an instance of Card.
2
+ def test(card, actual_value, test_value)
3
+ if card.num == "King"
4
+ test_value = 99
5
+ elsif card.num == "Joker"
6
+ test_value = 0
7
+ else; test_value = actual_value + card.value
8
+ end
9
+ test_value = -100 if test_value > 99
10
+ return test_value
11
+ end
12
+ # Tests if obj is not nil.
13
+ def not_nil?(obj)
14
+ if obj.nil?
15
+ return false
16
+ else
17
+ return true
18
+ end
19
+ end
20
+ # Converts input to an integer if String#capitalize does something. If parameter input is an abbreviation, _input_ is converted to what it stands for. Otherwise, it simply returns a capitalized version of _input_. If _input_ is nil or an emtpy string, raises a CardError
21
+ def converter(input)
22
+ abbrev = {"$" => "Joker", "K" => "King", "J" => "Jack", "Q" => "Queen", "A" => "Ace"}
23
+ raise(CardError, "Input cannot be blank") if input == String.new
24
+ if input.to_i == 0
25
+ case input.capitalize
26
+ when "$" then "Joker"
27
+ when "K" then "King"
28
+ when "J" then "Jack"
29
+ when "Q" then "Queen"
30
+ when "A" then "Ace"
31
+ end
32
+ else
33
+ input.to_i
34
+ end
35
+ end
36
+ # Expected errors
37
+ class CardError < Exception; end
38
+ class Card # Represents a card in the deck
39
+ # Gives the number on the card
40
+ attr_reader :num
41
+ # Gives the Card's value
42
+ attr_reader :value
43
+ # Backup method for Card#value
44
+ def _value
45
+ return case @num
46
+ when "Ace" then 1
47
+ when 2..3 then @num
48
+ when 4 then 0
49
+ when 5..8 then @num
50
+ when 9 then 0
51
+ when 10 then 10
52
+ when "Jack" then 0
53
+ when "Queen" then -10
54
+ when "King" then 99
55
+ when "Joker" then 0
56
+ end
57
+ end
58
+ # Creates a new card with num as the attribute :num
59
+ def initialize(num)
60
+ @num, @value = num, case num
61
+ when "Ace" then 1
62
+ when 4 then 0
63
+ when 9 then 0
64
+ when "Jack" then 0
65
+ when "Joker" then 0
66
+ when "King" then 99
67
+ when "Queen" then -10
68
+ else
69
+ num.to_i
70
+ end
71
+ end
72
+ end
73
+ class Hand # Creates an object that holds and can play cards. Interacts with Deck objects.
74
+ # The actual hand
75
+ attr_accessor :hand
76
+ # Creates a new Hand. The deck argument tells the object which deck to use in Hand#play
77
+ def initialize(deck_in_use)
78
+ @hand, @deck = [deck_in_use.draw, deck_in_use.draw, deck_in_use.draw], deck_in_use
79
+ end
80
+ # Gameplay method. The parameter 'card' is the card being played.
81
+ def play(card)
82
+ if card.num == "King"; $value = 99
83
+ elsif card.num == "Joker"; $value = 0
84
+ else; $value += card.value
85
+ end
86
+ i, done = 0, false
87
+ for index in @hand
88
+ if index.num == card.num and not done
89
+ discard = @hand[ i ]
90
+ @hand.delete_at i
91
+ @hand.push @deck.draw
92
+ @deck.discard discard
93
+ done = true
94
+ end
95
+ i += 1
96
+ end
97
+ end
98
+ # Allows you to see your cards.
99
+ def view
100
+ print "\tThese are your cards: "
101
+ @hand.each {|card| print "\t#{card.num}"}
102
+ end
103
+ end
104
+ # Combines sleep and a newline. 'p' is the amount of time waited.
105
+ def pause(p)
106
+ sleep p
107
+ puts
108
+ end
109
+ class Deck # Cards are stored in these objects
110
+ # The contents of the deck
111
+ attr_reader :cards
112
+ def initialize # Creates a new deck that can now be used for playing the game
113
+ @cards = Array.new
114
+ 4.times do # Add the cards to the deck
115
+ @cards.push Card.new("Ace")
116
+ @cards.push Card.new("King")
117
+ @cards.push Card.new("Queen")
118
+ @cards.push Card.new("Jack")
119
+ @cards.push Card.new(10)
120
+ @cards.push Card.new(9)
121
+ @cards.push Card.new(8)
122
+ @cards.push Card.new(7)
123
+ @cards.push Card.new(6)
124
+ @cards.push Card.new(5)
125
+ @cards.push Card.new(4)
126
+ @cards.push Card.new(3)
127
+ @cards.push Card.new(2)
128
+ end
129
+ 2.times {@cards.push Card.new("Joker")}
130
+ 50.times {@cards.shuffle!}
131
+ end
132
+ # Draw from the deck
133
+ def draw; @cards.shift; end
134
+ # Adds 'card' to the deck. Used with Hand#play.
135
+ def discard(card); @cards.push card; end
136
+ end
137
+
@@ -1,48 +1,48 @@
1
- deck = Deck.new
2
- describe Deck do
3
- subject {Deck.new}
4
- describe "#length" do
5
- it "should == 54" do; expect(subject.cards.length).to eq 54; end
6
- end
7
- end
8
- describe Card do
9
- cards = ["Ace", "King", "Queen", "Jack", "Joker"] + (2..10).to_a
10
- describe "#value" do
11
- for card in cards
12
- describe "#{card}" do
13
- it "should == #{Card.new(card)._value}" do;
14
- expect(Card.new(card).value).to eq Card.new(card)._value
15
- end
16
- end
17
- end
18
- end
19
- end
20
- describe "converter" do
21
- context "when a number" do
22
- it "should return the input as a number" do
23
- expect(converter("5")).to eq 5
24
- end
25
- end
26
- context "when an abbreveation" do
27
- it "should expand it" do
28
- expect(converter("K")).to eq "King"
29
- end
30
- end
31
- end
32
- describe Hand do
33
- hand = Hand.new Deck.new
34
- describe "#hand" do
35
- describe "#length" do
36
- subject { hand.hand.length }
37
- it "should == 3" do; expect( subject ).to eq 3; end
38
- end
39
- end
40
- describe "#initialize" do
41
- describe "Deck#length" do
42
- it "should have three less cards after initialization" do
43
- deck1, hand, deck2 = deck.cards.length, Hand.new( deck ), deck.cards.length
44
- expect( deck1 ).to be > deck2
45
- end
46
- end
47
- end
48
- end
1
+ deck = Deck.new
2
+ describe Deck do
3
+ subject {Deck.new}
4
+ describe "#length" do
5
+ it "should == 54" do; expect(subject.cards.length).to eq 54; end
6
+ end
7
+ end
8
+ describe Card do
9
+ cards = ["Ace", "King", "Queen", "Jack", "Joker"] + (2..10).to_a
10
+ describe "#value" do
11
+ for card in cards
12
+ describe "#{card}" do
13
+ it "should == #{Card.new(card)._value}" do;
14
+ expect(Card.new(card).value).to eq Card.new(card)._value
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ describe "converter" do
21
+ context "when a number" do
22
+ it "should return the input as a number" do
23
+ expect(converter("5")).to eq 5
24
+ end
25
+ end
26
+ context "when an abbreveation" do
27
+ it "should expand it" do
28
+ expect(converter("K")).to eq "King"
29
+ end
30
+ end
31
+ end
32
+ describe Hand do
33
+ hand = Hand.new Deck.new
34
+ describe "#hand" do
35
+ describe "#length" do
36
+ subject { hand.hand.length }
37
+ it "should == 3" do; expect( subject ).to eq 3; end
38
+ end
39
+ end
40
+ describe "#initialize" do
41
+ describe "Deck#length" do
42
+ it "should have three less cards after initialization" do
43
+ deck1, hand, deck2 = deck.cards.length, Hand.new( deck ), deck.cards.length
44
+ expect( deck1 ).to be > deck2
45
+ end
46
+ end
47
+ end
48
+ end
@@ -1,77 +1,76 @@
1
- require "99_game"
2
- # This file was generated by the `rspec --init` command. Conventionally, all
3
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
4
- # The generated `.rspec` file contains `--require spec_helper` which will cause this
5
- # file to always be loaded, without a need to explicitly require it in any files.
6
- #
7
- # Given that it is always loaded, you are encouraged to keep this file as
8
- # light-weight as possible. Requiring heavyweight dependencies from this file
9
- # will add to the boot time of your test suite on EVERY test run, even for an
10
- # individual file that may not need all of that loaded. Instead, make a
11
- # separate helper file that requires this one and then use it only in the specs
12
- # that actually need it.
13
- #
14
- # The `.rspec` file also contains a few flags that are not defaults but that
15
- # users commonly want.
16
- require_relative "lib/99_game.rb"
17
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
18
- RSpec.configure do |config|
19
- # The settings below are suggested to provide a good initial experience
20
- # with RSpec, but feel free to customize to your heart's content.
21
- # These two settings work together to allow you to limit a spec run
22
- # to individual examples or groups you care about by tagging them with
23
- # `:focus` metadata. When nothing is tagged with `:focus`, all examples
24
- # get run.
25
- config.filter_run :focus
26
- config.run_all_when_everything_filtered = true
27
-
28
- # Many RSpec users commonly either run the entire suite or an individual
29
- # file, and it's useful to allow more verbose output when running an
30
- # individual spec file.
31
- if config.files_to_run.one?
32
- # Use the documentation formatter for detailed output,
33
- # unless a formatter has already been configured
34
- # (e.g. via a command-line flag).
35
- config.default_formatter = 'doc'
36
- end
37
-
38
- # Print the 10 slowest examples and example groups at the
39
- # end of the spec run, to help surface which specs are running
40
- # particularly slow.
41
- config.profile_examples = 10
42
-
43
- # Run specs in random order to surface order dependencies. If you find an
44
- # order dependency and want to debug it, you can fix the order by providing
45
- # the seed, which is printed after each run.
46
- # --seed 1234
47
- config.order = :random
48
-
49
- # Seed global randomization in this process using the `--seed` CLI option.
50
- # Setting this allows you to use `--seed` to deterministically reproduce
51
- # test failures related to randomization by passing the same `--seed` value
52
- # as the one that triggered the failure.
53
- Kernel.srand config.seed
54
-
55
- # rspec-expectations config goes here. You can use an alternate
56
- # assertion/expectation library such as wrong or the stdlib/minitest
57
- # assertions if you prefer.
58
- config.expect_with :rspec do |expectations|
59
- # Enable only the newer, non-monkey-patching expect syntax.
60
- # For more details, see:
61
- # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
62
- expectations.syntax = :expect
63
- end
64
-
65
- # rspec-mocks config goes here. You can use an alternate test double
66
- # library (such as bogus or mocha) by changing the `mock_with` option here.
67
- config.mock_with :rspec do |mocks|
68
- # Enable only the newer, non-monkey-patching expect syntax.
69
- # For more details, see:
70
- # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
71
- mocks.syntax = :expect
72
-
73
- # Prevents you from mocking or stubbing a method that does not exist on
74
- # a real object. This is generally recommended.
75
- mocks.verify_partial_doubles = true
76
- end
77
- end
1
+ require "99_game"
2
+ # This file was generated by the `rspec --init` command. Conventionally, all
3
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
4
+ # The generated `.rspec` file contains `--require spec_helper` which will cause this
5
+ # file to always be loaded, without a need to explicitly require it in any files.
6
+ #
7
+ # Given that it is always loaded, you are encouraged to keep this file as
8
+ # light-weight as possible. Requiring heavyweight dependencies from this file
9
+ # will add to the boot time of your test suite on EVERY test run, even for an
10
+ # individual file that may not need all of that loaded. Instead, make a
11
+ # separate helper file that requires this one and then use it only in the specs
12
+ # that actually need it.
13
+ #
14
+ # The `.rspec` file also contains a few flags that are not defaults but that
15
+ # users commonly want.
16
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
17
+ RSpec.configure do |config|
18
+ # The settings below are suggested to provide a good initial experience
19
+ # with RSpec, but feel free to customize to your heart's content.
20
+ # These two settings work together to allow you to limit a spec run
21
+ # to individual examples or groups you care about by tagging them with
22
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
23
+ # get run.
24
+ config.filter_run :focus
25
+ config.run_all_when_everything_filtered = true
26
+
27
+ # Many RSpec users commonly either run the entire suite or an individual
28
+ # file, and it's useful to allow more verbose output when running an
29
+ # individual spec file.
30
+ if config.files_to_run.one?
31
+ # Use the documentation formatter for detailed output,
32
+ # unless a formatter has already been configured
33
+ # (e.g. via a command-line flag).
34
+ config.default_formatter = 'doc'
35
+ end
36
+
37
+ # Print the 10 slowest examples and example groups at the
38
+ # end of the spec run, to help surface which specs are running
39
+ # particularly slow.
40
+ config.profile_examples = 10
41
+
42
+ # Run specs in random order to surface order dependencies. If you find an
43
+ # order dependency and want to debug it, you can fix the order by providing
44
+ # the seed, which is printed after each run.
45
+ # --seed 1234
46
+ config.order = :random
47
+
48
+ # Seed global randomization in this process using the `--seed` CLI option.
49
+ # Setting this allows you to use `--seed` to deterministically reproduce
50
+ # test failures related to randomization by passing the same `--seed` value
51
+ # as the one that triggered the failure.
52
+ Kernel.srand config.seed
53
+
54
+ # rspec-expectations config goes here. You can use an alternate
55
+ # assertion/expectation library such as wrong or the stdlib/minitest
56
+ # assertions if you prefer.
57
+ config.expect_with :rspec do |expectations|
58
+ # Enable only the newer, non-monkey-patching expect syntax.
59
+ # For more details, see:
60
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
61
+ expectations.syntax = :expect
62
+ end
63
+
64
+ # rspec-mocks config goes here. You can use an alternate test double
65
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
66
+ config.mock_with :rspec do |mocks|
67
+ # Enable only the newer, non-monkey-patching expect syntax.
68
+ # For more details, see:
69
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
70
+ mocks.syntax = :expect
71
+
72
+ # Prevents you from mocking or stubbing a method that does not exist on
73
+ # a real object. This is generally recommended.
74
+ mocks.verify_partial_doubles = true
75
+ end
76
+ end
metadata CHANGED
@@ -1,17 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: 99_game
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.3.pre.68
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zachary Perlmutter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-16 00:00:00.000000000 Z
11
+ date: 2014-10-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: |
14
- This is a text-based interpretation of the card game 99. Comes with the gem in the form of an executable. Make sure to read the rules in `99_game -h` before playing.
13
+ description: ! 'This is a text-based interpretation of the card game 99. Comes with
14
+ the gem in the form of an executable. Make sure to read the rules in `99_game -h`
15
+ before playing.
16
+
17
+ '
15
18
  email: zrp200@gmail.com
16
19
  executables:
17
20
  - 99_game
@@ -20,12 +23,12 @@ extra_rdoc_files:
20
23
  - README.md
21
24
  - LICENSE.txt
22
25
  files:
23
- - ".rspec"
26
+ - .rspec
24
27
  - LICENSE.txt
25
28
  - README.md
26
29
  - bin/99_game
27
30
  - lib/99_game.rb
28
- - spec/lib/99_game.rb
31
+ - spec/lib/99_game_spec.rb
29
32
  - spec/spec_helper.rb
30
33
  homepage: https://rubygems.org/gems/99_game
31
34
  licenses:
@@ -37,22 +40,21 @@ require_paths:
37
40
  - lib
38
41
  required_ruby_version: !ruby/object:Gem::Requirement
39
42
  requirements:
40
- - - ">="
43
+ - - ! '>='
41
44
  - !ruby/object:Gem::Version
42
45
  version: 1.9.3
43
46
  required_rubygems_version: !ruby/object:Gem::Requirement
44
47
  requirements:
45
- - - ">="
48
+ - - ! '>'
46
49
  - !ruby/object:Gem::Version
47
- version: '0'
50
+ version: 1.3.1
48
51
  requirements: []
49
52
  rubyforge_project:
50
- rubygems_version: 2.3.0
53
+ rubygems_version: 2.4.2
51
54
  signing_key:
52
55
  specification_version: 4
53
56
  summary: The game of 99.
54
57
  test_files:
55
- - spec/lib/99_game.rb
56
- - ".rspec"
58
+ - spec/lib/99_game_spec.rb
59
+ - .rspec
57
60
  - spec/spec_helper.rb
58
- has_rdoc: