cribbage 0.1.0 → 0.1.1

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,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 200cb7218063ba97c8e79f52e32b12e869ec0224
4
- data.tar.gz: 02226a8ceda8219eac3bc0d17d0cf9e9f73467ea
3
+ metadata.gz: e815bde106e3529bbfc215373993536bb3b9f02a
4
+ data.tar.gz: c9a125f34f365a9058400b6345dad137c957a059
5
5
  SHA512:
6
- metadata.gz: 60093aa38cbcbe88620f2f9a3f34cf55975a9931ace6931005ef15353e0e4daf2cfdfcd75f3a4edd75e5d10eff07518b65c81e2d536a09c65cd1ad4c95a28eaa
7
- data.tar.gz: 363119ae1e3a7c1ddb34c6d83301ddb53d90cd7a2d2dcd051cd3f093611c42b21068db42ed62f038415448cf35a32c39aa039c11155a00af68106bf640ad9e33
6
+ metadata.gz: 2cbb03d76a9b9fe87cdb52662dfe83ee05e56d3f346076cc0b50522e4fd5f52e25f0df77608676f8b2935794a3be3a152f78deb908065522648f7d20263ca07e
7
+ data.tar.gz: d4b1125ef7baaf5047fdf3e924ba746128c3336e9ba1685e62f99d18cda67321e66c404c2fae2cbeb02af8f12d3a72f97b5e82eca361a50c84911d00b3cb0e6f
data/README.md CHANGED
@@ -1,7 +1,3 @@
1
- - Add suit unicode
2
- - publish
3
- - DRY
4
-
5
1
  # Cribbage
6
2
 
7
3
  Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/cribbage`. To experiment with that code, run `bin/console` for an interactive prompt.
data/lib/cribbage/cli.rb CHANGED
@@ -8,5 +8,7 @@ module Cribbage
8
8
  hand = Cribbage::Hand.new(cards)
9
9
  hand.print_score
10
10
  end
11
+
12
+ default_task :count
11
13
  end
12
14
  end
@@ -1,3 +1,3 @@
1
1
  module Cribbage
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/cribbage.rb CHANGED
@@ -22,6 +22,7 @@ module Cribbage
22
22
  attr_accessor :index # index in a hand. Ie A = 0,
23
23
 
24
24
  INDEX = %w(A 2 3 4 5 6 7 8 9 10 J Q K)
25
+ SUITS = {'H' => '♥', 'D' => '♦', 'C' => '♣', 'S' => '♠'}
25
26
 
26
27
  def initialize(str)
27
28
  raise "String cannot be blank!" if str.nil?
@@ -41,7 +42,7 @@ module Cribbage
41
42
  end
42
43
 
43
44
  def to_s
44
- "#{@face_value}#{@suit}"
45
+ "[#{@face_value}#{SUITS[@suit]}]"
45
46
  end
46
47
 
47
48
  def compute_value(char)
@@ -100,26 +101,29 @@ module Cribbage
100
101
  # Total Points: +17
101
102
  # Fifteens (+8): (5 5 5), (5 J), (5 J), (5 K)
102
103
  # Runs:
103
-
104
- ap "#{starter_card} | #{players_cards.join(' ')}"
105
- ap ""
106
- ap "Total Points: #{total_score}"
104
+ #
105
+ $stdout.printf "\n\n"
106
+ $stdout.printf "%-3s %-21s %-10s\n\n", '', 'Hand:', starter_card.to_s + "" + players_cards.join('')
107
107
 
108
108
  print_points :fifteens
109
109
  print_points :runs
110
110
  print_points :pairs
111
111
  print_points :flush
112
112
  print_points :nobs
113
- end
114
113
 
114
+ $stdout.printf "\n%-3s %-10s %-10s\n", '', 'Total:', "+#{total_score}"
115
+
116
+ $stdout.printf "\n\n"
117
+ end
118
+ #
115
119
  def print_points(key)
116
120
  if @points[key].nil?
117
121
  return false
118
122
  end
119
123
  cards = @points[key.to_sym][:cards] # should be array of array
120
- str = cards.map { |c| "[" + c.join(' ') + "]" }.join ", "
124
+ str = cards.map { |c| "" + c.join('') + "" }.join ", "
121
125
  title = key.to_s
122
- ap "#{title} (+#{@points[key][:point_value]}): #{str}"
126
+ $stdout.printf "%-3s %-10s %-10s %-10s\n", '', title, "+#{@points[key][:point_value]}", str
123
127
  end
124
128
 
125
129
  def print_cards(label, cards)
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.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - davycro