cards_lib 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e1bb4141856d6efdd82f36541751260759e812cf
4
- data.tar.gz: df5377901eecdc5d3a1342327f91d2c6e5f9f80d
3
+ metadata.gz: 20bebeb9aaab1323d73b92bb9315c639d8aa97fd
4
+ data.tar.gz: 95bd1fec2c0ad1f5c381fab7ea097ff755796357
5
5
  SHA512:
6
- metadata.gz: a71706bd2c83929d2d7af31acf4e90a81495d84079f280a5b9f86a3220c90fd6902d0e879a9a2999ca88d9b9d2d1f26c4eb02105cfeaf250ce3235c81cc6caae
7
- data.tar.gz: 70cb115f9e01ca9437e992ee45f9ca2ea99f112087e8cb3adff7d1fd4dff08bc19a65d29cba10aa6ad4ff2de379c5c140b5ae62dd1f4e13b578a2049253cf018
6
+ metadata.gz: 0f1bced5837fda262d4b1b566b2f0a3636f01a3eddebc09c506ff6877b9dde7dc640f11e0004e05fbb9f1aacb9f790b483c58f2fdcf230fe74a0b432ecba22b5
7
+ data.tar.gz: bdeb8a6e74ec116dc98d3ebcac4055bf4fc238612a21d52248b5247834b054e76b2a982da7ff956deb74c27118cf7e7737294b7db6d1ae4797cd685b548e20be
data/Gemfile CHANGED
@@ -7,3 +7,6 @@ group :development do
7
7
  gem "guard"
8
8
  gem "guard-minitest"
9
9
  end
10
+ if Gem::Dependency.new('', ">= 2.4.0").match?('', RUBY_VERSION)
11
+ gem "json", git: 'https://github.com/flori/json', branch: 'v1.8'
12
+ end
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015 Daniel P. Clark
3
+ Copyright (c) 2015-2016 Daniel P. Clark
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -101,11 +101,54 @@ entire hand evaluation where-as Rules are specific scenarios.
101
101
  the Cards are first initialized. Each Card holds its own Ranker
102
102
  object.
103
103
 
104
+ #Example Usage
105
+
106
+ ###High Card
107
+
108
+ ```ruby
109
+ include CardsLib
110
+ class CardRanks < Ranker
111
+ def initialize(card)
112
+ super card, "23456789TJQKA".chars
113
+ end
114
+ end
115
+
116
+ deck = Deck.new ranker: CardRanks
117
+ # => <Deck: 52 Cards - Seed#317847827465261913302134114334103894430>
118
+
119
+ first_card = deck.pluck
120
+ # => (Card)
121
+ first_card.face
122
+ # => "Th"
123
+ second_card = deck.pluck
124
+ # => (Card)
125
+ second_card.face
126
+ # => "6h"
127
+
128
+ case [first_card.value, second_card.value].max
129
+ when ->_{first_card.eql? second_card}
130
+ puts "It's a tie!"
131
+ when first_card.value
132
+ puts "First player wins!"
133
+ when second_card.value
134
+ puts "Second player wins!"
135
+ else
136
+ raise "There was a problem determining a winner"
137
+ end
138
+ end
139
+ # First player wins!
140
+ ```
141
+
142
+ The example above shows the shorthand way of creating a Ranker object with passing the ranks
143
+ as a simple list from least to greatest value. If you want to use a Hash (in case some cards
144
+ of different ranks may be the same value) you may, but you must then also define a Proc for
145
+ lookup. See [lib/cards_lib/standard/rankers/blackjack_ranker.rb](https://github.com/danielpclark/CardsLib/blob/master/lib/cards_lib/standard/rankers/blackjack_ranker.rb) for an example of how to implement that.
146
+
104
147
  ##License
105
148
 
106
149
  The MIT License (MIT)
107
150
 
108
- Copyright (c) 2015 by Daniel P. Clark
151
+ Copyright (c) 2015-2016 by Daniel P. Clark
109
152
 
110
153
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
111
154
 
data/lib/cards_lib.rb CHANGED
@@ -12,5 +12,5 @@ module CardsLib
12
12
  # Cards[]
13
13
  # generate Card instances from string
14
14
  # representations of their faces
15
- Cards = ->*c{ c.map {|*opts| Card.new(*opts.flatten)} }
15
+ Cards = ->*c{ c.map {|*opts| Card.new(*opts)} }
16
16
  end
@@ -1,3 +1,3 @@
1
1
  module CardsLib
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cards_lib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel P. Clark
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-26 00:00:00.000000000 Z
11
+ date: 2017-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -132,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
132
  version: '0'
133
133
  requirements: []
134
134
  rubyforge_project:
135
- rubygems_version: 2.6.4
135
+ rubygems_version: 2.6.8
136
136
  signing_key:
137
137
  specification_version: 4
138
138
  summary: OO Card Game Library