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 +4 -4
- data/Gemfile +3 -0
- data/LICENSE.txt +1 -1
- data/README.md +44 -1
- data/lib/cards_lib.rb +1 -1
- data/lib/cards_lib/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20bebeb9aaab1323d73b92bb9315c639d8aa97fd
|
4
|
+
data.tar.gz: 95bd1fec2c0ad1f5c381fab7ea097ff755796357
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f1bced5837fda262d4b1b566b2f0a3636f01a3eddebc09c506ff6877b9dde7dc640f11e0004e05fbb9f1aacb9f790b483c58f2fdcf230fe74a0b432ecba22b5
|
7
|
+
data.tar.gz: bdeb8a6e74ec116dc98d3ebcac4055bf4fc238612a21d52248b5247834b054e76b2a982da7ff956deb74c27118cf7e7737294b7db6d1ae4797cd685b548e20be
|
data/Gemfile
CHANGED
data/LICENSE.txt
CHANGED
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
data/lib/cards_lib/version.rb
CHANGED
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.
|
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:
|
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.
|
135
|
+
rubygems_version: 2.6.8
|
136
136
|
signing_key:
|
137
137
|
specification_version: 4
|
138
138
|
summary: OO Card Game Library
|