qi 10.0.0.beta2 → 10.0.0.beta4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/lib/qi/action.rb +9 -23
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eac5eea8bb1218d4db55138e7d80a4dcba2feb9ebe300e78235df8e558879856
4
- data.tar.gz: b81aece5af901f081d598a1e40a128ebff19dca023a61385a5b46de2648a4df6
3
+ metadata.gz: ba69668b35781db7bbad0806b6940d99924fa3693355f01538b14bb8ebf159e7
4
+ data.tar.gz: 8447f2df3687f661762d1a99adffc31640d693f52a4012adf2f89825b2614239
5
5
  SHA512:
6
- metadata.gz: e4c7e2919813e59af6f4d45bde55bcb575512026a525a2994c3a62f21becbc85c5b95cecbd44a9de96cabc6c379dd92765fce6fad9c99cf21d98ef24aaa88df8
7
- data.tar.gz: '0562650908ba50fd11cc086899170a69542b5d459bd49c9c4c3e189e028a33a25087dfb419d4df0e00d57e1058b7b832360d465e7ec89a86cb614013d1956ffb'
6
+ metadata.gz: 00aa0f50dd054bc1c15a0de068b4c7e2e3e18d2fc63da9db8c781f72058efc472409fe474545a6b088cb9a5b62ad87120baebbb3ad24e3cada79d6a3726f02c6
7
+ data.tar.gz: d6909071d69cd7308e2655a5331b1d522e424cf05b002a73da5a54e4c7f570533d44c7db23111f4b609d876bf415b742127e0613b38685a49ccc465638c57427
data/README.md CHANGED
@@ -13,7 +13,7 @@
13
13
  Add this line to your application's Gemfile:
14
14
 
15
15
  ```ruby
16
- gem "qi", ">= 10.0.0.beta2"
16
+ gem "qi", ">= 10.0.0.beta3"
17
17
  ```
18
18
 
19
19
  And then execute:
data/lib/qi/action.rb CHANGED
@@ -16,33 +16,19 @@ module Qi
16
16
  #
17
17
  # @return [Array] An action to change the position.
18
18
  def call(**diffs)
19
- captures = @captures
20
- squares = @squares
19
+ captures = @captures + Array(diffs.delete(CAPTURE_CHAR))
20
+ drop = diffs.delete(DROP_CHAR)
21
21
 
22
- diffs.each do |k, v|
23
- case String(k)
24
- when CAPTURE_CHAR
25
- captures = capture(v, *captures)
26
- when DROP_CHAR
27
- captures = drop(v, *captures)
28
- else
29
- squares = squares.merge(k => v)
30
- end
31
- end
32
-
33
- [captures, squares.compact]
34
- end
22
+ unless drop.nil?
23
+ index = captures.rindex(drop)
24
+ raise ::IndexError, "Piece #{drop.inspect} not captured!" if index.nil?
35
25
 
36
- private
26
+ captures.delete_at(index)
27
+ end
37
28
 
38
- def capture(item, *items)
39
- [item] + items
40
- end
29
+ squares = @squares.merge(diffs).compact
41
30
 
42
- def drop(item, *items)
43
- item_id = items.index(item) || raise(::IndexError, "Piece #{item.inspect} not found!")
44
- items.delete_at(item_id)
45
- items
31
+ [captures.sort, squares]
46
32
  end
47
33
  end
48
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qi
3
3
  version: !ruby/object:Gem::Version
4
- version: 10.0.0.beta2
4
+ version: 10.0.0.beta4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyril Kato
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-18 00:00:00.000000000 Z
11
+ date: 2023-04-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: An abstraction that could help to update positions for games like Shogi.
14
14
  email: contact@cyril.email
@@ -41,7 +41,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
41
41
  - !ruby/object:Gem::Version
42
42
  version: 1.3.1
43
43
  requirements: []
44
- rubygems_version: 3.4.1
44
+ rubygems_version: 3.4.6
45
45
  signing_key:
46
46
  specification_version: 4
47
47
  summary: An abstraction that could help to update positions for games like Shogi.