-
Notifications
You must be signed in to change notification settings - Fork 1
mapファイルからpngを生成する機能を作成しました #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
| import sys | ||
| from typing import List | ||
|
|
||
| from PIL import Image |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [mypy] reported by reviewdog 🐶
Cannot find implementation or library stub for module named "PIL" [import-not-found]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
いくつか気になった点をコメントしました.
先頭についてる文字で意味が変わります.
- IMO : 私の意見では
- FYI: ご参考までに
- want: できればやってほしい
- nits: 些細な指摘
src/ImageGenerator.py
Outdated
| # mapファイルが入ったディレクトリに移動 | ||
| os.chdir(dir_name) | ||
|
|
||
| # 画像を格納するディレクトリを作成し移動 | ||
| os.mkdir("map_images") | ||
| os.chdir("map_images") | ||
|
|
||
| for i in range(len(file_list)): | ||
| draWPng(file_list[i]) | ||
|
|
||
| # もとのディレクトリに戻る | ||
| os.chdir("../../") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
want: ディレクトリ移動ではなく, 相対パスで指定してマップファイルの読み取りと画像ファイルの書き出しをしてほしい.
noko1024
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
全体的にコメントしました!
分からないことや気になることがあったら,コメントやVCでいつでも相談してください!
Linterが怒っているところも修正をお願いします!
テストも書いてみよう!
src/ImageGenerator.py
Outdated
| map_list = changEArray(map_data) | ||
|
|
||
| # アイコン用の画像を開く | ||
| yuka = Image.open("../../icons/yuka.png") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
パスは相対表記ではなく, __file__やos.getcwd()を用いた方がOSなどの影響を受けづらいです
src/ImageGenerator.py
Outdated
| map_list = changEArray(map_data) | ||
|
|
||
| # アイコン用の画像を開く | ||
| yuka = Image.open("../../icons/yuka.png") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
item,hot,coolは英語表記なのでyuka,kabeも合わせたい!
src/ImageGenerator.py
Outdated
| if map_data[i] != "" and map_data[i][0] == "D": | ||
| map_list.append(re.split(",|\n", map_data[i].replace("D:", ""))) | ||
| elif map_data[i] != "" and map_data[i][0] == "H": | ||
| hot = re.split(",|\n", map_data[i].replace("H:", "")) | ||
| elif map_data[i] != "" and map_data[i][0] == "C": | ||
| cool = re.split(",|\n", map_data[i].replace("C:", "")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
map_data[i] != ""は共通の条件だから先に確認してbreakできるね!
| elif map_data[i] != "" and map_data[i][0] == "C": | ||
| cool = re.split(",|\n", map_data[i].replace("C:", "")) | ||
|
|
||
| map_list[int(cool[1])][int(cool[0])] = "C" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"H"や”C"だとなんのことか分かりづらいので
列挙型(Enum)を定義して管理したい!
src/ImageGenerator.py
Outdated
| dir_name = sys.argv[1] | ||
| file_list = os.listdir(dir_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
実行時の引数をParseして処理する関数に切り出して
任意のパス型などをこの先の関数で渡してあげれると
文字列の連結などを考えなくてもよくなるのでトライして欲しい!
ssuzzukki
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
タイポ修正、関数名の修正、型ヒントの修正、if文の条件文の修正、ファイル開閉や文字列操作に使うメソッドの変更
|
もう一度レビューしてほしいときは, レビュワーの横の矢印を選んでもう一度レビューできるようにしてください |
|
一旦Generaterだけでmainにマージしちゃいたいので, |
ディレクトリ名を指定するとそのディレクトリ内のmapファイルからpngを生成する機能を作成しました。生成された画像は指定したディレクトリの中に作った新たなディレクトリに格納されます。icons内の画像を変えると生成される画像の見た目を変えることができます。