Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 32.64 KB | None | 0 0
  1. bool Play::IsPossible(string value, int output) //To check which move is possible
  2. {
  3. if (value == "antonpiece1")
  4. {
  5. if (antonpiece1 == anton)
  6. {
  7. if (output == 6) //Choose a piece to start with
  8. {
  9. if (antonpiece1->next == antonpiece2 || antonpiece1->next == antonpiece3 || antonpiece1->next == antonpiece4)
  10. {
  11. cout << "Not possible to move " << (value) << endl;
  12. return false;
  13. }
  14. else
  15. {
  16. cout << "You can move " << (value) << endl;
  17. return true;
  18. }
  19. }
  20. else
  21. {
  22. cout << "Not possible to move " << (value) << endl;
  23. return false;
  24. }
  25. }
  26. else
  27. {
  28. Point* tee;
  29. tee = antonpiece1;
  30. bool TowardYourHome = false; //tee will go towards home if true
  31. for (int i = 0; i < output; i++)
  32. {
  33. if (tee->value == 24) //last space before going home, tells it to go to home space
  34. {
  35. TowardYourHome = true;
  36. }
  37. if (!TowardYourHome)
  38. {
  39. tee = tee->next;
  40. }
  41. if (TowardYourHome)
  42. {
  43. tee = tee->out;
  44. }
  45. if (tee == NULL) //if run out of spaces
  46. {
  47. cout << "Not possible to move " << (value) << endl;
  48. return false;
  49. }
  50. }
  51. if (tee == antonpiece2 || tee == antonpiece3 || tee == antonpiece4) //if space is occupied
  52. {
  53. cout << "Not possible to move " << (value) << endl;
  54. return false;
  55. }
  56. else
  57. {
  58. cout << "You can move " << (value) << endl;
  59. return true;
  60. }
  61. }
  62. }
  63. if (value == "antonpiece2")
  64. {
  65. if (antonpiece2 == anton)
  66. {
  67. if (output == 6) //Choose a piece to start with
  68. {
  69. if (antonpiece2->next == antonpiece1 || antonpiece2->next == antonpiece3 || antonpiece2->next == antonpiece4)
  70. {
  71. cout << "Not possible to move " << (value) << endl;
  72. return false;
  73. }
  74. else
  75. {
  76. cout << "You can move " << (value) << endl;
  77. return true;
  78. }
  79. }
  80. else
  81. {
  82. cout << "Not possible to move " << (value) << endl;
  83. return false;
  84. }
  85. }
  86. else
  87. {
  88. Point* tee;
  89. tee = antonpiece2;
  90. bool TowardYourHome = false; //tee will go towards home if true
  91. for (int i = 0; i < output; i++)
  92. {
  93. if (tee->value == 24) //last space before going home, tells it to go to home space
  94. {
  95. TowardYourHome = true;
  96. }
  97. if (!TowardYourHome)
  98. {
  99. tee = tee->next;
  100. }
  101. if (TowardYourHome)
  102. {
  103. tee = tee->out;
  104. }
  105. if (tee == NULL) //if run out of spaces
  106. {
  107. cout << "Not possible to move " << (value) << endl;
  108. return false;
  109. }
  110. }
  111. if (tee == antonpiece1 || tee == antonpiece3 || tee == antonpiece4) //if space is occupied
  112. {
  113. cout << "Not possible to move " << (value) << endl;
  114. return false;
  115. }
  116. else
  117. {
  118. cout << "You can move " << (value) << endl;
  119. return true;
  120. }
  121. }
  122. }
  123. if (value == "antonpiece3")
  124. {
  125. if (antonpiece3 == anton)
  126. {
  127. if (output == 6) //Choose a piece to start with
  128. {
  129. if (antonpiece3->next == antonpiece2 || antonpiece3->next == antonpiece1 || antonpiece3->next == antonpiece4)
  130. {
  131. cout << "Not possible to move " << (value) << endl;
  132. return false;
  133. }
  134. else
  135. {
  136. cout << "You can move " << (value) << endl;
  137. return true;
  138. }
  139. }
  140. else
  141. {
  142. cout << "Not possible to move " << (value) << endl;
  143. return false;
  144. }
  145. }
  146. else
  147. {
  148. Point* tee;
  149. tee = antonpiece3;
  150. bool TowardYourHome = false; //tee will go towards home if true
  151. for (int i = 0; i < output; i++)
  152. {
  153. if (tee->value == 24) //last space before going home, tells it to go to home space
  154. {
  155. TowardYourHome = true;
  156. }
  157. if (!TowardYourHome)
  158. {
  159. tee = tee->next;
  160. }
  161. if (TowardYourHome)
  162. {
  163. tee = tee->out;
  164. }
  165. if (tee == NULL) //if run out of spaces
  166. {
  167. cout << "Not possible to move " << (value) << endl;
  168. return false;
  169. }
  170. }
  171. if (tee == antonpiece2 || tee == antonpiece1 || tee == antonpiece4) //if space is occupied
  172. {
  173. cout << "Not possible to move " << (value) << endl;
  174. return false;
  175. }
  176. else
  177. {
  178. cout << "You can move " << (value) << endl;
  179. return true;
  180. }
  181. }
  182. }
  183. if (value == "antonpiece4")
  184. {
  185. if (antonpiece4 == anton)
  186. {
  187. if (output == 6) //Choose a piece to start with
  188. {
  189. if (antonpiece4->next == antonpiece2 || antonpiece4->next == antonpiece3 || antonpiece4->next == antonpiece1)
  190. {
  191. cout << "Not possible to move " << (value) << endl;
  192. return false;
  193. }
  194. else
  195. {
  196. cout << "You can move " << (value) << endl;
  197. return true;
  198. }
  199. }
  200. else
  201. {
  202. cout << "Not possible to move " << (value) << endl;
  203. return false;
  204. }
  205. }
  206. else
  207. {
  208. Point* tee;
  209. tee = antonpiece4;
  210. bool TowardYourHome = false; //tee will go towards home if true
  211. for (int i = 0; i < output; i++)
  212. {
  213. if (tee->value == 24) //last space before going home, tells it to go to home space
  214. {
  215. TowardYourHome = true;
  216. }
  217. if (!TowardYourHome)
  218. {
  219. tee = tee->next;
  220. }
  221. if (TowardYourHome)
  222. {
  223. tee = tee->out;
  224. }
  225. if (tee == NULL) //if run out of spaces
  226. {
  227. cout << "Not possible to move " << (value) << endl;
  228. return false;
  229. }
  230. }
  231. if (tee == antonpiece2 || tee == antonpiece3 || tee == antonpiece1) //if space is occupied
  232. {
  233. cout << "Not possible to move " << (value) << endl;
  234. return false;
  235. }
  236. else
  237. {
  238. cout << "You can move " << (value) << endl;
  239. return true;
  240. }
  241. }
  242. }
  243. if (value == "gabepiece1")
  244. {
  245. if (gabepiece1 == gabe)
  246. {
  247. if (output == 6) //Choose a piece to start with
  248. {
  249. if (gabepiece1->next == gabepiece2 || gabepiece1->next == gabepiece3 || gabepiece1->next == gabepiece4)
  250. {
  251. cout << "Not possible to move " << (value) << endl;
  252. return false;
  253. }
  254. else
  255. {
  256. cout << "You can move " << (value) << endl;
  257. return true;
  258. }
  259. }
  260. else
  261. {
  262. cout << "Not possible to move " << (value) << endl;
  263. return false;
  264. }
  265. }
  266. else
  267. {
  268. Point* tee;
  269. tee = gabepiece1;
  270. bool TowardYourHome = false; //tee will go towards home if true
  271. for (int i = 0; i < output; i++)
  272. {
  273. if (tee->value == 6) //last space before going home, tells it to go to home space
  274. {
  275. TowardYourHome = true;
  276. }
  277. if (!TowardYourHome)
  278. {
  279. tee = tee->next;
  280. }
  281. if (TowardYourHome)
  282. {
  283. tee = tee->out;
  284. }
  285. if (tee == NULL) //if run out of spaces
  286. {
  287. cout << "Not possible to move " << (value) << endl;
  288. return false;
  289. }
  290. }
  291. if (tee == gabepiece2 || tee == gabepiece3 || tee == gabepiece4) //if space is occupied
  292. {
  293. cout << "Not possible to move " << (value) << endl;
  294. return false;
  295. }
  296. else
  297. {
  298. cout << "You can move " << (value) << endl;
  299. return true;
  300. }
  301. }
  302. }
  303. if (value == "gabepiece2")
  304. {
  305. if (gabepiece2 == gabe)
  306. {
  307. if (output == 6) //Choose a piece to start with
  308. {
  309. if (gabepiece2->next == gabepiece1 || gabepiece2->next == gabepiece3 || gabepiece2->next == gabepiece4)
  310. {
  311. cout << "Not possible to move " << (value) << endl;
  312. return false;
  313. }
  314. else
  315. {
  316. cout << "You can move " << (value) << endl;
  317. return true;
  318. }
  319. }
  320. else
  321. {
  322. cout << "Not possible to move " << (value) << endl;
  323. return false;
  324. }
  325. }
  326. else
  327. {
  328. Point* tee;
  329. tee = gabepiece2;
  330. bool TowardYourHome = false; //tee will go towards home if true
  331. for (int i = 0; i < output; i++)
  332. {
  333. if (tee->value == 6) //last space before going home, tells it to go to home space
  334. {
  335. TowardYourHome = true;
  336. }
  337. if (!TowardYourHome)
  338. {
  339. tee = tee->next;
  340. }
  341. if (TowardYourHome)
  342. {
  343. tee = tee->out;
  344. }
  345. if (tee == NULL) //if run out of spaces
  346. {
  347. cout << "Not possible to move " << (value) << endl;
  348. return false;
  349. }
  350. }
  351. if (tee == gabepiece1 || tee == gabepiece3 || tee == gabepiece4) //if space is occupied
  352. {
  353. cout << "Not possible to move " << (value) << endl;
  354. return false;
  355. }
  356. else
  357. {
  358. cout << "You can move " << (value) << endl;
  359. return true;
  360. }
  361. }
  362. }
  363. if (value == "gabepiece3")
  364. {
  365. if (gabepiece3 == gabe)
  366. {
  367. if (output == 6) //Choose a piece to start with
  368. {
  369. if (gabepiece3->next == gabepiece2 || gabepiece3->next == gabepiece1 || gabepiece3->next == gabepiece4)
  370. {
  371. cout << "Not possible to move " << (value) << endl;
  372. return false;
  373. }
  374. else
  375. {
  376. cout << "You can move " << (value) << endl;
  377. return true;
  378. }
  379. }
  380. else
  381. {
  382. cout << "Not possible to move " << (value) << endl;
  383. return false;
  384. }
  385. }
  386. else
  387. {
  388. Point* tee;
  389. tee = gabepiece3;
  390. bool TowardYourHome = false; //tee will go towards home if true
  391. for (int i = 0; i < output; i++)
  392. {
  393. if (tee->value == 6) //last space before going home, tells it to go to home space
  394. {
  395. TowardYourHome = true;
  396. }
  397. if (!TowardYourHome)
  398. {
  399. tee = tee->next;
  400. }
  401. if (TowardYourHome)
  402. {
  403. tee = tee->out;
  404. }
  405. if (tee == NULL) //if run out of spaces
  406. {
  407. cout << "Not possible to move " << (value) << endl;
  408. return false;
  409. }
  410. }
  411. if (tee == gabepiece2 || tee == gabepiece1 || tee == gabepiece4) //if space is occupied
  412. {
  413. cout << "Not possible to move " << (value) << endl;
  414. return false;
  415. }
  416. else
  417. {
  418. cout << "You can move " << (value);
  419. return true;
  420. }
  421. }
  422. }
  423. if (value == "gabepiece4")
  424. {
  425. if (gabepiece4 == gabe)
  426. {
  427. if (output == 6) //Choose a piece to start with
  428. {
  429. if (gabepiece4->next == gabepiece2 || gabepiece4->next == gabepiece3 || gabepiece4->next == gabepiece1)
  430. {
  431. cout << "Not possible to move " << (value) << endl;
  432. return false;
  433. }
  434. else
  435. {
  436. cout << "You can move " << (value) << endl;
  437. return true;
  438. }
  439. }
  440. else
  441. {
  442. cout << "Not possible to move " << (value) << endl;
  443. return false;
  444. }
  445. }
  446. else
  447. {
  448. Point* tee;
  449. tee = gabepiece4;
  450. bool TowardYourHome = false; //tee will go towards home if true
  451. for (int i = 0; i < output; i++)
  452. {
  453. if (tee->value == 6) //last space before going home, tells it to go to home space
  454. {
  455. TowardYourHome = true;
  456. }
  457. if (!TowardYourHome)
  458. {
  459. tee = tee->next;
  460. }
  461. if (TowardYourHome)
  462. {
  463. tee = tee->out;
  464. }
  465. if (tee == NULL) //if run out of spaces
  466. {
  467. cout << "Not possible to move " << (value) << endl;
  468. return false;
  469. }
  470. }
  471. if (tee == gabepiece2 || tee == gabepiece3 || tee == gabepiece1) //if space is occupied
  472. {
  473. cout << "Not possible to move " << (value) << endl;
  474. return false;
  475. }
  476. else
  477. {
  478. cout << "You can move " << (value) << endl;
  479. return true;
  480. }
  481. }
  482. }
  483. if (value == "youngpiece1")
  484. {
  485. if (youngpiece1 == young)
  486. {
  487. if (output == 6) //Choose a piece to start with
  488. {
  489. if (youngpiece1->next == youngpiece2 || youngpiece1->next == youngpiece3 || youngpiece1->next == youngpiece4)
  490. {
  491. cout << "Not possible to move " << (value) << endl;
  492. return false;
  493. }
  494. else
  495. {
  496. cout << "You can move " << (value) << endl;
  497. return true;
  498. }
  499. }
  500. else
  501. {
  502. cout << "Not possible to move " << (value) << endl;
  503. return false;
  504. }
  505. }
  506. else
  507. {
  508. Point* tee;
  509. tee = youngpiece1;
  510. bool TowardYourHome = false; //tee will go towards home if true
  511. for (int i = 0; i < output; i++)
  512. {
  513. if (tee->value == 12) //last space before going home, tells it to go to home space
  514. {
  515. TowardYourHome = true;
  516. }
  517. if (!TowardYourHome)
  518. {
  519. tee = tee->next;
  520. }
  521. if (TowardYourHome)
  522. {
  523. tee = tee->out;
  524. }
  525. if (tee == NULL) //if run out of spaces
  526. {
  527. cout << "Not possible to move " << (value) << endl;
  528. return false;
  529. }
  530. }
  531. if (tee == youngpiece2 || tee == youngpiece3 || tee == youngpiece4) //if space is occupied
  532. {
  533. cout << "Not possible to move " << (value) << endl;
  534. return false;
  535. }
  536. else
  537. {
  538. cout << "You can move " << (value) << endl;
  539. return true;
  540. }
  541. }
  542. }
  543. if (value == "youngpiece2")
  544. {
  545. if (youngpiece2 == young)
  546. {
  547. if (output == 6) //Choose a piece to start with
  548. {
  549. if (youngpiece2->next == youngpiece1 || youngpiece2->next == youngpiece3 || youngpiece2->next == youngpiece4)
  550. {
  551. cout << "Not possible to move " << (value) << endl;
  552. return false;
  553. }
  554. else
  555. {
  556. cout << "You can move " << (value) << endl;
  557. return true;
  558. }
  559. }
  560. else
  561. {
  562. cout << "Not possible to move " << (value) << endl;
  563. return false;
  564. }
  565. }
  566. else
  567. {
  568. Point* tee;
  569. tee = youngpiece2;
  570. bool TowardYourHome = false; //tee will go towards home if true
  571. for (int i = 0; i < output; i++)
  572. {
  573. if (tee->value == 12) //last space before going home, tells it to go to home space
  574. {
  575. TowardYourHome = true;
  576. }
  577. if (!TowardYourHome)
  578. {
  579. tee = tee->next;
  580. }
  581. if (TowardYourHome)
  582. {
  583. tee = tee->out;
  584. }
  585. if (tee == NULL) //if run out of spaces
  586. {
  587. cout << "Not possible to move " << (value) << endl;
  588. return false;
  589. }
  590. }
  591. if (tee == youngpiece1 || tee == youngpiece3 || tee == youngpiece4) //if space is occupied
  592. {
  593. cout << "Not possible to move " << (value) << endl;
  594. return false;
  595. }
  596. else
  597. {
  598. cout << "You can move " << (value) << endl;
  599. return true;
  600. }
  601. }
  602. }
  603. if (value == "youngpiece3")
  604. {
  605. if (youngpiece3 == young)
  606. {
  607. if (output == 6) //Choose a piece to start with
  608. {
  609. if (youngpiece3->next == youngpiece2 || youngpiece3->next == youngpiece1 || youngpiece3->next == youngpiece4)
  610. {
  611. cout << "Not possible to move " << (value) << endl;
  612. return false;
  613. }
  614. else
  615. {
  616. cout << "You can move " << (value) << endl;
  617. return true;
  618. }
  619. }
  620. else
  621. {
  622. cout << "Not possible to move " << (value) << endl;
  623. return false;
  624. }
  625. }
  626. else
  627. {
  628. Point* tee;
  629. tee = youngpiece3;
  630. bool TowardYourHome = false; //tee will go towards home if true
  631. for (int i = 0; i < output; i++)
  632. {
  633. if (tee->value == 12) //last space before going home, tells it to go to home space
  634. {
  635. TowardYourHome = true;
  636. }
  637. if (!TowardYourHome)
  638. {
  639. tee = tee->next;
  640. }
  641. if (TowardYourHome)
  642. {
  643. tee = tee->out;
  644. }
  645. if (tee == NULL) //if run out of spaces
  646. {
  647. cout << "Not possible to move " << (value) << endl;
  648. return false;
  649. }
  650. }
  651. if (tee == youngpiece2 || tee == youngpiece1 || tee == youngpiece4) //if space is occupied
  652. {
  653. cout << "Not possible to move " << (value) << endl;
  654. return false;
  655. }
  656. else
  657. {
  658. cout << "You can move " << (value);
  659. return true;
  660. }
  661. }
  662. }
  663. if (value == "youngpiece4")
  664. {
  665. if (youngpiece4 == young)
  666. {
  667. if (output == 6) //Choose a piece to start with
  668. {
  669. if (youngpiece4->next == youngpiece2 || youngpiece4->next == youngpiece3 || youngpiece4->next == youngpiece1)
  670. {
  671. cout << "Not possible to move " << (value) << endl;
  672. return false;
  673. }
  674. else
  675. {
  676. cout << "You can move " << (value) << endl;
  677. return true;
  678. }
  679. }
  680. else
  681. {
  682. cout << "Not possible to move " << (value) << endl;
  683. return false;
  684. }
  685. }
  686. else
  687. {
  688. Point* tee;
  689. tee = youngpiece4;
  690. bool TowardYourHome = false; //tee will go towards home if true
  691. for (int i = 0; i < output; i++)
  692. {
  693. if (tee->value == 12) //last space before going home, tells it to go to home space
  694. {
  695. TowardYourHome = true;
  696. }
  697. if (!TowardYourHome)
  698. {
  699. tee = tee->next;
  700. }
  701. if (TowardYourHome)
  702. {
  703. tee = tee->out;
  704. }
  705. if (tee == NULL) //if run out of spaces
  706. {
  707. cout << "Not possible to move " << (value) << endl;
  708. return false;
  709. }
  710. }
  711. if (tee == youngpiece2 || tee == youngpiece3 || tee == youngpiece1) //if space is occupied
  712. {
  713. cout << "Not possible to move " << (value) << endl;
  714. return false;
  715. }
  716. else
  717. {
  718. cout << "You can move " << (value) << endl;
  719. return true;
  720. }
  721. }
  722. }
  723. if (value == "ronypiece1")
  724. {
  725. if (ronypiece1 == redstart)
  726. {
  727. if (output == 6) //Choose a piece to start with
  728. {
  729. if (ronypiece1->next == ronypiece2 || ronypiece1->next == ronypiece3 || ronypiece1->next == ronypiece4)
  730. {
  731. cout << "Not possible to move " << (value) << endl;
  732. return false;
  733. }
  734. else
  735. {
  736. cout << "You can move " << (value) << endl;
  737. return true;
  738. }
  739. }
  740. else
  741. {
  742. cout << "Not possible to move " << (value) << endl;
  743. return false;
  744. }
  745. }
  746. else
  747. {
  748. Point* tee;
  749. tee = ronypiece1;
  750. bool TowardYourHome = false; //tee will go towards home if true
  751. for (int i = 0; i < output; i++)
  752. {
  753. if (tee->value == 18) //last space before going home, tells it to go to home space
  754. {
  755. TowardYourHome = true;
  756. }
  757. if (!TowardYourHome)
  758. {
  759. tee = tee->next;
  760. }
  761. if (TowardYourHome)
  762. {
  763. tee = tee->out;
  764. }
  765. if (tee == NULL) //if run out of spaces
  766. {
  767. cout << "Not possible to move " << (value) << endl;
  768. return false;
  769. }
  770. }
  771. if (tee == ronypiece2 || tee == ronypiece3 || tee == ronypiece4) //if space is occupied
  772. {
  773. cout << "Not possible to move " << (value) << endl;
  774. return false;
  775. }
  776. else
  777. {
  778. cout << "You can move " << (value) << endl;
  779. return true;
  780. }
  781. }
  782. }
  783. if (value == "ronypiece2")
  784. {
  785. if (ronypiece2 == redstart)
  786. {
  787. if (output == 6) //Choose a piece to start with
  788. {
  789. if (ronypiece2->next == ronypiece1 || ronypiece2->next == ronypiece3 || ronypiece2->next == ronypiece4)
  790. {
  791. cout << "Not possible to move " << (value) << endl;
  792. return false;
  793. }
  794. else
  795. {
  796. cout << "You can move " << (value) << endl;
  797. return true;
  798. }
  799. }
  800. else
  801. {
  802. cout << "Not possible to move " << (value) << endl;
  803. return false;
  804. }
  805. }
  806. else
  807. {
  808. Point* tee;
  809. tee = ronypiece2;
  810. bool TowardYourHome = false; //tee will go towards home if true
  811. for (int i = 0; i < output; i++)
  812. {
  813. if (tee->value == 18) //last space before going home, tells it to go to home space
  814. {
  815. TowardYourHome = true;
  816. }
  817. if (!TowardYourHome)
  818. {
  819. tee = tee->next;
  820. }
  821. if (TowardYourHome)
  822. {
  823. tee = tee->out;
  824. }
  825. if (tee == NULL) //if run out of spaces
  826. {
  827. cout << "Not possible to move " << (value) << endl;
  828. return false;
  829. }
  830. }
  831. if (tee == ronypiece1 || tee == ronypiece3 || tee == ronypiece4) //if space is occupied
  832. {
  833. cout << "Not possible to move " << (value) << endl;
  834. return false;
  835. }
  836. else
  837. {
  838. cout << "You can move " << (value) << endl;
  839. return true;
  840. }
  841. }
  842. }
  843. if (value == "ronypiece3")
  844. {
  845. if (ronypiece3 == redstart)
  846. {
  847. if (output == 6) //Choose a piece to start with
  848. {
  849. if (ronypiece3->next == ronypiece2 || ronypiece3->next == ronypiece1 || ronypiece3->next == ronypiece4)
  850. {
  851. cout << "Not possible to move " << (value) << endl;
  852. return false;
  853. }
  854. else
  855. {
  856. cout << "You can move " << (value) << endl;
  857. return true;
  858. }
  859. }
  860. else
  861. {
  862. cout << "Not possible to move " << (value) << endl;
  863. return false;
  864. }
  865. }
  866. else
  867. {
  868. Point* tee;
  869. tee = ronypiece3;
  870. bool TowardYourHome = false; //tee will go towards home if true
  871. for (int i = 0; i < output; i++)
  872. {
  873. if (tee->value == 18) //last space before going home, tells it to go to home space
  874. {
  875. TowardYourHome = true;
  876. }
  877. if (!TowardYourHome)
  878. {
  879. tee = tee->next;
  880. }
  881. if (TowardYourHome)
  882. {
  883. tee = tee->out;
  884. }
  885. if (tee == NULL) //if run out of spaces
  886. {
  887. cout << "Not possible to move " << (value) << endl;
  888. return false;
  889. }
  890. }
  891. if (tee == ronypiece2 || tee == ronypiece1 || tee == ronypiece4) //if space is occupied
  892. {
  893. cout << "Not possible to move " << (value) << endl;
  894. return false;
  895. }
  896. else
  897. {
  898. cout << "You can move " << (value) << endl;
  899. return true;
  900. }
  901. }
  902. }
  903. if (value == "ronypiece4")
  904. {
  905. if (ronypiece4 == redstart)
  906. {
  907. if (output == 6) //Choose a piece to start with
  908. {
  909. if (ronypiece4->next == ronypiece2 || ronypiece4->next == ronypiece3 || ronypiece4->next == ronypiece1)
  910. {
  911. cout << "Not possible to move " << (value) << endl;
  912. return false;
  913. }
  914. else
  915. {
  916. cout << "You can move " << (value) << endl;
  917. return true;
  918. }
  919. }
  920. else
  921. {
  922. cout << "Not possible to move " << (value) << endl;
  923. return false;
  924. }
  925. }
  926. else
  927. {
  928. Point* tee;
  929. tee = ronypiece4;
  930. bool TowardYourHome = false; //tee will go towards home if true
  931. for (int i = 0; i < output; i++)
  932. {
  933. if (tee->value == 18) //last space before going home, tells it to go to home space
  934. {
  935. TowardYourHome = true;
  936. }
  937. if (!TowardYourHome)
  938. {
  939. tee = tee->next;
  940. }
  941. if (TowardYourHome)
  942. {
  943. tee = tee->out;
  944. }
  945. if (tee == NULL) //if run out of spaces
  946. {
  947. cout << "Not possible to move " << (value) << endl;
  948. return false;
  949. }
  950. }
  951. if (tee == ronypiece2 || tee == ronypiece3 || tee == ronypiece1) //if space is occupied
  952. {
  953. cout << "Not possible to move " << (value) << endl;
  954. return false;
  955. }
  956. else
  957. {
  958. cout << "You can move " << (value) << endl;
  959. return true;
  960. }
  961. }
  962. }
  963. }
  964.  
  965. bool TroubleBoard::AnyPossible(int output, string playerColour) //Determines if any output is possible
  966. {
  967. if (playerColour == "blue")
  968. {
  969. if (IsPossible("antonpiece1", output) == false & IsPossible("antonpiece2", output) == false & IsPossible("antonpiece3", output) == false & IsPossible("antonpiece4", output) == false)
  970. {
  971. cout << "Not possible to move any of your pieces with " << (output);
  972. cin.ignore(std::numeric_limits<streamsize>::max(),'n');
  973. return false;
  974. }
  975. else
  976. {
  977. return true;
  978. }
  979. }
  980. if (playerColour == "green")
  981. {
  982. if (IsPossible("gabepiece1", output) == false & IsPossible("gabepiece2", output) == false & IsPossible("gabepiece3", output) == false & IsPossible("gabepiece4", output) == false)
  983. {
  984. cout << "Not possible to move any of your pieces with " << (output);
  985. cin.ignore(std::numeric_limits<streamsize>::max(),'n');
  986. return false;
  987. }
  988. else
  989. {
  990. return true;
  991. }
  992. }
  993. if (playerColour == "yellow")
  994. {
  995. if (IsPossible("youngpiece1", output) == false & IsPossible("youngpiece2", output) == false & IsPossible("youngpiece3", output) == false & IsPossible("youngpiece4", output) & false)
  996. {
  997. cout << "Not possible to move any of your pieces with " << (output);
  998. cin.ignore(std::numeric_limits<streamsize>::max(),'n');
  999. return false;
  1000. }
  1001. else
  1002. {
  1003. return true;
  1004. }
  1005. }
  1006. if (playerColour == "red")
  1007. {
  1008. if (IsPossible("ronypiece1", output) == false & IsPossible("ronypiece2", output) == false & IsPossible("ronypiece3", output) == false & IsPossible("ronypiece4", output) == false)
  1009. {
  1010. cout << "Not possible to move any of your pieces with " << (output);
  1011. cin.ignore(std::numeric_limits<streamsize>::max(),'n');
  1012. return false;
  1013. }
  1014. else
  1015. {
  1016. return true;
  1017. }
  1018. }
  1019.  
  1020. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement