This is an implementation of the game yahtzee. It allows you to score using multiples of any number, full house, straights, and of course, the infamous yahtzee. When you run the code the game will start with player 1, the dice will roll and display the dice values. It will ask the user of they want to reroll any dice. If the user enters "y" the game will ask what dice they want to reroll. Then the game will ask the user if they want to reroll the dice again. if the user enters "n" the game will then ask the user what score they want. Then after the players turn it will display the score. After player 1s turn players 2 turn will start. Once player 2 turn is done. The game will continue until a player wins the game.
Source Code:
There are 3 classes dice, game, and scorecard. The dice classs has dice, rollDice, displayDice, rerollDice, and getDiceValues functions. The rollDice function rolls the dice at the start of a players turn. The displayDice shows the dice that was rolled. The reRollDice function allows the user to reroll dice if they want to. GetDiceValues function gets the dice values this is how the other classes get the values.
The game class uses all the functions in the other classes to make the game work. It also has a pointstoscore function where it will print out all the scores available and then the user will enter what score they want. The play function organizes how the game works.
For the scorecard class, the updatescore function takes the scoring type, player num, and number of points and puts it in the map. The calculateScore function calculates the players score, it uses the dice array and scoring type and player num. The getScore, gets the players score. The scoresFilled function gives you the number of spots in the scorescard that are filled. It returns the number of scores the player has.
The build tools that we used is Cmake and make to build our project and run it.
We used catch2 library to create our test cases to ensure our code works properly. We integrated catch2 with cmake for convience which allows everything to run smoothly.
-
Nicholas Laviano: Created the game.h and game.cpp and also helped made part of the yahtzee.cpp file. Made part of the README.md file and helped with creating test cases
-
Kaleb LuceWireman: Created the scorecard.h and scorecard.cpp and also made part of the yahtzee.cpp file. Made the Cmake file and the CI/CD .yml file. Added the catch2.hpp file.
-
Owen Harnishfeger: Created the dice.h and dice.cpp and also helped made part of the yahtzee.cpp file. Made part of the README.md file and made the test cases.
For CI/CD we utilized Cmake to create a generic make file to be run on the docker image. We then made the docker image compile and run the tests.cpp file to ensure that the test cases work on each commit.
- Create or upload files
- Add files using the command line or push an existing Git repository with the following command:
cd existing_repo
git remote add origin https://gitlab.com/cs30602/se3540_spring2024_a04_g11.git
git branch -M main
git push -uf origin main