Advertisement
Guest User

Untitled

a guest
May 3rd, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.83 KB | None | 0 0
  1. /* Lab 5 - Trouver le Dalek
  2.  
  3. Programmé par : Elouan Colichet, Dylan Girard, Vincent Bradette
  4.  
  5. Professeur : René Aubry
  6. */
  7.  
  8. #include "stdafx.h"
  9. #include "stdio.h"
  10. #include <string>
  11. #include <iostream>
  12. #include <Windows.h>
  13. #include <time.h>
  14.  
  15. using namespace std;
  16.  
  17. HANDLE hConsole;
  18.  
  19. // Constante
  20. #define maxvie 5
  21. #define departpuissance 25
  22. #define maxpuissance 100
  23.  
  24. int viesRestantes = 0;
  25.  
  26. bool _salle = false;
  27. int _pGauche = 0, _milieu = 0, _pDroite = 0, _porte1 = 0, _porte2 = 0, _porte3 = 0, _porte4 = 0, _porte5 = 0, _porte6 = 0, _choix = 0;
  28.  
  29. class Personnage {
  30. public:
  31. int _position, _regeneration = 0, _puissance = 25;
  32. string _arme_main_droite = { "aucunes" };
  33. void affiPortes();
  34. void affiCouloirs(int position);
  35. void random();
  36. void posiPerso(int portes);
  37. void couloirs(int direction);
  38. void perdu();
  39. void header();
  40. void Salle1();
  41.  
  42. int _nb_vies, _pGauche, _milieu, _pDroite;
  43. char _tab_portes[3] = { '\x0B2', '\x0B2', '\x0B2' };
  44. char _tabEtage[3] = { '\x0B0', '\x0B0', '\x0B0' };
  45. char __porte1[2] = { '\x0B0', '\x0B0' };
  46. char __porte2[2] = { '\x0B0', '\x0B0' };
  47.  
  48. Personnage(int, int);
  49. };
  50.  
  51. class Magicien : public Personnage
  52. {
  53. public:
  54.  
  55. void Salle2(); // La salle des 6 _portes
  56. void iniPortes(); //initialisation des _portes
  57. void perdu2();
  58. int choix;
  59.  
  60. Magicien(int, int);
  61. };
  62.  
  63. Personnage::Personnage(int nb_vies, int puissance)
  64. {
  65. _nb_vies = nb_vies;
  66. _puissance = puissance;
  67. }
  68.  
  69. Magicien::Magicien(int nb_vies, int puissance):Personnage(nb_vies, puissance)
  70. {
  71. _nb_vies = nb_vies;
  72. _puissance = puissance;
  73. }
  74.  
  75. void Personnage::posiPerso(int portes)
  76. {
  77. random();
  78. if (_salle == true)
  79. {
  80. switch (portes)
  81. {
  82. case 1: {
  83. cout << "Vous entrez dans la porte gauche..." << endl;
  84. if (_pGauche == 0)
  85. {
  86. _nb_vies++;
  87. cout << "Vous gagnez une vie ! nb vies = " << _nb_vies << endl;
  88. }
  89. if (_pGauche == 1)
  90. {
  91. cout << "EXTERMINATE ! ..... Vous \x088tes mort...." << endl;
  92. system("pause");
  93. system("cls");
  94. perdu();
  95. }
  96. system("pause");
  97. system("cls");
  98. break;
  99. }
  100.  
  101. case 2: {
  102. cout << "Vous entrez dans la porte du milieu" << endl;
  103. if (_milieu == 0)
  104. {
  105. _nb_vies++;
  106. cout << "Vous gagnez une vie ! nb vies = " << _nb_vies << endl;
  107. }
  108. if (_milieu == 1)
  109. {
  110. cout << "EXTERMINATE ! ..... Vous \x088tes mort...." << endl;
  111. system("pause");
  112. system("cls");
  113. perdu();
  114. }
  115. system("pause");
  116. system("cls");
  117. break;
  118. }
  119.  
  120. case 3: {
  121. cout << "Vous entrez dans la porte droite" << endl;
  122. if (_pDroite == 0)
  123. {
  124. _nb_vies++;
  125. cout << "Vous gagnez une vie ! nb vies = " << _nb_vies << endl;
  126. }
  127. if (_pDroite == 1)
  128. {
  129. cout << "EXTERMINATE ! ..... Vous \x088tes mort...." << endl;
  130. system("pause");
  131. system("cls");
  132. perdu();
  133. }
  134. break;
  135. }
  136.  
  137. default:
  138. break;
  139. }
  140. }
  141.  
  142.  
  143. if (_salle == false)
  144. {
  145. switch (portes)
  146. {
  147. case 1: {
  148. cout << "Vous entrez dans la porte gauche...." << endl;
  149. break;
  150. }
  151.  
  152. case 2: {
  153. cout << "Vous montez les escaliers..." << endl;
  154. _salle = true;
  155. break;
  156. }
  157.  
  158. case 3: {
  159. cout << "Vous entrez dans la porte droite...." << endl;
  160. break;
  161. }
  162.  
  163. default:
  164. break;
  165. }
  166. }
  167.  
  168.  
  169. }
  170.  
  171. void Personnage::couloirs(int direction)
  172. {
  173. if (direction == 1)
  174. {
  175. cin >> direction;
  176. switch (direction)
  177. {
  178. case 1: {
  179. _nb_vies++;
  180. cout << "Vous descendez les escaliers et d\x082" << "couvrez une vie ! Nb Vies = " << _nb_vies << endl;
  181. system("pause");
  182. system("cls");
  183. break;
  184. }
  185. case 2: {
  186. _nb_vies++;
  187. cout << "Vous allez au fond du couloir et d\x082" << "couvrez une vie ! Nb Vies = " << _nb_vies << endl;
  188. system("pause");
  189. system("cls");
  190. break;
  191. }
  192. default:
  193. cout << "OUPS ! Rechoississez" << endl;
  194. couloirs(direction);
  195. }
  196.  
  197. Salle1();
  198. }
  199. if (direction == 3)
  200. {
  201. cin >> direction;
  202. switch (direction)
  203. {
  204. case 1: {
  205. _nb_vies++;
  206. cout << "Vous descendez les escaliers et d\x082" << "couvrez une vie ! Nb Vies = " << _nb_vies << endl;
  207. system("pause");
  208. system("cls");
  209. break;
  210. }
  211. case 2: {
  212. _nb_vies++;
  213. cout << "Vous allez au fond du couloir et d\x082" << "couvrez une vie ! Nb Vies = " << _nb_vies << endl;
  214. system("pause");
  215. system("cls");
  216. break;
  217. }
  218. default:
  219. cout << "OUPS ! Rechoississez" << endl;
  220. couloirs(direction);
  221. }
  222.  
  223. Salle1();
  224. }
  225. }
  226.  
  227. void Personnage::perdu()
  228. {
  229. int choix = 0;
  230. system("cls");
  231. cout << "Voulez vous retenter ?" << endl;
  232. cout << "oui(1) non (2)" << endl;
  233. cin >> choix;
  234. if (choix == 1)
  235. {
  236. _regeneration++;
  237. cout << "REGENERATION numero " << _regeneration << " ! " << "Allons-Y !" << endl;
  238. system("pause");
  239. system("cls");
  240. _salle = false;
  241. Salle1();
  242. }
  243. if (choix == 2)
  244. {
  245. cout << "Ok.. les Daleks ont envahis la Terre mais bon ..." << endl;
  246. cout << "C'est pas comme si la Terre n'allais pas \x088tre detruite..." << endl;
  247. cout << "Bye !" << endl;
  248. system("pause");
  249. system("cls");
  250. exit(0);
  251. }
  252. }
  253.  
  254. void Personnage::random()
  255. {
  256. srand((unsigned int)time(NULL));
  257.  
  258. _pGauche = rand() % 2;
  259. _pDroite = rand() % 2;
  260. _milieu = rand() % 2;
  261. }
  262.  
  263. void Personnage::affiCouloirs(int position)
  264. {
  265. for (int inst = 0; inst < 2; inst++)
  266. {
  267. if (position == 1)
  268. {
  269. cout << " " << __porte1[inst] << " ";
  270. }
  271. if (position == 3)
  272. {
  273. cout << " " << __porte2[inst] << " ";
  274. }
  275. }
  276. }
  277.  
  278. void Personnage::affiPortes()
  279. {
  280. if (_salle == false)
  281. {
  282. for (int inst = 0; inst < 3; inst++)
  283. {
  284. cout << " " << _tab_portes[inst] << " ";
  285. }
  286. cout << endl;
  287. }
  288. if (_salle == true)
  289. {
  290. for (int inst = 0; inst < 3; inst++)
  291. {
  292. cout << " " << _tabEtage[inst] << " ";
  293. }
  294. cout << endl;
  295. }
  296. }
  297.  
  298. void Personnage::header()
  299. {
  300. cout << "##############################################################################" << endl;
  301. cout << "###### Wibbly Wobbly Timey Wimey ! #########" << endl;
  302. cout << "##############################################################################" << endl << endl;
  303. cout << "Nb de vies = " << _nb_vies << endl;
  304. cout << "Arme = " << _arme_main_droite << endl;
  305. cout << "Puissance = " << _puissance << endl;
  306. cout << endl;
  307. }
  308.  
  309. void Personnage::Salle1()
  310. {
  311. int position = 0, choixArmes = 0;
  312.  
  313. cout << "Seigneur du temps ! bienvenue ! Vous avez \x082t\x082 contraint de vous retrouver \n sur une des lunes de SKARO," << endl;
  314. cout << "plan\x08Ate des Daleks, enemi de votre race. Vous tentez de leurs \x082" << "chapper mais vous devez pour cela rester discret." << endl;
  315. system("pause");
  316. system("cls");
  317. while (_nb_vies < 5)
  318. {
  319. if (_arme_main_droite == "aucunes")
  320. {
  321. header();
  322.  
  323. cout << "Choississez une arme parmis ces suivantes : " << endl << "1 - Canif" << endl << "2 - Marteau" << endl << "3 - Pioche" << endl;
  324.  
  325. cin >> choixArmes;
  326.  
  327. if (choixArmes == 1)
  328. {
  329. _arme_main_droite = { "Canif" };
  330. cout << "Vous choississez donc le " << _arme_main_droite << endl;
  331. system("pause");
  332. system("cls");
  333. }
  334. if (choixArmes == 2)
  335. {
  336. _arme_main_droite = { "Marteau" };
  337. cout << "Vous choississez donc le " << _arme_main_droite << endl;
  338. system("pause");
  339. system("cls");
  340. }
  341. if (choixArmes == 3)
  342. {
  343. _arme_main_droite = { "Pioche" };
  344. cout << "Vous choississez donc le " << _arme_main_droite << endl;
  345. system("pause");
  346. system("cls");
  347. }
  348. }
  349. else
  350. {
  351. header();
  352.  
  353. if (_salle == false)
  354. {
  355. affiPortes();
  356. cout << endl << "Quelle porte choississez vous ? input 1/2/3" << endl;
  357. cin >> position;
  358.  
  359. while (position <= 0 || position > 3)
  360. {
  361. cout << "Veuillez entrer de nouveau votre choix de porte. input 1/2/3" << endl;
  362. cin >> position;
  363. }
  364.  
  365. if (position == 1)
  366. {
  367. cout << "Quelle direction choississez vous ? Escalier (1) Couloir (2)" << endl;
  368. affiCouloirs(position);
  369. couloirs(position);
  370. }
  371.  
  372. if (position == 3)
  373. {
  374. cout << "Quelle direction choississez vous ? Escalier (1) Couloir (2)" << endl;
  375. affiCouloirs(position);
  376. couloirs(position);
  377. }
  378. }
  379.  
  380. affiPortes();
  381. posiPerso(position);
  382. system("pause");
  383.  
  384. if (_salle == true)
  385. {
  386. system("cls");
  387.  
  388. header();
  389.  
  390.  
  391. affiPortes();
  392. cout << "Vous entrez dans une grande salle dans laquelle se trouve trois portes." << endl;
  393. cout << "l'une d'entre elle cache un Dalek.... Bonne chance !" << endl;
  394. cout << "Veuillez entrer votre choix de porte de l'\x082tage input 1/2/3" << endl;
  395. cin >> position;
  396.  
  397. while (position <= 0 || position > 3)
  398. {
  399. cout << "Veuillez entrer de nouveau votre choix de porte input 1/2/3" << endl;
  400. cin >> position;
  401. }
  402. posiPerso(position);
  403. system("pause");
  404.  
  405. _salle = false;
  406. }
  407. }
  408. system("cls");
  409. }
  410.  
  411. Magicien magicien(1,1);
  412. magicien.iniPortes();
  413.  
  414. system("pause");
  415. }
  416.  
  417. void Magicien::Salle2()
  418. {
  419. int choix;
  420. cout << "Vous \x088tes desormais un magicien accomplis," << endl;
  421. cout << "vous poss\x08A" << "der un b\x083ton tueur d'ennemies" << endl << endl << endl;
  422. system("pause");
  423. system("cls");
  424.  
  425. cout << "===================================================================" << endl;
  426. cout << "| Salle 2 |" << endl;
  427. cout << "===================================================================" << endl << endl;
  428. cout << "Nb vies = " << _nb_vies << endl;
  429. cout << "Arme = " << _arme_main_droite << endl;
  430. cout << "Puissance = " << _puissance << endl << endl;
  431. cout << "Vous \x088tes dans une salle circulaire en cercle de 360" << "\xf8 " << endl << "ronde avec les coins de la piece arrondis." << endl;
  432. cout << "De plus, la piece est composer de 6 portes" << endl << "(placer de facon a ce que chaque porte forme un cercle )." << endl;
  433. cout << "Vous devez choisir une porte entre les 6 devants vous." << endl;
  434. cout << "Choisissez un chiffre de 1 \x085" << " 6" << endl;
  435. cin >> choix;
  436.  
  437. switch (choix) {
  438. case 1:
  439. {
  440. if (_porte1 == 0)
  441. {
  442. _nb_vies = 0;
  443.  
  444. perdu2();
  445. }
  446. else { _nb_vies += 1; }
  447. break;
  448. }
  449. case 2:
  450. {
  451. if (_porte2 == 0)
  452. {
  453. _nb_vies = 0;
  454. perdu();
  455. }
  456. else { _nb_vies = _nb_vies + 1; }
  457. break;
  458. }
  459. case 3:
  460. {
  461. if (_porte3 == 0)
  462. {
  463. _nb_vies = 0;
  464. perdu();
  465. }
  466. else { _nb_vies = _nb_vies + 1; }
  467. break;
  468. }
  469. case 4:
  470. {
  471. if (_porte4 == 0)
  472. {
  473. _nb_vies = 0;
  474. perdu();
  475. }
  476. else { _nb_vies = _nb_vies + 1; }
  477. break;
  478. }
  479. case 5:
  480. {
  481. if (_porte5 == 0)
  482. {
  483. _nb_vies = 0;
  484. perdu();
  485. }
  486. else { _nb_vies = _nb_vies + 1; }
  487. break;
  488. }
  489. case 6:
  490. {
  491. if (_porte6 == 0)
  492. {
  493. _nb_vies = 0;
  494. perdu();
  495. }
  496. else { _nb_vies = _nb_vies + 1; }
  497. break;
  498. }
  499. }
  500.  
  501. system("cls");
  502. cout << "Vous avez reussi, vous sentez votre puissance augmenter" << endl;
  503. cout << "Vous vous retrouvez avec un b\x083ton magique disparition des obstacle" << endl;
  504. }
  505.  
  506. void Magicien::perdu2()
  507. {
  508. system("cls");
  509. cout << "Voulez vous retenter ?" << endl;
  510. cout << "oui(1) non (2)" << endl;
  511. cin >> _choix;
  512. if (_choix == 1)
  513. {
  514. _regeneration++;
  515. cout << "REGENERATION numero " << _regeneration << " ! " << "Allons-Y !" << endl;
  516. system("pause");
  517. system("cls");
  518. Personnage personnage(1,1);
  519. personnage.Salle1();
  520. }
  521. if (_choix == 2)
  522. {
  523. cout << "Ok.. les Daleks ont envahis la Terre mais bon ..." << endl;
  524. cout << "C'est pas comme si la Terre n'allais pas \x088\tre detruite..." << endl;
  525. cout << "Bye !" << endl;
  526. system("pause");
  527. system("cls");
  528. exit(0);
  529. }
  530. }
  531.  
  532. void Magicien::iniPortes() {
  533.  
  534. srand((unsigned int)time(NULL)); // initialisation de rand
  535.  
  536. _porte1 = rand() % 2;
  537.  
  538. _porte2 = rand() % 2;
  539.  
  540. _porte3 = rand() % 2;
  541.  
  542. _porte4 = rand() % 2;
  543.  
  544. _porte5 = rand() % 2;
  545.  
  546. _porte6 = rand() % 2;
  547.  
  548. Salle2();
  549. }
  550.  
  551. void main()
  552. {
  553. Personnage personnage(1,1);
  554. personnage.Salle1();
  555. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement