Python-Easy-Chess-GUI icon indicating copy to clipboard operation
Python-Easy-Chess-GUI copied to clipboard

[IMPROVE] Modularize project into packages. (v1.15)

Open alfredo-f opened this issue 3 years ago • 10 comments

WHAT

Improve project structure by modularizing different components.

WHY

  1. Improve the process of adding new features
  2. Improve maintainability
  3. I am Italian, but still I can't develop with this kind of spaghetti :)

HOW

  1. Create a separate package python_easy_chess_gui
  2. Move all constant global variables to config
  3. Move classes to 3 main sub-packages
  • engine_package
  • play_package
  • ui_package
  1. Parametrize with global variables the folder paths
  • Book
  • Engines
  • Icon
  • Images

alfredo-f avatar Aug 15 '22 06:08 alfredo-f

Thanks, I will check this.

fsmosca avatar Aug 15 '22 07:08 fsmosca

@fsmosca

Added commit

I forgot a couple of imports for chess modules

alfredo-f avatar Aug 15 '22 11:08 alfredo-f

Started checking this PR.

  • [x] Engine install
  • [x] Engine edit
  • [x] Engine delete
  • [x] Set engine adviser
  • [x] Set engine opponent
  • [x] Set engine depth
  • [x] Set book
  • [x] Engine time
  • [x] User time
  • [x] Board flip
  • [x] Board color
  • [x] Board Theme
  • [x] Settings/game
  • [x] Engine play
  • [x] Save to Mygames
  • [x] Save to white repertoire
  • [x] Save to black repertoire
  • [x] Auto save games
  • [x] Resign
  • [x] User wins
  • [x] User draws
  • [x] New game
  • [x] FEN paste
  • [x] Engine go
  • [x] Engine move now
  • [x] Computer checkmates user
  • [x] User checkmates computer
  • [x] User stalemates computer
  • [x] Draw by insufficient mating material
  • [x] Draw by 3-fold repetition
  • [x] Draw by 50-move draw rule
  • [x] E.P. capture
  • [x] Queen promotion
  • [x] Minor promotion
  • [ ] Compile to exe and test

fsmosca avatar Aug 27 '22 06:08 fsmosca

@alfredo-f have you tried converting this to windows exe using pyinstaller? All my attempts so far in creating an exe were unsuccessful.

fsmosca avatar Aug 27 '22 13:08 fsmosca

@alfredo-f have you tried converting this to windows exe using pyinstaller? All my attempts so far in creating an exe were unsuccessful.

Never mind, I got it now.

fsmosca avatar Aug 27 '22 13:08 fsmosca

New issue, I can build an exe, but I cannot save the new installed engine in json. After restart, the new installed engine is not there. And I cannot find the engine json file. Perhaps the json files should be saved outside of the python_easy_chess_gui folder.

fsmosca avatar Aug 27 '22 14:08 fsmosca

New issue, I can build an exe, but I cannot save the new installed engine in json. After restart, the new installed engine is not there. And I cannot find the engine json file. Perhaps the json files should be saved outside of the python_easy_chess_gui folder.

I can fix this now. This is due to ROOT_PATH definition. It has to be defined also with executable.

fsmosca avatar Aug 28 '22 02:08 fsmosca

@alfredo-f

These are the issues that I found, the windows executable that I built complains about these issues.

  1. Define the string properly example.
engine_config_file = ROOT_PATH / 'pecg_engines.json'

With f string it should be:

engine_config_file = f'{ROOT_PATH}/pecg_engines.json'

A lot of these are in config.py.

image

And here.

image

  1. In the init, detect if the app is an exe.

image

fsmosca avatar Aug 28 '22 03:08 fsmosca

Awesome! Can you push the changes?

alfredo-f avatar Aug 28 '22 05:08 alfredo-f

I have an error when trying to push some changes.

image

fsmosca avatar Aug 29 '22 01:08 fsmosca