qi 10.0.0.beta3 → 10.0.0.beta4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/qi/action.rb +9 -10
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ed62693adaee42b6e7a64ea4e3475154b3ba8cf1af7a68d0ec33835183ec7270
4
- data.tar.gz: 2d1fde31acc76b566da0ad07126debb554b26623417ed5b450da6310765bff15
3
+ metadata.gz: ba69668b35781db7bbad0806b6940d99924fa3693355f01538b14bb8ebf159e7
4
+ data.tar.gz: 8447f2df3687f661762d1a99adffc31640d693f52a4012adf2f89825b2614239
5
5
  SHA512:
6
- metadata.gz: 50722f79e25fa9012be5c44a93b6bc4667b03caae75de426fe84ab62b007a241bf9c956c7ce03843348f673a273d7a543dae05af2479b4f66ef0e929e6f8cfd2
7
- data.tar.gz: 9f11b1e6ef5fe6a901bea7242f94d7640789c114ec6173e6047e15b48d67a38fad18e3bc0fda3962cd9b148558d65142abb563225802e4f3fb788a025d4826d1
6
+ metadata.gz: 00aa0f50dd054bc1c15a0de068b4c7e2e3e18d2fc63da9db8c781f72058efc472409fe474545a6b088cb9a5b62ad87120baebbb3ad24e3cada79d6a3726f02c6
7
+ data.tar.gz: d6909071d69cd7308e2655a5331b1d522e424cf05b002a73da5a54e4c7f570533d44c7db23111f4b609d876bf415b742127e0613b38685a49ccc465638c57427
data/lib/qi/action.rb CHANGED
@@ -16,20 +16,19 @@ module Qi
16
16
  #
17
17
  # @return [Array] An action to change the position.
18
18
  def call(**diffs)
19
- capture = diffs.delete(CAPTURE_CHAR)
20
- drop = diffs.delete(DROP_CHAR)
19
+ captures = @captures + Array(diffs.delete(CAPTURE_CHAR))
20
+ drop = diffs.delete(DROP_CHAR)
21
21
 
22
- change(*@captures, capture:, drop:, **diffs)
23
- end
22
+ unless drop.nil?
23
+ index = captures.rindex(drop)
24
+ raise ::IndexError, "Piece #{drop.inspect} not captured!" if index.nil?
24
25
 
25
- private
26
+ captures.delete_at(index)
27
+ end
26
28
 
27
- def change(*captures, capture: nil, drop: nil, **squares)
28
- captures.unshift(capture) unless capture.nil?
29
- captures.delete(drop) { |key| raise ::IndexError, "Capture #{key.inspect} not found!" } unless drop.nil?
30
- squares = @squares.merge(squares).compact
29
+ squares = @squares.merge(diffs).compact
31
30
 
32
- [captures, squares]
31
+ [captures.sort, squares]
33
32
  end
34
33
  end
35
34
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qi
3
3
  version: !ruby/object:Gem::Version
4
- version: 10.0.0.beta3
4
+ version: 10.0.0.beta4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyril Kato