Fort Boyard: The Game
- Gabriel: Developer (Logical Challenges, Chance Challenges, GUI, the Pere Fouras Challenge)
- Jules: Developer (Math Challenges, Final Challenge, Utility Functions, the Pere Fouras Challenge, No-GUI part)
This project is a text-based and GUI-based adventure game inspired by the French TV show "Fort Boyard." Players navigate through a series of challenges to collect keys and ultimately reach the treasure room. The game features a variety of mini-games, including mathematical problems, logical puzzles, chance-based games and riddles, designed to test the player's skills and luck.
- Variety of Challenges: The game offers a diverse set of challenges:
- Math Challenges: Factorial calculations, linear equation solving, prime number identification, and math roulette.
- Logical Challenges: A strategic Nim game (against a "master" AI) and Tic Tac Toe.
- Chance Challenges: A shell game and a dice-rolling game.
- Pere Fouras Challenge: A riddle challenge where you have to find the answer based on a question.
- Final Challenge: A word-guessing game based on clues.
- GUI-based and No-GUI based Interface: Most challenges offer both a console-based and a graphical user interface (GUI) version using Pygame.
- Multiplayer Support: The game supports 1 to 3 players.
- Progress Tracking: The game keeps track of the number of keys each player has collected.
- Dynamic Gameplay: Random elements in challenges ensure replayability.
- Introduction and Storytelling: Engaging text-based introduction and progress updates.
- Programming Language: Python
- Libraries:
pygame
: For graphics, user interface, video and event handling.random
: For generating random numbers and choices.json
: For loading riddles and clues from JSON files.time
: For managing time-related events and animations.math
: For mathematical calculations.pygamevideo
: To play videos.
- Tools:
- Git (for version control)
-
Clone the Git Repository:
git clone https://github.com/paxo-rch/python-project-efrei-1
-
Set up the Development Environment:
-
Python: Ensure you have Python 3.x installed.
-
Pygame: Install the required libraries using pip:
pip install pygame pygamevideo
-
-
Run the Application:
-
Navigate to the project directory in your terminal.
-
Execute the
main.py
file:python main.py
-
-
Gameplay:
- Follow the on-screen instructions (either in the console or the GUI).
- The game will guide you through the introduction, player setup, and challenges.
- In GUI mode, interact with buttons and input fields using your mouse and keyboard.
- Start Menu:
- Display the game title and a "PRESS SPACE TO PLAY" prompt.
- Play an intro video.
- Introduction:
- Display a text-based introduction to the game's story and objectives.
- Player Count Selection:
- Prompt the user to choose the number of players (1-3).
- Player Information Input:
- For each player, prompt for their name, profession, and whether they are the leader (if no leader is selected, the first player is automatically assigned as the leader).
- Challenge Menu:
- Present a menu to choose a challenge type: Math, Logic, Chance, or Pere Fouras (riddle).
- Player Choice:
- Ask the user to choose which player will attempt the challenge.
- Challenge Execution:
- Run the selected challenge.
- Determine if the player won (got a key) or lost.
- Update the player's key count accordingly.
- Key Check:
- After each challenge, check if the total number of keys collected by all players is 3 or more.
- Final Challenge (if 3 or more keys):
- If enough keys are collected, proceed to the treasure room challenge.
- Present 3 clues initially, then more if needed.
- Prompt the player to guess the code word.
- Determine if the player won or lost the final challenge.
- Game End:
- Display a "You won!" or "You lost!" message based on the final challenge outcome.
- Show the scores of each player (name and number of keys).
Here's a simplified overview of the functions, grouped by file. Details about parameters and specific behaviors are found within the code comments.
shell_game()
: Simulates a shell game.roll_dice_game()
: Simulates a dice-rolling game.chance_challenge()
: Randomly selects and runs a chance challenge.shell_game()
: GUI version of the shell game.roll_dice_game()
: GUI version of the dice-rolling game.chance_challenge(player)
: GUI for selecting and playing chance challenges.
treasure_room()
: No-GUI version of the treasure room challenge.final_challenge(players)
: GUI version of the final challenge.winner(who, players)
: Displays the game over screen and player scores.
display_sticks(n)
: Displays sticks for the Nim game.player_removal(n)
: Gets player input for Nim.master_removal(n)
: AI logic for Nim.nim_game()
: Main Nim game logic.display_grid(grid)
: Displays the Tic Tac Toe grid.check_victory(grid, symbol)
: Checks for a win in Tic Tac Toe.master_move(grid)
: AI logic for Tic Tac Toe.player_turn(grid)
: Gets player input for Tic Tac Toe.master_turn(grid)
: Executes the master's turn in Tic Tac Toe.full_grid(grid)
: Checks if the Tic Tac Toe grid is full.check_result(grid)
: Checks for a win or draw in Tic Tac Toe.tictactoe_game()
: Main Tic Tac Toe game logic.nim_game(player)
: GUI version of the Nim game.winner(who)
: Displays the game over screen for Nim.
Factorial(n)
: Calculates the factorial of n.math_challenge_factorial()
: Factorial challenge.solve_linear_equation()
: Generates a linear equation.math_challenge_equation()
: Linear equation challenge.math_roulette_challenge()
: Math roulette challenge.is_prime(n)
: Checks if a number is prime.nearest_prime(n)
: Finds the nearest prime to n.math_challenge_prime()
: Nearest prime challenge.math_challenge()
: Randomly selects and runs a math challenge.equation_challenge()
: GUI version of the equation challenge.factorial_challenge()
: GUI version of the factorial challenge.prime_challenge()
: GUI version of the prime challenge.math_challenge(player)
: GUI for selecting and playing math challenges.
load_riddles(file)
: Loads riddles from a JSON file.pere_fouras_riddles()
: No-GUI version of the Pere Fouras riddle challenge.pere_fouras_riddles(player)
: GUI version of the Pere Fouras riddle challenge.
StartMenufunc()
: Displays the start menu.Introduction()
: Displays the game introduction.PlayerCount()
: Prompts for the number of players.Compose_Equipe(nbr)
: Gets player information.ChallengeMenu()
: Displays the challenge selection menu.PlayerChoice(game)
: Handles player selection for challenges and game logic.
history(text)
: Logs text to thehistory.txt
file.nuage_forward(w, c=None)
: Animates clouds moving forward.nuage_backward(w)
: Animates clouds moving backward.
Object
: Base class for all GUI objects.Box
: A customizable box widget.Label
: A text label widget.Input
: A text input widget.Grid
: A grid widget.Win
: The main window widget.convertToGrid(l, forEach=None)
: Converts a list to a grid of widgets.
- Input Validation:
- The
player_removal
function inlogical_challenges.py
validates that the player's input in the Nim game is within the allowed range (1, 2, or 3). - The
player_turn
function inlogical_challenges.py
validates that the player's input in Tic Tac Toe is within the allowed range and that the chosen cell is empty. - In general, user input is cast to the appropriate data type (e.g.,
int
,float
) and checked for validity where necessary.
- The
- Error Handling:
- The
load_riddles
function uses atry-except
block to handle potentialFileNotFoundError
when loading JSON files. - The
loadImage
method of theObject
class includes error handling for loading images in the GUI. - The game includes basic error handling for unexpected input types.
- The
- Intervals:
- The
nim_game
function ensures that the player can only remove 1, 2, or 3 sticks. - The
tictactoe_game
ensures that players can only place their symbol in empty cells within the 3x3 grid.
- The
- Known Bugs:
- In
final_challenge.py
, in thekeyboard_listener
function, the keys are limited to letters and backspace, the numbers don't work, they should be added. - In
math_challenges.py
, in theequation_challenge
function, the numbers generated for a and b don't take into account negative values, they should be added.
- In
- Project, repository creation, initial file structure setup, implementation of the different sub-projects in terminal mode
- Work on the first versions of the math and logic challenges. Integration of the Pere Fouras riddle challenge.
- Implementation of chance challenges. Development of the initial version of the final challenge.
- Introduction of the GUI using Pygame for math and logic challenges. Started work on enhancing the user interface.
- Continued development of the GUI for chance challenges and the final challenge. Refinement of game aesthetics.
- Implementation of cloud animation for transitions between game screens.
- Development of core game logic, including player count selection and team composition. Implemented basic challenge selection menu.
- Finalization of the GUI for all challenges. Bug fixes and improvements to user interaction.
- Code optimization and final touches to the user interface.
- Final review, writing of documentation, and project submission.
Decisions Made:
- Using Pygame for the GUI to enhance player engagement.
- Implementing a cloud animation for smoother transitions between game phases.
Problems Encountered:
- Initial difficulties with Pygame event handling, resolved by restructuring the event loop.
- Challenges in synchronizing animations with game logic, addressed through code optimization.
- Gabriel:
- Development of the whole GUI module
- Implementation of the GUI for most challenges.
- Design and implementation of some challenges with GUI.
- Creation of utility functions and overall code organization.
- Jules:
- Development of the cloud animation.
- Development of the initial game structure and core logic.
- Implementation of the math challenges, both console-based and GUI versions.
- Design and implementation of the final challenge.
- Creation of utility functions and overall code organization.
- Unit Tests: Individual functions were tested during development to ensure they work correctly in isolation (e.g.,
Factorial
,is_prime
,nearest_prime
). - Integration Tests: Challenges were tested together to ensure they integrate correctly with the main game loop and player data.
- Gameplay Tests: The entire game was played multiple times to test the flow, challenge selection, key collection, and final challenge.
- Input Validation Tests: Various inputs were tested to ensure the game handles them correctly.
- GUI Tests: The GUI was tested to ensure buttons, input fields, and labels work as expected and the layout is correct (after some bug fixes).
- Nim Game:
- Test Case: Player inputs 1, 2, and 3.
- Result: Game proceeds correctly.
- Test Case: Player inputs 0, 4.
- Result: Game prompts the player to re-enter a valid number.
- Test Case: Player inputs 1, 2, and 3.
- Tic Tac Toe:
- Test Case: Player tries to place a symbol in an occupied cell.
- Result: Game prompts the player to choose an empty cell.
- Test Case: Player wins the game.
- Result: Game declares the player as the winner.
- Test Case: Player tries to place a symbol in an occupied cell.
- Math Challenges:
- Test Case: Correct and incorrect answers for each type of math problem.
- Result: Game correctly identifies correct and incorrect answers and awards keys accordingly.
- Test Case: Correct and incorrect answers for each type of math problem.
- Chance Challenges:
- Test Case: Run each chance challenge multiple times to ensure randomness.
- Result: Games behave randomly as expected.
- Test Case: Run each chance challenge multiple times to ensure randomness.
- Pere Fouras Challenge:
- Test Case: Correct and incorrect answers for different riddles.
- Result: Game correctly identifies correct and incorrect answers and awards keys accordingly.
- Test Case: Correct and incorrect answers for different riddles.
- Final Challenge:
- Test Case: Correct and incorrect code word guesses.
- Result: Game correctly identifies correct and incorrect guesses, provides additional clues, and determines the winner or loser.
- Test Case: Correct and incorrect code word guesses.
Here are some screenshots showing the tests in action (you would replace these with actual screenshots from your game):
GUI Start Menu
GUI Introduction
GUI Player Count
GUI Player Info
GUI Challenge Menu
Player Selection
Game Won
Other games