Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool Play::IsPossible(string value, int output) //To check which move is possible
- {
- if (value == "antonpiece1")
- {
- if (antonpiece1 == anton)
- {
- if (output == 6) //Choose a piece to start with
- {
- if (antonpiece1->next == antonpiece2 || antonpiece1->next == antonpiece3 || antonpiece1->next == antonpiece4)
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- else
- {
- cout << "You can move " << (value) << endl;
- return true;
- }
- }
- else
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- }
- else
- {
- Point* tee;
- tee = antonpiece1;
- bool TowardYourHome = false; //tee will go towards home if true
- for (int i = 0; i < output; i++)
- {
- if (tee->value == 24) //last space before going home, tells it to go to home space
- {
- TowardYourHome = true;
- }
- if (!TowardYourHome)
- {
- tee = tee->next;
- }
- if (TowardYourHome)
- {
- tee = tee->out;
- }
- if (tee == NULL) //if run out of spaces
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- }
- if (tee == antonpiece2 || tee == antonpiece3 || tee == antonpiece4) //if space is occupied
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- else
- {
- cout << "You can move " << (value) << endl;
- return true;
- }
- }
- }
- if (value == "antonpiece2")
- {
- if (antonpiece2 == anton)
- {
- if (output == 6) //Choose a piece to start with
- {
- if (antonpiece2->next == antonpiece1 || antonpiece2->next == antonpiece3 || antonpiece2->next == antonpiece4)
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- else
- {
- cout << "You can move " << (value) << endl;
- return true;
- }
- }
- else
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- }
- else
- {
- Point* tee;
- tee = antonpiece2;
- bool TowardYourHome = false; //tee will go towards home if true
- for (int i = 0; i < output; i++)
- {
- if (tee->value == 24) //last space before going home, tells it to go to home space
- {
- TowardYourHome = true;
- }
- if (!TowardYourHome)
- {
- tee = tee->next;
- }
- if (TowardYourHome)
- {
- tee = tee->out;
- }
- if (tee == NULL) //if run out of spaces
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- }
- if (tee == antonpiece1 || tee == antonpiece3 || tee == antonpiece4) //if space is occupied
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- else
- {
- cout << "You can move " << (value) << endl;
- return true;
- }
- }
- }
- if (value == "antonpiece3")
- {
- if (antonpiece3 == anton)
- {
- if (output == 6) //Choose a piece to start with
- {
- if (antonpiece3->next == antonpiece2 || antonpiece3->next == antonpiece1 || antonpiece3->next == antonpiece4)
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- else
- {
- cout << "You can move " << (value) << endl;
- return true;
- }
- }
- else
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- }
- else
- {
- Point* tee;
- tee = antonpiece3;
- bool TowardYourHome = false; //tee will go towards home if true
- for (int i = 0; i < output; i++)
- {
- if (tee->value == 24) //last space before going home, tells it to go to home space
- {
- TowardYourHome = true;
- }
- if (!TowardYourHome)
- {
- tee = tee->next;
- }
- if (TowardYourHome)
- {
- tee = tee->out;
- }
- if (tee == NULL) //if run out of spaces
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- }
- if (tee == antonpiece2 || tee == antonpiece1 || tee == antonpiece4) //if space is occupied
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- else
- {
- cout << "You can move " << (value) << endl;
- return true;
- }
- }
- }
- if (value == "antonpiece4")
- {
- if (antonpiece4 == anton)
- {
- if (output == 6) //Choose a piece to start with
- {
- if (antonpiece4->next == antonpiece2 || antonpiece4->next == antonpiece3 || antonpiece4->next == antonpiece1)
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- else
- {
- cout << "You can move " << (value) << endl;
- return true;
- }
- }
- else
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- }
- else
- {
- Point* tee;
- tee = antonpiece4;
- bool TowardYourHome = false; //tee will go towards home if true
- for (int i = 0; i < output; i++)
- {
- if (tee->value == 24) //last space before going home, tells it to go to home space
- {
- TowardYourHome = true;
- }
- if (!TowardYourHome)
- {
- tee = tee->next;
- }
- if (TowardYourHome)
- {
- tee = tee->out;
- }
- if (tee == NULL) //if run out of spaces
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- }
- if (tee == antonpiece2 || tee == antonpiece3 || tee == antonpiece1) //if space is occupied
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- else
- {
- cout << "You can move " << (value) << endl;
- return true;
- }
- }
- }
- if (value == "gabepiece1")
- {
- if (gabepiece1 == gabe)
- {
- if (output == 6) //Choose a piece to start with
- {
- if (gabepiece1->next == gabepiece2 || gabepiece1->next == gabepiece3 || gabepiece1->next == gabepiece4)
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- else
- {
- cout << "You can move " << (value) << endl;
- return true;
- }
- }
- else
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- }
- else
- {
- Point* tee;
- tee = gabepiece1;
- bool TowardYourHome = false; //tee will go towards home if true
- for (int i = 0; i < output; i++)
- {
- if (tee->value == 6) //last space before going home, tells it to go to home space
- {
- TowardYourHome = true;
- }
- if (!TowardYourHome)
- {
- tee = tee->next;
- }
- if (TowardYourHome)
- {
- tee = tee->out;
- }
- if (tee == NULL) //if run out of spaces
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- }
- if (tee == gabepiece2 || tee == gabepiece3 || tee == gabepiece4) //if space is occupied
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- else
- {
- cout << "You can move " << (value) << endl;
- return true;
- }
- }
- }
- if (value == "gabepiece2")
- {
- if (gabepiece2 == gabe)
- {
- if (output == 6) //Choose a piece to start with
- {
- if (gabepiece2->next == gabepiece1 || gabepiece2->next == gabepiece3 || gabepiece2->next == gabepiece4)
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- else
- {
- cout << "You can move " << (value) << endl;
- return true;
- }
- }
- else
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- }
- else
- {
- Point* tee;
- tee = gabepiece2;
- bool TowardYourHome = false; //tee will go towards home if true
- for (int i = 0; i < output; i++)
- {
- if (tee->value == 6) //last space before going home, tells it to go to home space
- {
- TowardYourHome = true;
- }
- if (!TowardYourHome)
- {
- tee = tee->next;
- }
- if (TowardYourHome)
- {
- tee = tee->out;
- }
- if (tee == NULL) //if run out of spaces
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- }
- if (tee == gabepiece1 || tee == gabepiece3 || tee == gabepiece4) //if space is occupied
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- else
- {
- cout << "You can move " << (value) << endl;
- return true;
- }
- }
- }
- if (value == "gabepiece3")
- {
- if (gabepiece3 == gabe)
- {
- if (output == 6) //Choose a piece to start with
- {
- if (gabepiece3->next == gabepiece2 || gabepiece3->next == gabepiece1 || gabepiece3->next == gabepiece4)
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- else
- {
- cout << "You can move " << (value) << endl;
- return true;
- }
- }
- else
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- }
- else
- {
- Point* tee;
- tee = gabepiece3;
- bool TowardYourHome = false; //tee will go towards home if true
- for (int i = 0; i < output; i++)
- {
- if (tee->value == 6) //last space before going home, tells it to go to home space
- {
- TowardYourHome = true;
- }
- if (!TowardYourHome)
- {
- tee = tee->next;
- }
- if (TowardYourHome)
- {
- tee = tee->out;
- }
- if (tee == NULL) //if run out of spaces
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- }
- if (tee == gabepiece2 || tee == gabepiece1 || tee == gabepiece4) //if space is occupied
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- else
- {
- cout << "You can move " << (value);
- return true;
- }
- }
- }
- if (value == "gabepiece4")
- {
- if (gabepiece4 == gabe)
- {
- if (output == 6) //Choose a piece to start with
- {
- if (gabepiece4->next == gabepiece2 || gabepiece4->next == gabepiece3 || gabepiece4->next == gabepiece1)
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- else
- {
- cout << "You can move " << (value) << endl;
- return true;
- }
- }
- else
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- }
- else
- {
- Point* tee;
- tee = gabepiece4;
- bool TowardYourHome = false; //tee will go towards home if true
- for (int i = 0; i < output; i++)
- {
- if (tee->value == 6) //last space before going home, tells it to go to home space
- {
- TowardYourHome = true;
- }
- if (!TowardYourHome)
- {
- tee = tee->next;
- }
- if (TowardYourHome)
- {
- tee = tee->out;
- }
- if (tee == NULL) //if run out of spaces
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- }
- if (tee == gabepiece2 || tee == gabepiece3 || tee == gabepiece1) //if space is occupied
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- else
- {
- cout << "You can move " << (value) << endl;
- return true;
- }
- }
- }
- if (value == "youngpiece1")
- {
- if (youngpiece1 == young)
- {
- if (output == 6) //Choose a piece to start with
- {
- if (youngpiece1->next == youngpiece2 || youngpiece1->next == youngpiece3 || youngpiece1->next == youngpiece4)
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- else
- {
- cout << "You can move " << (value) << endl;
- return true;
- }
- }
- else
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- }
- else
- {
- Point* tee;
- tee = youngpiece1;
- bool TowardYourHome = false; //tee will go towards home if true
- for (int i = 0; i < output; i++)
- {
- if (tee->value == 12) //last space before going home, tells it to go to home space
- {
- TowardYourHome = true;
- }
- if (!TowardYourHome)
- {
- tee = tee->next;
- }
- if (TowardYourHome)
- {
- tee = tee->out;
- }
- if (tee == NULL) //if run out of spaces
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- }
- if (tee == youngpiece2 || tee == youngpiece3 || tee == youngpiece4) //if space is occupied
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- else
- {
- cout << "You can move " << (value) << endl;
- return true;
- }
- }
- }
- if (value == "youngpiece2")
- {
- if (youngpiece2 == young)
- {
- if (output == 6) //Choose a piece to start with
- {
- if (youngpiece2->next == youngpiece1 || youngpiece2->next == youngpiece3 || youngpiece2->next == youngpiece4)
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- else
- {
- cout << "You can move " << (value) << endl;
- return true;
- }
- }
- else
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- }
- else
- {
- Point* tee;
- tee = youngpiece2;
- bool TowardYourHome = false; //tee will go towards home if true
- for (int i = 0; i < output; i++)
- {
- if (tee->value == 12) //last space before going home, tells it to go to home space
- {
- TowardYourHome = true;
- }
- if (!TowardYourHome)
- {
- tee = tee->next;
- }
- if (TowardYourHome)
- {
- tee = tee->out;
- }
- if (tee == NULL) //if run out of spaces
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- }
- if (tee == youngpiece1 || tee == youngpiece3 || tee == youngpiece4) //if space is occupied
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- else
- {
- cout << "You can move " << (value) << endl;
- return true;
- }
- }
- }
- if (value == "youngpiece3")
- {
- if (youngpiece3 == young)
- {
- if (output == 6) //Choose a piece to start with
- {
- if (youngpiece3->next == youngpiece2 || youngpiece3->next == youngpiece1 || youngpiece3->next == youngpiece4)
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- else
- {
- cout << "You can move " << (value) << endl;
- return true;
- }
- }
- else
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- }
- else
- {
- Point* tee;
- tee = youngpiece3;
- bool TowardYourHome = false; //tee will go towards home if true
- for (int i = 0; i < output; i++)
- {
- if (tee->value == 12) //last space before going home, tells it to go to home space
- {
- TowardYourHome = true;
- }
- if (!TowardYourHome)
- {
- tee = tee->next;
- }
- if (TowardYourHome)
- {
- tee = tee->out;
- }
- if (tee == NULL) //if run out of spaces
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- }
- if (tee == youngpiece2 || tee == youngpiece1 || tee == youngpiece4) //if space is occupied
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- else
- {
- cout << "You can move " << (value);
- return true;
- }
- }
- }
- if (value == "youngpiece4")
- {
- if (youngpiece4 == young)
- {
- if (output == 6) //Choose a piece to start with
- {
- if (youngpiece4->next == youngpiece2 || youngpiece4->next == youngpiece3 || youngpiece4->next == youngpiece1)
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- else
- {
- cout << "You can move " << (value) << endl;
- return true;
- }
- }
- else
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- }
- else
- {
- Point* tee;
- tee = youngpiece4;
- bool TowardYourHome = false; //tee will go towards home if true
- for (int i = 0; i < output; i++)
- {
- if (tee->value == 12) //last space before going home, tells it to go to home space
- {
- TowardYourHome = true;
- }
- if (!TowardYourHome)
- {
- tee = tee->next;
- }
- if (TowardYourHome)
- {
- tee = tee->out;
- }
- if (tee == NULL) //if run out of spaces
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- }
- if (tee == youngpiece2 || tee == youngpiece3 || tee == youngpiece1) //if space is occupied
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- else
- {
- cout << "You can move " << (value) << endl;
- return true;
- }
- }
- }
- if (value == "ronypiece1")
- {
- if (ronypiece1 == redstart)
- {
- if (output == 6) //Choose a piece to start with
- {
- if (ronypiece1->next == ronypiece2 || ronypiece1->next == ronypiece3 || ronypiece1->next == ronypiece4)
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- else
- {
- cout << "You can move " << (value) << endl;
- return true;
- }
- }
- else
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- }
- else
- {
- Point* tee;
- tee = ronypiece1;
- bool TowardYourHome = false; //tee will go towards home if true
- for (int i = 0; i < output; i++)
- {
- if (tee->value == 18) //last space before going home, tells it to go to home space
- {
- TowardYourHome = true;
- }
- if (!TowardYourHome)
- {
- tee = tee->next;
- }
- if (TowardYourHome)
- {
- tee = tee->out;
- }
- if (tee == NULL) //if run out of spaces
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- }
- if (tee == ronypiece2 || tee == ronypiece3 || tee == ronypiece4) //if space is occupied
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- else
- {
- cout << "You can move " << (value) << endl;
- return true;
- }
- }
- }
- if (value == "ronypiece2")
- {
- if (ronypiece2 == redstart)
- {
- if (output == 6) //Choose a piece to start with
- {
- if (ronypiece2->next == ronypiece1 || ronypiece2->next == ronypiece3 || ronypiece2->next == ronypiece4)
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- else
- {
- cout << "You can move " << (value) << endl;
- return true;
- }
- }
- else
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- }
- else
- {
- Point* tee;
- tee = ronypiece2;
- bool TowardYourHome = false; //tee will go towards home if true
- for (int i = 0; i < output; i++)
- {
- if (tee->value == 18) //last space before going home, tells it to go to home space
- {
- TowardYourHome = true;
- }
- if (!TowardYourHome)
- {
- tee = tee->next;
- }
- if (TowardYourHome)
- {
- tee = tee->out;
- }
- if (tee == NULL) //if run out of spaces
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- }
- if (tee == ronypiece1 || tee == ronypiece3 || tee == ronypiece4) //if space is occupied
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- else
- {
- cout << "You can move " << (value) << endl;
- return true;
- }
- }
- }
- if (value == "ronypiece3")
- {
- if (ronypiece3 == redstart)
- {
- if (output == 6) //Choose a piece to start with
- {
- if (ronypiece3->next == ronypiece2 || ronypiece3->next == ronypiece1 || ronypiece3->next == ronypiece4)
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- else
- {
- cout << "You can move " << (value) << endl;
- return true;
- }
- }
- else
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- }
- else
- {
- Point* tee;
- tee = ronypiece3;
- bool TowardYourHome = false; //tee will go towards home if true
- for (int i = 0; i < output; i++)
- {
- if (tee->value == 18) //last space before going home, tells it to go to home space
- {
- TowardYourHome = true;
- }
- if (!TowardYourHome)
- {
- tee = tee->next;
- }
- if (TowardYourHome)
- {
- tee = tee->out;
- }
- if (tee == NULL) //if run out of spaces
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- }
- if (tee == ronypiece2 || tee == ronypiece1 || tee == ronypiece4) //if space is occupied
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- else
- {
- cout << "You can move " << (value) << endl;
- return true;
- }
- }
- }
- if (value == "ronypiece4")
- {
- if (ronypiece4 == redstart)
- {
- if (output == 6) //Choose a piece to start with
- {
- if (ronypiece4->next == ronypiece2 || ronypiece4->next == ronypiece3 || ronypiece4->next == ronypiece1)
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- else
- {
- cout << "You can move " << (value) << endl;
- return true;
- }
- }
- else
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- }
- else
- {
- Point* tee;
- tee = ronypiece4;
- bool TowardYourHome = false; //tee will go towards home if true
- for (int i = 0; i < output; i++)
- {
- if (tee->value == 18) //last space before going home, tells it to go to home space
- {
- TowardYourHome = true;
- }
- if (!TowardYourHome)
- {
- tee = tee->next;
- }
- if (TowardYourHome)
- {
- tee = tee->out;
- }
- if (tee == NULL) //if run out of spaces
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- }
- if (tee == ronypiece2 || tee == ronypiece3 || tee == ronypiece1) //if space is occupied
- {
- cout << "Not possible to move " << (value) << endl;
- return false;
- }
- else
- {
- cout << "You can move " << (value) << endl;
- return true;
- }
- }
- }
- }
- bool TroubleBoard::AnyPossible(int output, string playerColour) //Determines if any output is possible
- {
- if (playerColour == "blue")
- {
- if (IsPossible("antonpiece1", output) == false & IsPossible("antonpiece2", output) == false & IsPossible("antonpiece3", output) == false & IsPossible("antonpiece4", output) == false)
- {
- cout << "Not possible to move any of your pieces with " << (output);
- cin.ignore(std::numeric_limits<streamsize>::max(),'n');
- return false;
- }
- else
- {
- return true;
- }
- }
- if (playerColour == "green")
- {
- if (IsPossible("gabepiece1", output) == false & IsPossible("gabepiece2", output) == false & IsPossible("gabepiece3", output) == false & IsPossible("gabepiece4", output) == false)
- {
- cout << "Not possible to move any of your pieces with " << (output);
- cin.ignore(std::numeric_limits<streamsize>::max(),'n');
- return false;
- }
- else
- {
- return true;
- }
- }
- if (playerColour == "yellow")
- {
- if (IsPossible("youngpiece1", output) == false & IsPossible("youngpiece2", output) == false & IsPossible("youngpiece3", output) == false & IsPossible("youngpiece4", output) & false)
- {
- cout << "Not possible to move any of your pieces with " << (output);
- cin.ignore(std::numeric_limits<streamsize>::max(),'n');
- return false;
- }
- else
- {
- return true;
- }
- }
- if (playerColour == "red")
- {
- if (IsPossible("ronypiece1", output) == false & IsPossible("ronypiece2", output) == false & IsPossible("ronypiece3", output) == false & IsPossible("ronypiece4", output) == false)
- {
- cout << "Not possible to move any of your pieces with " << (output);
- cin.ignore(std::numeric_limits<streamsize>::max(),'n');
- return false;
- }
- else
- {
- return true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement