jkf 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/jkf/converter/csa.rb +13 -5
- data/lib/jkf/converter/kif.rb +4 -2
- data/lib/jkf/converter/kifuable.rb +0 -2
- data/lib/jkf/version.rb +1 -1
- metadata +3 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ea59b45dcef66f1538bdd64d25fba421e6c5c7f458846dccfd5727b49755d420
|
4
|
+
data.tar.gz: db04f6d1d141e00700d785c4026064ae69d6a547051defdb52fb325c3d98acb5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9104756b9fecb562b97e90ff5e191603b1b4437e94edd228a4c2f986f0e09c64d1047236c7c432f16b904e079241d0425c0e6f97d5e010dc2505da0d3adb4d50
|
7
|
+
data.tar.gz: fe28d5a3f3077d27b854435242ed4d98a71eec681b089428a990501b42a9ab4189138a681ce565c395d8e9c8e3d812eb8894ed70dc625d94b9f251485d047867
|
data/lib/jkf/converter/csa.rb
CHANGED
@@ -27,7 +27,7 @@ module Jkf::Converter
|
|
27
27
|
|
28
28
|
def convert_initial(initial)
|
29
29
|
result = ""
|
30
|
-
data = initial["data"]
|
30
|
+
data = initial["data"] || {}
|
31
31
|
result += if initial["preset"] == "OTHER"
|
32
32
|
convert_board(data["board"])
|
33
33
|
else
|
@@ -56,9 +56,10 @@ module Jkf::Converter
|
|
56
56
|
|
57
57
|
def convert_moves(moves)
|
58
58
|
result = ""
|
59
|
+
before_pos = nil
|
59
60
|
moves.each do |move|
|
60
61
|
next if move == {}
|
61
|
-
result += convert_move(move["move"]) if move["move"]
|
62
|
+
result += convert_move(move["move"], before_pos) if move["move"]
|
62
63
|
result += convert_special(move["special"], move["color"]) if move["special"]
|
63
64
|
if move["time"]
|
64
65
|
result += "," + convert_time(move["time"])
|
@@ -66,14 +67,20 @@ module Jkf::Converter
|
|
66
67
|
result += "\n"
|
67
68
|
end
|
68
69
|
result += convert_comments(move["comments"]) if move["comments"]
|
70
|
+
before_pos = move["move"]["to"] if move["move"] && move["move"]["to"]
|
69
71
|
end
|
70
72
|
result
|
71
73
|
end
|
72
74
|
|
73
|
-
def convert_move(move)
|
75
|
+
def convert_move(move, before_pos)
|
74
76
|
result = csa_color(move["color"])
|
75
77
|
result += move["from"] ? pos2str(move["from"]) : "00"
|
76
|
-
result
|
78
|
+
result += if move["to"]
|
79
|
+
pos2str(move["to"]) + move["piece"]
|
80
|
+
else
|
81
|
+
pos2str(before_pos) + move["piece"]
|
82
|
+
end
|
83
|
+
result
|
77
84
|
end
|
78
85
|
|
79
86
|
def convert_special(special, color = nil)
|
@@ -111,7 +118,8 @@ module Jkf::Converter
|
|
111
118
|
def convert_preset(preset)
|
112
119
|
"PI" +
|
113
120
|
case preset
|
114
|
-
when "HIRATE"
|
121
|
+
when "HIRATE" # 平手
|
122
|
+
""
|
115
123
|
when "KY" # 香落ち
|
116
124
|
"11KY"
|
117
125
|
when "KY_R" # 右香落ち
|
data/lib/jkf/converter/kif.rb
CHANGED
@@ -10,7 +10,7 @@ module Jkf::Converter
|
|
10
10
|
setup_players!(jkf)
|
11
11
|
|
12
12
|
result = ""
|
13
|
-
result += convert_header(jkf["header"]) if jkf["header"]
|
13
|
+
result += convert_header(jkf["header"], jkf) if jkf["header"]
|
14
14
|
result += convert_initial(jkf["initial"]) if jkf["initial"]
|
15
15
|
result += @header2.join
|
16
16
|
result += "手数----指手---------消費時間--\n"
|
@@ -23,7 +23,7 @@ module Jkf::Converter
|
|
23
23
|
result
|
24
24
|
end
|
25
25
|
|
26
|
-
def convert_header(header)
|
26
|
+
def convert_header(header, jkf)
|
27
27
|
header.map do |(key, value)|
|
28
28
|
result = "#{key}:#{value}\n"
|
29
29
|
if key =~ /\A[先後上下]手\Z/
|
@@ -33,6 +33,8 @@ module Jkf::Converter
|
|
33
33
|
@header2 << result
|
34
34
|
end
|
35
35
|
nil
|
36
|
+
elsif key == "手合割" && jkf["initial"] && jkf["initial"]["preset"] && value == preset2str(jkf["initial"]["preset"])
|
37
|
+
nil
|
36
38
|
else
|
37
39
|
result
|
38
40
|
end
|
data/lib/jkf/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jkf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- iyuuya
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: converter/parser of records of shogi
|
14
14
|
email:
|
@@ -66,10 +66,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
66
66
|
- !ruby/object:Gem::Version
|
67
67
|
version: '0'
|
68
68
|
requirements: []
|
69
|
-
|
70
|
-
rubygems_version: 2.5.1
|
69
|
+
rubygems_version: 3.0.3
|
71
70
|
signing_key:
|
72
71
|
specification_version: 4
|
73
72
|
summary: jkf/csa/kif/ki2 parser and converter
|
74
73
|
test_files: []
|
75
|
-
has_rdoc:
|