jkf 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/jkf/converter/ki2.rb +37 -13
- data/lib/jkf/converter/kif.rb +36 -13
- 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: 80b961d103b0c7155b4ac36d77e9d3ddb40a03a3
|
4
|
+
data.tar.gz: b22def70291acf60b94fa289614fd8b254c6ac8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f7e92e39cf7caa4de99366b4645de4a42a57d664eb8b10e832d1fa651a03d07d053c3f3f5eb4685a4cde3bc38f65b7c5166b8c0f65acb0d5aee33c5240d0264
|
7
|
+
data.tar.gz: dca0b0cbe829920b2ef816e138592965f4b62e7ca00115de5509558853987b56150f3a11b8af6a3fb7443cfeb8102e87a0710a1bcd4cd8de5ad613ae5e826c53
|
data/lib/jkf/converter/ki2.rb
CHANGED
@@ -8,9 +8,19 @@ module Jkf::Converter
|
|
8
8
|
end
|
9
9
|
@forks = []
|
10
10
|
|
11
|
+
players_flag = :sengo
|
12
|
+
hash['header'] && hash['header'].keys.find { |key| key =~ /[上下]手/ } && players_flag = :uwasimo
|
13
|
+
@players = if players_flag == :uwasimo
|
14
|
+
['下', '上']
|
15
|
+
else
|
16
|
+
['先', '後']
|
17
|
+
end
|
18
|
+
@header2 = []
|
19
|
+
|
11
20
|
result = ''
|
12
21
|
result += convert_header(hash['header']) if hash['header']
|
13
22
|
result += convert_initial(hash['initial']) if hash['initial']
|
23
|
+
result += @header2.join
|
14
24
|
result += convert_moves(hash['moves']) if hash['moves']
|
15
25
|
if @forks.size > 0
|
16
26
|
result += "\n"
|
@@ -21,33 +31,45 @@ module Jkf::Converter
|
|
21
31
|
end
|
22
32
|
|
23
33
|
def convert_header(header)
|
24
|
-
header.map { |(key, value)|
|
34
|
+
header.map { |(key, value)|
|
35
|
+
result = "#{key}:#{value}\n"
|
36
|
+
if key =~ /\A[先後上下]手\Z/
|
37
|
+
if key =~ /[先下]/
|
38
|
+
@header2.unshift result
|
39
|
+
else
|
40
|
+
@header2 << result
|
41
|
+
end
|
42
|
+
nil
|
43
|
+
else
|
44
|
+
result
|
45
|
+
end
|
46
|
+
}.compact.join
|
25
47
|
end
|
26
48
|
|
49
|
+
|
27
50
|
def convert_initial(initial)
|
28
51
|
result = ''
|
29
52
|
result += "手合割:#{preset2str(initial["preset"])}\n" if initial["preset"] != "OTHER"
|
53
|
+
footer = ''
|
30
54
|
|
31
55
|
data = initial["data"]
|
32
56
|
|
33
57
|
if data
|
34
|
-
if data['color'] ==
|
35
|
-
result += "先手番\n"
|
36
|
-
elsif data['color'] == 1
|
37
|
-
result += "後手番\n"
|
38
|
-
end
|
58
|
+
result += "#{@players[1]}手番\n" if data['color'] == 1
|
39
59
|
|
40
60
|
if data['hands']
|
41
|
-
if data['hands'][0]
|
42
|
-
result += '先手の持駒:'
|
43
|
-
result += convert_motigoma(data['hands'][0])
|
44
|
-
end
|
45
61
|
if data['hands'][1]
|
46
|
-
result +=
|
62
|
+
result += "#{@players[1]}手の持駒:"
|
47
63
|
result += convert_motigoma(data['hands'][1])
|
48
64
|
end
|
65
|
+
if data['hands'][0]
|
66
|
+
footer += "#{@players[0]}手の持駒:"
|
67
|
+
footer += convert_motigoma(data['hands'][0])
|
68
|
+
end
|
49
69
|
end
|
50
70
|
|
71
|
+
footer += "#{@players[0]}手番\n" if data['color'] == 0
|
72
|
+
|
51
73
|
if data['board']
|
52
74
|
result += " 9 8 7 6 5 4 3 2 1\n"
|
53
75
|
result += "+---------------------------+\n"
|
@@ -63,6 +85,8 @@ module Jkf::Converter
|
|
63
85
|
end
|
64
86
|
end
|
65
87
|
|
88
|
+
result += footer
|
89
|
+
|
66
90
|
result
|
67
91
|
end
|
68
92
|
|
@@ -119,7 +143,7 @@ module Jkf::Converter
|
|
119
143
|
result = "まで#{index+1}手"
|
120
144
|
|
121
145
|
if special == 'TORYO' || special =~ /ILLEGAL/
|
122
|
-
turn = index % 2
|
146
|
+
turn = @players[index % 2]
|
123
147
|
result += "で#{turn}手の"
|
124
148
|
result += case special
|
125
149
|
when "TORYO" then "勝ち"
|
@@ -127,7 +151,7 @@ module Jkf::Converter
|
|
127
151
|
when "ILLEGAL_MOVE" then "反則負け"
|
128
152
|
end
|
129
153
|
else
|
130
|
-
turn = index % 2
|
154
|
+
turn = @players[(index+1) % 2]
|
131
155
|
result += case special
|
132
156
|
when "TIME_UP" then "で時間切れにより#{turn}手の勝ち"
|
133
157
|
when "CHUDAN" then "で中断"
|
data/lib/jkf/converter/kif.rb
CHANGED
@@ -8,9 +8,19 @@ module Jkf::Converter
|
|
8
8
|
end
|
9
9
|
@forks = []
|
10
10
|
|
11
|
+
players_flag = :sengo
|
12
|
+
hash['header'] && hash['header'].keys.find { |key| key =~ /[上下]手/ } && players_flag = :uwasimo
|
13
|
+
@players = if players_flag == :uwasimo
|
14
|
+
['下', '上']
|
15
|
+
else
|
16
|
+
['先', '後']
|
17
|
+
end
|
18
|
+
@header2 = []
|
19
|
+
|
11
20
|
result = ''
|
12
21
|
result += convert_header(hash['header']) if hash['header']
|
13
22
|
result += convert_initial(hash['initial']) if hash['initial']
|
23
|
+
result += @header2.join
|
14
24
|
result += "手数----指手---------消費時間--\n"
|
15
25
|
result += convert_moves(hash['moves'])
|
16
26
|
if @forks.size > 0
|
@@ -24,33 +34,44 @@ module Jkf::Converter
|
|
24
34
|
protected
|
25
35
|
|
26
36
|
def convert_header(header)
|
27
|
-
header.map { |(key, value)|
|
37
|
+
header.map { |(key, value)|
|
38
|
+
result = "#{key}:#{value}\n"
|
39
|
+
if key =~ /\A[先後上下]手\Z/
|
40
|
+
if key =~ /[先下]/
|
41
|
+
@header2.unshift result
|
42
|
+
else
|
43
|
+
@header2 << result
|
44
|
+
end
|
45
|
+
nil
|
46
|
+
else
|
47
|
+
result
|
48
|
+
end
|
49
|
+
}.compact.join
|
28
50
|
end
|
29
51
|
|
30
52
|
def convert_initial(initial)
|
31
53
|
result = ''
|
32
54
|
result += "手合割:#{preset2str(initial["preset"])}\n" if initial["preset"] != "OTHER"
|
55
|
+
footer = ''
|
33
56
|
|
34
57
|
data = initial["data"]
|
35
58
|
|
36
59
|
if data
|
37
|
-
if data['color'] ==
|
38
|
-
result += "先手番\n"
|
39
|
-
elsif data['color'] == 1
|
40
|
-
result += "後手番\n"
|
41
|
-
end
|
60
|
+
result += "#{@players[1]}手番\n" if data['color'] == 1
|
42
61
|
|
43
62
|
if data['hands']
|
44
|
-
if data['hands'][0]
|
45
|
-
result += '先手の持駒:'
|
46
|
-
result += convert_motigoma(data['hands'][0])
|
47
|
-
end
|
48
63
|
if data['hands'][1]
|
49
|
-
result +=
|
64
|
+
result += "#{@players[1]}手の持駒:"
|
50
65
|
result += convert_motigoma(data['hands'][1])
|
51
66
|
end
|
67
|
+
if data['hands'][0]
|
68
|
+
footer += "#{@players[0]}手の持駒:"
|
69
|
+
footer += convert_motigoma(data['hands'][0])
|
70
|
+
end
|
52
71
|
end
|
53
72
|
|
73
|
+
footer += "#{@players[0]}手番\n" if data['color'] == 0
|
74
|
+
|
54
75
|
if data['board']
|
55
76
|
result += " 9 8 7 6 5 4 3 2 1\n"
|
56
77
|
result += "+---------------------------+\n"
|
@@ -66,6 +87,8 @@ module Jkf::Converter
|
|
66
87
|
end
|
67
88
|
end
|
68
89
|
|
90
|
+
result += footer
|
91
|
+
|
69
92
|
result
|
70
93
|
end
|
71
94
|
|
@@ -134,7 +157,7 @@ module Jkf::Converter
|
|
134
157
|
result = "まで#{index+1}手"
|
135
158
|
|
136
159
|
if special == 'TORYO' || special =~ /ILLEGAL/
|
137
|
-
turn = index % 2
|
160
|
+
turn = @players[index % 2]
|
138
161
|
result += "で#{turn}手の"
|
139
162
|
result += case special
|
140
163
|
when "TORYO" then "勝ち"
|
@@ -142,7 +165,7 @@ module Jkf::Converter
|
|
142
165
|
when "ILLEGAL_MOVE" then "反則負け"
|
143
166
|
end
|
144
167
|
else
|
145
|
-
turn = index % 2
|
168
|
+
turn = @players[(index+1) % 2]
|
146
169
|
result += case special
|
147
170
|
when "TIME_UP" then "で時間切れにより#{turn}手の勝ち"
|
148
171
|
when "CHUDAN" then "で中断"
|
data/lib/jkf/version.rb
CHANGED