poker_card 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +31 -0
- data/ext/poker_card/Cargo.lock +291 -0
- data/ext/poker_card/Cargo.toml +11 -0
- data/ext/poker_card/extconf.rb +5 -0
- data/ext/poker_card/src/lib.rs +140 -0
- data/lib/poker_card/poker_card.bundle +0 -0
- data/lib/poker_card/version.rb +5 -0
- data/lib/poker_card.rb +10 -0
- metadata +82 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e574b2dd0831dab465ae5a0b02a450531fc71b1248a8cf2c584b1c3d0cf9167e
|
4
|
+
data.tar.gz: 9376ec3a2a98b246f8fe13219750a5b0771e995f007b88092ece6b141cba9521
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5a70af17108f9c06ddbb434da32c39f01045bf11aeecebc0994cab9fcafb7b5883c4a2ed48d3a36dc6b6ce2d8bcc92c66bc983b67f8d9b43f5e3ca1cec3a2474
|
7
|
+
data.tar.gz: 89a56432d14402e396ae139be1636050b1600d9428fca169837653c57d27172a6975ea5c6edef98f7955dbdac0a31782a406198c864ca187a3beeb0822ef2e75
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# PokerCard
|
2
|
+
|
3
|
+
TODO: Delete this and the text below, and describe your gem
|
4
|
+
|
5
|
+
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/poker_card`. To experiment with that code, run `bin/console` for an interactive prompt.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
|
10
|
+
|
11
|
+
Install the gem and add to the application's Gemfile by executing:
|
12
|
+
|
13
|
+
$ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
|
14
|
+
|
15
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
16
|
+
|
17
|
+
$ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Development
|
24
|
+
|
25
|
+
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.
|
26
|
+
|
27
|
+
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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
28
|
+
|
29
|
+
## Contributing
|
30
|
+
|
31
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/poker_card.
|
@@ -0,0 +1,291 @@
|
|
1
|
+
# This file is automatically @generated by Cargo.
|
2
|
+
# It is not intended for manual editing.
|
3
|
+
version = 3
|
4
|
+
|
5
|
+
[[package]]
|
6
|
+
name = "aho-corasick"
|
7
|
+
version = "0.7.20"
|
8
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
9
|
+
checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac"
|
10
|
+
dependencies = [
|
11
|
+
"memchr",
|
12
|
+
]
|
13
|
+
|
14
|
+
[[package]]
|
15
|
+
name = "bindgen"
|
16
|
+
version = "0.60.1"
|
17
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
18
|
+
checksum = "062dddbc1ba4aca46de6338e2bf87771414c335f7b2f2036e8f3e9befebf88e6"
|
19
|
+
dependencies = [
|
20
|
+
"bitflags",
|
21
|
+
"cexpr",
|
22
|
+
"clang-sys",
|
23
|
+
"lazy_static",
|
24
|
+
"lazycell",
|
25
|
+
"peeking_take_while",
|
26
|
+
"proc-macro2",
|
27
|
+
"quote",
|
28
|
+
"regex",
|
29
|
+
"rustc-hash",
|
30
|
+
"shlex",
|
31
|
+
]
|
32
|
+
|
33
|
+
[[package]]
|
34
|
+
name = "bitflags"
|
35
|
+
version = "1.3.2"
|
36
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
37
|
+
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
38
|
+
|
39
|
+
[[package]]
|
40
|
+
name = "cc"
|
41
|
+
version = "1.0.78"
|
42
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
43
|
+
checksum = "a20104e2335ce8a659d6dd92a51a767a0c062599c73b343fd152cb401e828c3d"
|
44
|
+
|
45
|
+
[[package]]
|
46
|
+
name = "cexpr"
|
47
|
+
version = "0.6.0"
|
48
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
49
|
+
checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
|
50
|
+
dependencies = [
|
51
|
+
"nom",
|
52
|
+
]
|
53
|
+
|
54
|
+
[[package]]
|
55
|
+
name = "cfg-if"
|
56
|
+
version = "1.0.0"
|
57
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
58
|
+
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
59
|
+
|
60
|
+
[[package]]
|
61
|
+
name = "clang-sys"
|
62
|
+
version = "1.4.0"
|
63
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
64
|
+
checksum = "fa2e27ae6ab525c3d369ded447057bca5438d86dc3a68f6faafb8269ba82ebf3"
|
65
|
+
dependencies = [
|
66
|
+
"glob",
|
67
|
+
"libc",
|
68
|
+
"libloading",
|
69
|
+
]
|
70
|
+
|
71
|
+
[[package]]
|
72
|
+
name = "glob"
|
73
|
+
version = "0.3.1"
|
74
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
75
|
+
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
|
76
|
+
|
77
|
+
[[package]]
|
78
|
+
name = "holdem-hand-evaluator"
|
79
|
+
version = "0.1.0"
|
80
|
+
dependencies = [
|
81
|
+
"holdem-hand-evaluator-assets",
|
82
|
+
]
|
83
|
+
|
84
|
+
[[package]]
|
85
|
+
name = "holdem-hand-evaluator-assets"
|
86
|
+
version = "0.1.0"
|
87
|
+
|
88
|
+
[[package]]
|
89
|
+
name = "lazy_static"
|
90
|
+
version = "1.4.0"
|
91
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
92
|
+
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
93
|
+
|
94
|
+
[[package]]
|
95
|
+
name = "lazycell"
|
96
|
+
version = "1.3.0"
|
97
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
98
|
+
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
|
99
|
+
|
100
|
+
[[package]]
|
101
|
+
name = "libc"
|
102
|
+
version = "0.2.139"
|
103
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
104
|
+
checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79"
|
105
|
+
|
106
|
+
[[package]]
|
107
|
+
name = "libloading"
|
108
|
+
version = "0.7.4"
|
109
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
110
|
+
checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f"
|
111
|
+
dependencies = [
|
112
|
+
"cfg-if",
|
113
|
+
"winapi",
|
114
|
+
]
|
115
|
+
|
116
|
+
[[package]]
|
117
|
+
name = "magnus"
|
118
|
+
version = "0.4.4"
|
119
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
120
|
+
checksum = "fc87660cd7daa49fddbfd524c836de54d5c927d520cd163f43700c5087c57d6c"
|
121
|
+
dependencies = [
|
122
|
+
"magnus-macros",
|
123
|
+
"rb-sys",
|
124
|
+
"rb-sys-env",
|
125
|
+
]
|
126
|
+
|
127
|
+
[[package]]
|
128
|
+
name = "magnus-macros"
|
129
|
+
version = "0.3.0"
|
130
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
131
|
+
checksum = "206cb23bfeea05180c97522ef6a3e52a4eb17b0ed2f30ee3ca9c4f994d2378ae"
|
132
|
+
dependencies = [
|
133
|
+
"proc-macro2",
|
134
|
+
"quote",
|
135
|
+
"syn",
|
136
|
+
]
|
137
|
+
|
138
|
+
[[package]]
|
139
|
+
name = "memchr"
|
140
|
+
version = "2.5.0"
|
141
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
142
|
+
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
|
143
|
+
|
144
|
+
[[package]]
|
145
|
+
name = "minimal-lexical"
|
146
|
+
version = "0.2.1"
|
147
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
148
|
+
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
149
|
+
|
150
|
+
[[package]]
|
151
|
+
name = "nom"
|
152
|
+
version = "7.1.2"
|
153
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
154
|
+
checksum = "e5507769c4919c998e69e49c839d9dc6e693ede4cc4290d6ad8b41d4f09c548c"
|
155
|
+
dependencies = [
|
156
|
+
"memchr",
|
157
|
+
"minimal-lexical",
|
158
|
+
]
|
159
|
+
|
160
|
+
[[package]]
|
161
|
+
name = "peeking_take_while"
|
162
|
+
version = "0.1.2"
|
163
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
164
|
+
checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
|
165
|
+
|
166
|
+
[[package]]
|
167
|
+
name = "poker_card"
|
168
|
+
version = "0.4.0"
|
169
|
+
dependencies = [
|
170
|
+
"holdem-hand-evaluator",
|
171
|
+
"magnus",
|
172
|
+
]
|
173
|
+
|
174
|
+
[[package]]
|
175
|
+
name = "proc-macro2"
|
176
|
+
version = "1.0.49"
|
177
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
178
|
+
checksum = "57a8eca9f9c4ffde41714334dee777596264c7825420f521abc92b5b5deb63a5"
|
179
|
+
dependencies = [
|
180
|
+
"unicode-ident",
|
181
|
+
]
|
182
|
+
|
183
|
+
[[package]]
|
184
|
+
name = "quote"
|
185
|
+
version = "1.0.23"
|
186
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
187
|
+
checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b"
|
188
|
+
dependencies = [
|
189
|
+
"proc-macro2",
|
190
|
+
]
|
191
|
+
|
192
|
+
[[package]]
|
193
|
+
name = "rb-sys"
|
194
|
+
version = "0.9.55"
|
195
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
196
|
+
checksum = "9b0e0a7b82a0070b27f93f23ded0a53eb4ff293f9ae5fd5feb0cf4f569ec9534"
|
197
|
+
dependencies = [
|
198
|
+
"rb-sys-build",
|
199
|
+
]
|
200
|
+
|
201
|
+
[[package]]
|
202
|
+
name = "rb-sys-build"
|
203
|
+
version = "0.9.55"
|
204
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
205
|
+
checksum = "d6793b584f6689338ed60d0d2a9c5f0e3b12fc8fa735d7045c7dd1c9c638eaf6"
|
206
|
+
dependencies = [
|
207
|
+
"bindgen",
|
208
|
+
"cc",
|
209
|
+
"regex",
|
210
|
+
"shell-words",
|
211
|
+
]
|
212
|
+
|
213
|
+
[[package]]
|
214
|
+
name = "rb-sys-env"
|
215
|
+
version = "0.1.1"
|
216
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
217
|
+
checksum = "74c38752410925faeb82c400c06ba2fd9ee6aa8f719dd33994c9e53f5242d25f"
|
218
|
+
|
219
|
+
[[package]]
|
220
|
+
name = "regex"
|
221
|
+
version = "1.7.1"
|
222
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
223
|
+
checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733"
|
224
|
+
dependencies = [
|
225
|
+
"aho-corasick",
|
226
|
+
"memchr",
|
227
|
+
"regex-syntax",
|
228
|
+
]
|
229
|
+
|
230
|
+
[[package]]
|
231
|
+
name = "regex-syntax"
|
232
|
+
version = "0.6.28"
|
233
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
234
|
+
checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848"
|
235
|
+
|
236
|
+
[[package]]
|
237
|
+
name = "rustc-hash"
|
238
|
+
version = "1.1.0"
|
239
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
240
|
+
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
|
241
|
+
|
242
|
+
[[package]]
|
243
|
+
name = "shell-words"
|
244
|
+
version = "1.1.0"
|
245
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
246
|
+
checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde"
|
247
|
+
|
248
|
+
[[package]]
|
249
|
+
name = "shlex"
|
250
|
+
version = "1.1.0"
|
251
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
252
|
+
checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3"
|
253
|
+
|
254
|
+
[[package]]
|
255
|
+
name = "syn"
|
256
|
+
version = "1.0.107"
|
257
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
258
|
+
checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5"
|
259
|
+
dependencies = [
|
260
|
+
"proc-macro2",
|
261
|
+
"quote",
|
262
|
+
"unicode-ident",
|
263
|
+
]
|
264
|
+
|
265
|
+
[[package]]
|
266
|
+
name = "unicode-ident"
|
267
|
+
version = "1.0.6"
|
268
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
269
|
+
checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc"
|
270
|
+
|
271
|
+
[[package]]
|
272
|
+
name = "winapi"
|
273
|
+
version = "0.3.9"
|
274
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
275
|
+
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
276
|
+
dependencies = [
|
277
|
+
"winapi-i686-pc-windows-gnu",
|
278
|
+
"winapi-x86_64-pc-windows-gnu",
|
279
|
+
]
|
280
|
+
|
281
|
+
[[package]]
|
282
|
+
name = "winapi-i686-pc-windows-gnu"
|
283
|
+
version = "0.4.0"
|
284
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
285
|
+
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
286
|
+
|
287
|
+
[[package]]
|
288
|
+
name = "winapi-x86_64-pc-windows-gnu"
|
289
|
+
version = "0.4.0"
|
290
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
291
|
+
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
@@ -0,0 +1,140 @@
|
|
1
|
+
use core::cell::Ref;
|
2
|
+
use std::cell::RefCell;
|
3
|
+
|
4
|
+
use magnus::{define_module, function, method, prelude::*, wrap, Error};
|
5
|
+
|
6
|
+
use holdem_hand_evaluator::{
|
7
|
+
compute_alive_cards, get_card, get_hand_category, heads_up_win_frequency, Hand, HandCategory,
|
8
|
+
};
|
9
|
+
|
10
|
+
fn hand_category_to_string(hand_category: HandCategory) -> String {
|
11
|
+
match hand_category {
|
12
|
+
HandCategory::HighCard => String::from("HighCard"),
|
13
|
+
HandCategory::OnePair => String::from("OnePair"),
|
14
|
+
HandCategory::TwoPair => String::from("TwoPair"),
|
15
|
+
HandCategory::ThreeOfAKind => String::from("ThreeOfAKind"),
|
16
|
+
HandCategory::Straight => String::from("Straight"),
|
17
|
+
HandCategory::Flush => String::from("Flush"),
|
18
|
+
HandCategory::FullHouse => String::from("FullHouse"),
|
19
|
+
HandCategory::FourOfAKind => String::from("FourOfAKind"),
|
20
|
+
HandCategory::StraightFlush => String::from("StraightFlush"),
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
#[wrap(class = "PokerCard::RustHand")]
|
25
|
+
struct RustHand(RefCell<Hand>);
|
26
|
+
|
27
|
+
impl RustHand {
|
28
|
+
fn new() -> Self {
|
29
|
+
Self(RefCell::new(Hand::new()))
|
30
|
+
}
|
31
|
+
|
32
|
+
fn parse(string: String) -> Self {
|
33
|
+
Self(RefCell::new(string.parse::<Hand>().unwrap()))
|
34
|
+
}
|
35
|
+
|
36
|
+
fn size(&self) -> usize {
|
37
|
+
self.hand().len()
|
38
|
+
}
|
39
|
+
|
40
|
+
fn rank(&self) -> u16 {
|
41
|
+
self.hand().evaluate()
|
42
|
+
}
|
43
|
+
|
44
|
+
fn add_card(&self, val: usize) {
|
45
|
+
*self.0.borrow_mut() = self.hand().add_card(val);
|
46
|
+
}
|
47
|
+
|
48
|
+
fn category(&self) -> String {
|
49
|
+
hand_category_to_string(get_hand_category(self.rank()))
|
50
|
+
}
|
51
|
+
|
52
|
+
fn hand(&self) -> Ref<'_, Hand> {
|
53
|
+
self.0.borrow()
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
#[wrap(class = "PokerCard::RustHeadUp")]
|
58
|
+
struct RustHeadUp {}
|
59
|
+
|
60
|
+
impl RustHeadUp {
|
61
|
+
fn win_frequency(
|
62
|
+
hand1: &RustHand,
|
63
|
+
hand2: &RustHand,
|
64
|
+
board: &RustHand,
|
65
|
+
dead_cards: &RustHand,
|
66
|
+
) -> (u32, u32, u32) {
|
67
|
+
heads_up_win_frequency(
|
68
|
+
&hand1.hand(),
|
69
|
+
&hand2.hand(),
|
70
|
+
&board.hand(),
|
71
|
+
&dead_cards.hand(),
|
72
|
+
)
|
73
|
+
}
|
74
|
+
|
75
|
+
fn outs(
|
76
|
+
hand1: &RustHand,
|
77
|
+
hand2: &RustHand,
|
78
|
+
board: &RustHand,
|
79
|
+
dead_cards: &RustHand,
|
80
|
+
) -> Vec<String> {
|
81
|
+
let start_freq = heads_up_win_frequency(
|
82
|
+
&hand1.hand(),
|
83
|
+
&hand2.hand(),
|
84
|
+
&board.hand(),
|
85
|
+
&dead_cards.hand(),
|
86
|
+
);
|
87
|
+
let win_hand;
|
88
|
+
let lose_hand;
|
89
|
+
if start_freq.0 > start_freq.1 {
|
90
|
+
win_hand = hand1;
|
91
|
+
lose_hand = hand2;
|
92
|
+
} else {
|
93
|
+
win_hand = hand2;
|
94
|
+
lose_hand = hand1;
|
95
|
+
}
|
96
|
+
|
97
|
+
let alive_cards = compute_alive_cards(
|
98
|
+
hand1.hand().get_mask()
|
99
|
+
| hand2.hand().get_mask()
|
100
|
+
| board.hand().get_mask()
|
101
|
+
| dead_cards.hand().get_mask(),
|
102
|
+
);
|
103
|
+
let mut return_v: Vec<String> = vec![];
|
104
|
+
|
105
|
+
for card in alive_cards.iter() {
|
106
|
+
let b = board.hand().clone();
|
107
|
+
|
108
|
+
let freq = heads_up_win_frequency(
|
109
|
+
&win_hand.hand(),
|
110
|
+
&lose_hand.hand(),
|
111
|
+
&b.add_card(*card),
|
112
|
+
&dead_cards.hand(),
|
113
|
+
);
|
114
|
+
|
115
|
+
if freq.0 <= freq.1 {
|
116
|
+
return_v.push(get_card(*card));
|
117
|
+
}
|
118
|
+
}
|
119
|
+
return_v
|
120
|
+
}
|
121
|
+
}
|
122
|
+
|
123
|
+
#[magnus::init]
|
124
|
+
fn init() -> Result<(), Error> {
|
125
|
+
let module = define_module("PokerCard")?;
|
126
|
+
|
127
|
+
let class = module.define_class("RustHand", Default::default())?;
|
128
|
+
class.define_singleton_method("new", function!(RustHand::new, 0))?;
|
129
|
+
class.define_singleton_method("parse", function!(RustHand::parse, 1))?;
|
130
|
+
class.define_method("size", method!(RustHand::size, 0))?;
|
131
|
+
class.define_method("add_card", method!(RustHand::add_card, 1))?;
|
132
|
+
class.define_method("category", method!(RustHand::category, 0))?;
|
133
|
+
class.define_method("rank", method!(RustHand::rank, 0))?;
|
134
|
+
|
135
|
+
let class = module.define_module("RustHeadUp")?;
|
136
|
+
class.define_singleton_method("win_frequency", function!(RustHeadUp::win_frequency, 4))?;
|
137
|
+
class.define_singleton_method("outs", function!(RustHeadUp::outs, 4))?;
|
138
|
+
|
139
|
+
Ok(())
|
140
|
+
}
|
Binary file
|
data/lib/poker_card.rb
ADDED
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: poker_card
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- kyohah
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-03-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake-compiler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rb_sys
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Write a longer description or delete this line.
|
42
|
+
email:
|
43
|
+
- kyohah@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions:
|
46
|
+
- ext/poker_card/extconf.rb
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- README.md
|
50
|
+
- ext/poker_card/Cargo.lock
|
51
|
+
- ext/poker_card/Cargo.toml
|
52
|
+
- ext/poker_card/extconf.rb
|
53
|
+
- ext/poker_card/src/lib.rs
|
54
|
+
- lib/poker_card.rb
|
55
|
+
- lib/poker_card/poker_card.bundle
|
56
|
+
- lib/poker_card/version.rb
|
57
|
+
homepage: https://github.com/kyohah/poker_card
|
58
|
+
licenses: []
|
59
|
+
metadata:
|
60
|
+
homepage_uri: https://github.com/kyohah/poker_card
|
61
|
+
source_code_uri: https://github.com/kyohah/poker_card
|
62
|
+
changelog_uri: https://github.com/kyohah/poker_card/CHANGELOG.md
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: 2.6.0
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
requirements: []
|
78
|
+
rubygems_version: 3.4.1
|
79
|
+
signing_key:
|
80
|
+
specification_version: 4
|
81
|
+
summary: Write a short summary, because RubyGems requires one.
|
82
|
+
test_files: []
|