Advertisement
Guest User

Untitled

a guest
Oct 5th, 2017
809
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 74.40 KB | None | 0 0
  1.  
  2. Click here to enable desktop notifications for Gmail. Learn more Hide
  3. Gmail
  4. COMPOSE
  5. Labels
  6. Inbox (488)
  7. Starred
  8. Important
  9. Sent Mail
  10. Drafts (18)
  11. Notes
  12. Personal
  13. Travel
  14. More
  15. Hangouts
  16.  
  17.  
  18.  
  19.  
  20. Move to Inbox More
  21. 1 of 14
  22.  
  23. Collapse all Print all In new window
  24. Final Code
  25. Inbox
  26. x
  27.  
  28. Aspen Clements <aspen.rae11@gmail.com>
  29. Attachments5/2/15
  30.  
  31. to me
  32. I will rename it and zip it. Do you want me to submit it tonight?
  33.  
  34. Attachments area
  35.  
  36. Austin Ryan <arryan22@gmail.com>
  37. 5/2/15
  38.  
  39. to Aspen
  40. Yup good to go!
  41.  
  42.  
  43.  
  44. Click here to Reply or Forward
  45. 5.39 GB (35%) of 15 GB used
  46. Manage
  47. Terms - Privacy
  48. Last account activity: 0 minutes ago
  49. Details
  50. Aspen Clements's profile photo
  51. Aspen Clements
  52. aspen.rae11@gmail.com
  53.  
  54. Show details
  55. Get a Gmail custom address (you@yourcompany)
  56. Recommended for business email users
  57. Get started
  58.  
  59. //
  60. // Final Project - Yahtzee.c
  61. // Purpose: to perform a two person game of yahtzee while displaying scores and dice rolls
  62. // Authors: Aspen Clements and Austin Ryan
  63. // Date Modified: 4/29/15.
  64. //
  65. // Begin Program - this program will begin and display the rules once
  66. // Display Rules
  67. // (ROLL 1)
  68. // Player 1 rolls 5 dice of values 1 through 6
  69. // Conditions are set to correctly set values to each current scoring option
  70. // A scoresheet graphic is displayed below the dice graphic showing current score options and your permanent scores
  71. // Player 1 is given the option to end your turn and choose a current score as your permanent score, or reroll certain dice.
  72. // If player chooses to end turn, you must choose a permanent scoring option that has not already been chosen
  73. // BREAK TO PLAYER TWO'S FIRST ROLL
  74. // (ROLL 2)
  75. // If player 1 rerolls (FIRST REROLL) the player will reroll the chosen specific dice
  76. // When dice are rerolled, the new randomly rolled values of dice are displayed in a graphic and new current score options are calculated and displayed below the second roll.
  77. // Player 1 is given the option to end your turn and choose a current score as your permanent score, or reroll once more
  78. // If player chooses to end turn, you must choose a permanent scoring option that has not already been chosen
  79. // BREAK TO PLAYER TWO'S FIRST ROLL
  80. // (ROLL 3)
  81. // If player 1 rerolls (SECOND AND LAST REROLL) the player will reroll the chosen specific dice
  82. // When dice are rerolled, the new randomly rolled values of dice are displayed in a graphic and new current score options are calculated and displayed below the third roll.
  83. // Player 1 now MUST choose a permanent scoring option that has not already been chosen
  84. // PLAYER TWO BEINGS THEIR TURN
  85. // Player 2's turn is exactly the same, but provides different permanent score values.
  86. // Provide a loop that loops 13 times for both player 1 and player 2 so that all permanent scores are set for each player.
  87. // After the all turns are finished (loop is finished), add up the total sum of ones, twos, threes, fours, fives, and sixes score
  88. // if that score is greater than or equal to 63, add a bonus of 35 to the total score
  89. // calculate a total score for each player by adding up all permanent scores for each player
  90. // display final scorecards for each player with sum, bonus, and total.
  91. // display a graphic that tells who won the game and the final total scores for each player.
  92.  
  93. #include <stdio.h>
  94. #include <stdlib.h>
  95. #include <math.h>
  96. #include <string.h>
  97. #include <time.h>
  98.  
  99. void DisplayRules();
  100. void PrintDiceAndScore();
  101. void ReRoll();
  102. void ScoreCard();
  103. void ScoreCardFinal();
  104. void PrintDicePlayerTwo();
  105. void PrintDiceAndScorePlayerTwo();
  106. void ReRollPlayerTwo();
  107. void ScoreCardPlayerTwo();
  108. void ScoreCardFinalPlayerTwo();
  109. void PointAllocation();
  110. void PointAllocation_PlayerTwo();
  111. void Results();
  112.  
  113.  
  114. #define numPossibleRolls 6
  115. # define maxNumTurns 12
  116. # define Entries 5
  117.  
  118. int entry, roll[Entries], sumOfDice = 0;
  119. int ones_score, perm_ones_score = -1 , twos_score, perm_twos_score = -1, threes_score, perm_threes_score = -1, fours_score, perm_fours_score = -1, fives_score, perm_fives_score = -1;
  120. int sixes_score, perm_sixes_score = -1, threeOfAKind_score, perm_threeOfAKind_Score = -1, fourOfAKind_score, perm_fourOfAKind_score = -1, yahtzee_score, perm_yahtzee_Score = -1, fullHouse1, fullHouse2;
  121. int fullHouse_score, perm_fullHouse_score = -1, smallStraight_score, perm_smallStraight_score = -1, largeStraight_score, perm_largeStraight_score = -1;
  122. int entry = 0;
  123. int ones_score = 0, twos_score = 0, threes_score = 0, fours_score = 0, fives_score = 0, sixes_score = 0, fullHouse1 = 0, fullHouse2 = 0, fullHouse_score = 0;
  124. int threeOfAKind_score = 0, fourOfAKind_score =0, smallStraight_score = 0, largeStraight_score = 0, yahtzee_score = 0;
  125. int bonus_score = 0, chance_score = 0, perm_chance_score = -1, total_score = 0, num_turns =0;
  126. int sum_score, numDiceChange, dieChange, changingDice, allocation_command = 0;
  127. char command, display0, display1, display2, display3;
  128. int sum, total, bonus;
  129. int perm_ones_score_player_two = -1, perm_twos_score_player_two = -1, perm_threes_score_player_two = -1, perm_fours_score_player_two = -1, perm_fives_score_player_two = -1;
  130. int perm_sixes_score_player_two = -1, perm_threeOfAKind_score_player_two = -1, perm_fourOfAKind_score_player_two = -1, perm_smallStraight_score_player_two = -1;
  131. int perm_largeStraight_score_player_two = -1, perm_fullHouse_score_player_two = -1, perm_chance_score_player_two = -1, perm_yahtzee_score_player_two = -1;
  132. int sum_player_two, total_player_two, bonus_player_two, num_roll = 0;
  133.  
  134. int main(void)
  135. {
  136. DisplayRules();
  137. srand(time(NULL));
  138.  
  139. for(num_turns = 0; num_turns <= maxNumTurns; num_turns ++)
  140. {
  141. for(entry = 0; entry < Entries; entry++) //initilizing array entries to randomly selected values 1 to 5
  142. {
  143. roll[entry] = rand()% numPossibleRolls + 1;
  144. sumOfDice = sumOfDice + roll[entry];
  145. }
  146. PrintDiceAndScore();
  147.  
  148. printf("\n\nWould you like to finish your turn or roll a number of dice again? The commands are listed below. Please enter the corresponding letter to continue.");
  149. ReRoll();
  150.  
  151. if(command != 'a')
  152. {
  153. printf("\nYou are allowed to roll the dice one more time for this turn. What would you like to do?");
  154. ReRoll();
  155. }
  156.  
  157. PointAllocation();
  158.  
  159. /////////////////////////////////////////////////////////////////////// PLAYER TWO/////////////////////////////////////////////////////////////////////////////////
  160. for(entry = 0; entry < Entries; entry++)
  161. {
  162. roll[entry] = rand()% numPossibleRolls + 1;
  163. sumOfDice = sumOfDice + roll[entry];
  164. }
  165.  
  166. PrintDiceAndScorePlayerTwo();
  167.  
  168. printf("\n\nWould you like to finish your turn or reroll some number of dice? \n");
  169. printf("\nThe commands are listed below. Please enter the corresponding letter to continue.");
  170. ReRollPlayerTwo();
  171.  
  172. if(command != 'a')
  173. {
  174. printf("\nYou are allowed to roll the dice one more time for this turn. What would you like to do?");
  175. ReRollPlayerTwo();
  176. }
  177.  
  178. PointAllocation_PlayerTwo();
  179.  
  180. }
  181. ScoreCardFinal();
  182. ScoreCardFinalPlayerTwo();
  183. Results();
  184. }
  185.  
  186. ///////////////////////////////////////////////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////////////////////////////////////
  187.  
  188. void DisplayRules()
  189. {
  190. printf("\n WELCOME TO YAHTZEE!"); // INTRO with rules
  191. printf("\n\n INSTRUCTIONS");
  192. printf("\n\n ****OBJECT****");
  193. printf("\n\nRoll dice for scoring combinations and get the highest total score");
  194. printf("\n\n ****HOW TO PLAY****");
  195. printf("\n\nOn your turn, you may roll the dice up to three times,");
  196. printf("\nalthough you may stop and score after your first or");
  197. printf("\nsecond roll. Your first roll is rolled for you.");
  198. printf("\n\nFirst roll: 5 dice are rolled for you. You may choose to");
  199. printf("\nreroll ANY or ALL dice, or choose to end your turn and");
  200. printf("\nchoose a score.");
  201. printf("\n\nSecond roll: You may stop and score here, or reroll ANY or ALL dice");
  202. printf("\nthat you choose.");
  203. printf("\n\nThird roll: You MUST choose to score once you have rolled three times.");
  204. printf("\n\n ****SCORING****");
  205. printf("\n\nThere are thirteen different scoring options, which will be");
  206. printf("\nautomatically calculated for you when you roll and");
  207. printf("\nwill be displayed in the current roll section of your score card.");
  208. printf("\nYou can only choose each scoring option once.");
  209. printf("\n\nUPPER SECTION");
  210. printf("\n\nOnes: Total of ones rolled");
  211. printf("\nTwos: Total of twos rolled");
  212. printf("\nThrees: Total of threes rolled");
  213. printf("\nFours: Total of fours rolled");
  214. printf("\nFives: Total of fives rolled");
  215. printf("\nSixes: TOtal of sixes rolled");
  216. printf("\n\nExample: Rolling 3 Sixes = a score of 18.");
  217. printf("\n\nLOWER SECTION");
  218. printf("\n\n3 of a kind - If dice include 3 or more of the same number, your score is the total of your five dice");
  219. printf("\n4 of a kind - If dice include 4 or more of the same number, your score is the total of your five dice.");
  220. printf("\nFull House - If dice show three of one number and two of another, you can score 25 points");
  221. printf("\nSmall Straight - If there is a sequence of four numbers, you can score 30 points.");
  222. printf("\nLarge straight - If there is a sequence of five numbers, you can score 40 points");
  223. printf("\nYahtzee - If dice include 5 of the same number, your can score 50 points.");
  224. printf("\n\nIf conditions are not met for any of these score options, the score is zero.");
  225. printf("\n\nChance - Total of all of your 5 dice, no conditions need to be met.");
  226. printf("\n\n ****ENDING A GAME*****");
  227. printf("\n\nAfter each player has filled in all 13 scoring option boxes, the game ends.");
  228. printf("\nYour final score card is now displayed, and the winner is the player with");
  229. printf("\nthe highest total score.");
  230. printf("\n\nThe sum section is the total number of ones, twos, threes, fours, fives, and sixes.");
  231. printf("\nIf the sum is greater to or equal to 63, a bonus of 35 points is added to your total.");
  232. printf("\nIf the sum is less than 63, the bonus is zero.");
  233. printf("\n\nThe total section is the total of all 13 scoring options plus the bonus.\n\n");
  234. }
  235.  
  236. void PrintDiceAndScore()
  237. {
  238. entry = 0;
  239. ones_score = 0, twos_score = 0, threes_score = 0, fours_score = 0, fives_score = 0, sixes_score = 0, fullHouse1 = 0, fullHouse2 = 0, fullHouse_score = 0, chance_score = 0;
  240. threeOfAKind_score = 0, fourOfAKind_score =0, smallStraight_score = 0, largeStraight_score = 0, yahtzee_score = 0, sumOfDice = 0;
  241.  
  242. char display0[100]={'\0'};// first line of full display
  243. char display1[100]={'\0'};// second line of full display
  244. char display2[100]={'\0'};// third line of full display
  245. char display3[100]={'\0'};// fourth line of full display
  246.  
  247. char digit_0_0[12] = " __ ___ __ "; //setting display for each die face
  248. char digit_0_1[12] = " | | ";
  249. char digit_0_2[12] = " | * | ";
  250. char digit_0_3[12] = " |_ ___ _| ";
  251.  
  252. char digit_1_0[12] = " __ ___ __ ";
  253. char digit_1_1[12] = " | * | ";
  254. char digit_1_2[12] = " | | ";
  255. char digit_1_3[12] = " |_ ___*_| ";
  256.  
  257. char digit_2_0[12] = " __ ___ __ ";
  258. char digit_2_1[12] = " | * | ";
  259. char digit_2_2[12] = " | * | ";
  260. char digit_2_3[12] = " |_ ___*_| ";
  261.  
  262.  
  263. char digit_3_0[12] = " __ ___ __ ";
  264. char digit_3_1[12] = " | * * | ";
  265. char digit_3_2[12] = " | | ";
  266. char digit_3_3[12] = " |_*___*_| ";
  267.  
  268.  
  269. char digit_4_0[12] = " __ ___ __ ";
  270. char digit_4_1[12] = " | * * | ";
  271. char digit_4_2[12] = " | * | ";
  272. char digit_4_3[12] = " |_*___*_| ";
  273.  
  274. char digit_5_0[12] = " __ ___ __ ";
  275. char digit_5_1[12] = " | * * | ";
  276. char digit_5_2[12] = " | * * | ";
  277. char digit_5_3[12] = " |_* __*_| ";
  278.  
  279. for(entry = 0; entry < 5; entry++)
  280. {
  281. sumOfDice = sumOfDice + roll[entry];
  282.  
  283. switch(roll[entry])
  284. {
  285. case 1:
  286.  
  287. strcat(display0, digit_0_0); //print die face
  288. strcat(display1, digit_0_1);
  289. strcat(display2, digit_0_2);
  290. strcat(display3, digit_0_3);
  291. ones_score = ones_score + 1;
  292. if(ones_score == 2) //to check for full house and two of a kind
  293. {
  294. if(twos_score == 6 || threes_score == 9 || fours_score == 12 || fives_score == 15 || sixes_score == 18)
  295. {
  296. fullHouse2 = 1;
  297. fullHouse1 = 1;
  298. }
  299. }
  300.  
  301. if(ones_score == 3) // to check for full house and three of a kind
  302. {
  303. threeOfAKind_score = sumOfDice;
  304. fullHouse2 = 1;
  305.  
  306. if(twos_score == 4 || threes_score == 6 || fours_score == 8 || fives_score == 10 || sixes_score == 12)
  307. fullHouse1 = 1; //to make sure we do not have false poitives with three of a kind
  308. }
  309. if(ones_score == 4) //check for of a kind
  310. fourOfAKind_score = sumOfDice;
  311. if(ones_score == 5) //yahtzee check
  312. yahtzee_score = 50;
  313. break;
  314.  
  315. case 2:
  316. strcat(display0, digit_1_0); //display die face
  317. strcat(display1, digit_1_1);
  318. strcat(display2, digit_1_2);
  319. strcat(display3, digit_1_3);
  320. twos_score = twos_score + 2;
  321.  
  322. if(twos_score == 4) //two of a kind or full house check
  323. {
  324. if(ones_score == 3 || threes_score == 9 || fours_score == 12 || fives_score == 15 || sixes_score == 18)
  325. {
  326. fullHouse2 = 1;
  327. fullHouse1 = 1;
  328. }
  329. }
  330.  
  331. if(twos_score == 6) // three of a kind or full house check
  332. {
  333. threeOfAKind_score = sumOfDice;
  334. fullHouse2 = 1;
  335.  
  336. if(ones_score == 2 || threes_score == 6 || fours_score == 8 || fives_score == 10 || sixes_score == 12)
  337. fullHouse1 = 1;
  338. }
  339. if(twos_score == 8) //four of a kind checl
  340. fourOfAKind_score = sumOfDice;
  341. if(twos_score == 10) //yahtzee check
  342. yahtzee_score = 50;
  343. break;
  344.  
  345. case 3:
  346. strcat(display0, digit_2_0); //display die face
  347. strcat(display1, digit_2_1);
  348. strcat(display2, digit_2_2);
  349. strcat(display3, digit_2_3);
  350. threes_score = threes_score + 3;
  351.  
  352. if(threes_score == 6) //two of a kind or full house check
  353. {
  354. if(ones_score == 3 || twos_score == 6 || fours_score == 12 || fives_score == 15 || sixes_score == 18)
  355. {
  356. fullHouse2 = 1;
  357. fullHouse1 = 1;
  358. }
  359. }
  360.  
  361. if(threes_score == 9) //three of a kind or full house check
  362. {
  363. threeOfAKind_score = sumOfDice;
  364. fullHouse2 = 1;
  365.  
  366. if(ones_score == 2 || twos_score == 4 || fours_score == 8 || fives_score == 10 || sixes_score == 12)
  367. fullHouse1 = 1;
  368. }
  369. if(threes_score == 12) // four of a kind check
  370. fourOfAKind_score = sumOfDice;
  371. if(threes_score == 15) //yahtzee check
  372. yahtzee_score = 50;
  373. break;
  374.  
  375. case 4:
  376. strcat(display0, digit_3_0); //display face of die
  377. strcat(display1, digit_3_1);
  378. strcat(display2, digit_3_2);
  379. strcat(display3, digit_3_3);
  380. fours_score = fours_score + 4;
  381.  
  382. if(fours_score == 8) //two of a kind or full house check
  383. {
  384. if(ones_score == 3 || twos_score == 6 || threes_score == 9 || fives_score == 15 || sixes_score == 18)
  385. {
  386. fullHouse2 = 1;
  387. fullHouse1 = 1;
  388. }
  389. }
  390.  
  391. if(fours_score == 12) //three of a kind or full house check
  392. {
  393. threeOfAKind_score = sumOfDice;
  394. fullHouse2 = 1;
  395.  
  396. if(ones_score == 2 || twos_score == 4 || threes_score == 6 || fives_score == 10 || sixes_score == 12)
  397. fullHouse1 = 1;
  398. }
  399. if(fours_score == 16) //four of a kind check
  400. fourOfAKind_score = sumOfDice;
  401. if(fours_score == 20) //yahtzee check
  402. yahtzee_score = 50;
  403. break;
  404.  
  405. case 5:
  406. strcat(display0, digit_4_0); //display die face
  407. strcat(display1, digit_4_1);
  408. strcat(display2, digit_4_2);
  409. strcat(display3, digit_4_3);
  410. fives_score = fives_score + 5;
  411.  
  412. if(fives_score == 10) //two of a kind or full house check
  413. {
  414. if(ones_score == 3 || twos_score == 6 || fours_score == 12 || threes_score == 9 || sixes_score == 18)
  415. {
  416. fullHouse2 = 1;
  417. fullHouse1 = 1;
  418. }
  419. }
  420.  
  421. if(fives_score == 15) //three of a kind or full house check
  422. {
  423. threeOfAKind_score = sumOfDice;
  424. fullHouse2 = 1;
  425.  
  426. if(ones_score == 2 || twos_score == 4 || threes_score == 6 || fours_score == 8 || sixes_score == 12)
  427. fullHouse1 = 1;
  428. }
  429. if(fives_score == 20) //four of a kind
  430. fourOfAKind_score = sumOfDice;
  431. if(fives_score == 25) //yahtzee
  432. yahtzee_score = 50;
  433. break;
  434.  
  435. case 6:
  436. strcat(display0, digit_5_0); //display die face
  437. strcat(display1, digit_5_1);
  438. strcat(display2, digit_5_2);
  439. strcat(display3, digit_5_3);
  440. sixes_score = sixes_score + 6;
  441.  
  442. if(sixes_score == 12) //two of a kind or full house check
  443. {
  444. if(ones_score == 3 || twos_score == 6 || fours_score == 12 || fives_score == 15 || threes_score == 9)
  445. {
  446. fullHouse2 = 1;
  447. fullHouse1 = 1;
  448. }
  449. }
  450.  
  451. if(sixes_score == 18) //three of a kind or full house check
  452. {
  453. threeOfAKind_score = sumOfDice;
  454. fullHouse2 = 1;
  455.  
  456. if(ones_score == 2 || twos_score == 4 || threes_score == 6 || fours_score == 8 || fives_score == 10)
  457. fullHouse1 = 1;
  458. }
  459. if(sixes_score == 24) //four of a kind
  460. fourOfAKind_score = sumOfDice;
  461. if(sixes_score == 30) //yahtzee
  462. yahtzee_score = 50;
  463. break;
  464. }
  465.  
  466.  
  467. // large straight if statements
  468. if(ones_score == 1 && twos_score == 2 && threes_score == 3 && fours_score == 4 && fives_score == 5)
  469. {
  470. largeStraight_score = 40;
  471. }
  472. if(twos_score == 2 && threes_score == 3 && fours_score == 4 && fives_score == 5 && sixes_score == 6)
  473. {
  474. largeStraight_score = 40;
  475. }
  476. //***small straight if statements***
  477. if(ones_score == 1 && twos_score == 2 && threes_score == 3 && fours_score == 4 && fives_score == 5)
  478. {
  479. smallStraight_score = 30;
  480. }
  481. if(twos_score == 2 && threes_score == 3 && fours_score == 4 && fives_score == 5 && sixes_score == 6)
  482. {
  483. smallStraight_score = 30;
  484. }
  485. if(ones_score == 1 && twos_score == 2 && threes_score == 3 && fours_score == 4)
  486. {
  487. smallStraight_score = 30;
  488. }
  489. if(ones_score == 2 && twos_score == 2 && threes_score == 3 && fours_score == 4)
  490. {
  491. smallStraight_score = 30;
  492. }
  493. if(ones_score == 1 && twos_score == 4 && threes_score == 3 && fours_score == 4)
  494. {
  495. smallStraight_score = 30;
  496. }
  497. if(ones_score == 1 && twos_score == 2 && threes_score == 6 && fours_score == 4)
  498. {
  499. smallStraight_score = 30;
  500. }
  501. if(ones_score == 1 && twos_score == 2 && threes_score == 3 && fours_score == 8)
  502. {
  503. smallStraight_score = 30;
  504. }
  505. if(twos_score == 2 && threes_score == 3 && fours_score == 4 && fives_score == 5)
  506. {
  507. smallStraight_score = 30;
  508. }
  509. if(twos_score == 4 && threes_score == 3 && fours_score == 4 && fives_score == 5)
  510. {
  511. smallStraight_score = 30;
  512. }
  513. if(twos_score == 2 && threes_score == 6 && fours_score == 4 && fives_score == 5)
  514. {
  515. smallStraight_score = 30;
  516. }
  517. if(twos_score == 2 && threes_score == 3 && fours_score == 8 && fives_score == 5)
  518. {
  519. smallStraight_score = 30;
  520. }
  521. if(twos_score == 2 && threes_score == 3 && fours_score == 4 && fives_score == 10)
  522. {
  523. smallStraight_score = 30;
  524. }
  525. if(threes_score == 3 && fours_score == 4 && fives_score == 5 && sixes_score == 6)
  526. {
  527. smallStraight_score = 30;
  528. }
  529. if(threes_score == 6 && fours_score == 4 && fives_score == 5 && sixes_score == 6)
  530. {
  531. smallStraight_score = 30;
  532. }
  533. if(threes_score == 3 && fours_score == 8 && fives_score == 5 && sixes_score == 6)
  534. {
  535. smallStraight_score = 30;
  536. }
  537. if(threes_score == 3 && fours_score == 4 && fives_score == 10 && sixes_score == 6)
  538. {
  539. smallStraight_score = 30;
  540. }
  541. if(threes_score == 3 && fours_score == 4 && fives_score == 5 && sixes_score == 12)
  542. {
  543. smallStraight_score = 30;
  544. }
  545.  
  546. }
  547. printf("%s\n",display0); //printing die
  548. printf("%s\n",display1);
  549. printf("%s\n",display2);
  550. printf("%s\n",display3);
  551.  
  552. //chance check
  553. for(entry = 0; entry < 5; entry++)
  554. {
  555. chance_score = chance_score + roll[entry];
  556. }
  557. if(fullHouse1 == 1 && fullHouse2 == 1)
  558. fullHouse_score = 25;
  559.  
  560. ScoreCard();
  561.  
  562. }
  563.  
  564. void ReRoll()
  565. {
  566.  
  567. int loop_command = 1, loop2;
  568.  
  569. while(loop_command > 0)
  570. {
  571. printf("\n Command Meaning ");
  572. printf("\n a Finish Roll");
  573. printf("\n b Roll some number of dice");
  574. printf("\n c Exit the program all together\n");
  575. printf("\n\n Please enter the option you would like.");
  576. scanf("%c", &command);
  577.  
  578. switch(command)
  579. {
  580. case'a':
  581. loop_command = -1; //exit loop
  582. break;
  583. case'b':
  584. printf("How many die would you like to change (1 through 5)? Please enter that number now.");
  585. loop2 = 1;
  586. while (loop2 > 0) //to ensure invalid entries do not pass
  587. {
  588. scanf("%i", &numDiceChange);
  589. while(getchar() != '\n') {}
  590. if (numDiceChange > 0 && numDiceChange < 6)
  591. loop2 = -1;
  592. else
  593. {
  594. printf("This is an invalid entry. Please enter a valid entry.");
  595. }
  596. }
  597. printf("\nPlease enter the dice you would like to reroll. For example if you want to reroll the second and fifth die that appeared enter 2 5 then press enter.");
  598. printf("\nThe number of die is from left to right. The dice number must be seperated by a space.");
  599.  
  600. for(changingDice = 0; changingDice < numDiceChange; changingDice ++)
  601. {
  602. scanf("\n%i", &dieChange);
  603. switch(dieChange) //changing entries randomly
  604. {
  605. case(1):
  606. roll[0] = rand()% numPossibleRolls + 1;
  607. break;
  608. case(2):
  609. roll[1] = rand()% numPossibleRolls + 1;
  610. break;
  611. case(3):
  612. roll[2] = rand()% numPossibleRolls + 1;
  613. break;
  614. case(4):
  615. roll[3] = rand()% numPossibleRolls + 1;
  616. break;
  617. case(5):
  618. roll[4] = rand()% numPossibleRolls + 1;
  619. break;
  620.  
  621. }
  622. dieChange = 0;
  623. }
  624. printf("\nYour new dice and scoresheet are \n");
  625. PrintDiceAndScore();
  626. loop_command = -1;
  627. break;
  628. case'c':
  629. printf("\nThank you for playing. The program in now terminating. \n\n");
  630. exit(0);
  631. break;
  632. default:
  633. printf("\n Error. You must enter a, b, or c. Please enter a valid command.");
  634. break;
  635.  
  636. }
  637. }
  638. while(getchar() != '\n') {}
  639. }
  640.  
  641.  
  642. void ScoreCard()
  643. {
  644. printf("\n___________________________________________________________");
  645. printf("\n SCORECARD - PLAYER 1 ");
  646. printf("\n___________________________________________________________");
  647. printf("\n Current Roll Score ");
  648. printf("\n-------------------|-------------------|-------------------");
  649. printf("\n Ones %i ", ones_score);
  650.  
  651. if(perm_ones_score >= 0) //when print score only when that score has been selected
  652. printf(" %i ", perm_ones_score);
  653.  
  654. printf("\n-------------------|-------------------|-------------------");
  655. printf("\n Twos %i ", twos_score);
  656.  
  657. if(perm_twos_score >= 0)
  658. printf(" %i ", perm_twos_score);
  659.  
  660. printf("\n-------------------|-------------------|-------------------");
  661. printf("\n Threes %i ", threes_score);
  662.  
  663. if(perm_threes_score >= 0)
  664. printf(" %i ", perm_threes_score);
  665.  
  666. printf("\n-------------------|-------------------|-------------------");
  667. printf("\n Fours %i ", fours_score);
  668.  
  669. if(perm_fours_score >= 0)
  670. printf(" %i ", perm_fours_score);
  671.  
  672. printf("\n-------------------|-------------------|-------------------");
  673. printf("\n Fives %i ", fives_score);
  674.  
  675. if(perm_fives_score >= 0)
  676. printf(" %i ", perm_fives_score);
  677.  
  678. printf("\n-------------------|-------------------|-------------------");
  679. printf("\n Sixes %i ", sixes_score);
  680.  
  681. if(perm_sixes_score >= 0)
  682. printf(" %i ", perm_sixes_score);
  683. printf("\n***********************************************************");
  684. printf("\n Sum ");
  685. printf("\n-------------------|-------------------|-------------------");
  686. printf("\n Bonus ");
  687. printf("\n***********************************************************");
  688. printf("\n Three of a kind %i ", threeOfAKind_score);
  689.  
  690. if(perm_threeOfAKind_Score >= 0)
  691. printf(" %i ", perm_threeOfAKind_Score);
  692.  
  693. printf("\n-------------------|-------------------|-------------------");
  694. printf("\n Four of a kind %i ", fourOfAKind_score);
  695.  
  696. if(perm_fourOfAKind_score >= 0)
  697. printf(" %i ", perm_fourOfAKind_score);
  698.  
  699. printf("\n-------------------|-------------------|-------------------");
  700. printf("\n Full House %i ", fullHouse_score);
  701.  
  702. if(perm_fullHouse_score >= 0)
  703. printf(" %i ", perm_fullHouse_score);
  704.  
  705. printf("\n-------------------|-------------------|-------------------");
  706. printf("\n Small straight %i ", smallStraight_score);
  707.  
  708. if(perm_smallStraight_score >= 0)
  709. printf(" %i ", perm_smallStraight_score);
  710.  
  711. printf("\n-------------------|-------------------|-------------------");
  712. printf("\n Large straight %i ", largeStraight_score);
  713.  
  714. if(perm_largeStraight_score >= 0)
  715. printf(" %i ", perm_largeStraight_score);
  716. printf("\n-------------------|-------------------|-------------------");
  717. printf("\n Chance %i ", chance_score);
  718.  
  719. if(perm_chance_score >= 0)
  720. printf(" %i ", perm_chance_score);
  721.  
  722. printf("\n-------------------|-------------------|-------------------");
  723. printf("\n YAHTZHEE %i ", yahtzee_score);
  724.  
  725. if(perm_yahtzee_Score >= 0)
  726. printf(" %i ", perm_yahtzee_Score);
  727. printf("\n*******************|***************************************");
  728. printf("\n TOTAL SCORE ");
  729. printf("\n___________________|___________________|___________________\n");
  730. }
  731.  
  732. void PointAllocation()
  733. {
  734. int loop_command = 1;
  735.  
  736. while(loop_command > 0) //ensure a valid entry is inputted
  737. {
  738. printf("\n\n Where would you like your points to be allocated? To select your choice enter the command from the command list below");
  739. printf("\n Command Points to ");
  740. printf("\n 1 Ones");
  741. printf("\n 2 Twos");
  742. printf("\n 3 Threes");
  743. printf("\n 4 Fours");
  744. printf("\n 5 Fives");
  745. printf("\n 6 Sixes");
  746. printf("\n 7 Three of a kind");
  747. printf("\n 8 Four of a kind");
  748. printf("\n 9 Full House");
  749. printf("\n 10 Small Straight");
  750. printf("\n 11 Large Straight");
  751. printf("\n 12 Chance");
  752. printf("\n 13 Yahtzee\n");
  753.  
  754. scanf("%d", &allocation_command);
  755. while(getchar() != '\n') {}
  756. switch (allocation_command)
  757. {
  758. case 1:
  759. if(perm_ones_score == -1)//to ensure score hasnt already been set
  760. {
  761. perm_ones_score = ones_score;
  762. loop_command = -1;
  763. }
  764. else
  765. printf("\n This score has already been set. Please choose another command.\n\n");
  766. break;
  767. case 2:
  768. if(perm_twos_score == -1) //to ensure score hasnt already been set
  769. {
  770. perm_twos_score = twos_score;
  771. loop_command = -1;
  772. }
  773. else
  774. printf("\n This score has already been set. Please choose another command.\n\n");
  775. break;
  776. case 3:
  777. if(perm_threes_score == -1) //to ensure score hasnt already been set
  778. {
  779. perm_threes_score = threes_score;
  780. loop_command = -1;
  781. }
  782. else
  783. printf("\n This score has already been set. Please choose another command.\n\n");
  784. allocation_command = -1;
  785. break;
  786. case 4:
  787. if(perm_fours_score == -1) //to ensure score hasnt already been set
  788. {
  789. perm_fours_score = fours_score;
  790. loop_command = -1;
  791. }
  792. else
  793. printf("\n This score has already been set. Please choose another command.\n\n");
  794.  
  795. break;
  796. case 5:
  797. if(perm_fives_score == -1) //to ensure score hasnt already been set
  798. {
  799. perm_fives_score = fives_score;
  800. loop_command = -1;
  801. }
  802. else
  803. printf("\n This score has already been set. Please choose another command.\n\n");
  804. break;
  805. case 6:
  806. if(perm_sixes_score == -1) //to ensure score hasnt already been set
  807. {
  808. perm_sixes_score = sixes_score;
  809. loop_command = -1;
  810. }
  811. else
  812. printf("\n This score has already been set. Please choose another command.\n\n");
  813. break;
  814. case 7:
  815. if(perm_threeOfAKind_Score == -1) //to ensure score hasnt already been set
  816. {
  817. perm_threeOfAKind_Score = threeOfAKind_score;
  818. loop_command = -1;
  819. }
  820. else
  821. printf("\n This score has already been set. Please choose another command.\n\n");
  822. break;
  823. case 8:
  824. if(perm_fourOfAKind_score == -1) //to ensure score hasnt already been set
  825. {
  826. perm_fourOfAKind_score = fourOfAKind_score;
  827. loop_command = -1;
  828. }
  829. else
  830. printf("\n This score has already been set. Please choose another command.\n\n");
  831. break;
  832. case 9:
  833. if(perm_fullHouse_score == -1) //to ensure score hasnt already been set
  834. {
  835. perm_fullHouse_score = fullHouse_score;
  836. loop_command = -1;
  837. }
  838. else
  839. printf("\n This score has already been set. Please choose another command.\n\n");
  840. break;
  841. case 10:
  842. if(perm_smallStraight_score == -1) //to ensure score hasnt already been set
  843. {
  844. perm_smallStraight_score = smallStraight_score;
  845. loop_command = -1;
  846. }
  847. else
  848. printf("\n This score has already been set. Please choose another command.\n\n");
  849. break;
  850. case 11:
  851. if(perm_largeStraight_score == -1) //to ensure score hasnt already been set
  852. {
  853. perm_largeStraight_score = largeStraight_score;
  854. loop_command = -1;
  855. }
  856. else
  857. printf("\n This score has already been set. Please choose another command.\n\n");
  858. break;
  859. case 12:
  860. if(perm_chance_score == -1) //to ensure score hasnt already been set
  861. {
  862. perm_chance_score = chance_score;
  863. loop_command = -1;
  864. }
  865. else
  866. printf("\n This score has already been set. Please choose another command.\n\n");
  867. break;
  868. case 13:
  869. if(perm_yahtzee_Score == -1) //to ensure score hasnt already been set
  870. {
  871. perm_yahtzee_Score = yahtzee_score;
  872. loop_command = -1;
  873. }
  874. else
  875. printf("\n This score has already been set. Please choose another command.\n\n");
  876. break;
  877.  
  878.  
  879. }
  880. }
  881. }
  882.  
  883. void ScoreCardFinal()
  884. {
  885. sum = perm_ones_score + perm_twos_score + perm_threes_score + perm_fours_score + perm_fives_score + perm_sixes_score;
  886. printf("\n___________________________________________________________");
  887. printf("\n SCORECARD - PLAYER 1 ");
  888. printf("\n___________________________________________________________");
  889. printf("\n Current Roll Score ");
  890. printf("\n-------------------|-------------------|-------------------");
  891. printf("\n Ones %i ", ones_score);
  892.  
  893. if(perm_ones_score >= 0) //print only set scores
  894. printf(" %i ", perm_ones_score);
  895.  
  896. printf("\n-------------------|-------------------|-------------------");
  897. printf("\n Twos %i ", twos_score);
  898.  
  899. if(perm_twos_score >= 0)
  900. printf(" %i ", perm_twos_score);
  901.  
  902. printf("\n-------------------|-------------------|-------------------");
  903. printf("\n Threes %i ", threes_score);
  904.  
  905. if(perm_threes_score >= 0)
  906. printf(" %i ", perm_threes_score);
  907.  
  908. printf("\n-------------------|-------------------|-------------------");
  909. printf("\n Fours %i ", fours_score);
  910.  
  911. if(perm_fours_score >= 0)
  912. printf(" %i ", perm_fours_score);
  913.  
  914. printf("\n-------------------|-------------------|-------------------");
  915. printf("\n Fives %i ", fives_score);
  916.  
  917. if(perm_fives_score >= 0)
  918. printf(" %i ", perm_fives_score);
  919.  
  920. printf("\n-------------------|-------------------|-------------------");
  921. printf("\n Sixes %i ", sixes_score);
  922.  
  923. if(perm_sixes_score >= 0)
  924. printf(" %i ", perm_sixes_score);
  925. printf("\n***********************************************************");
  926. printf("\n Sum | | %i ", sum);
  927. printf("\n-------------------|-------------------|-------------------");
  928. printf("\n Bonus | ");
  929.  
  930. if(sum >= 63)
  931. {
  932. bonus = 35; // bonus score only applies when all number scores sum up to more than 63
  933. printf(" %i ", bonus);
  934. }
  935. else
  936. printf("0");
  937.  
  938. printf("\n***********************************************************");
  939. printf("\n Three of a kind %i ", threeOfAKind_score);
  940.  
  941. if(perm_threeOfAKind_Score >= 0)
  942. printf(" %i ", perm_threeOfAKind_Score);
  943.  
  944. printf("\n-------------------|-------------------|-------------------");
  945. printf("\n Four of a kind %i ", fourOfAKind_score);
  946.  
  947. if(perm_fourOfAKind_score >= 0)
  948. printf(" %i ", perm_fourOfAKind_score);
  949.  
  950. printf("\n-------------------|-------------------|-------------------");
  951. printf("\n Full House %i ", fullHouse_score);
  952.  
  953. if(perm_fullHouse_score >= 0)
  954. printf(" %i ", perm_fullHouse_score);
  955.  
  956. printf("\n-------------------|-------------------|-------------------");
  957. printf("\n Small straight %i ", smallStraight_score);
  958.  
  959. if(perm_smallStraight_score >= 0)
  960. printf(" %i ", perm_smallStraight_score);
  961.  
  962. printf("\n-------------------|-------------------|-------------------");
  963. printf("\n Large straight %i ", largeStraight_score);
  964.  
  965. if(perm_largeStraight_score >= 0)
  966. printf(" %i ", perm_largeStraight_score);
  967. printf("\n-------------------|-------------------|-------------------");
  968. printf("\n Chance %i ", chance_score);
  969.  
  970. if(perm_chance_score >= 0)
  971. printf(" %i ", perm_chance_score);
  972.  
  973. printf("\n-------------------|-------------------|-------------------");
  974. printf("\n YAHTZHEE %i ", yahtzee_score);
  975.  
  976. if(perm_yahtzee_Score >= 0)
  977. printf(" %i ", perm_yahtzee_Score);
  978. printf("\n*******************|***************************************");
  979. total = sum + bonus + perm_threeOfAKind_Score + perm_fourOfAKind_score + perm_fullHouse_score + perm_smallStraight_score + perm_largeStraight_score + perm_chance_score + perm_yahtzee_Score;
  980. printf("\n TOTAL SCORE %i ", total); //total score sumation
  981. printf("\n___________________|___________________|___________________\n");
  982. }
  983.  
  984. void PrintDiceAndScorePlayerTwo() //same function as player one
  985. {
  986. entry = 0;
  987. ones_score = 0, twos_score = 0, threes_score = 0, fours_score = 0, fives_score = 0, sixes_score = 0, fullHouse1 = 0, fullHouse2 = 0, fullHouse_score = 0, chance_score = 0;
  988. threeOfAKind_score = 0, fourOfAKind_score =0, smallStraight_score = 0, largeStraight_score = 0, yahtzee_score = 0, sumOfDice = 0;
  989.  
  990. char display0[100]={'\0'};// first line of full display
  991. char display1[100]={'\0'};// second line of full display
  992. char display2[100]={'\0'};// third line of full display
  993. char display3[100]={'\0'};// fourth line of full display
  994.  
  995. char digit_0_0[12] = " __ ___ __ ";
  996. char digit_0_1[12] = " | | ";
  997. char digit_0_2[12] = " | * | ";
  998. char digit_0_3[12] = " |_ ___ _| ";
  999.  
  1000. char digit_1_0[12] = " __ ___ __ ";
  1001. char digit_1_1[12] = " | * | ";
  1002. char digit_1_2[12] = " | | ";
  1003. char digit_1_3[12] = " |_ ___*_| ";
  1004.  
  1005. char digit_2_0[12] = " __ ___ __ ";
  1006. char digit_2_1[12] = " | * | ";
  1007. char digit_2_2[12] = " | * | ";
  1008. char digit_2_3[12] = " |_ ___*_| ";
  1009.  
  1010.  
  1011. char digit_3_0[12] = " __ ___ __ ";
  1012. char digit_3_1[12] = " | * * | ";
  1013. char digit_3_2[12] = " | | ";
  1014. char digit_3_3[12] = " |_*___*_| ";
  1015.  
  1016.  
  1017. char digit_4_0[12] = " __ ___ __ ";
  1018. char digit_4_1[12] = " | * * | ";
  1019. char digit_4_2[12] = " | * | ";
  1020. char digit_4_3[12] = " |_*___*_| ";
  1021.  
  1022. char digit_5_0[12] = " __ ___ __ ";
  1023. char digit_5_1[12] = " | * * | ";
  1024. char digit_5_2[12] = " | * * | ";
  1025. char digit_5_3[12] = " |_* __*_| ";
  1026.  
  1027. for(entry = 0; entry < 5; entry++)
  1028. {
  1029. sumOfDice = sumOfDice + roll[entry];
  1030.  
  1031. switch(roll[entry])
  1032. {
  1033. case 1:
  1034.  
  1035. strcat(display0, digit_0_0);
  1036. strcat(display1, digit_0_1);
  1037. strcat(display2, digit_0_2);
  1038. strcat(display3, digit_0_3);
  1039. ones_score = ones_score + 1;
  1040. if(ones_score == 2)
  1041. {
  1042. if(twos_score == 6 || threes_score == 9 || fours_score == 12 || fives_score == 15 || sixes_score == 18)
  1043. {
  1044. fullHouse2 = 1;
  1045. fullHouse1 = 1;
  1046. }
  1047. }
  1048.  
  1049. if(ones_score == 3)
  1050. {
  1051. threeOfAKind_score = sumOfDice;
  1052. fullHouse2 = 1;
  1053.  
  1054. if(twos_score == 4 || threes_score == 6 || fours_score == 8 || fives_score == 10 || sixes_score == 12)
  1055. fullHouse1 = 1; //to make sure we do not have false poitives with three of a kind
  1056. }
  1057. if(ones_score == 4)
  1058. fourOfAKind_score = sumOfDice;
  1059. if(ones_score == 5)
  1060. yahtzee_score = 50;
  1061. break;
  1062.  
  1063. case 2:
  1064. strcat(display0, digit_1_0);
  1065. strcat(display1, digit_1_1);
  1066. strcat(display2, digit_1_2);
  1067. strcat(display3, digit_1_3);
  1068. twos_score = twos_score + 2;
  1069.  
  1070. if(twos_score == 4)
  1071. {
  1072. if(ones_score == 3 || threes_score == 9 || fours_score == 12 || fives_score == 15 || sixes_score == 18)
  1073. {
  1074. fullHouse2 = 1;
  1075. fullHouse1 = 1;
  1076. }
  1077. }
  1078.  
  1079. if(twos_score == 6)
  1080. {
  1081. threeOfAKind_score = sumOfDice;
  1082. fullHouse2 = 1;
  1083.  
  1084. if(ones_score == 2 || threes_score == 6 || fours_score == 8 || fives_score == 10 || sixes_score == 12)
  1085. fullHouse1 = 1;
  1086. }
  1087. if(twos_score == 8)
  1088. fourOfAKind_score = sumOfDice;
  1089. if(twos_score == 10)
  1090. yahtzee_score = 50;
  1091. break;
  1092.  
  1093. case 3:
  1094. strcat(display0, digit_2_0);
  1095. strcat(display1, digit_2_1);
  1096. strcat(display2, digit_2_2);
  1097. strcat(display3, digit_2_3);
  1098. threes_score = threes_score + 3;
  1099.  
  1100. if(threes_score == 6)
  1101. {
  1102. if(ones_score == 3 || twos_score == 6 || fours_score == 12 || fives_score == 15 || sixes_score == 18)
  1103. {
  1104. fullHouse2 = 1;
  1105. fullHouse1 = 1;
  1106. }
  1107. }
  1108.  
  1109. if(threes_score == 9)
  1110. {
  1111. threeOfAKind_score = sumOfDice;
  1112. fullHouse2 = 1;
  1113.  
  1114. if(ones_score == 2 || twos_score == 4 || fours_score == 8 || fives_score == 10 || sixes_score == 12)
  1115. fullHouse1 = 1;
  1116. }
  1117. if(threes_score == 12)
  1118. fourOfAKind_score = sumOfDice;
  1119. if(threes_score == 15)
  1120. yahtzee_score = 50;
  1121. break;
  1122.  
  1123. case 4:
  1124. strcat(display0, digit_3_0);
  1125. strcat(display1, digit_3_1);
  1126. strcat(display2, digit_3_2);
  1127. strcat(display3, digit_3_3);
  1128. fours_score = fours_score + 4;
  1129.  
  1130. if(fours_score == 8)
  1131. {
  1132. if(ones_score == 3 || twos_score == 6 || threes_score == 9 || fives_score == 15 || sixes_score == 18)
  1133. {
  1134. fullHouse2 = 1;
  1135. fullHouse1 = 1;
  1136. }
  1137. }
  1138.  
  1139. if(fours_score == 12)
  1140. {
  1141. threeOfAKind_score = sumOfDice;
  1142. fullHouse2 = 1;
  1143.  
  1144. if(ones_score == 2 || twos_score == 4 || threes_score == 6 || fives_score == 10 || sixes_score == 12)
  1145. fullHouse1 = 1;
  1146. }
  1147. if(fours_score == 16)
  1148. fourOfAKind_score = sumOfDice;
  1149. if(fours_score == 20)
  1150. yahtzee_score = 50;
  1151. break;
  1152.  
  1153. case 5:
  1154. strcat(display0, digit_4_0);
  1155. strcat(display1, digit_4_1);
  1156. strcat(display2, digit_4_2);
  1157. strcat(display3, digit_4_3);
  1158. fives_score = fives_score + 5;
  1159.  
  1160. if(fives_score == 10)
  1161. {
  1162. if(ones_score == 3 || twos_score == 6 || fours_score == 12 || threes_score == 9 || sixes_score == 18)
  1163. {
  1164. fullHouse2 = 1;
  1165. fullHouse1 = 1;
  1166. }
  1167. }
  1168.  
  1169. if(fives_score == 15)
  1170. {
  1171. threeOfAKind_score = sumOfDice;
  1172. fullHouse2 = 1;
  1173.  
  1174. if(ones_score == 2 || twos_score == 4 || threes_score == 6 || fours_score == 8 || sixes_score == 12)
  1175. fullHouse1 = 1;
  1176. }
  1177. if(fives_score == 20)
  1178. fourOfAKind_score = sumOfDice;
  1179. if(fives_score == 25)
  1180. yahtzee_score = 50;
  1181. break;
  1182.  
  1183. case 6:
  1184. strcat(display0, digit_5_0);
  1185. strcat(display1, digit_5_1);
  1186. strcat(display2, digit_5_2);
  1187. strcat(display3, digit_5_3);
  1188. sixes_score = sixes_score + 6;
  1189.  
  1190. if(sixes_score == 12)
  1191. {
  1192. if(ones_score == 3 || twos_score == 6 || fours_score == 12 || fives_score == 15 || threes_score == 9)
  1193. {
  1194. fullHouse2 = 1;
  1195. fullHouse1 = 1;
  1196. }
  1197. }
  1198.  
  1199. if(sixes_score == 18)
  1200. {
  1201. threeOfAKind_score = sumOfDice;
  1202. fullHouse2 = 1;
  1203.  
  1204. if(ones_score == 2 || twos_score == 4 || threes_score == 6 || fours_score == 8 || fives_score == 10)
  1205. fullHouse1 = 1;
  1206. }
  1207. if(sixes_score == 24)
  1208. fourOfAKind_score = sumOfDice;
  1209. if(sixes_score == 30)
  1210. yahtzee_score = 50;
  1211. break;
  1212. }
  1213.  
  1214.  
  1215. // large straight if statements
  1216. if(ones_score == 1 && twos_score == 2 && threes_score == 3 && fours_score == 4 && fives_score == 5)
  1217. {
  1218. largeStraight_score = 40;
  1219. }
  1220. if(twos_score == 2 && threes_score == 3 && fours_score == 4 && fives_score == 5 && sixes_score == 6)
  1221. {
  1222. largeStraight_score = 40;
  1223. }
  1224. //***small straight if statements***
  1225. if(ones_score == 1 && twos_score == 2 && threes_score == 3 && fours_score == 4 && fives_score == 5)
  1226. {
  1227. smallStraight_score = 30;
  1228. }
  1229. if(twos_score == 2 && threes_score == 3 && fours_score == 4 && fives_score == 5 && sixes_score == 6)
  1230. {
  1231. smallStraight_score = 30;
  1232. }
  1233. if(ones_score == 1 && twos_score == 2 && threes_score == 3 && fours_score == 4)
  1234. {
  1235. smallStraight_score = 30;
  1236. }
  1237. if(ones_score == 2 && twos_score == 2 && threes_score == 3 && fours_score == 4)
  1238. {
  1239. smallStraight_score = 30;
  1240. }
  1241. if(ones_score == 1 && twos_score == 4 && threes_score == 3 && fours_score == 4)
  1242. {
  1243. smallStraight_score = 30;
  1244. }
  1245. if(ones_score == 1 && twos_score == 2 && threes_score == 6 && fours_score == 4)
  1246. {
  1247. smallStraight_score = 30;
  1248. }
  1249. if(ones_score == 1 && twos_score == 2 && threes_score == 3 && fours_score == 8)
  1250. {
  1251. smallStraight_score = 30;
  1252. }
  1253. if(twos_score == 2 && threes_score == 3 && fours_score == 4 && fives_score == 5)
  1254. {
  1255. smallStraight_score = 30;
  1256. }
  1257. if(twos_score == 4 && threes_score == 3 && fours_score == 4 && fives_score == 5)
  1258. {
  1259. smallStraight_score = 30;
  1260. }
  1261. if(twos_score == 2 && threes_score == 6 && fours_score == 4 && fives_score == 5)
  1262. {
  1263. smallStraight_score = 30;
  1264. }
  1265. if(twos_score == 2 && threes_score == 3 && fours_score == 8 && fives_score == 5)
  1266. {
  1267. smallStraight_score = 30;
  1268. }
  1269. if(twos_score == 2 && threes_score == 3 && fours_score == 4 && fives_score == 10)
  1270. {
  1271. smallStraight_score = 30;
  1272. }
  1273. if(threes_score == 3 && fours_score == 4 && fives_score == 5 && sixes_score == 6)
  1274. {
  1275. smallStraight_score = 30;
  1276. }
  1277. if(threes_score == 6 && fours_score == 4 && fives_score == 5 && sixes_score == 6)
  1278. {
  1279. smallStraight_score = 30;
  1280. }
  1281. if(threes_score == 3 && fours_score == 8 && fives_score == 5 && sixes_score == 6)
  1282. {
  1283. smallStraight_score = 30;
  1284. }
  1285. if(threes_score == 3 && fours_score == 4 && fives_score == 10 && sixes_score == 6)
  1286. {
  1287. smallStraight_score = 30;
  1288. }
  1289. if(threes_score == 3 && fours_score == 4 && fives_score == 5 && sixes_score == 12)
  1290. {
  1291. smallStraight_score = 30;
  1292. }
  1293.  
  1294. }
  1295.  
  1296. printf("%s\n",display0);
  1297. printf("%s\n",display1);
  1298. printf("%s\n",display2);
  1299. printf("%s\n",display3);
  1300.  
  1301. //chance
  1302. for(entry = 0; entry < Entries; entry++)
  1303. {
  1304. chance_score = chance_score + roll[entry];
  1305. }
  1306. if(fullHouse1 == 1 && fullHouse2 == 1)
  1307. fullHouse_score = 25;
  1308.  
  1309. ScoreCardPlayerTwo();
  1310.  
  1311. }
  1312.  
  1313. void ReRollPlayerTwo() //same function as for palyer one
  1314. {
  1315. int loop_command = 1, loop2;
  1316. while (loop_command > 0)
  1317. {
  1318. printf("\n Command Meaning ");
  1319. printf("\n a Finish Roll");
  1320. printf("\n b Roll some number of dice");
  1321. printf("\n c Exit the program all together\n");
  1322. printf("\n\n Please enter the option you would like.");
  1323. scanf("%c", &command);
  1324.  
  1325. switch(command)
  1326. {
  1327. case'a':
  1328. loop_command = -1;
  1329. break;
  1330. case'b':
  1331. printf("How many die would you like to change (1 through 5)? Please enter that number now.");
  1332. loop2 =1;
  1333. while (loop2 > 0)
  1334. {
  1335. scanf("%i", &numDiceChange);
  1336. while(getchar() != '\n') {}
  1337. if (numDiceChange > 0 && numDiceChange < 6)
  1338. loop2 = -1;
  1339. else
  1340. {
  1341. printf("This is an invalid entry. Please enter a valid entry.");
  1342. }
  1343. }
  1344. printf("\nPlease enter the dice you would like to reroll. For example if you want to reroll the second die that appeared enter 2 then press enter.\n");
  1345. printf("The number of die is from left to right, and there must be a space between each number.");
  1346.  
  1347. for(changingDice = 0; changingDice < numDiceChange; changingDice ++)
  1348. {
  1349. scanf("\n%i", &dieChange);
  1350. switch(dieChange)
  1351. {
  1352. case(1):
  1353. roll[0] = rand()% numPossibleRolls + 1;
  1354. break;
  1355. case(2):
  1356. roll[1] = rand()% numPossibleRolls + 1;
  1357. break;
  1358. case(3):
  1359. roll[2] = rand()% numPossibleRolls + 1;
  1360. break;
  1361. case(4):
  1362. roll[3] = rand()% numPossibleRolls + 1;
  1363. break;
  1364. case(5):
  1365. roll[4] = rand()% numPossibleRolls + 1;
  1366. break;
  1367.  
  1368. }
  1369. dieChange = 0;
  1370. }
  1371. printf("\nYour new dice and scoresheet are \n");
  1372. PrintDiceAndScorePlayerTwo();
  1373. loop_command = -1;
  1374. break;
  1375. case'c':
  1376. printf("\nThank you for playing. The program in now terminating.\n\n ");
  1377. exit(0);
  1378. break;
  1379. default:
  1380. printf("\n Error. You must enter a, b, or c. Please enter a valid command.");
  1381. break;
  1382. }
  1383. while(getchar() != '\n') {}
  1384. }
  1385. }
  1386.  
  1387.  
  1388. void PrintDicePlayerTwo() //sane functiona s for one
  1389. {
  1390. char display0, display1, display2, display3;
  1391. printf("%c\n",display0);
  1392. printf("%c\n",display1);
  1393. printf("%c\n",display2);
  1394. printf("%c\n",display3);
  1395. }
  1396.  
  1397. void ScoreCardPlayerTwo()
  1398. {
  1399. printf("\n___________________________________________________________");
  1400. printf("\n SCORECARD - PLAYER 2 ");
  1401. printf("\n___________________________________________________________");
  1402. printf("\n Current Roll Score ");
  1403. printf("\n-------------------|-------------------|-------------------");
  1404. printf("\n Ones %i ", ones_score);
  1405.  
  1406. if(perm_ones_score_player_two >= 0)
  1407. printf(" %i ", perm_ones_score_player_two);
  1408.  
  1409. printf("\n-------------------|-------------------|-------------------");
  1410. printf("\n Twos %i ", twos_score);
  1411.  
  1412. if(perm_twos_score_player_two >= 0)
  1413. printf(" %i ", perm_twos_score_player_two);
  1414.  
  1415. printf("\n-------------------|-------------------|-------------------");
  1416. printf("\n Threes %i ", threes_score);
  1417.  
  1418. if(perm_threes_score_player_two >= 0)
  1419. printf(" %i ", perm_threes_score_player_two);
  1420.  
  1421. printf("\n-------------------|-------------------|-------------------");
  1422. printf("\n Fours %i ", fours_score);
  1423.  
  1424. if(perm_fours_score_player_two >= 0)
  1425. printf(" %i ", perm_fours_score_player_two);
  1426.  
  1427. printf("\n-------------------|-------------------|-------------------");
  1428. printf("\n Fives %i ", fives_score);
  1429.  
  1430. if(perm_fives_score_player_two >= 0)
  1431. printf(" %i ", perm_fives_score_player_two);
  1432.  
  1433. printf("\n-------------------|-------------------|-------------------");
  1434. printf("\n Sixes %i ", sixes_score);
  1435.  
  1436. if(perm_sixes_score_player_two >= 0)
  1437. printf(" %i ", perm_sixes_score_player_two);
  1438. printf("\n***********************************************************");
  1439. printf("\n Sum ");
  1440. printf("\n-------------------|-------------------|-------------------");
  1441. printf("\n Bonus ");
  1442. printf("\n***********************************************************");
  1443. printf("\n Three of a kind %i ", threeOfAKind_score);
  1444.  
  1445. if(perm_threeOfAKind_score_player_two >= 0)
  1446. printf(" %i ", perm_threeOfAKind_score_player_two);
  1447.  
  1448. printf("\n-------------------|-------------------|-------------------");
  1449. printf("\n Four of a kind %i ", fourOfAKind_score);
  1450.  
  1451. if(perm_fourOfAKind_score_player_two >= 0)
  1452. printf(" %i ", perm_fourOfAKind_score_player_two);
  1453.  
  1454. printf("\n-------------------|-------------------|-------------------");
  1455. printf("\n Full House %i ", fullHouse_score);
  1456.  
  1457. if(perm_fullHouse_score_player_two >= 0)
  1458. printf(" %i ", perm_fullHouse_score_player_two);
  1459.  
  1460. printf("\n-------------------|-------------------|-------------------");
  1461. printf("\n Small straight %i ", smallStraight_score);
  1462.  
  1463. if(perm_smallStraight_score_player_two >= 0)
  1464. printf(" %i ", perm_smallStraight_score_player_two);
  1465.  
  1466. printf("\n-------------------|-------------------|-------------------");
  1467. printf("\n Large straight %i ", largeStraight_score);
  1468.  
  1469. if(perm_largeStraight_score_player_two >= 0)
  1470. printf(" %i ", perm_largeStraight_score_player_two);
  1471. printf("\n-------------------|-------------------|-------------------");
  1472. printf("\n Chance %i ", chance_score);
  1473.  
  1474. if(perm_chance_score_player_two >= 0)
  1475. printf(" %i ", perm_chance_score_player_two);
  1476.  
  1477. printf("\n-------------------|-------------------|-------------------");
  1478. printf("\n YAHTZHEE %i ", yahtzee_score);
  1479.  
  1480. if(perm_yahtzee_score_player_two >= 0)
  1481. printf(" %i ", perm_yahtzee_score_player_two);
  1482. printf("\n*******************|***************************************");
  1483. printf("\n TOTAL SCORE ");
  1484. printf("\n___________________|___________________|___________________\n");
  1485. }
  1486.  
  1487. void ScoreCardFinalPlayerTwo()
  1488. {
  1489. sum_player_two = perm_ones_score_player_two + perm_twos_score_player_two + perm_threes_score_player_two + perm_fours_score_player_two + perm_fives_score_player_two + perm_sixes_score_player_two;
  1490. printf("\n___________________________________________________________");
  1491. printf("\n SCORECARD - PLAYER 2 ");
  1492. printf("\n___________________________________________________________");
  1493. printf("\n Current Roll Score ");
  1494. printf("\n-------------------|-------------------|-------------------");
  1495. printf("\n Ones %i ", ones_score);
  1496.  
  1497. if(perm_ones_score_player_two >= 0)
  1498. printf(" %i ", perm_ones_score_player_two);
  1499.  
  1500. printf("\n-------------------|-------------------|-------------------");
  1501. printf("\n Twos %i ", twos_score);
  1502.  
  1503. if(perm_twos_score_player_two >= 0)
  1504. printf(" %i ", perm_twos_score_player_two);
  1505.  
  1506. printf("\n-------------------|-------------------|-------------------");
  1507. printf("\n Threes %i ", threes_score);
  1508.  
  1509. if(perm_threes_score_player_two >= 0)
  1510. printf(" %i ", perm_threes_score_player_two);
  1511.  
  1512. printf("\n-------------------|-------------------|-------------------");
  1513. printf("\n Fours %i ", fours_score);
  1514.  
  1515. if(perm_fours_score_player_two >= 0)
  1516. printf(" %i ", perm_fours_score_player_two);
  1517.  
  1518. printf("\n-------------------|-------------------|-------------------");
  1519. printf("\n Fives %i ", fives_score);
  1520.  
  1521. if(perm_fives_score_player_two >= 0)
  1522. printf(" %i ", perm_fives_score_player_two);
  1523.  
  1524. printf("\n-------------------|-------------------|-------------------");
  1525. printf("\n Sixes %i ", sixes_score);
  1526.  
  1527. if(perm_sixes_score >= 0)
  1528. printf(" %i ", perm_sixes_score);
  1529. printf("\n***********************************************************");
  1530. printf("\n Sum | | %i ", sum_player_two);
  1531. printf("\n-------------------|-------------------|-------------------");
  1532. printf("\n Bonus | ");
  1533.  
  1534. if(sum_player_two >= 63)
  1535. {
  1536. bonus_player_two = 35;
  1537. printf(" %i ", bonus_player_two);
  1538. }
  1539. else
  1540. printf("0");
  1541.  
  1542. printf("\n***********************************************************");
  1543. printf("\n Three of a kind %i ", threeOfAKind_score);
  1544.  
  1545. if(perm_threeOfAKind_score_player_two >= 0)
  1546. printf(" %i ", perm_threeOfAKind_score_player_two);
  1547.  
  1548. printf("\n-------------------|-------------------|-------------------");
  1549. printf("\n Four of a kind %i ", fourOfAKind_score);
  1550.  
  1551. if(perm_fourOfAKind_score_player_two >= 0)
  1552. printf(" %i ", perm_fourOfAKind_score_player_two);
  1553.  
  1554. printf("\n-------------------|-------------------|-------------------");
  1555. printf("\n Full House %i ", fullHouse_score);
  1556.  
  1557. if(perm_fullHouse_score_player_two >= 0)
  1558. printf(" %i ", perm_fullHouse_score_player_two);
  1559.  
  1560. printf("\n-------------------|-------------------|-------------------");
  1561. printf("\n Small straight %i ", smallStraight_score);
  1562.  
  1563. if(perm_smallStraight_score_player_two >= 0)
  1564. printf(" %i ", perm_smallStraight_score_player_two);
  1565.  
  1566. printf("\n-------------------|-------------------|-------------------");
  1567. printf("\n Large straight %i ", largeStraight_score);
  1568.  
  1569. if(perm_largeStraight_score_player_two >= 0)
  1570. printf(" %i ", perm_largeStraight_score_player_two);
  1571. printf("\n-------------------|-------------------|-------------------");
  1572. printf("\n Chance %i ", chance_score);
  1573.  
  1574. if(perm_chance_score_player_two >= 0)
  1575. printf(" %i ", perm_chance_score_player_two);
  1576.  
  1577. printf("\n-------------------|-------------------|-------------------");
  1578. printf("\n YAHTZHEE %i ", yahtzee_score);
  1579.  
  1580. if(perm_yahtzee_score_player_two >= 0)
  1581. printf(" %i ", perm_yahtzee_score_player_two);
  1582. printf("\n*******************|***************************************");
  1583. total_player_two = sum_player_two + bonus_player_two + perm_threeOfAKind_score_player_two + perm_fourOfAKind_score_player_two + perm_fullHouse_score_player_two + perm_smallStraight_score_player_two + perm_largeStraight_score_player_two + perm_chance_score_player_two + perm_yahtzee_score_player_two;
  1584. printf("\n TOTAL SCORE %i ", total_player_two);
  1585. printf("\n___________________|___________________|___________________\n");
  1586. }
  1587.  
  1588. void PointAllocation_PlayerTwo()
  1589. {
  1590. int loop_command = 1;
  1591.  
  1592. while(loop_command > 0)
  1593. {
  1594. printf("\n\n Where would you like your points to be allocated? To select your choice enter the command from the command list below");
  1595. printf("\n Command Points to ");
  1596. printf("\n 1 Ones");
  1597. printf("\n 2 Twos");
  1598. printf("\n 3 Threes");
  1599. printf("\n 4 Fours");
  1600. printf("\n 5 Fives");
  1601. printf("\n 6 Sixes");
  1602. printf("\n 7 Three of a kind");
  1603. printf("\n 8 Four of a kind");
  1604. printf("\n 9 Full House");
  1605. printf("\n 10 Small Straight");
  1606. printf("\n 11 Large Straight");
  1607. printf("\n 12 Chance");
  1608. printf("\n 13 Yahtzee\n");
  1609.  
  1610. scanf("%d", &allocation_command);
  1611. while(getchar() != '\n') {}
  1612. switch (allocation_command)
  1613. {
  1614. case 1:
  1615. if(perm_ones_score_player_two == -1)//to ensure score hasnt already been set
  1616. {
  1617. perm_ones_score_player_two = ones_score;
  1618. loop_command = -1;
  1619. }
  1620. else
  1621. printf("\n This score has already been set. Please choose another command.\n\n");
  1622. break;
  1623. case 2:
  1624. if(perm_twos_score_player_two == -1) //to ensure score hasnt already been set
  1625. {
  1626. perm_twos_score_player_two = twos_score;
  1627. loop_command = -1;
  1628. }
  1629. else
  1630. printf("\n This score has already been set. Please choose another command.\n\n");
  1631. break;
  1632. case 3:
  1633. if(perm_threes_score_player_two == -1) //to ensure score hasnt already been set
  1634. {
  1635. perm_threes_score_player_two = threes_score;
  1636. loop_command = -1;
  1637. }
  1638. else
  1639. printf("\n This score has already been set. Please choose another command.\n\n");
  1640. allocation_command = -1;
  1641. break;
  1642. case 4:
  1643. if(perm_fours_score_player_two == -1) //to ensure score hasnt already been set
  1644. {
  1645. perm_fours_score_player_two = fours_score;
  1646. loop_command = -1;
  1647. }
  1648. else
  1649. printf("\n This score has already been set. Please choose another command.\n\n");
  1650.  
  1651. break;
  1652. case 5:
  1653. if(perm_fives_score_player_two == -1) //to ensure score hasnt already been set
  1654. {
  1655. perm_fives_score_player_two = fives_score;
  1656. loop_command = -1;
  1657. }
  1658. else
  1659. printf("\n This score has already been set. Please choose another command.\n\n");
  1660. break;
  1661. case 6:
  1662. if(perm_sixes_score_player_two == -1) //to ensure score hasnt already been set
  1663. {
  1664. perm_sixes_score_player_two = sixes_score;
  1665. loop_command = -1;
  1666. }
  1667. else
  1668. printf("\n This score has already been set. Please choose another command.\n\n");
  1669. break;
  1670. case 7:
  1671. if(perm_threeOfAKind_score_player_two == -1) //to ensure score hasnt already been set
  1672. {
  1673. perm_threeOfAKind_score_player_two = threeOfAKind_score;
  1674. loop_command = -1;
  1675. }
  1676. else
  1677. printf("\n This score has already been set. Please choose another command.\n\n");
  1678. break;
  1679. case 8:
  1680. if(perm_fourOfAKind_score_player_two == -1) //to ensure score hasnt already been set
  1681. {
  1682. perm_fourOfAKind_score_player_two = fourOfAKind_score;
  1683. loop_command = -1;
  1684. }
  1685. else
  1686. printf("\n This score has already been set. Please choose another command.\n\n");
  1687. break;
  1688. case 9:
  1689. if(perm_fullHouse_score_player_two == -1) //to ensure score hasnt already been set
  1690. {
  1691. perm_fullHouse_score_player_two = fullHouse_score;
  1692. loop_command = -1;
  1693. }
  1694. else
  1695. printf("\n This score has already been set. Please choose another command.\n\n");
  1696. break;
  1697. case 10:
  1698. if(perm_smallStraight_score_player_two == -1) //to ensure score hasnt already been set
  1699. {
  1700. perm_smallStraight_score_player_two = smallStraight_score;
  1701. loop_command = -1;
  1702. }
  1703. else
  1704. printf("\n This score has already been set. Please choose another command.\n\n");
  1705. break;
  1706. case 11:
  1707. if(perm_largeStraight_score_player_two == -1) //to ensure score hasnt already been set
  1708. {
  1709. perm_largeStraight_score_player_two = largeStraight_score;
  1710. loop_command = -1;
  1711. }
  1712. else
  1713. printf("\n This score has already been set. Please choose another command.\n\n");
  1714. break;
  1715. case 12:
  1716. if(perm_chance_score_player_two == -1) //to ensure score hasnt already been set
  1717. {
  1718. perm_chance_score_player_two = chance_score;
  1719. loop_command = -1;
  1720. }
  1721. else
  1722. printf("\n This score has already been set. Please choose another command.\n\n");
  1723. break;
  1724. case 13:
  1725. if(perm_yahtzee_score_player_two == -1) //to ensure score hasnt already been set
  1726. {
  1727. perm_yahtzee_score_player_two = yahtzee_score;
  1728. loop_command = -1;
  1729. }
  1730. else
  1731. printf("\n This score has already been set. Please choose another command.\n\n");
  1732. break;
  1733. }
  1734.  
  1735. }
  1736. }
  1737.  
  1738. void Results()
  1739. {
  1740. if(total > total_player_two) // wille display which player one and what their score was
  1741. {
  1742. printf("\n***********************************************************");
  1743. printf("\n CONGRATULATIONS TO THE WINNER:");
  1744. printf("\n PLAYER 1 ");
  1745. printf("\n FINAL SCORE: PLAYER 1: %i PLAYER 2: %i", total, total_player_two);
  1746. printf("\n***********************************************************");
  1747. }
  1748. if(total_player_two > total)
  1749. {
  1750. printf("\n***********************************************************");
  1751. printf("\n CONGRATULATIONS TO THE WINNER: ");
  1752. printf("\n PLAYER 2 ");
  1753. printf("\n FINAL SCORE: PLAYER 1: %i PLAYER 2: %i", total, total_player_two);
  1754. printf("\n***********************************************************");
  1755. }
  1756. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement