Realtime chess with a Clash Royale style elixir bar.
This is a barebones proof of concept for a variant of Chess which allows for realtime piece movement. Movement is restricted in two ways: A piece is put on "cooldown" after it is moved, and cannot be moved again for 2 seconds. Additionally, an elixir/mana bar slowly fills up over time, and a piece can only be moved if you have enough elixir to cover its "move cost". The move cost of each piece is as follows:
Queen - 9
Rook - 5
Bishop - 3
Knight - 3
King/Castling - 2
Pawn - 1
This game does not include a "check/checkmate" mechanic due to the realtime nature of the game. Instead, the game is won when a piece is able to capture the enemy king.
As this is a proof of concept, special care has not been put into ensuring the game is unable to be tampered with client-side. The server does not do extensive checks or record keeping to ensure the "rules" are being followed, and instead assumes both clients are acting in good faith. It only serves to allow the game to be played realtime by two players.
This project is loosely based on the teachings of Tech With Tim's Python Online Game Tutorial.
These steps should be performed on any machines that will be used to host or play the game.
- Install Python version 3.7 or higher.
- Install Pygame into your python install using
pip install pygame. - Download the source code contained in this repository.
- Modify
settings.pyto have the proper IP for your machine, and a port which does not conflict with any other port on the server's network.
- If you are going to use this computer as a server, hosting a game for 2 clients to play, set
SERVER_IPandSERVER_PORT. If you intend to host the game for only machines on the same network as your server computer,SERVER_IPshould be the local IP of the server's computer on your network. If you intend to allow computers outside of your network to connect to your server to play the game,SERVER_IPshould be the public IP of the server's computer's network, and you must port forward theSERVER_PORTto your server computer. - If you are going to use this computer as a client, connecting to a server to play the game, set
CLIENT_IPandCLIENT_PORT. If you are connecting to a machine on the same network as your client computer,CLIENT_IPshould be the local IP of the server's computer on your network. If you intend to connect to a machine on a different network than your client computer,CLIENT_IPshould be the public IP of that server's computer's network. You should use the sameCLIENT_PORTthat the server used as theirSERVER_PORT.
- Run one
server.pyand connect to it by running twoclient.pys.