cardcounter 0.1.11
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 +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +40 -0
- data/Rakefile +6 -0
- data/bin/cardcounter +5 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/cardcounter.gemspec +33 -0
- data/lib/cardcounter.rb +124 -0
- data/lib/cardcounter/version.rb +3 -0
- data/lib/cardcounting.rb +0 -0
- data/lib/deck.rb +32 -0
- data/lib/fakework.rb +23 -0
- data/lib/run_program.rb +3 -0
- metadata +119 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 2461d19f04d3a0dea21413545c6b222e8c18b383
|
|
4
|
+
data.tar.gz: 7681d32dba732f3a25d56578746a0428ea0cf17a
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 84254762ec39e9920f8c93a788703b99ca5cc31e56c228694558e1f11521ea1e8555735bd21a0386d1347b7c6ce4356babb4dd50e24f34a819cac9e0e0e484d5
|
|
7
|
+
data.tar.gz: 459977efa1e6d87d361ed590b8e8369d8578149fe10c7717ffac7f946e04c4675ecab5bdc7e7603eff9640e0bd1bbaba84ccb4c1aecc5508236538431424c1d1
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015 David Goodman
|
|
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
|
|
13
|
+
all 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
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Cardcounter
|
|
2
|
+
|
|
3
|
+
Welcome to cardcounter, a ruby gem to practice counting cards via the command line. The gem allows you to choose how many decks to use, and how long to practice for. There is also a 'boss' feature at the end to print out some git nonsense and makes it look like you are doing work.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
gem 'cardcounter'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
And then execute:
|
|
14
|
+
|
|
15
|
+
$ bundle
|
|
16
|
+
|
|
17
|
+
Or install it yourself as:
|
|
18
|
+
|
|
19
|
+
$ gem install cardcounter
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
Cardcounter is a command line tool, anytime that you have an open terminal just type cardcounter to begin
|
|
24
|
+
|
|
25
|
+
$ cardcounter
|
|
26
|
+
|
|
27
|
+
## Development
|
|
28
|
+
|
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
30
|
+
|
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
32
|
+
|
|
33
|
+
## Contributing
|
|
34
|
+
|
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/cardcounter.
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
## License
|
|
39
|
+
|
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/cardcounter
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "cardcounter"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/cardcounter.gemspec
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'cardcounter/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "cardcounter"
|
|
8
|
+
spec.version = Cardcounter::VERSION
|
|
9
|
+
spec.authors = ["David Goodman"]
|
|
10
|
+
spec.email = ["goodman.david.h@gmail.com"]
|
|
11
|
+
|
|
12
|
+
spec.summary = "Work is overrated, learn how to gamble"
|
|
13
|
+
spec.description = "A gem to be able to practice counting cards via the command line"
|
|
14
|
+
spec.homepage = "https://github.com/dgoodman1224/cardcounter"
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
|
|
17
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
|
18
|
+
# delete this section to allow pushing this gem to any host.
|
|
19
|
+
if spec.respond_to?(:metadata)
|
|
20
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
|
21
|
+
else
|
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
26
|
+
spec.executables = ["cardcounter"]
|
|
27
|
+
spec.require_paths = ["lib"]
|
|
28
|
+
|
|
29
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
|
30
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
31
|
+
spec.add_development_dependency "rspec"
|
|
32
|
+
spec.add_development_dependency "colorize", "~> 0.7.7"
|
|
33
|
+
end
|
data/lib/cardcounter.rb
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
require "cardcounter/version"
|
|
2
|
+
require 'colorize'
|
|
3
|
+
|
|
4
|
+
require_relative 'deck.rb'
|
|
5
|
+
require "fakework"
|
|
6
|
+
|
|
7
|
+
module CardCounter
|
|
8
|
+
CARD_COUNTING_VALUES = {
|
|
9
|
+
2 => 1,
|
|
10
|
+
3 => 1,
|
|
11
|
+
4 => 1,
|
|
12
|
+
5 => 1,
|
|
13
|
+
6 => 1,
|
|
14
|
+
7 => 0,
|
|
15
|
+
8 => 0,
|
|
16
|
+
9 => 0,
|
|
17
|
+
10 => -1,
|
|
18
|
+
11 => -1,
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
def self.run_program
|
|
22
|
+
puts "Welcome to card counter, a way to practice counting cards vis the command line"
|
|
23
|
+
puts "We use standard counting, where 2-6 = +1, 7-9 = 0, and 10-A = -1"
|
|
24
|
+
puts "Press enter when you are ready to move on"
|
|
25
|
+
move_on = gets.chomp
|
|
26
|
+
run_round
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def self.run_round
|
|
30
|
+
get_settings_for_counting
|
|
31
|
+
start_counting
|
|
32
|
+
count_again?
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def self.get_settings_for_counting
|
|
36
|
+
@count = 0
|
|
37
|
+
system("clear")
|
|
38
|
+
puts 'How many decks would you like to use?'
|
|
39
|
+
@deck_number = gets.chomp.to_i
|
|
40
|
+
puts 'Great, about how much time would you like ex: 15 second'
|
|
41
|
+
@time_to_count = gets.chomp.to_i
|
|
42
|
+
puts "And finally what speed do you want? Easy, Medium or Hard?"
|
|
43
|
+
@level = gets.chomp.downcase
|
|
44
|
+
if @level == 'easy'
|
|
45
|
+
@speed = 1.0
|
|
46
|
+
elsif @level == 'medium'
|
|
47
|
+
@speed = 0.75
|
|
48
|
+
elsif @level == 'hard'
|
|
49
|
+
@speed = 0.5
|
|
50
|
+
else
|
|
51
|
+
puts 'You didnt quite listen there, lets just go medium'
|
|
52
|
+
@speed = 0.75
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def self.start_counting
|
|
57
|
+
@cards = []
|
|
58
|
+
@deck_number.times {@cards += Deck.new.cards}
|
|
59
|
+
@cards.shuffle!
|
|
60
|
+
countdown
|
|
61
|
+
count_cards
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def self.countdown
|
|
65
|
+
system"clear"
|
|
66
|
+
counter = 3
|
|
67
|
+
3.times do
|
|
68
|
+
puts "Lets begin in .........."
|
|
69
|
+
puts " #{counter}"
|
|
70
|
+
counter -= 1
|
|
71
|
+
sleep(1); system("clear")
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def self.count_cards
|
|
76
|
+
ending_time = Time.now + @time_to_count
|
|
77
|
+
until Time.now > ending_time
|
|
78
|
+
if @cards.empty?
|
|
79
|
+
puts 'No cards left'.red
|
|
80
|
+
break
|
|
81
|
+
end
|
|
82
|
+
card = @cards.pop
|
|
83
|
+
puts "#{card.rank}"
|
|
84
|
+
@count += CARD_COUNTING_VALUES[card.value]
|
|
85
|
+
sleep(@speed)
|
|
86
|
+
system("clear")
|
|
87
|
+
sleep(0.10)
|
|
88
|
+
end
|
|
89
|
+
guess_count
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def self.guess_count
|
|
93
|
+
puts 'Time is up. What is the count?'.blue
|
|
94
|
+
guessed_count = gets.chomp.to_i
|
|
95
|
+
puts "You guessed #{guessed_count} the correct count is #{@count}"
|
|
96
|
+
3.times {puts ''}
|
|
97
|
+
if guessed_count == @count
|
|
98
|
+
puts "You crushed it that is correct! Count was #{@count}"
|
|
99
|
+
elsif @count != 0
|
|
100
|
+
puts "You were off by #{(((@count - guessed_count).to_f/@count) *100).abs}%"
|
|
101
|
+
else
|
|
102
|
+
puts "The count was even should have guessed 0".red
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def self.count_again?
|
|
107
|
+
puts "Would like you like to play again?"
|
|
108
|
+
puts 'Please say yes or no, or boss and we will make it look like you are doing work'
|
|
109
|
+
answer = gets.chomp
|
|
110
|
+
if answer == 'yes' || answer == 'y'
|
|
111
|
+
run_round
|
|
112
|
+
elsif answer == 'boss'
|
|
113
|
+
print_fake_work_things
|
|
114
|
+
else
|
|
115
|
+
puts 'Cool, see you later and enjoy your new money'
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def self.print_fake_work_things
|
|
120
|
+
FakeWork.git_work
|
|
121
|
+
sleep(0.5)
|
|
122
|
+
FakeWork.up_to_date
|
|
123
|
+
end
|
|
124
|
+
end
|
data/lib/cardcounting.rb
ADDED
|
File without changes
|
data/lib/deck.rb
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
class Deck
|
|
2
|
+
attr_reader :cards
|
|
3
|
+
|
|
4
|
+
def initialize
|
|
5
|
+
@cards = []
|
|
6
|
+
create_standard_deck
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def create_standard_deck
|
|
10
|
+
card_values = {'2' => 2,'3' => 3,'4' => 4,'5' => 5,'6' => 6,'7' => 7,'8' => 8,
|
|
11
|
+
'9' => 9,'10' => 10,'J' => 10,'Q' => 10,'K' => 10,
|
|
12
|
+
'A' => 11}
|
|
13
|
+
suits = ['S', 'D', 'C', 'H']
|
|
14
|
+
suits.each do |suit|
|
|
15
|
+
card_values.each do |rank, value|
|
|
16
|
+
card = Card.new(rank, value, suit)
|
|
17
|
+
@cards.push(card)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
class Card
|
|
24
|
+
|
|
25
|
+
attr_reader :rank, :suit, :value
|
|
26
|
+
|
|
27
|
+
def initialize(rank, value, suit)
|
|
28
|
+
@value = value
|
|
29
|
+
@rank = rank
|
|
30
|
+
@suit = suit
|
|
31
|
+
end
|
|
32
|
+
end
|
data/lib/fakework.rb
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module FakeWork
|
|
2
|
+
def FakeWork.git_work
|
|
3
|
+
#prints gake git stayemnets to the screen as if you just pushed something
|
|
4
|
+
puts '➜ repo.github.fake git:(development) ✗ git commit -m "User wants to get good at counting cards and become a millionaire"'
|
|
5
|
+
puts '[development 3a21d20] change file name'
|
|
6
|
+
puts '4 file changed, 75 insertions(+), 24 deletions(-)'
|
|
7
|
+
puts ' rename basic.html => bitch.html (100%)'
|
|
8
|
+
puts '➜ repo.github.fake git:(development) git push origin development'
|
|
9
|
+
puts 'Counting objects: 6, done.'
|
|
10
|
+
puts 'Delta compression using up to 8 threads.'
|
|
11
|
+
puts 'Compressing objects: 100% (2/2), done.'
|
|
12
|
+
puts 'Writing objects: 100% (2/2), 274 bytes | 0 bytes/s, done.'
|
|
13
|
+
puts 'Total 2 (delta 0), reused 0 (delta 0)'
|
|
14
|
+
puts 'To https://github.com/random/boss-dont-look/work'
|
|
15
|
+
puts ' 736bdh4..3a7dhs0 development -> development'
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def FakeWork.up_to_date
|
|
19
|
+
puts 'On branch master'
|
|
20
|
+
puts 'Your branch is up-to-date with origin/development.'
|
|
21
|
+
puts 'nothing to commit, working directory clean'
|
|
22
|
+
end
|
|
23
|
+
end
|
data/lib/run_program.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: cardcounter
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.11
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- David Goodman
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2015-07-26 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.10'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.10'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: colorize
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: 0.7.7
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: 0.7.7
|
|
69
|
+
description: A gem to be able to practice counting cards via the command line
|
|
70
|
+
email:
|
|
71
|
+
- goodman.david.h@gmail.com
|
|
72
|
+
executables:
|
|
73
|
+
- cardcounter
|
|
74
|
+
extensions: []
|
|
75
|
+
extra_rdoc_files: []
|
|
76
|
+
files:
|
|
77
|
+
- ".gitignore"
|
|
78
|
+
- ".rspec"
|
|
79
|
+
- ".travis.yml"
|
|
80
|
+
- Gemfile
|
|
81
|
+
- LICENSE.txt
|
|
82
|
+
- README.md
|
|
83
|
+
- Rakefile
|
|
84
|
+
- bin/cardcounter
|
|
85
|
+
- bin/console
|
|
86
|
+
- bin/setup
|
|
87
|
+
- cardcounter.gemspec
|
|
88
|
+
- lib/cardcounter.rb
|
|
89
|
+
- lib/cardcounter/version.rb
|
|
90
|
+
- lib/cardcounting.rb
|
|
91
|
+
- lib/deck.rb
|
|
92
|
+
- lib/fakework.rb
|
|
93
|
+
- lib/run_program.rb
|
|
94
|
+
homepage: https://github.com/dgoodman1224/cardcounter
|
|
95
|
+
licenses:
|
|
96
|
+
- MIT
|
|
97
|
+
metadata:
|
|
98
|
+
allowed_push_host: https://rubygems.org
|
|
99
|
+
post_install_message:
|
|
100
|
+
rdoc_options: []
|
|
101
|
+
require_paths:
|
|
102
|
+
- lib
|
|
103
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
104
|
+
requirements:
|
|
105
|
+
- - ">="
|
|
106
|
+
- !ruby/object:Gem::Version
|
|
107
|
+
version: '0'
|
|
108
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
|
+
requirements:
|
|
110
|
+
- - ">="
|
|
111
|
+
- !ruby/object:Gem::Version
|
|
112
|
+
version: '0'
|
|
113
|
+
requirements: []
|
|
114
|
+
rubyforge_project:
|
|
115
|
+
rubygems_version: 2.4.5
|
|
116
|
+
signing_key:
|
|
117
|
+
specification_version: 4
|
|
118
|
+
summary: Work is overrated, learn how to gamble
|
|
119
|
+
test_files: []
|