bymayanksingh / connect4

🎮 It is a two-player connection game in which the players first choose a color and then take turns dropping one colored disc from the top into a seven-column, six-row vertically suspended grid. The pieces fall straight down, occupying the lowest available space within the column, user wins by forming row of four of same color
MIT License
23 stars 27 forks source link

Refactor #8

Closed smithandrewl closed 5 years ago

smithandrewl commented 5 years ago

This should address #2

This change creates the following main classes ConnectGame GameBoard GameData GameRenderer

ConnectGame is created by game.py and contains the logic for the game. GameBoard contains holds data for the game board and contains methods to operate on it GameData contains all of the game data (including a GameBoard instance) GameRenderer "renders" the game data object by drawing to the screen and playing audio.

game.py creates the ConnectGame and only processes mouse and keyboard input, delegating to the ConnectGame object.

An external library, event_bus is used to dispatch events from one place and listen for them in another place. It allows the ConnectGame class to notify the GameRenderer class to do something without having to tightly couple them together.

I also added type hints (https://docs.python.org/3/library/typing.html) to most variables. This allows the editor that I use (PyCharm) to notify me if I put a string where an int should be.

I also ran black and isort.

bymayanksingh commented 5 years ago

Thanks a ton @smithandrewl !!

That is complete overhaul of the project, I am currently reviewing your pull request and will get back to you soon :)

bymayanksingh commented 5 years ago

Fantastic Job @smithandrewl !! :100: I am so happy with the outcome, hats off to your efforts. :) You made this project highly readable and friendly for future contributors, now finally I can think of adding in new features, all thanks to you, changes looks good to me, merging in your awesome PR.

Thanks again !! :+1: