Advertisement
Guest User

Untitled

a guest
Dec 10th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.62 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <time.h>
  5. #include <cctype>
  6. #include <string>
  7. #include <chrono>
  8. #include <thread>
  9. #include <ctime>
  10.  
  11.  
  12. /*Current Problems:
  13. -Game Time Is Off
  14. -Game Time Is Stuck
  15. -Computer's Turn Does Not Process/Loop Correctly
  16. -Player's Turn Does Not Loop
  17. -No Return Zone Implemented
  18. -Need To Implement Final Score
  19. */
  20.  
  21. using namespace std;
  22.  
  23. //Goals And Returns:
  24.  
  25. //Player Goal In Zone 1
  26. //Computer Goal In Zone 5
  27. //Returns 1,2,3,4,5 According To The Zone The Ball Was Turned Over In
  28. //Returns 6 If The Player/Computer Scores
  29.  
  30. //Function Initialization
  31. int PlayerLoop(int startTime);
  32. int ComputerLoop(int startTime);
  33. bool IsGameOver(int startTime);
  34. int GetAccuracy();
  35. void Menu();
  36. int GetCoinToss();
  37. int GameStart();
  38. int ComputerGen();
  39.  
  40. //Kick Percentages
  41. const int zone1ShortKick = 60;
  42. const int zone1LongKick = 20;
  43. const int zone1GoalKick = 75;
  44.  
  45. const int zone2ShortKick = 70;
  46. const int zone2LongKick = 25;
  47. const int zone2GoalKick = 5;
  48.  
  49. const int zone3ShortKick = 80;
  50. const int zone3LongKick = 35;
  51.  
  52.  
  53. int main()
  54. {
  55. srand(time(0));
  56. int startTime = time(NULL);
  57.  
  58. //TESTING SPACE
  59. //TESTING SPACE
  60.  
  61. Menu();
  62.  
  63. //Scoring
  64. int playerScore;
  65. int computerScore;
  66. playerScore = 0;
  67. computerScore = 0;
  68.  
  69. //Game Start If/Else
  70. char play;
  71. cout << "Press 1. To Play" << endl;
  72. cout << "Press 2. To Exit" << endl;
  73. cin >> play;
  74.  
  75. int zone = 3;
  76. if (play = 1)
  77. {
  78. //Game starts here
  79.  
  80. if (GameStart() == 1)
  81. {
  82. cout << "It's The Player's Turn." << endl;
  83. PlayerLoop(startTime);
  84. do
  85. {
  86. cout << "It Is Now The Computer's Turn." << endl;
  87. ComputerLoop(startTime);
  88. cout << "It Is Now The Player's Turn." << endl;
  89. PlayerLoop(startTime);
  90.  
  91. } while (IsGameOver(startTime) == false);
  92. }
  93. else
  94. {
  95. cout << "It's The Computer's Turn." << endl;
  96. ComputerLoop(startTime);
  97. do
  98. {
  99. cout << "It Is Now The Player's Turn." << endl;
  100. PlayerLoop(startTime);
  101. cout << "It Is Now The Computer's Turn." << endl;
  102. ComputerLoop(startTime);
  103.  
  104. } while (IsGameOver(startTime) == false);
  105.  
  106. }
  107.  
  108. //After Game Ends
  109. cout << "The Game Is Over!" << endl;
  110. cout << "The Player's Score Is: " << playerScore << endl;
  111. cout << "The Computer's Score Is: " << computerScore << endl;
  112. if (playerScore > computerScore)
  113. {
  114. cout << "Congratulations, You Won!";
  115. }
  116. else
  117. {
  118. cout << "You Lose. Better Luck Next Time!";
  119. }
  120.  
  121. }
  122. else
  123. {
  124. exit(0);
  125. }
  126.  
  127.  
  128. return 0;
  129. }
  130.  
  131. int GetAccuracy()
  132. {
  133. //Min - Max Variables
  134. int min = 0;
  135. int max = 100;
  136.  
  137.  
  138.  
  139. int randomNumber = rand() % (min - max) + 1;
  140. return randomNumber;
  141. }
  142.  
  143. //Menu for when the game is first started, or a previous game has finished
  144. void Menu()
  145. {
  146.  
  147. //Game Menu
  148. cout << "===================================================" << endl;
  149. cout << "===============Soccer Game Project=================" << endl;
  150. cout << "===================================================" << endl;
  151. cout << "== How To Play: ==" << endl;
  152. cout << "== 5 Minute Games ==" << endl;
  153. cout << "== - ==" << endl;
  154. cout << "== Player With The Highest Score Wins ==" << endl;
  155. cout << "== - ==" << endl;
  156. cout << "== Move Ball To Opponents Goal ==" << endl;
  157. cout << "== - ==" << endl;
  158. cout << "== Takes 2 Short Kicks To Advance Zones ==" << endl;
  159. cout << "== - ==" << endl;
  160. cout << "== Takes 1 Long Kick To Advance Zones ==" << endl;
  161. cout << "== - ==" << endl;
  162. cout << "== Long Kicks Are More Likely To Get Intercepted ==" << endl;
  163. cout << "== Goal Kicks Have A Better Chance At Landing ==" << endl;
  164. cout << "== The Closer The Ball Is To The Scoring Zone ==" << endl;
  165. cout << "== - ==" << endl;
  166. cout << "== Controls: ==" << endl;
  167. cout << "== 1. Short Kick ==" << endl;
  168. cout << "== 2. Long Kick ==" << endl;
  169. cout << "== 3. Goal Kick ==" << endl;
  170. cout << "== - ==" << endl;
  171. cout << "===================================================" << endl;
  172. cout << "Press Enter To Continue" << endl;
  173. cin.ignore();
  174. }
  175.  
  176.  
  177.  
  178.  
  179. int ComputerGen()
  180. {
  181. //Min - Max Variables
  182. int min = 0;
  183. int max = 100;
  184.  
  185.  
  186. int randomNumber = rand() % (min - max) + 1;
  187. return randomNumber;
  188. }
  189.  
  190. int GetCoinToss()
  191. {
  192. //Min - Max Variables
  193. int min = 0;
  194. int max = 1;
  195.  
  196. int coinToss = rand() % (min - max) + 1;
  197. return coinToss;
  198. }
  199.  
  200. int GameStart()
  201. {
  202. //Variables
  203. char headsOrTails;
  204. int playerInput;
  205.  
  206. do
  207. {
  208. cout << "The Game Will Now Start With A Coin Toss." << endl;
  209. cout << "Do You Choose Heads Or Tails?" << endl;
  210. cout << "Please type h for Heads or h for Tails." << endl;
  211. cout << "Input is case-sensitive." << endl;
  212. cin >> headsOrTails;
  213.  
  214. //Get Player's Choice
  215. if (headsOrTails == 'h')
  216. {
  217. playerInput = 1;
  218. }
  219. else if (headsOrTails == 't')
  220. {
  221. playerInput = 0;
  222. }
  223. else
  224. {
  225. cout << "Input Incorrect. Please type h for Heads or t for Tails." << endl; //Need to fix. Not looping.
  226. }
  227. } while (headsOrTails != 'h' && headsOrTails != 't');
  228.  
  229. //Determine Winner
  230. if (GetCoinToss() == playerInput)
  231. {
  232. //Player
  233. return 1;
  234. }
  235. else
  236. {
  237. //Computer
  238. return 0;
  239. }
  240.  
  241. }
  242.  
  243. int PlayerLoop(int startTime)
  244. {
  245. //Variables
  246. char kickType;
  247. int maxTime;
  248. maxTime = 300;
  249.  
  250. int zone;
  251. zone = 3;
  252.  
  253. bool opponentHasBall;
  254. opponentHasBall = false;
  255.  
  256. //Do-While Loop
  257. do
  258. {
  259. cout << "Game Time:" << startTime << "/300 Seconds." << endl;
  260. cout << "The Ball Is In Zone " << zone << " Your Opponents Goal Is In Zone 5" << endl;
  261. cout << "It Is Your Move." << endl;
  262. cout << "Press 1. for Short Kick, press 2. for Long Kick, or press 3 for Goal Kick." << endl;
  263. cin >> kickType;
  264.  
  265. //Kick Choice
  266.  
  267. //Short Kick
  268. if (kickType == '1')
  269. {
  270.  
  271. cout << "Kick Type: 1 selected." << endl;
  272. std::this_thread::sleep_for(std::chrono::milliseconds(1000));
  273.  
  274. if (zone == 1)
  275. {
  276. //test
  277. cout << "In Zone 1." << endl;
  278. std::this_thread::sleep_for(std::chrono::milliseconds(1000));
  279.  
  280. if (GetAccuracy() < zone1ShortKick)
  281. {
  282. std::this_thread::sleep_for(std::chrono::milliseconds(200));
  283. cout << "First pass is a success." << endl;
  284. if (GetAccuracy() < zone1ShortKick)
  285. {
  286. std::this_thread::sleep_for(std::chrono::milliseconds(200));
  287. cout << "Second pass is a success." << endl;
  288. std::this_thread::sleep_for(std::chrono::milliseconds(200));
  289. cout << "The ball moves to zone 2." << endl;
  290. zone = 2;
  291.  
  292. }
  293. else
  294. {
  295. opponentHasBall = true;
  296. cout << "Turnover! Your opponent now has the ball." << endl;
  297. }
  298. }
  299. else
  300. {
  301. opponentHasBall = true;
  302. cout << "Turnover! Your opponent now has the ball." << endl;
  303. }
  304. }
  305. else if (zone == 2)
  306. {
  307. //test
  308. cout << "In Zone 2." << endl;
  309. std::this_thread::sleep_for(std::chrono::milliseconds(1000));
  310.  
  311. if (GetAccuracy() < zone2ShortKick)
  312. {
  313. std::this_thread::sleep_for(std::chrono::milliseconds(200));
  314. cout << "First pass is a success." << endl;
  315. if (GetAccuracy() < zone2ShortKick)
  316. {
  317. std::this_thread::sleep_for(std::chrono::milliseconds(200));
  318. cout << "Second pass is a success." << endl;
  319. std::this_thread::sleep_for(std::chrono::milliseconds(200));
  320. cout << "The ball moves to zone 3." << endl;
  321. zone = 3;
  322. }
  323. else
  324. {
  325. opponentHasBall = true;
  326. cout << "Turnover! Your opponent now has the ball." << endl;
  327. }
  328. }
  329. else
  330. {
  331. opponentHasBall = true;
  332. cout << "Turnover! Your opponent now has the ball." << endl;
  333. }
  334. }
  335. else if (zone == 3)
  336. {
  337. //test
  338. cout << "In Zone 3." << endl;
  339. std::this_thread::sleep_for(std::chrono::milliseconds(1000));
  340.  
  341. if (GetAccuracy() < zone3ShortKick)
  342. {
  343. std::this_thread::sleep_for(std::chrono::milliseconds(200));
  344. cout << "First pass is a success." << endl;
  345. if (GetAccuracy() < zone3ShortKick)
  346. {
  347. std::this_thread::sleep_for(std::chrono::milliseconds(200));
  348. cout << "Second pass is a success." << endl;
  349. std::this_thread::sleep_for(std::chrono::milliseconds(200));
  350. cout << "The ball moves to zone 4." << endl;
  351. zone = 4;
  352. }
  353. else
  354. {
  355. opponentHasBall == true;
  356. cout << "Turnover! Your opponent now has the ball." << endl;
  357. }
  358. }
  359. else
  360. {
  361. opponentHasBall = true;
  362. cout << "Turnover! Your opponent now has the ball." << endl;
  363. }
  364. }
  365. else if (zone == 4)
  366. {
  367. //test
  368. cout << "In Zone 4." << endl;
  369. std::this_thread::sleep_for(std::chrono::milliseconds(1000));
  370.  
  371. if (GetAccuracy() < zone2ShortKick)
  372. {
  373. std::this_thread::sleep_for(std::chrono::milliseconds(200));
  374. cout << "First pass is a success." << endl;
  375. if (GetAccuracy() < zone2ShortKick)
  376. {
  377. std::this_thread::sleep_for(std::chrono::milliseconds(200));
  378. cout << "Second pass is a success." << endl;
  379. std::this_thread::sleep_for(std::chrono::milliseconds(200));
  380. cout << "The ball moves to zone 5." << endl;
  381. zone = 5;
  382. }
  383. else
  384. {
  385. opponentHasBall = true;
  386. cout << "Turnover! Your opponent now has the ball." << endl;
  387. }
  388. }
  389. else
  390. {
  391. opponentHasBall = true;
  392. cout << "Turnover! Your opponent now has the ball." << endl;
  393. }
  394. }
  395. else if (zone == 5)
  396. {
  397. //test
  398. cout << "In Zone 5." << endl;
  399. std::this_thread::sleep_for(std::chrono::milliseconds(1000));
  400.  
  401. if (GetAccuracy() < zone1ShortKick)
  402. {
  403. std::this_thread::sleep_for(std::chrono::milliseconds(200));
  404. cout << "First pass is a success." << endl;
  405. if (GetAccuracy() < zone1ShortKick)
  406. {
  407. std::this_thread::sleep_for(std::chrono::milliseconds(200));
  408. cout << "Second pass is a success." << endl;
  409. std::this_thread::sleep_for(std::chrono::milliseconds(200));
  410. cout << "The ball stays in zone 5" << endl;
  411. zone = 5;
  412. }
  413. else
  414. {
  415. opponentHasBall = true;
  416. cout << "Turnover! Your opponent now has the ball." << endl;
  417. }
  418. }
  419. else
  420. {
  421. opponentHasBall = true;
  422. cout << "Turnover! Your opponent now has the ball." << endl;
  423. }
  424. }
  425. }
  426.  
  427. //Long Kick
  428. else if (kickType == '2')
  429. {
  430. cout << "Kick Type: 2 selected." << endl;
  431. std::this_thread::sleep_for(std::chrono::milliseconds(1000));
  432.  
  433. if (zone == 1)
  434. {
  435. cout << "In Zone 1." << endl;
  436. if (GetAccuracy() < zone1LongKick)
  437. {
  438. std::this_thread::sleep_for(std::chrono::milliseconds(200));
  439. cout << "The pass is successful." << endl;
  440. std::this_thread::sleep_for(std::chrono::milliseconds(200));
  441. cout << "The ball moves to zone 2." << endl;
  442. zone = 2;
  443. }
  444. else
  445. {
  446. opponentHasBall = true;
  447. cout << "Turnover! Your opponent now has the ball." << endl;
  448. }
  449. }
  450. else if (zone == 2)
  451. {
  452. cout << "In Zone 2." << endl;
  453. if (GetAccuracy() < zone2LongKick)
  454. {
  455. std::this_thread::sleep_for(std::chrono::milliseconds(200));
  456. cout << "The pass is successful." << endl;
  457. std::this_thread::sleep_for(std::chrono::milliseconds(200));
  458. cout << "The ball moves to zone 3." << endl;
  459. zone = 3;
  460. }
  461. else
  462. {
  463. opponentHasBall = true;
  464. cout << "Turnover! Your opponent now has the ball." << endl;
  465. }
  466. }
  467. else if (zone == 3)
  468. {
  469. cout << "In Zone 3." << endl;
  470. if (GetAccuracy() < zone3LongKick)
  471. {
  472. std::this_thread::sleep_for(std::chrono::milliseconds(200));
  473. cout << "The pass is successful." << endl;
  474. std::this_thread::sleep_for(std::chrono::milliseconds(200));
  475. cout << "The ball moves to zone 4." << endl;
  476. zone = 4;
  477. }
  478. else
  479. {
  480. opponentHasBall = true;
  481. cout << "Turnover! Your opponent now has the ball." << endl;
  482. }
  483. }
  484. else if (zone == 4)
  485. {
  486. cout << "In Zone 4." << endl;
  487. if (GetAccuracy() < zone2LongKick)
  488. {
  489. std::this_thread::sleep_for(std::chrono::milliseconds(200));
  490. cout << "The pass is successful." << endl;
  491. std::this_thread::sleep_for(std::chrono::milliseconds(200));
  492. cout << "The ball moves to zone 5." << endl;
  493. zone = 5;
  494. }
  495. else
  496. {
  497. opponentHasBall = true;
  498. cout << "Turnover! Your opponent now has the ball." << endl;
  499. }
  500. }
  501. else if (zone == 5)
  502. {
  503. cout << "In Zone 5." << endl;
  504. if (GetAccuracy() < zone1LongKick)
  505. {
  506. std::this_thread::sleep_for(std::chrono::milliseconds(200));
  507. cout << "The ball stays in zone 5." << endl;
  508. zone = 5;
  509. }
  510. else
  511. {
  512. opponentHasBall = true;
  513. cout << "Turnover! Your opponent now has the ball." << endl;
  514. }
  515. }
  516. }
  517.  
  518. //Goal Kick
  519. else if (kickType == '3')
  520. {
  521. cout << "Kick Type: 3 selected." << endl;
  522. std::this_thread::sleep_for(std::chrono::milliseconds(1000));
  523.  
  524. if (zone == 1)
  525. {
  526. cout << "In Zone 1." << endl;
  527. if (GetAccuracy() < 0)
  528. {
  529.  
  530. }
  531. else
  532. {
  533. opponentHasBall = true;
  534. cout << "Turnover! Your opponent now has the ball." << endl;
  535. }
  536. }
  537. else if (zone == 2)
  538. {
  539. cout << "In Zone 2." << endl;
  540. if (GetAccuracy() < 0)
  541. {
  542.  
  543. }
  544. else
  545. {
  546. opponentHasBall = true;
  547. cout << "Turnover! Your opponent now has the ball." << endl;
  548. }
  549. }
  550. else if (zone == 3)
  551. {
  552. cout << "In Zone 3." << endl;
  553. if (GetAccuracy() < 0)
  554. {
  555.  
  556. }
  557. else
  558. {
  559. opponentHasBall = true;
  560. cout << "Turnover! Your opponent now has the ball." << endl;
  561. }
  562. }
  563. else if (zone == 4)
  564. {
  565. cout << "In Zone 4." << endl;
  566. if (GetAccuracy() < zone2GoalKick)
  567. {
  568. std::this_thread::sleep_for(std::chrono::milliseconds(200));
  569. cout << "The pass is successful." << endl;
  570. std::this_thread::sleep_for(std::chrono::milliseconds(200));
  571. cout << "You scored a goal!" << endl;
  572. return 6;
  573. }
  574. else
  575. {
  576. opponentHasBall = true;
  577. cout << "Turnover! Your opponent now has the ball." << endl;
  578. }
  579. }
  580. else if (zone == 5)
  581. {
  582. cout << "In Zone 5." << endl;
  583. if (GetAccuracy() < zone1GoalKick)
  584. {
  585. std::this_thread::sleep_for(std::chrono::milliseconds(200));
  586. cout << "The pass is successful." << endl;
  587. std::this_thread::sleep_for(std::chrono::milliseconds(200));
  588. cout << "You scored a goal!" << endl;
  589. return 6;
  590. }
  591. else
  592. {
  593. opponentHasBall = true;
  594. cout << "Turnover! Your opponent now has the ball." << endl;
  595. }
  596. }
  597. }
  598. else
  599. {
  600. cout << "Input Incorrect." << endl;
  601. cout << "Press 1. for Short Kick, press 2. for Long Kick, or press 3 for Goal Kick." << endl;
  602. }
  603. } while ((kickType != '1' && kickType != '2' && kickType != '3' && opponentHasBall == false) && IsGameOver(startTime) != false);
  604. }
  605.  
  606. //Player Goal In Zone 1
  607. //Computer Goal In Zone 5
  608.  
  609. int ComputerLoop(int startTime)
  610. {
  611. //Variables
  612. char kickType;
  613. int maxTime;
  614. maxTime = 300;
  615.  
  616. int zone;
  617. zone = 3;
  618.  
  619. bool opponentHasBall;
  620. opponentHasBall = false;
  621.  
  622. int decide = ComputerGen();
  623.  
  624. //Do-While Loop
  625.  
  626. //Kick Type
  627. //SK: decide < 40
  628. //LK: 41 < decide < 50
  629. //GK: 51 < decide
  630. do
  631. {
  632. //Zone 1
  633. if (zone == 1)
  634. {
  635. cout << "Your opponent is in Zone 1." << endl;
  636. std::this_thread::sleep_for(std::chrono::milliseconds(200));
  637. cout << "Your opponent shoots for a goal!" << endl;
  638. if (GetAccuracy() < zone1GoalKick)
  639. {
  640. std::this_thread::sleep_for(std::chrono::milliseconds(200));
  641. cout << "Your opponent scores!" << endl;
  642. return 6;
  643. }
  644. else
  645. {
  646. opponentHasBall = true;
  647. }
  648. }
  649.  
  650. //Zone 2
  651. else if (zone == 2)
  652. {
  653. cout << "Your opponent is in Zone 2." << endl;
  654. std::this_thread::sleep_for(std::chrono::milliseconds(200));
  655. //Short Kick
  656. if (decide < 40)
  657. {
  658. cout << "Your opponent uses a short kick." << endl;
  659. if (GetAccuracy() < zone2ShortKick)
  660. {
  661. std::this_thread::sleep_for(std::chrono::milliseconds(200));
  662. cout << "First pass is a success." << endl;
  663. if (GetAccuracy() < zone2ShortKick)
  664. {
  665. std::this_thread::sleep_for(std::chrono::milliseconds(200));
  666. cout << "Second pass is a success." << endl;
  667. cout << "The ball moves to zone 1." << endl;
  668. zone = 1;
  669. }
  670. else
  671. {
  672. cout << "Turnover!" << endl;
  673. opponentHasBall = true;
  674. }
  675. }
  676. else
  677. {
  678. cout << "Turnover!" << endl;
  679. opponentHasBall = true;
  680. }
  681. }
  682. //Long Kick
  683. else if (41 < decide < 50)
  684. {
  685. cout << "Your opponent uses a long kick." << endl;
  686. if (GetAccuracy() < zone2LongKick)
  687. {
  688. std::this_thread::sleep_for(std::chrono::milliseconds(200));
  689. cout << "The pass is successful." << endl;
  690. cout << "The ball moves to zone 1." << endl;
  691. zone = 1;
  692. }
  693. else
  694. {
  695. cout << "Turnover!" << endl;
  696. opponentHasBall = true;
  697. }
  698. }
  699. //Goal Kick
  700. else if (51 < decide)
  701. {
  702. cout << "Your opponent shoots for a goal!" << endl;
  703. if (GetAccuracy() < zone2GoalKick)
  704. {
  705. std::this_thread::sleep_for(std::chrono::milliseconds(200));
  706. cout << "Your opponent scores!" << endl;
  707. return 6;
  708. }
  709. else
  710. {
  711. cout << "Turnover!" << endl;
  712. opponentHasBall = true;
  713. }
  714. }
  715. }
  716. //Zone 3
  717. else if (zone == 3)
  718. {
  719. cout << "Your opponent is in Zone 3." << endl;
  720.  
  721. //Short Kick
  722. if (decide < 49)
  723. {
  724. std::this_thread::sleep_for(std::chrono::milliseconds(200));
  725. cout << "Your opponent uses a short kick." << endl;
  726. if (GetAccuracy() < zone3ShortKick)
  727. {
  728. std::this_thread::sleep_for(std::chrono::milliseconds(200));
  729. cout << "First pass is a success." << endl;
  730. if (GetAccuracy() < zone3ShortKick)
  731. {
  732. std::this_thread::sleep_for(std::chrono::milliseconds(200));
  733. cout << "Second pass is a success." << endl;
  734. cout << "The ball moves to zone 2." << endl;
  735. zone = 2;
  736. }
  737. else
  738. {
  739. cout << "Turnover!" << endl;
  740. opponentHasBall = true;
  741. }
  742. }
  743. else
  744. {
  745. cout << "Turnover!" << endl;
  746. opponentHasBall = true;
  747. }
  748. }
  749. //Long Kick
  750. else (50 < decide);
  751. {
  752. cout << "Your opponent uses a long kick." << endl;
  753. if (GetAccuracy() < zone3LongKick)
  754. {
  755. std::this_thread::sleep_for(std::chrono::milliseconds(200));
  756. cout << "The pass is successful." << endl;
  757. cout << "The ball moves to zone 2." << endl;
  758. zone = 2;
  759. }
  760. else
  761. {
  762. cout << "Turnover!" << endl;
  763. opponentHasBall = true;
  764. }
  765. }
  766. }
  767.  
  768. //Zone 4
  769.  
  770. else if (zone == 4)
  771. {
  772. cout << "Your opponent is in Zone 4." << endl;
  773.  
  774. //Short Kick
  775. if (decide < 49)
  776. {
  777. cout << "Your opponent uses a short kick." << endl;
  778. if (GetAccuracy() < zone3ShortKick)
  779. {
  780. std::this_thread::sleep_for(std::chrono::milliseconds(200));
  781. cout << "First pass is a success." << endl;
  782. if (GetAccuracy() < zone3ShortKick)
  783. {
  784. std::this_thread::sleep_for(std::chrono::milliseconds(200));
  785. cout << "Second pass is a success." << endl;
  786. cout << "The ball moves to zone 3." << endl;
  787. zone = 3;
  788. }
  789. else
  790. {
  791. cout << "Turnover!" << endl;
  792. opponentHasBall = true;
  793. }
  794. }
  795. else
  796. {
  797. cout << "Turnover!" << endl;
  798. opponentHasBall = true;
  799. }
  800. }
  801. //Long Kick
  802. else (50 < decide);
  803. {
  804. cout << "Your opponent uses a long kick." << endl;
  805. if (GetAccuracy() < zone3LongKick)
  806. {
  807. std::this_thread::sleep_for(std::chrono::milliseconds(200));
  808. cout << "The pass is successful." << endl;
  809. cout << "The ball moves to zone 3." << endl;
  810. zone = 3;
  811. }
  812. else
  813. {
  814. cout << "Turnover!" << endl;
  815. opponentHasBall = true;
  816. }
  817. }
  818. }
  819.  
  820. //Zone 5
  821. else if (zone == 5)
  822. {
  823. cout << "Your opponent is in Zone 5." << endl;
  824.  
  825. //Short Kick
  826. if (decide < 49)
  827. {
  828. cout << "Your opponent uses a short kick." << endl;
  829. if (GetAccuracy() < zone3ShortKick)
  830. {
  831. std::this_thread::sleep_for(std::chrono::milliseconds(200));
  832. cout << "First pass is a success." << endl;
  833. if (GetAccuracy() < zone3ShortKick)
  834. {
  835. std::this_thread::sleep_for(std::chrono::milliseconds(200));
  836. cout << "Second pass is a success." << endl;
  837. cout << "The ball moves to zone 4." << endl;
  838. zone = 4;
  839. }
  840. else
  841. {
  842. cout << "Turnover!" << endl;
  843. opponentHasBall = true;
  844. }
  845. }
  846. else
  847. {
  848. cout << "Turnover!" << endl;
  849. opponentHasBall = true;
  850. }
  851. }
  852. //Long Kick
  853. else if (50 < decide)
  854. {
  855. cout << "Your opponent uses a long kick." << endl;
  856. if (GetAccuracy() < zone3LongKick)
  857. {
  858. std::this_thread::sleep_for(std::chrono::milliseconds(200));
  859. cout << "The pass is successful." << endl;
  860. cout << "The ball moves to zone 4." << endl;
  861. zone = 4;
  862. }
  863. else
  864. {
  865. cout << "Turnover!" << endl;
  866. opponentHasBall = true;
  867. }
  868. }
  869. }
  870.  
  871.  
  872. } while (opponentHasBall = false);
  873. }
  874.  
  875. const int GameRunTime = 5;
  876.  
  877. bool IsGameOver(int startTime)
  878. {
  879. int currentTime = time(NULL);
  880. int elapsed = currentTime - startTime;
  881.  
  882. if (elapsed >= GameRunTime * 60)
  883. {
  884. return true;
  885. }
  886.  
  887. return false;
  888. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement