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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3671bd3e91867b5fe62e2618b7619a0c9cd75c625e840fdca34362ec0e45b1b3
4
- data.tar.gz: 76629e02cdd5f6716ff72a2b42326afd98c18e386f20e0c97f756dd90be857ce
3
+ metadata.gz: 83f609edbce3d087076e1d4ab3fba82d8192c6cb05fafbe05448d730107d6bdd
4
+ data.tar.gz: 75aec7bda7ca453d7180911769e60811802bbcf9124c1dab9b8e2fe2a7e8e10f
5
5
  SHA512:
6
- metadata.gz: 4dbbcc3cfeacdb24bf11cced9854b464a66523e622f64a5be4cc28ea3ad6add68267f3fa0a87b103fba1de37043e8e9017cbdf8d719524efc8f2baab61f7c214
7
- data.tar.gz: 02dd3fd0fd6a7e23370b07ebc3ecdcc25660a58073215ec55d64b1f98b61667ccdee6e0e8752ab743a06df301d25d838eca312922107b74b274424ca040c31e0
6
+ metadata.gz: c279ae94aac1d1513ae32cc3b38363b15f6a888269051d7c06e80f4a92f0ba34bbc5a9b1ae73e63f55f1b0c3249cd19d9c491a7f232f3bfba51a94ba93461b98
7
+ data.tar.gz: af65b637c5000dc9503246dc65f07adf546a5a687657cf67f7c5bfc742fd5059027816314ee687d2fd3bf19d56d7f884bb6646dd8350e4c8afa5e964c46f975e
data/README.md CHANGED
@@ -1,9 +1,12 @@
1
- # poker-engine
2
- Poker library written in Ruby :heart:
1
+ # Poker Engine
3
2
 
4
- ## Try it
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
- There is simple console interface, run `./examples/simple-gameplay.rb` and play!
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
- Run `rspec`
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]
@@ -1,3 +1,3 @@
1
1
  module PokerEngine
2
- VERSION = '1.1.1'.freeze
2
+ VERSION = '1.1.2'.freeze
3
3
  end
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.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-09-29 00:00:00.000000000 Z
11
+ date: 2020-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hamster