大砲の補足情報と砲兵の裏画像リストから、不足する大砲のタイプを
リストに出力ツールをPythonで作成した。
1.入力
(1)大砲の補足情報(手動作成)
未作成の砲兵裏画像を自動的に追加する際に参照する定数(下図)。
(2)砲兵の裏画像リスト
砲兵の裏画像リスト作成ツールで出力するもの(下図)。
2.プログラム
3.出力
下記のようなcsvファイルに出力する。これを見て、大砲の補足情報に追加が
必要な大砲のタイプが分かる。
<個人的な感想>
大砲の補足情報は、定数として使われる。その為、予め過不足なくデータが
出来ている事が不可欠である。今回のツールで、ゲームに使う為に必要な
砲兵のタイプが自動的に分かるので、作業が楽である。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
import numpy as np | |
with open(r'D:\WORK\temp\BatailleWK\Gun_info_Al.csv', 'r', encoding='utf-8') as f: | |
rearid = csv.reader(f) | |
datax=[i for i in rearid] | |
f.close() | |
with open(r'D:\WORK\temp\BatailleWK\unit_art_Al.csv', 'r', encoding='utf-8') as f: | |
rearid = csv.reader(f) | |
datax2=[i for i in rearid] | |
f.close() | |
filepath=r'D:\WORK\temp\BatailleWK\add_art_Al.csv' | |
add_table=[['追加砲兵タイプ']] | |
for i in range(1,len(datax2)): | |
gun_info=str(datax2[i]) | |
gun_type=gun_info[2:9] | |
match='no' | |
for j in range(1,len(datax)): | |
if gun_type == datax[j][0]: | |
match='yes' | |
break | |
if match=='no': | |
addx=gun_type | |
add_table.append(addx) | |
#CSVファイルがデータ毎に改行できるよう、2次元リストにする | |
ainfo=np.array(add_table).reshape(-1,1).tolist() | |
with open(filepath, 'w', newline='', encoding='utf-8') as f: | |
csv_data=csv.writer(f) | |
csv_data.writerows(ainfo) | |
f.close() |