7_half 0.0.0.pre → 0.0.1.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/bin/{7_1-2 → 7_half} +42 -42
- data/lib/card.rb +15 -15
- data/lib/deck.rb +19 -19
- data/lib/hand.rb +21 -21
- metadata +17 -18
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NWNmZGRlMDEyYmY1YWVmOWUwNjUzZDgxNmZhNGI2NjY0OTNiZDk2Mw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZTM5ZDZkY2ZkZDFmMTg1MWM4NTZjN2E1YjkyMDU3ODZkNTEzMzIwOQ==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZTQ1NTcxYTc5ZjZjOWU1NGQ2MGYyZGRkYWE2ZTM2NGNmZTY5MTYyNDYxNjVi
|
10
|
+
YjE4Y2RmZGViMzc2OTNmZjRkMDM3MzNiMDE5NTFkNjAxNTQ5ZjhmZWQyY2Yx
|
11
|
+
ODE2ZjNjMDZkODBjYjU5MTIxOTQ2NWY4Yzk5ZTMwMmQ3YjA5MjU=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
OTg4MDIyMWYyMDY2N2U3N2QxNGM3MjBkNzA0OWY0MzM5ZTRjMmNjMzk3MGQy
|
14
|
+
ODNiYWZlNzU0ZDNlNzcxZGIxN2M1NmE1MzYzNmQ3MjAxNjgwNjMzM2UyNDY5
|
15
|
+
ZjI4ZDQ4NmI5Y2Y4NmJjNzJjZTJhNzZkNDc3N2FkMDMxYTk5YTA=
|
data/bin/{7_1-2 → 7_half}
RENAMED
@@ -1,42 +1,42 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "hand"
|
4
|
-
def s_puts(message, time=0.5)
|
5
|
-
puts "\t" + message
|
6
|
-
sleep time
|
7
|
-
end
|
8
|
-
|
9
|
-
player, dealer = Hand.new, Hand.new
|
10
|
-
s_puts "Your turn!", 1
|
11
|
-
loop do # Player's turn
|
12
|
-
s_puts "You have #{player.cards.view}"
|
13
|
-
break if (player.bust? || player.value == 7.5)
|
14
|
-
print "\tDo you want to (h)it or (s)tay? "
|
15
|
-
case gets.chomp.downcase[0]
|
16
|
-
when 'h' then player.hit
|
17
|
-
when 's' then break
|
18
|
-
end
|
19
|
-
s_puts String.new, 1
|
20
|
-
end
|
21
|
-
if player.bust?
|
22
|
-
s_puts "You bust @ #{player.value}!", 1
|
23
|
-
s_puts "You lose"
|
24
|
-
exit
|
25
|
-
end
|
26
|
-
until dealer.value > Hand::MDSV
|
27
|
-
s_puts "The dealer hits"
|
28
|
-
dealer.hit
|
29
|
-
end
|
30
|
-
if dealer.bust?
|
31
|
-
s_puts "The dealer busts @ #{dealer.value}
|
32
|
-
s_puts "You win!", 2
|
33
|
-
elsif dealer.value > player.value || dealer.value == player.value
|
34
|
-
s_puts "You lose"
|
35
|
-
elsif dealer.value < player.value
|
36
|
-
s_puts "You win"
|
37
|
-
else
|
38
|
-
raise "Win error"
|
39
|
-
end
|
40
|
-
|
41
|
-
|
42
|
-
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "hand"
|
4
|
+
def s_puts(message, time=0.5)
|
5
|
+
puts "\t" + message
|
6
|
+
sleep time
|
7
|
+
end
|
8
|
+
|
9
|
+
player, dealer = Hand.new, Hand.new
|
10
|
+
s_puts "Your turn!", 1
|
11
|
+
loop do # Player's turn
|
12
|
+
s_puts "You have #{player.cards.view}"
|
13
|
+
break if (player.bust? || player.value == 7.5)
|
14
|
+
print "\tDo you want to (h)it or (s)tay? "
|
15
|
+
case gets.chomp.downcase[0]
|
16
|
+
when 'h' then player.hit
|
17
|
+
when 's' then break
|
18
|
+
end
|
19
|
+
s_puts String.new, 1
|
20
|
+
end
|
21
|
+
if player.bust?
|
22
|
+
s_puts "You bust @ #{player.value}!", 1
|
23
|
+
s_puts "You lose"
|
24
|
+
exit
|
25
|
+
end
|
26
|
+
until dealer.value > Hand::MDSV
|
27
|
+
s_puts "The dealer hits"
|
28
|
+
dealer.hit
|
29
|
+
end
|
30
|
+
if dealer.bust?
|
31
|
+
s_puts "The dealer busts @ #{dealer.value}
|
32
|
+
s_puts "You win!", 2
|
33
|
+
elsif dealer.value > player.value || dealer.value == player.value
|
34
|
+
s_puts "You lose"
|
35
|
+
elsif dealer.value < player.value
|
36
|
+
s_puts "You win"
|
37
|
+
else
|
38
|
+
raise "Win error"
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
|
data/lib/card.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
require "card_deck"
|
2
|
-
class CardDeck::Card # Main object used. Makes this a 'Card' game
|
3
|
-
def value
|
4
|
-
case num
|
5
|
-
when "Ace" then 1
|
6
|
-
when 2..7 then num
|
7
|
-
when "King" then 0.5
|
8
|
-
when "Queen" then 0.5
|
9
|
-
when "Jack" then 0.5
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
|
15
|
-
|
1
|
+
require "card_deck"
|
2
|
+
class CardDeck::Card # Main object used. Makes this a 'Card' game
|
3
|
+
def value
|
4
|
+
case num
|
5
|
+
when "Ace" then 1
|
6
|
+
when 2..7 then num
|
7
|
+
when "King" then 0.5
|
8
|
+
when "Queen" then 0.5
|
9
|
+
when "Jack" then 0.5
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
|
data/lib/deck.rb
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
-
require_relative "card.rb" # Load modified CardDeck::Card
|
2
|
-
class Deck # The 40-card deck used in this game
|
3
|
-
attr_reader :cards # The cards in the deck
|
4
|
-
def initialize
|
5
|
-
@cards = Array.new
|
6
|
-
for suit in CardDeck::Card::SUIT
|
7
|
-
stock "Ace", suit
|
8
|
-
stock "King", suit
|
9
|
-
stock "Queen", suit
|
10
|
-
stock "Jack", suit
|
11
|
-
for num in (2..7).to_a; stock num, suit; end
|
12
|
-
end
|
13
|
-
@cards.shuffle!
|
14
|
-
end
|
15
|
-
def length; @cards.length; end # How many cards are in @cards
|
16
|
-
def draw; @cards.shift; end # Draw a card from @cards
|
17
|
-
private
|
18
|
-
def stock(card, suit); @cards.push CardDeck::Card.new(card, suit); end # Creates a card and puts it into @cards
|
19
|
-
end
|
1
|
+
require_relative "card.rb" # Load modified CardDeck::Card
|
2
|
+
class Deck # The 40-card deck used in this game
|
3
|
+
attr_reader :cards # The cards in the deck
|
4
|
+
def initialize
|
5
|
+
@cards = Array.new
|
6
|
+
for suit in CardDeck::Card::SUIT
|
7
|
+
stock "Ace", suit
|
8
|
+
stock "King", suit
|
9
|
+
stock "Queen", suit
|
10
|
+
stock "Jack", suit
|
11
|
+
for num in (2..7).to_a; stock num, suit; end
|
12
|
+
end
|
13
|
+
@cards.shuffle!
|
14
|
+
end
|
15
|
+
def length; @cards.length; end # How many cards are in @cards
|
16
|
+
def draw; @cards.shift; end # Draw a card from @cards
|
17
|
+
private
|
18
|
+
def stock(card, suit); @cards.push CardDeck::Card.new(card, suit); end # Creates a card and puts it into @cards
|
19
|
+
end
|
data/lib/hand.rb
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
require_relative "deck.rb" # Load Deck
|
2
|
-
class Hand # Acts as the player
|
3
|
-
attr_accessor :cards # The cards in your hand
|
4
|
-
DECK = Deck.new # The deck used in the game
|
5
|
-
MDSV = 7.5 * (17.0/21.0) # Minimum value the dealer can stay at. Uses the same ratio as blackjack1.
|
6
|
-
def initialize; @cards = [DECK.draw]; end
|
7
|
-
def hit; @cards.push DECK.draw; end # Adds a card to your hand, increasing your value
|
8
|
-
def value # The combined value of all the cards in your hand
|
9
|
-
sum = 0.0
|
10
|
-
for c in @cards; sum += c.value; end
|
11
|
-
return sum
|
12
|
-
end
|
13
|
-
def bust? # Returns true if #value > 7.5
|
14
|
-
if value > 7.5 then true
|
15
|
-
else
|
16
|
-
false
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
|
1
|
+
require_relative "deck.rb" # Load Deck
|
2
|
+
class Hand # Acts as the player
|
3
|
+
attr_accessor :cards # The cards in your hand
|
4
|
+
DECK = Deck.new # The deck used in the game
|
5
|
+
MDSV = 7.5 * (17.0/21.0) # Minimum value the dealer can stay at. Uses the same ratio as blackjack1.
|
6
|
+
def initialize; @cards = [DECK.draw]; end
|
7
|
+
def hit; @cards.push DECK.draw; end # Adds a card to your hand, increasing your value
|
8
|
+
def value # The combined value of all the cards in your hand
|
9
|
+
sum = 0.0
|
10
|
+
for c in @cards; sum += c.value; end
|
11
|
+
return sum
|
12
|
+
end
|
13
|
+
def bust? # Returns true if #value > 7.5
|
14
|
+
if value > 7.5 then true
|
15
|
+
else
|
16
|
+
false
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: 7_half
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zachary Perlmutter
|
@@ -14,59 +14,59 @@ dependencies:
|
|
14
14
|
name: rspec
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ! '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ! '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec-its
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ! '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ! '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: card_deck
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '2.0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '2.0'
|
55
|
-
description: "\tThe is a game played in parts of Africa. It is played with a 30
|
56
|
-
deck or a 52 card deck with all the 8s, 9s. and 10s removed. It works like
|
57
|
-
except you bust at 7½ and face cards are worth ½. You start with one card
|
58
|
-
against the dealer.\n"
|
55
|
+
description: ! "\tThe is a game played in parts of Africa. It is played with a 30
|
56
|
+
card deck or a 52 card deck with all the 8s, 9s. and 10s removed. It works like
|
57
|
+
blackjack except you bust at 7½ and face cards are worth ½. You start with one card
|
58
|
+
and play against the dealer.\n"
|
59
59
|
email: zrp200@gmail.com
|
60
60
|
executables:
|
61
|
-
-
|
61
|
+
- 7_half
|
62
62
|
extensions: []
|
63
63
|
extra_rdoc_files: []
|
64
64
|
files:
|
65
|
-
- bin/
|
65
|
+
- bin/7_half
|
66
66
|
- lib/card.rb
|
67
67
|
- lib/deck.rb
|
68
68
|
- lib/hand.rb
|
69
|
-
homepage: http://github.com/zrp200/
|
69
|
+
homepage: http://github.com/zrp200/7_half
|
70
70
|
licenses: []
|
71
71
|
metadata: {}
|
72
72
|
post_install_message:
|
@@ -75,19 +75,18 @@ require_paths:
|
|
75
75
|
- lib
|
76
76
|
required_ruby_version: !ruby/object:Gem::Requirement
|
77
77
|
requirements:
|
78
|
-
- -
|
78
|
+
- - ! '>='
|
79
79
|
- !ruby/object:Gem::Version
|
80
80
|
version: '0'
|
81
81
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
82
|
requirements:
|
83
|
-
- -
|
83
|
+
- - ! '>'
|
84
84
|
- !ruby/object:Gem::Version
|
85
85
|
version: 1.3.1
|
86
86
|
requirements: []
|
87
87
|
rubyforge_project:
|
88
|
-
rubygems_version: 2.4.
|
88
|
+
rubygems_version: 2.4.2
|
89
89
|
signing_key:
|
90
90
|
specification_version: 4
|
91
91
|
summary: The game of 7½
|
92
92
|
test_files: []
|
93
|
-
has_rdoc:
|