I want to be able to give the developer an easy way to configure a computer player, using a JSON file that lists all the different types of bots with their settings. This will be part of the chess game web component, a way for the user to select not only the human player, but also to select one of many different types of computer players, from easy to hard for example.
I have listed all the settings into the "chess-game.json" file. It lists all the computer plays, each with their computer player configuration settings. There are a number of different places that need updating to add this in.
When loading in the CSS and HTML parts, I also need to load in the JSON file. The three parts are all loaded at the same time.
The JSON file is fetched much like the CSS and HTML files are. The JSON text data is converted into an object. After this the player list is created, with the human player added to it first, followed by all the computer players from the JSON file.
Before the menu dialog is shown, the list of player options is added to the select elements. These are the different players shown in the drop-down lists. For each player option I set the inner text, using the name of the player, and set the value to be the same as the index of the player within the list.
The final part is added into the "New Game" click event function. I get which option the user selected for player 1 and 2, setting if they are human or computer, and then setting the related configuration information. This is all that is required to get the different computer player types set up and working.
I didn't really like how some of the chess game squares looked when the user selected a piece. I have restyled some of the CSS to make it look smoother by rounding the possible move borders. This also included the move animations. Everything looks a little better now.
The other part I wanted to improve is the source file headers. At the moment they only contain the name of the module, but I want to add some information about what the class inside does. It will only be a small description, nothing too big, I don't want to list all the functions giving detailed information about what they do and their parameters. That sort of thing is best placed inside mark down files or other documentation.
I have also created a mark down file for the GitHub repository. This has information about what the chess library does, how to use it, and where to look to see a live example.