ruby-blackjack 0.2 → 0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +6 -0
- data/bin/bundle +3 -0
- data/bin/rails +4 -0
- data/bin/rake +4 -0
- data/bin/setup +29 -0
- data/lib/blackjack/blackjack_cli.rb +1 -1
- data/lib/blackjack/game.rb +11 -5
- data/test/controllers/home_controller_test.rb +9 -0
- data/test/test_helper.rb +10 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cdea56b85c116fc3a4b57dbdf766f305f3af2832
|
4
|
+
data.tar.gz: 67b6addb052e8378a377a17771e631173546816f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 244b423811bd6719f546ea89970502ee1161af9637f6c5d837b02f76d2955e114635e4c2307b8cb2cf114a9e8a6a282e5b80c9835300aff34e51644b46569242
|
7
|
+
data.tar.gz: 790a84700c025bd9da3a817f46212189fd9f476da9912c5774328a266b1adcc7e818c48902d9ed007043a3aa32ac03cd5a0161e8b4dab7cfaa9f9c5b470239ba
|
data/Rakefile
CHANGED
data/bin/bundle
ADDED
data/bin/rails
ADDED
data/bin/rake
ADDED
data/bin/setup
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
# path to your application root.
|
5
|
+
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
6
|
+
|
7
|
+
Dir.chdir APP_ROOT do
|
8
|
+
# This script is a starting point to setup your application.
|
9
|
+
# Add necessary setup steps to this file:
|
10
|
+
|
11
|
+
puts "== Installing dependencies =="
|
12
|
+
system "gem install bundler --conservative"
|
13
|
+
system "bundle check || bundle install"
|
14
|
+
|
15
|
+
# puts "\n== Copying sample files =="
|
16
|
+
# unless File.exist?("config/database.yml")
|
17
|
+
# system "cp config/database.yml.sample config/database.yml"
|
18
|
+
# end
|
19
|
+
|
20
|
+
puts "\n== Preparing database =="
|
21
|
+
system "bin/rake db:setup"
|
22
|
+
|
23
|
+
puts "\n== Removing old logs and tempfiles =="
|
24
|
+
system "rm -f log/*"
|
25
|
+
system "rm -rf tmp/cache"
|
26
|
+
|
27
|
+
puts "\n== Restarting application server =="
|
28
|
+
system "touch tmp/restart.txt"
|
29
|
+
end
|
@@ -61,7 +61,7 @@ class BlackjackCli
|
|
61
61
|
elsif result[2] == 'loss'
|
62
62
|
puts ' You lost :( '.set_attributes([RED_BG, BLACK_FG])
|
63
63
|
elsif result[2] == 'draw'
|
64
|
-
puts " It's a draw ".set_attributes([
|
64
|
+
puts " It's a draw ".set_attributes([YELLOW_BG, BLACK_FG])
|
65
65
|
end
|
66
66
|
|
67
67
|
if result[2] != 'undecided'
|
data/lib/blackjack/game.rb
CHANGED
@@ -100,10 +100,15 @@ class Game
|
|
100
100
|
# @return [Card Array, Card Array, string] the result of the drawing. Refer to evaluate() for details
|
101
101
|
def stand
|
102
102
|
@dealer_cards[1].flip_over
|
103
|
-
|
104
|
-
|
103
|
+
result = [@player_cards.clone, @dealer_cards.clone, 'undecided']
|
104
|
+
while @dealer_score < 17 and result[2] == 'undecided'
|
105
|
+
result = hit(true)
|
106
|
+
end
|
107
|
+
if result[2] == 'undecided'
|
108
|
+
evaluate(true)
|
109
|
+
else
|
110
|
+
result
|
105
111
|
end
|
106
|
-
evaluate(true)
|
107
112
|
end
|
108
113
|
|
109
114
|
|
@@ -143,11 +148,12 @@ class Game
|
|
143
148
|
# Resets the game to enable starting a new game.
|
144
149
|
# @return [Card Array, Card Array] the user's cards and the dealer's cards
|
145
150
|
def cleanup
|
151
|
+
if @dealer_cards[1].is_flipped
|
152
|
+
@dealer_cards[1].flip_over
|
153
|
+
end
|
146
154
|
@used_cards += @player_cards + @dealer_cards
|
147
155
|
@player_score = 0
|
148
156
|
@dealer_score = 0
|
149
|
-
@player_ace_count = 0
|
150
|
-
@dealer_ace_count = 0
|
151
157
|
old_player_cards = @player_cards.clone
|
152
158
|
old_dealer_cards = @dealer_cards.clone
|
153
159
|
@player_cards = []
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
ENV['RAILS_ENV'] ||= 'test'
|
2
|
+
require File.expand_path('../../config/environment', __FILE__)
|
3
|
+
require 'rails/test_help'
|
4
|
+
|
5
|
+
class ActiveSupport::TestCase
|
6
|
+
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
|
7
|
+
fixtures :all
|
8
|
+
|
9
|
+
# Add more helper methods to be used by all tests here...
|
10
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-blackjack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.3'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hermann Krumrey
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A Blackjack CLI game
|
14
14
|
email: hermann@krumreyh.com
|
@@ -21,11 +21,17 @@ files:
|
|
21
21
|
- README.md
|
22
22
|
- Rakefile
|
23
23
|
- bin/blackjack
|
24
|
+
- bin/bundle
|
25
|
+
- bin/rails
|
26
|
+
- bin/rake
|
27
|
+
- bin/setup
|
24
28
|
- lib/blackjack/blackjack_cli.rb
|
25
29
|
- lib/blackjack/game.rb
|
26
30
|
- lib/blackjack/objects/card.rb
|
27
31
|
- lib/blackjack/strings/string.rb
|
28
32
|
- lib/ruby-blackjack.rb
|
33
|
+
- test/controllers/home_controller_test.rb
|
34
|
+
- test/test_helper.rb
|
29
35
|
homepage: http://gitlab.namibsun.net/namboy94/ruby-blackjack
|
30
36
|
licenses:
|
31
37
|
- GPL-3.0
|