Skip to content
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

No such file or directory: 'source\\data\\map\\level_6.json' #14

Closed
tscswcn opened this issue Dec 24, 2019 · 2 comments
Closed

No such file or directory: 'source\\data\\map\\level_6.json' #14

tscswcn opened this issue Dec 24, 2019 · 2 comments

Comments

@tscswcn
Copy link

tscswcn commented Dec 24, 2019

Traceback (most recent call last):
File "main.py", line 5, in
main()
File "E:\PythonPlantsVsZombies-master\source\main.py", line 14, in main
game.main()
File "E:\PythonPlantsVsZombies-master\source\tool.py", line 82, in main
self.update()
File "E:\PythonPlantsVsZombies-master\source\tool.py", line 54, in update
self.flip_state()
File "E:\PythonPlantsVsZombies-master\source\tool.py", line 64, in flip_state
self.state.startup(self.current_time, persist)
File "E:\PythonPlantsVsZombies-master\source\state\level.py", line 21, in startup
self.loadMap()
File "E:\PythonPlantsVsZombies-master\source\state\level.py", line 28, in loadMap
f = open(file_path)
FileNotFoundError: [Errno 2] No such file or directory: 'source\data\map\level_6.json'

@marblexu
Copy link
Owner

因为目前level_5.json 是最后一关,代码里没有加判断是否是最后一关,所以继续去读取下一关level_6.json的文件,但是不存在level_6.json文件,然后出错。

@akihiro-coder
Copy link

akihiro-coder commented May 18, 2023

Was this bug fixed? I faced this bug when c.LEVEL_NUM == 5.
After inspecting the codes, I changed line of add 1 to c.LEVEL_NUM to ↓↓

def checkGameState(self):                                                                                                                                                           
         if self.checkVictory():
             if self.game_info[c.LEVEL_NUM] < 5:
                 self.game_info[c.LEVEL_NUM] += 1
             self.next = c.GAME_VICTORY
             self.done = True

, then the games worked well as c.LEVEL_NUM == 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants