Skip to content

refactor: Convert Games Python CLI scripts to follow procedural guidelines#825

Merged
steam-bell-92 merged 2 commits into
steam-bell-92:mainfrom
mrdeyroy:fix/games-projects-guidelines
May 27, 2026
Merged

refactor: Convert Games Python CLI scripts to follow procedural guidelines#825
steam-bell-92 merged 2 commits into
steam-bell-92:mainfrom
mrdeyroy:fix/games-projects-guidelines

Conversation

@mrdeyroy
Copy link
Copy Markdown
Contributor

Description

This pull request addresses Issue #805 by refactoring all purely CLI-based projects within the games/ directory to adhere strictly to the project's procedural programming guidelines (No def, No class).

Fixes #805

Changes Made:

  • Completely refactored 12 CLI game scripts from Object-Oriented/Functional paradigms into pure procedural while True: game loops.
  • Replaced complex OOP mechanisms (like AI paths, card tracking, and timed threads) with flat control flow logic using dictionaries and lists for state management.
  • Ensured all visual elements, console clearing, CLI styling, emojis, and gameplay features remain intact exactly as they were before the refactor.
  • Rewrote the unit test module test_number_guessing.py to properly execute and test procedural scripts utilizing exec() combined with unittest.mock.patch.

Files Modified:

  • games/Blackjack-21/Blackjack-21.py
  • games/Dots-Boxes-AI/Dots-Boxes-AI.py
  • games/Emoji-Memory-Game/Emoji-Memory-Game.py
  • games/FLAMES-Game/FLAMES-Game.py
  • games/Number-Guessing-Game/Number-Guessing-Game.py
  • games/Number-Sliding-Puzzle/Number-Sliding-Puzzle.py
  • games/Reverse-Hangman-Game/Reverse-Hangman-Game.py
  • games/Rock-Paper-Scissor/Rock-Paper-Scissor.py
  • games/Tic-Tac-Toe/Tic-Tac-Toe.py
  • games/War-Card-Game/War-Card-Game.py
  • games/Whack-a-Mole/Whack-a-Mole.py
  • games/Word-Scramble-Game/Word-Scramble-Game.py
  • tests/test_number_guessing.py

Testing:

  • Verified that all 112 repository unit tests pass successfully.
  • Conducted manual edge-case testing for non-blocking I/O elements (e.g., in Whack-a-Mole) to ensure cross-platform compatibility within the procedural constraint.

Note to Maintainers:

Please add the following labels after merging: gssoc, gssoc-ext, python, refactor.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 27, 2026

@mrdeyroy is attempting to deploy a commit to the Anuj's projects Team on Vercel.

A member of the Team first needs to authorize it.

Comment thread games/Reverse-Hangman-Game/Reverse-Hangman-Game.py Fixed
@mrdeyroy
Copy link
Copy Markdown
Contributor Author

@steam-bell-92 You can check now!

@steam-bell-92 steam-bell-92 merged commit fc88a39 into steam-bell-92:main May 27, 2026
8 of 9 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

🎉 Thank you for your contribution!

Your Pull Request has been merged successfully.

We appreciate the time and effort you put into improving this project. Contributions like yours help the repository grow and stay useful for everyone.

If you'd like to contribute again, please check the open issues and make sure you are assigned before opening another Pull Request.

Thanks again for your support! 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: Convert Games Python CLI scripts to follow procedural guidelines

3 participants