poker-engine 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +31 -7
- data/lib/poker_engine/next_actions.rb +1 -1
- data/lib/poker_engine/state_operations.rb +2 -0
- data/lib/poker_engine/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83f609edbce3d087076e1d4ab3fba82d8192c6cb05fafbe05448d730107d6bdd
|
4
|
+
data.tar.gz: 75aec7bda7ca453d7180911769e60811802bbcf9124c1dab9b8e2fe2a7e8e10f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c279ae94aac1d1513ae32cc3b38363b15f6a888269051d7c06e80f4a92f0ba34bbc5a9b1ae73e63f55f1b0c3249cd19d9c491a7f232f3bfba51a94ba93461b98
|
7
|
+
data.tar.gz: af65b637c5000dc9503246dc65f07adf546a5a687657cf67f7c5bfc742fd5059027816314ee687d2fd3bf19d56d7f884bb6646dd8350e4c8afa5e964c46f975e
|
data/README.md
CHANGED
@@ -1,9 +1,12 @@
|
|
1
|
-
#
|
2
|
-
Poker library written in Ruby :heart:
|
1
|
+
# Poker Engine
|
3
2
|
|
4
|
-
|
3
|
+
Horizontally scalable, immutable, and thread-safe poker library written in Ruby,
|
4
|
+
utilizing the [Redux design pattern](https://redux.js.org/recipes/structuring-reducers/structuring-reducers#structuring-reducers)
|
5
|
+
and [Persistent data structures](https://en.wikipedia.org/wiki/Persistent_data_structure).
|
5
6
|
|
6
|
-
|
7
|
+
## Example
|
8
|
+
|
9
|
+
There is a simple console interface that you can run `./examples/simple-gameplay.rb` and play against yourself!
|
7
10
|
|
8
11
|
Valid moves:
|
9
12
|
- check
|
@@ -12,7 +15,28 @@ Valid moves:
|
|
12
15
|
- raise [bet amount], example: __raise 100__
|
13
16
|
|
14
17
|
## Documentation
|
15
|
-
In progress
|
16
|
-
## Tests
|
17
18
|
|
18
|
-
|
19
|
+
You can think about the `PokerEngine::Game` like for a state machine. You can initiate it with `.start` and you can transition from one state in another with `.next`.
|
20
|
+
|
21
|
+
For more info check you can check the [console example](./examples/simple-gameplay.rb) or the [integration spec](./spec/integration_spec.rb).
|
22
|
+
|
23
|
+
## Setup
|
24
|
+
|
25
|
+
1. Make sure you have Ruby and bundler installed
|
26
|
+
|
27
|
+
2. Clone the repo
|
28
|
+
|
29
|
+
```shell
|
30
|
+
git clone git@github.com:kanevk/poker-engine.git
|
31
|
+
```
|
32
|
+
|
33
|
+
3. Install the dependencies
|
34
|
+
```shell
|
35
|
+
bundle
|
36
|
+
```
|
37
|
+
|
38
|
+
4. Run tests
|
39
|
+
|
40
|
+
```shell
|
41
|
+
bundle exec rspec -fd
|
42
|
+
```
|
@@ -19,7 +19,7 @@ module PokerEngine
|
|
19
19
|
when :check, :call, :raise, :fold
|
20
20
|
player_id = state_operations.next_player_id
|
21
21
|
|
22
|
-
if player_id == state[:current_player_id]
|
22
|
+
if player_id == state[:current_player_id] || state_operations.one_player_left?
|
23
23
|
[{ type: :game_end, winner_ids: [player_id] }]
|
24
24
|
elsif player_id == state[:aggressor_id] && !state_operations.next_stage?
|
25
25
|
players = Hamster.to_ruby state[:players].values
|
@@ -26,6 +26,8 @@ module PokerEngine
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def next_player_id
|
29
|
+
raise 'Invalid state' if active_players.count.zero?
|
30
|
+
|
29
31
|
ordered_player_ids.cycle.each_with_index.find do |id, order_index|
|
30
32
|
order_index > ordered_player_ids.index(state[:current_player_id]) &&
|
31
33
|
players[id][:active]
|
data/lib/poker_engine/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: poker-engine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kamen Kanev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hamster
|