jkf 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jkf/converter/ki2.rb +1 -1
- data/lib/jkf/converter/kif.rb +1 -1
- data/lib/jkf/parser/kif.rb +17 -4
- data/lib/jkf/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc949b63200215816a909361e5bfd25e7e500a75
|
4
|
+
data.tar.gz: 4c3401109c8a2605ec059125150da420bf765bb9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64198f8a7885426c309a9700ec4e576363bdf339f0e523a4b0ea0375552fc4d51ca5f457945cb7271fc585dc494ccf3d9f75132620dbecdc306b05c01d887f97
|
7
|
+
data.tar.gz: 298dd0d297f5897fd1cf4065d00a6d49e687fc577c8fc7368a71981689ba87aaa6d9cbfe099f3bd87b4201d85f7ef59352fc5a8ced0da415af1d489b2b4725fb
|
data/lib/jkf/converter/ki2.rb
CHANGED
data/lib/jkf/converter/kif.rb
CHANGED
data/lib/jkf/parser/kif.rb
CHANGED
@@ -57,7 +57,7 @@ module Jkf::Parser
|
|
57
57
|
end
|
58
58
|
if ret["initial"] && ret["initial"]["data"]
|
59
59
|
if ret["header"]["手番"]
|
60
|
-
ret["initial"]["data"]["color"] = ("下先".
|
60
|
+
ret["initial"]["data"]["color"] = ("下先".include?(ret["header"]["手番"]) ? 0 : 1)
|
61
61
|
ret["header"].delete("手番")
|
62
62
|
else
|
63
63
|
ret["initial"]["data"]["color"] = 0
|
@@ -81,6 +81,7 @@ module Jkf::Parser
|
|
81
81
|
fork_stack << _fork
|
82
82
|
fork_stack << now_fork
|
83
83
|
end
|
84
|
+
reverse_color(ret['moves']) if ret["initial"] && ret["initial"]["data"] && ret["initial"]["data"]["color"] == 1
|
84
85
|
ret
|
85
86
|
}.call(s2, s3, s4, s6, s7)
|
86
87
|
s0 = s1
|
@@ -634,8 +635,8 @@ module Jkf::Parser
|
|
634
635
|
s6 = parse_from
|
635
636
|
if s6 != :failed
|
636
637
|
@reported_pos = s4
|
637
|
-
s5 = -> (fugou, from) {
|
638
|
-
ret = { "piece" => fugou["piece"] }
|
638
|
+
s5 = -> (teban, fugou, from) {
|
639
|
+
ret = { "color" => teban2color(teban.join), "piece" => fugou["piece"] }
|
639
640
|
if fugou["to"]
|
640
641
|
ret["to"] = fugou["to"]
|
641
642
|
else
|
@@ -644,7 +645,7 @@ module Jkf::Parser
|
|
644
645
|
ret["promote"] = true if fugou["promote"]
|
645
646
|
ret["from"] = from if from
|
646
647
|
ret
|
647
|
-
}.call(s5, s6)
|
648
|
+
}.call(s2, s5, s6)
|
648
649
|
s4 = s5
|
649
650
|
else
|
650
651
|
@current_pos = s4
|
@@ -1519,6 +1520,11 @@ module Jkf::Parser
|
|
1519
1520
|
}[preset.gsub(/\s/, "")]
|
1520
1521
|
end
|
1521
1522
|
|
1523
|
+
def teban2color(teban)
|
1524
|
+
teban = teban.to_i unless teban.is_a? Fixnum
|
1525
|
+
(teban+1) % 2
|
1526
|
+
end
|
1527
|
+
|
1522
1528
|
def make_hand(str)
|
1523
1529
|
# Kifu for iPhoneは半角スペース区切り
|
1524
1530
|
kinds = str.split(/[ ]/)
|
@@ -1532,5 +1538,12 @@ module Jkf::Parser
|
|
1532
1538
|
|
1533
1539
|
ret
|
1534
1540
|
end
|
1541
|
+
|
1542
|
+
def reverse_color(moves)
|
1543
|
+
moves.each do |move|
|
1544
|
+
move['move']['color'] = (move['move']['color'] + 1) % 2 if move['move'] && move['move']['color']
|
1545
|
+
move['forks'].each { |_fork| reverse_color(_fork) } if move['forks']
|
1546
|
+
end
|
1547
|
+
end
|
1535
1548
|
end
|
1536
1549
|
end
|
data/lib/jkf/version.rb
CHANGED