BeesInTheTrap is a command-line-based PHP game developed as part of an interview task. The goal is to destroy a hive of bees before they sting you to death. The game is designed using modern PHP styles and design principles, incorporating Symfony components while avoiding the use of a fully prebuilt framework.
- Overview
- Rules
- Installation
- How to Play
- Features
- Development Process
- Technologies Used
- Testing
- Future Improvements
- License
- The game runs from the command line.
- Players start with 100 HP and aim to destroy all bees in the hive.
- Bees are categorized into three types: Queen Bee, Worker Bee, and Drone Bee.
- The game alternates turns between the player and the bees.
- A player types
hitto take their turn. After the player’s turn, the bees attack. - The game displays a message after each turn, describing the outcome, e.g.,
"Direct Hit! You took 12 hit points from a Drone bee". - The game ends when either all bees are dead or the player is dead.
- Players can
auto spinto let the game play out automatically to its conclusion.
- Lifespan: 100 Hit Points
- Hit Damage: 10 HP deducted from the Queen’s lifespan per hit
- Sting Damage: Player loses 10 HP per sting
- Quantity: 1
- Lifespan: 75 Hit Points
- Hit Damage: 25 HP deducted from Worker’s lifespan per hit
- Sting Damage: Player loses 5 HP per sting
- Quantity: 5
- Lifespan: 60 Hit Points
- Hit Damage: 30 HP deducted from Drone’s lifespan per hit
- Sting Damage: Player loses 1 HP per sting
- Quantity: 25
- Each bee type has different hit and sting damage.
- Bees and players have a chance to miss their attacks.
- The bee and player targets are chosen randomly but should reflect statistical chances based on bee types.
- Destroying the Queen Bee results in all remaining bees dying.
To set up the game, follow these steps:
-
Clone the Repository:
git clone https://github.com/yourusername/beesinthetrap.git
-
Navigate to the Project Directory:
cd beesinthetrap -
Install Dependencies:
Ensure you have Composer installed and run:
composer install
-
Make the Game Executable:
chmod +x beesinthetrap
To start the game, execute the following command from the project's root directory:
./beesinthetrap- Manual Play: Type
hitwhen prompted to take your turn. - Auto Play: Type
autoto let the game run automatically to its conclusion. - Exit Game: The game ends automatically when the player or all bees are dead, displaying a summary of the game.
- Interactive Gameplay: Turn-by-turn interaction with dynamic game messages.
- Randomized Turns: Random selection of bees for a statistically accurate game experience.
- Single-Player Mode: Play against the computer-controlled bee hive.
- Auto-Spin Mode: Option to let the game play out automatically.
- Game Summary: Displays detailed game results at the end.
This project was developed with the following approach:
- Analysis and Planning: Thoroughly understanding the game rules and requirements.
- Design: Outlining the game structure and flow.
- Implementation: Writing the game logic in PHP, ensuring modern design principles.
- Testing: Writing unit tests to ensure all components work as expected.
- Refinement: Enhancing the game based on feedback and testing results.
- PHP: The main language used to develop the game.
- Symfony Components: Utilized
symfony/consolefor command-line interactions. - Composer: Used for managing PHP dependencies.
Unit tests are included to ensure the game logic and components function correctly. To run the tests, execute the following command:
composer testHere are some areas where the game could be expanded or improved:
- Graphical Interface: Implement a GUI version for a more visually engaging experience.
- Difficulty Levels: Add varying difficulty settings to challenge players.
- Multiplayer Option: Introduce a mode for multiple players to compete against each other.
- Leaderboards: Implement online leaderboards for global competition.
This project is licensed under the MIT License. See the LICENSE file for details.
Thank you for exploring BeesInTheTrap. Your feedback and contributions are welcome. Enjoy the game and aim for victory!