cribbage 0.1.1 → 0.1.2
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 +4 -4
- data/README.md +8 -26
- data/lib/cribbage.rb +1 -4
- data/lib/cribbage/cli.rb +6 -3
- data/lib/cribbage/console.rb +13 -0
- data/lib/cribbage/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e8eb071f2d7d1d495312d89006b59d9bd96733a8
|
|
4
|
+
data.tar.gz: a82df26346d5c682a3067188ea691d5b414b73ff
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: eae17feb668ad0f921a3ea609187bd1b6379663a0eb6bc1c5d911e3c0947b572cd64cf06d06434f234a9b8b2d69cb6e144804f734b78528fa9b6c2afed11a15d
|
|
7
|
+
data.tar.gz: 6dae959043a91b55a9e3b9d6b3789c9f7ae91da4ce3812e1b5de9b2a0d7900c18e15afc9bea7e785fe3d8048118b5a9ccac03edd67c585d0ec23cb41cca8bf5c
|
data/README.md
CHANGED
|
@@ -1,41 +1,23 @@
|
|
|
1
1
|
# Cribbage
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Simple gem to count a cribbage hand from the terminal.
|
|
4
4
|
|
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
|
6
5
|
|
|
7
6
|
## Installation
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
```ruby
|
|
12
|
-
gem 'cribbage'
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
And then execute:
|
|
16
|
-
|
|
17
|
-
$ bundle
|
|
18
|
-
|
|
19
|
-
Or install it yourself as:
|
|
20
|
-
|
|
8
|
+
Install from your terminal's default ruby environment as:
|
|
21
9
|
$ gem install cribbage
|
|
22
10
|
|
|
23
11
|
## Usage
|
|
24
12
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
## Development
|
|
28
|
-
|
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. 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
|
|
13
|
+
Run `cribbage count` to compute points. The first argument is the flip card. The next 4 arguments are the players cards:
|
|
34
14
|
|
|
35
|
-
|
|
15
|
+
$ cribbage count 4H 5D 6S 7C 8D
|
|
36
16
|
|
|
17
|
+
### Card syntax
|
|
37
18
|
|
|
38
|
-
|
|
19
|
+
The first character is the card's value. Face cards are labelled by their first letter. "J" = jack, "Q" = queen, "K" = king, and "A" = ace.
|
|
39
20
|
|
|
40
|
-
The
|
|
21
|
+
The last character is the card's suit. "H" = heart, "S" = spade, "D" = diamond, and "C" = club.
|
|
41
22
|
|
|
23
|
+
These characters are *not* case sensitive. "jD" and "Jd" would both mean a jack of diamonds.
|
data/lib/cribbage.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require "cribbage/version"
|
|
2
|
+
require "cribbage/console"
|
|
2
3
|
require 'awesome_print'
|
|
3
4
|
|
|
4
5
|
module Cribbage
|
|
@@ -37,10 +38,6 @@ module Cribbage
|
|
|
37
38
|
@card_str = str
|
|
38
39
|
end
|
|
39
40
|
|
|
40
|
-
def to_human_readable_format
|
|
41
|
-
"#{@value} of #{@suit}"
|
|
42
|
-
end
|
|
43
|
-
|
|
44
41
|
def to_s
|
|
45
42
|
"[#{@face_value}#{SUITS[@suit]}]"
|
|
46
43
|
end
|
data/lib/cribbage/cli.rb
CHANGED
|
@@ -2,13 +2,16 @@ require 'thor'
|
|
|
2
2
|
require 'cribbage'
|
|
3
3
|
module Cribbage
|
|
4
4
|
class CLI < Thor
|
|
5
|
-
desc "count
|
|
5
|
+
desc "count FLIP_CARD CARD_1 CARD_2 CARD_3 CARD_4", "count points in hand of five cards"
|
|
6
6
|
def count(*cards)
|
|
7
7
|
|
|
8
|
+
if cards.size != 5
|
|
9
|
+
Console.error "You must input 5 cards"
|
|
10
|
+
exit
|
|
11
|
+
end
|
|
12
|
+
|
|
8
13
|
hand = Cribbage::Hand.new(cards)
|
|
9
14
|
hand.print_score
|
|
10
15
|
end
|
|
11
|
-
|
|
12
|
-
default_task :count
|
|
13
16
|
end
|
|
14
17
|
end
|
data/lib/cribbage/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cribbage
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- davycro
|
|
@@ -85,6 +85,7 @@ files:
|
|
|
85
85
|
- exe/cribbage
|
|
86
86
|
- lib/cribbage.rb
|
|
87
87
|
- lib/cribbage/cli.rb
|
|
88
|
+
- lib/cribbage/console.rb
|
|
88
89
|
- lib/cribbage/version.rb
|
|
89
90
|
homepage:
|
|
90
91
|
licenses:
|