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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: cad7bbf021250fb745379dfde6cdd189ac23065f
4
- data.tar.gz: eff17d1efc52ff07bdc58bc6d4b61afa0022a1fb
2
+ SHA256:
3
+ metadata.gz: ea59b45dcef66f1538bdd64d25fba421e6c5c7f458846dccfd5727b49755d420
4
+ data.tar.gz: db04f6d1d141e00700d785c4026064ae69d6a547051defdb52fb325c3d98acb5
5
5
  SHA512:
6
- metadata.gz: 081f1b970eb509aaa33495fb14459d6a37ce7510f59d94a1ee9ea1c3b2f23319b6ccb36383029f456cfa681d3ae5e7ab164dfde4f647ae25d8ddd3d1f46a7906
7
- data.tar.gz: 7d0bb2322d33f323f64b82350108721b2d6694a04000879a58e9d87299bc4426deed8b730c28f85288b8b54d73e7f011d41d37cbeac1e2b3f60f81e145686a18
6
+ metadata.gz: 9104756b9fecb562b97e90ff5e191603b1b4437e94edd228a4c2f986f0e09c64d1047236c7c432f16b904e079241d0425c0e6f97d5e010dc2505da0d3adb4d50
7
+ data.tar.gz: fe28d5a3f3077d27b854435242ed4d98a71eec681b089428a990501b42a9ab4189138a681ce565c395d8e9c8e3d812eb8894ed70dc625d94b9f251485d047867
@@ -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 + pos2str(move["to"]) + move["piece"]
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" # 右香落ち
@@ -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
@@ -108,8 +108,6 @@ module Jkf::Converter
108
108
  n2zen(move["to"]["x"]) + n2kan(move["to"]["y"])
109
109
  elsif move["same"]
110
110
  "同 "
111
- else
112
- raise "error??"
113
111
  end
114
112
  result += csa2kind(move["piece"])
115
113
  result += "成" if move["promote"]
@@ -1,4 +1,4 @@
1
1
  module Jkf
2
2
  # Gem version
3
- VERSION = "0.4.2".freeze
3
+ VERSION = "0.4.3".freeze
4
4
  end
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.2
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: 2016-02-25 00:00:00.000000000 Z
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
- rubyforge_project:
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: