Skip to content

AxAks/P4_Programme-python_tournoi-echecs

Repository files navigation

P4_python_program_chess-tournament

Chapters

  1. Presentation
  2. Prerequisites
  3. Installation
  4. Execution
  5. Usage
  6. Generation of a code review report with flake8-html

1. Presentation

This Python program is an offline management tool running in a terminal for the organization of chess tournaments using the swiss-system.


2. Prerequisites

This program runs under python 3.9 in a virtual environment.
Thus, it is usable on Windows, Unix-based operating systems insofar as the followings are installed:

  • python 3.9 (including pip3)
  • virtualenv

Linux
installation of python3.9:
$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt update
$ sudo apt install python3.9
installation of pip3:
$ wget https://bootstrap.pypa.io/get-pip.py
$ python3.9 get-pip.py
$ pip --version
Installation of virtualenv :
$ sudo apt install virtualenv

Mac
installation of python3.9 and pip3:
$ brew install python@3.9
(pip3 comes along with it) if not, download and install the file get-pip.py from https://bootstrap.pypa.io/get-pip.py
$ py get-pip.py
Installation of virtualenv :
$ pip3 install virtualenv

Windows
installation of python3.9 and pip3:
Download and install python 3.9 for windows from python.org
(pip3 comes along with it)
if not, download and install the file get-pip.py from https://bootstrap.pypa.io/get-pip.py
$ py get-pip.py
Installation of virtualenv :
$ pip install virtualenv


3. Installation

Download the project:
Via Git
$ git clone https://github.com/AxAks/P4_Programme-python_tournoi-echecs.git

Via the Web

Linux / Mac
in the project directory in a shell:
create the virtual environment
$ python3.9 -m virtualenv 'venv_name'
activate the environment:
$ source 'venv_name'/bin/activate
install project requirements:
$ pip install -r requirements.txt

Windows
in the project directory in a shell:
create the virtual environment
$ virtualenv 'venv_name'
activate the environment:
$ C:\Users'Username''venv_name'\Scripts\activate.bat
install project requirements:
$ pip install -r requirements.txt


## 4. Execution from the terminal, in the root directory of the project:

activate the environment:
$ source 'venv_name'/bin/activate
launch the program:
$ python main.py
-> The home menu is then dislayed in the terminal


5. Usage

Homepage Menu
Navigate through the menu with digits to select a menu option
0: Quit the program (saves state before exiting)
1: Back to Home Menu
2: Back to previous screen
3: Load database
4: Save to database
n: Menu specific choices

From Home Menu
Launch a new tournament or search a previously saved Tournament

  • enables to:
  1. directly launch a new tournament
  2. search an ongoing tournament to land on its managing page. You can resume it from there.

Manage Players or registered Tournaments

  • enables to:
  1. add players / display reports on registered players
  2. add tournaments for later / display reports on saved tournaments (finished or not),

Tournament process

  • Launch New Tournament (from Home Menu)
    -> Fill the form to create and register the tournament
    -> You are redirected to this Tournament specific page
    -> Select Proceed Tournament to enter results of the matches of Round one
    -> the round is saved and you are redirected to the Tournament's page
    -> Select Proceed Tournament to enter the next rounds results
    -> The tournament is over when all the rounds have been played or when all Players have played together.
    -> When the tournament is over, select Proceed Tournament once more to update players rankings and close the tournament

A tournament can be paused at the end of each round and resumed

  • Search Registered Tournament To Resume(from Home Menu)
  • Select One (from Tournaments Management Page)
    -> Select Proceed Tournament to enter the next results of next round

Specific Tournament's Page
Reach the page

  • Search Registered Tournament To Resume(from Home Menu)

  • Select One (from Tournaments Management Page)

  • Proceed Tournament
    -> enter next step of the Tournament

  • Sort Players by Last Name, Ranking, Result
    -> displays all the players of the tournament by the selected criteria

  • Display Next Round Matchups -> displays the matchups for the next round to be played

  • Display Number of Rounds Played -> displays the number of rounds already played and the total number of rounds

  • Display Rounds and Matches
    -> displays the results of all matches of all previous rounds

  • Display Not Played Matchups
    -> lists for all players the possible next opponents

Player Management Menu
Player Creation

  • Add player
    -> fill the form and validate each field: the player is created;
    -> if cancelled the player is not created and you land back to the Player Management page

Player Ranking Update (anytime)

  • Update Player Ranking
    -> search the player by ID
    -> enter the new ranking
    -> the new ranking is saved

Display all Players by Last Name

  • Display By Last Name
    -> All Players in the registry are returned sorted by Last Name

Display all Players by Ranking

  • Display by Ranking
    -> All Players in the registry are returned by Ranking from highest to lowest

Search Players by ID

  • Search by Id
    -> enter an ID or part of an ID
    -> all matching players are returned

Tournament Management Menu
Tournament Creation

  • Add Tournament
    -> fill the form and validate each field: the tournament is created
    -> if cancelled the tournament is not created and you land back to the Tournament Management page

Display By Start Date, Name, or Location

  • Display By Start Date, Name or Location
    -> All Tournament in the registry are returned sorted by the selected criteria

Search Tournaments

  • Search Tournaments
    -> enter a date or name or location or part of them
    -> all matching tournaments are returned

Select One Tournament

  • Select One
    -> enter a date or name or location or part of them
    -> When only one result returns, you are redirect to this Tournament Page

6. Generation of a code review report

flake8_html
Launch the Analysis

  • at the project root level
    $ flake8 --format=html --htmldir=flake-report . -v format = format of the report (html)
    htmldir = name of the directory to be created to store the report (mandatory)
    . = current directory
    -v = verbose (optional)

  • from anywhere in the system
    $ flake8 --format=html --htmldir=flake-report --config=[path/to/config/file] [path/to/project/root/] -v
    config = 'setup.cfg', located at the root of the project (mandatory if not in the working directory)

see more options here:
https://flake8.pycqa.org/en/latest/user/options.html
note: setup.cfg file excluding files from the analysis and setting te limit to 119 characters per line

to read the reports:

  • browse files to the 'flake-report' directory
  • open the file index.html in a web-browser

About

Projet d'apprentissage Programme python hors-ligne de gestion de tournoi d'echecs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published