Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <thread>
- #include <algorithm>
- #include <functional>
- #include <array>
- #include <vector>
- using namespace std;
- struct card {
- string palo;
- string num;
- int value = 0;
- };
- card deck[52];
- card player[6];
- card player2[6];
- card player3[6];
- card player4[6];
- card pool;
- int checked[5] = { 0,0,0,0,0 };
- int sameCount = 0;
- int pairCount = 0;
- int threeCount = 0;
- int fourCount = 0;
- int numCards = 0;
- int numPlayers = 2;
- int win = 0;
- int currentPlayer = 1;
- int winturn = 0;
- int playerPoints = 0;
- int player2Points = 0;
- int player3Points = 0;
- int player4Points = 0;
- inline int random(int inicio, int limite) { return inicio + rand() % (1 + limite - inicio); }
- void shuffle();
- void menu();
- void givecards();
- void playeraction();
- void shiftcards();
- void drawcard();
- void pooldraw();
- void showhand(int draw);
- int checkwin(int confirm);
- void test();
- void drawpool();
- int main()
- {
- setlocale(LC_ALL, "spanish");
- srand(time(NULL));
- menu();
- shuffle();
- givecards();
- pooldraw();
- playeraction();
- }
- void menu()
- {
- int option = 0;
- numCards = 0;
- pool.value = 0;
- cout << "GO FISH RECARGADO" << endl;
- cout << "(1) 2 jugadores\n(2) 3 jugadores\n(3) 4 jugadores\nIngrese opción: " << endl;
- cin >> option;
- switch (option) {
- case 1:
- numPlayers = 2;
- break;
- case 2:
- numPlayers = 3;
- break;
- case 3:
- numPlayers = 4;
- break;
- default:
- cout << "Ingrese una opción válida." << endl;
- break;
- }
- }
- void shuffle() {
- srand(time(NULL));
- int dispose[52] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0, };
- for (int i = 0; i < 52; i++) {
- deck[i].value = random(1, 13);
- dispose[i] = random(1, 4);
- if (dispose[i] == 1)
- deck[i].palo = "CORAZONES";
- else if (dispose[i] == 2)
- deck[i].palo = "DIAMANTES";
- else if (dispose[i] == 3)
- deck[i].palo = "ESPADAS";
- else if (dispose[i] == 4)
- deck[i].palo = "TRÉBOLES";
- if (deck[i].value == 1)
- deck[i].num = "AS";
- else if (deck[i].value == 2)
- deck[i].num = "2";
- else if (deck[i].value == 3)
- deck[i].num = "3";
- else if (deck[i].value == 4)
- deck[i].num = "4";
- else if (deck[i].value == 5)
- deck[i].num = "5";
- else if (deck[i].value == 6)
- deck[i].num = "6";
- else if (deck[i].value == 7)
- deck[i].num = "7";
- else if (deck[i].value == 8)
- deck[i].num = "8";
- else if (deck[i].value == 9)
- deck[i].num = "9";
- else if (deck[i].value == 10)
- deck[i].num = "10";
- else if (deck[i].value == 11) {
- deck[i].num = "JOTA";
- }
- else if (deck[i].value == 12) {
- deck[i].num = "REINA";
- }
- else if (deck[i].value == 13) {
- deck[i].num = "REY";
- }
- }
- }
- void givecards()
- {
- for (int i = 0; i < 5; i++) {
- player[i].num = deck[i].num;
- player[i].palo = deck[i].palo;
- player[i].value = deck[i].value;
- numCards++;
- }
- for (int i = 0; i < 5; i++) {
- player2[i].num = deck[numCards].num;
- player2[i].palo = deck[numCards].palo;
- player2[i].value = deck[numCards].value;
- numCards++;
- }
- for (int i = 0; i < 5; i++) {
- player3[i].num = deck[numCards].num;
- player3[i].palo = deck[numCards].palo;
- player3[i].value = deck[numCards].value;
- numCards++;
- }
- for (int i = 0; i < 5; i++) {
- player4[i].num = deck[numCards].num;
- player4[i].palo = deck[numCards].palo;
- player4[i].value = deck[numCards].value;
- numCards++;
- }
- player[5].num = "0";
- player[5].palo = "non";
- player[5].value = 0;
- player2[5].num = "0";
- player2[5].palo = "non";
- player2[5].value = 0;
- player3[5].num = "0";
- player3[5].palo = "non";
- player3[5].value = 0;
- player4[5].num = "0";
- player4[5].palo = "non";
- player4[5].value = 0;
- }
- void pooldraw() {
- pool.value = deck[numCards].value;
- pool.num = deck[numCards].num;
- pool.palo = deck[numCards].palo;
- numCards++;
- }
- void drawpool() {
- if (currentPlayer == 1) {
- player[5].value = pool.value;
- player[5].num = pool.num;
- player[5].palo = pool.palo;
- }
- else if (currentPlayer == 2) {
- player2[5].value = pool.value;
- player2[5].num = pool.num;
- player2[5].palo = pool.palo;
- }
- else if (currentPlayer == 3) {
- player3[5].value = pool.value;
- player3[5].num = pool.num;
- player3[5].palo = pool.palo;
- }
- else if (currentPlayer == 4) {
- player4[5].value = pool.value;
- player4[5].num = pool.num;
- player4[5].palo = pool.palo;
- }
- else {
- cout << "DRAW?";
- }
- numCards++;
- }
- void test() {
- player[0].num = "5";
- player[0].palo = "CORAZÓN";
- player[0].value = 5;
- player[1].num = "5";
- player[1].palo = "TRÉBOLES";
- player[1].value = 5;
- player[2].num = "5";
- player[2].palo = "DIAMANTES";
- player[2].value = 5;
- player[3].num = "3";
- player[3].palo = "ESPADAS";
- player[3].value = 3;
- player[4].num = "3";
- player[4].palo = "CORAZÓN";
- player[4].value = 3;
- }
- void playeraction() {
- int option = 0;
- win = 0;
- winturn = 0;
- while (win == 0) {
- system("cls");
- showhand(0);
- cout << "\n(1) Jalar carta de pool\n(2) Jalar carta de mazo\n";
- if (checkwin(0) == 1)
- cout << "(3) Hacer jugada";
- cout << "Ingrese su opción:";
- cin >> option;
- switch (option) {
- case 1:
- drawpool();
- break;
- case 2:
- drawcard();
- break;
- case 3:
- checkwin(1);
- default:
- cout << "Ingrese una opción válida.";
- break;
- }
- system("cls");
- showhand(1);
- cout << "Ingrese qué carta quiere descartar: ";
- cin >> option;
- if (currentPlayer == 1) {
- switch (option) {
- case 1:
- pool.value = player[0].value;
- pool.num = player[0].num;
- pool.palo = player[0].palo;
- player[0].value = 0;
- break;
- case 2:
- pool.value = player[1].value;
- pool.num = player[1].num;
- pool.palo = player[1].palo;
- player[1].value = 0;
- break;
- case 3:
- pool.value = player[2].value;
- pool.num = player[2].num;
- pool.palo = player[2].palo;
- player[2].value = 0;
- break;
- case 4:
- pool.value = player[3].value;
- pool.num = player[3].num;
- pool.palo = player[3].palo;
- player[3].value = 0;
- break;
- case 5:
- pool.value = player[4].value;
- pool.num = player[4].num;
- pool.palo = player[4].palo;
- player[4].value = 0;
- break;
- case 6:
- pool.value = player[5].value;
- pool.num = player[5].num;
- pool.palo = player[5].palo;
- player[5].value = 0;
- break;
- default:
- cout << "Ingrese una opción válida.";
- break;
- }
- }
- else if (currentPlayer == 2) {
- switch (option) {
- case 1:
- pool.value = player2[0].value;
- pool.num = player2[0].num;
- pool.palo = player2[0].palo;
- player2[0].value = 0;
- break;
- case 2:
- pool.value = player2[1].value;
- pool.num = player2[1].num;
- pool.palo = player2[1].palo;
- player2[1].value = 0;
- break;
- case 3:
- pool.value = player2[2].value;
- pool.num = player2[2].num;
- pool.palo = player2[2].palo;
- player2[2].value = 0;
- break;
- case 4:
- pool.value = player2[3].value;
- pool.num = player2[3].num;
- pool.palo = player2[3].palo;
- player2[3].value = 0;
- break;
- case 5:
- pool.value = player2[4].value;
- pool.num = player2[4].num;
- pool.palo = player2[4].palo;
- player2[4].value = 0;
- break;
- case 6:
- pool.value = player2[5].value;
- pool.num = player2[5].num;
- pool.palo = player2[5].palo;
- player2[5].value = 0;
- break;
- default:
- cout << "Ingrese una opción válida.";
- break;
- }
- }
- else if (currentPlayer == 3) {
- switch (option) {
- case 1:
- pool.value = player3[0].value;
- pool.num = player3[0].num;
- pool.palo = player3[0].palo;
- player3[0].value = 0;
- break;
- case 2:
- pool.value = player3[1].value;
- pool.num = player3[1].num;
- pool.palo = player3[1].palo;
- player3[1].value = 0;
- break;
- case 3:
- pool.value = player3[2].value;
- pool.num = player3[2].num;
- pool.palo = player3[2].palo;
- player3[2].value = 0;
- break;
- case 4:
- pool.value = player3[3].value;
- pool.num = player3[3].num;
- pool.palo = player3[3].palo;
- player3[3].value = 0;
- break;
- case 5:
- pool.value = player3[4].value;
- pool.num = player3[4].num;
- pool.palo = player3[4].palo;
- player3[4].value = 0;
- break;
- case 6:
- pool.value = player3[5].value;
- pool.num = player3[5].num;
- pool.palo = player3[5].palo;
- player3[5].value = 0;
- break;
- default:
- cout << "Ingrese una opción válida.";
- break;
- }
- }
- else if (currentPlayer == 4) {
- switch (option) {
- case 1:
- pool.value = player4[0].value;
- pool.num = player4[0].num;
- pool.palo = player4[0].palo;
- player4[0].value = 0;
- break;
- case 2:
- pool.value = player4[1].value;
- pool.num = player4[1].num;
- pool.palo = player4[1].palo;
- player4[1].value = 0;
- break;
- case 3:
- pool.value = player4[2].value;
- pool.num = player4[2].num;
- pool.palo = player4[2].palo;
- player4[2].value = 0;
- break;
- case 4:
- pool.value = player4[3].value;
- pool.num = player4[3].num;
- pool.palo = player4[3].palo;
- player4[3].value = 0;
- break;
- case 5:
- pool.value = player4[4].value;
- pool.num = player4[4].num;
- pool.palo = player4[4].palo;
- player4[4].value = 0;
- break;
- case 6:
- pool.value = player4[5].value;
- pool.num = player4[5].num;
- pool.palo = player4[5].palo;
- player4[5].value = 0;
- break;
- default:
- cout << "Ingrese una opción válida.";
- break;
- }
- }
- shiftcards();
- cout << pairCount << endl;
- cout << threeCount << endl;
- cout << fourCount << endl;
- currentPlayer++;
- if (winturn == 1)
- winturn++;
- else if (winturn > numPlayers)
- win = 1;
- cin >> option;
- }
- }
- // Winning round
- int checkwin(int confirm) {
- int num[5] = { 0,0,0,0,0 };
- int possiblePlay = 0;
- sameCount = 0;
- pairCount = 0;
- threeCount = 0;
- fourCount = 0;
- checked[0] = 0;
- checked[1] = 0;
- checked[2] = 0;
- checked[3] = 0;
- checked[4] = 0;
- if (currentPlayer == 1) {
- for (int i = 0; i < 6; i++) {
- if (player[0].value == player[i].value && i != 0) {
- sameCount++;
- if (sameCount == 1) {
- pairCount++;
- }
- else if (sameCount == 2) {
- pairCount = 0;
- threeCount++;
- }
- else if (sameCount == 3) {
- fourCount++;
- pairCount = 0;
- threeCount = 0;
- }
- }
- }
- sameCount = 0;
- checked[0] = player[0].value;
- for (int i = 0; i < 6; i++) {
- if (player[1].value == player[i].value && i != 1 && player[1].value != checked[0]) {
- sameCount++;
- if (sameCount == 1) {
- pairCount++;
- }
- else if (sameCount == 2) {
- pairCount = 0;
- threeCount++;
- }
- else if (sameCount == 3) {
- fourCount++;
- pairCount = 0;
- threeCount = 0;
- }
- }
- }
- sameCount = 0;
- checked[1] = player[1].value;
- for (int i = 0; i < 6; i++) {
- if (player[2].value == player[i].value && i != 2 && player[2].value != checked[1] && player[2].value != checked[0]) {
- sameCount++;
- if (sameCount == 1) {
- pairCount++;
- }
- else if (sameCount == 2) {
- pairCount = 0;
- threeCount++;
- }
- else if (sameCount == 3) {
- fourCount++;
- pairCount = 0;
- threeCount = 0;
- }
- }
- }
- sameCount = 0;
- checked[2] = player[2].value;
- for (int i = 0; i < 6; i++) {
- if (player[3].value == player[i].value && i != 3 && player[3].value != checked[2] && player[3].value != checked[1] && player[3].value != checked[0]) {
- sameCount++;
- if (sameCount == 1) {
- pairCount++;
- }
- else if (sameCount == 2) {
- pairCount = 0;
- threeCount++;
- }
- else if (sameCount == 3) {
- fourCount++;
- pairCount = 0;
- threeCount = 0;
- }
- }
- }
- sameCount = 0;
- checked[3] = player[3].value;
- for (int i = 0; i < 6; i++) {
- if (player[4].value == player[i].value && i != 4 && player[4].value != checked[3] && player[4].value != checked[2] && player[4].value != checked[1] && player[4].value != checked[0]) {
- sameCount++;
- if (sameCount == 1) {
- pairCount++;
- }
- else if (sameCount == 2) {
- pairCount = 0;
- threeCount++;
- }
- else if (sameCount == 3) {
- fourCount++;
- pairCount = 0;
- threeCount = 0;
- }
- }
- }
- sameCount = 0;
- checked[4] = player[4].value;
- for (int i = 0; i < 6; i++) {
- if (player[5].value == player[i].value && i != 5 && player[5].value != checked[4] && player[5].value != checked[3] && player[5].value != checked[2] && player[5].value != checked[1] && player[5].value != checked[0]) {
- sameCount++;
- if (sameCount == 1) {
- pairCount++;
- }
- else if (sameCount == 2) {
- pairCount = 0;
- threeCount++;
- }
- else if (sameCount == 3) {
- fourCount++;
- pairCount = 0;
- threeCount = 0;
- }
- }
- }
- if (pairCount == 3) {
- win = 1;
- }
- else if (pairCount == 1 && threeCount == 1) {
- winturn = 0;
- }
- }
- else if (currentPlayer == 2) {
- for (int i = 0; i < 6; i++) {
- if (player2[0].value == player2[i].value && i != 0) {
- sameCount++;
- if (sameCount == 1) {
- pairCount++;
- }
- else if (sameCount == 2) {
- pairCount = 0;
- threeCount++;
- }
- else if (sameCount == 3) {
- fourCount++;
- pairCount = 0;
- threeCount = 0;
- }
- }
- }
- sameCount = 0;
- checked[0] = player2[0].value;
- for (int i = 0; i < 6; i++) {
- if (player2[1].value == player2[i].value && i != 1 && player2[1].value != checked[0]) {
- sameCount++;
- if (sameCount == 1) {
- pairCount++;
- }
- else if (sameCount == 2) {
- pairCount = 0;
- threeCount++;
- }
- else if (sameCount == 3) {
- fourCount++;
- pairCount = 0;
- threeCount = 0;
- }
- }
- }
- sameCount = 0;
- checked[1] = player2[1].value;
- for (int i = 0; i < 6; i++) {
- if (player2[2].value == player2[i].value && i != 2 && player2[2].value != checked[1] && player2[2].value != checked[0]) {
- sameCount++;
- if (sameCount == 1) {
- pairCount++;
- }
- else if (sameCount == 2) {
- pairCount = 0;
- threeCount++;
- }
- else if (sameCount == 3) {
- fourCount++;
- pairCount = 0;
- threeCount = 0;
- }
- }
- }
- sameCount = 0;
- checked[2] = player2[2].value;
- for (int i = 0; i < 6; i++) {
- if (player2[3].value == player2[i].value && i != 3 && player2[3].value != checked[2] && player2[3].value != checked[1] && player2[3].value != checked[0]) {
- sameCount++;
- if (sameCount == 1) {
- pairCount++;
- }
- else if (sameCount == 2) {
- pairCount = 0;
- threeCount++;
- }
- else if (sameCount == 3) {
- fourCount++;
- pairCount = 0;
- threeCount = 0;
- }
- }
- }
- sameCount = 0;
- checked[3] = player2[3].value;
- for (int i = 0; i < 6; i++) {
- if (player2[4].value == player2[i].value && i != 4 && player2[4].value != checked[3] && player2[4].value != checked[2] && player2[4].value != checked[1] && player2[4].value != checked[0]) {
- sameCount++;
- if (sameCount == 1) {
- pairCount++;
- }
- else if (sameCount == 2) {
- pairCount = 0;
- threeCount++;
- }
- else if (sameCount == 3) {
- fourCount++;
- pairCount = 0;
- threeCount = 0;
- }
- }
- }
- sameCount = 0;
- checked[4] = player2[4].value;
- for (int i = 0; i < 6; i++) {
- if (player2[5].value == player2[i].value && i != 5 && player2[5].value != checked[4] && player2[5].value != checked[3] && player2[5].value != checked[2] && player2[5].value != checked[1] && player2[5].value != checked[0]) {
- sameCount++;
- if (sameCount == 1) {
- pairCount++;
- }
- else if (sameCount == 2) {
- pairCount = 0;
- threeCount++;
- }
- else if (sameCount == 3) {
- fourCount++;
- pairCount = 0;
- threeCount = 0;
- }
- }
- }
- if (pairCount == 3) {
- win = 1;
- }
- else if (pairCount == 1 && threeCount == 1) {
- winturn = 0;
- }
- }
- else if (currentPlayer == 3) {
- for (int i = 0; i < 6; i++) {
- if (player3[0].value == player3[i].value && i != 0) {
- sameCount++;
- if (sameCount == 1) {
- pairCount++;
- }
- else if (sameCount == 2) {
- pairCount = 0;
- threeCount++;
- }
- else if (sameCount == 3) {
- fourCount++;
- pairCount = 0;
- threeCount = 0;
- }
- }
- }
- sameCount = 0;
- checked[0] = player3[0].value;
- for (int i = 0; i < 6; i++) {
- if (player3[1].value == player3[i].value && i != 1 && player3[1].value != checked[0]) {
- sameCount++;
- if (sameCount == 1) {
- pairCount++;
- }
- else if (sameCount == 2) {
- pairCount = 0;
- threeCount++;
- }
- else if (sameCount == 3) {
- fourCount++;
- pairCount = 0;
- threeCount = 0;
- }
- }
- }
- sameCount = 0;
- checked[1] = player3[1].value;
- for (int i = 0; i < 6; i++) {
- if (player3[2].value == player3[i].value && i != 2 && player3[2].value != checked[1] && player3[2].value != checked[0]) {
- sameCount++;
- if (sameCount == 1) {
- pairCount++;
- }
- else if (sameCount == 2) {
- pairCount = 0;
- threeCount++;
- }
- else if (sameCount == 3) {
- fourCount++;
- pairCount = 0;
- threeCount = 0;
- }
- }
- }
- sameCount = 0;
- checked[2] = player3[2].value;
- for (int i = 0; i < 6; i++) {
- if (player3[3].value == player3[i].value && i != 3 && player3[3].value != checked[2] && player3[3].value != checked[1] && player3[3].value != checked[0]) {
- sameCount++;
- if (sameCount == 1) {
- pairCount++;
- }
- else if (sameCount == 2) {
- pairCount = 0;
- threeCount++;
- }
- else if (sameCount == 3) {
- fourCount++;
- pairCount = 0;
- threeCount = 0;
- }
- }
- }
- sameCount = 0;
- checked[3] = player3[3].value;
- for (int i = 0; i < 6; i++) {
- if (player3[4].value == player3[i].value && i != 4 && player3[4].value != checked[3] && player3[4].value != checked[2] && player3[4].value != checked[1] && player3[4].value != checked[0]) {
- sameCount++;
- if (sameCount == 1) {
- pairCount++;
- }
- else if (sameCount == 2) {
- pairCount = 0;
- threeCount++;
- }
- else if (sameCount == 3) {
- fourCount++;
- pairCount = 0;
- threeCount = 0;
- }
- }
- }
- sameCount = 0;
- checked[4] = player3[4].value;
- for (int i = 0; i < 6; i++) {
- if (player3[5].value == player3[i].value && i != 5 && player3[5].value != checked[4] && player3[5].value != checked[3] && player3[5].value != checked[2] && player3[5].value != checked[1] && player3[5].value != checked[0]) {
- sameCount++;
- if (sameCount == 1) {
- pairCount++;
- }
- else if (sameCount == 2) {
- pairCount = 0;
- threeCount++;
- }
- else if (sameCount == 3) {
- fourCount++;
- pairCount = 0;
- threeCount = 0;
- }
- }
- }
- }
- else if (currentPlayer == 4) {
- for (int i = 0; i < 6; i++) {
- if (player4[0].value == player4[i].value && i != 0) {
- sameCount++;
- if (sameCount == 1) {
- pairCount++;
- }
- else if (sameCount == 2) {
- pairCount = 0;
- threeCount++;
- }
- else if (sameCount == 3) {
- fourCount++;
- pairCount = 0;
- threeCount = 0;
- }
- }
- }
- sameCount = 0;
- checked[0] = player4[0].value;
- for (int i = 0; i < 6; i++) {
- if (player4[1].value == player4[i].value && i != 1 && player4[1].value != checked[0]) {
- sameCount++;
- if (sameCount == 1) {
- pairCount++;
- }
- else if (sameCount == 2) {
- pairCount = 0;
- threeCount++;
- }
- else if (sameCount == 3) {
- fourCount++;
- pairCount = 0;
- threeCount = 0;
- }
- }
- }
- sameCount = 0;
- checked[1] = player4[1].value;
- for (int i = 0; i < 6; i++) {
- if (player4[2].value == player4[i].value && i != 2 && player4[2].value != checked[1] && player4[2].value != checked[0]) {
- sameCount++;
- if (sameCount == 1) {
- pairCount++;
- }
- else if (sameCount == 2) {
- pairCount = 0;
- threeCount++;
- }
- else if (sameCount == 3) {
- fourCount++;
- pairCount = 0;
- threeCount = 0;
- }
- }
- }
- sameCount = 0;
- checked[2] = player4[2].value;
- for (int i = 0; i < 6; i++) {
- if (player4[3].value == player4[i].value && i != 3 && player4[3].value != checked[2] && player4[3].value != checked[1] && player4[3].value != checked[0]) {
- sameCount++;
- if (sameCount == 1) {
- pairCount++;
- }
- else if (sameCount == 2) {
- pairCount = 0;
- threeCount++;
- }
- else if (sameCount == 3) {
- fourCount++;
- pairCount = 0;
- threeCount = 0;
- }
- }
- }
- sameCount = 0;
- checked[3] = player4[3].value;
- for (int i = 0; i < 6; i++) {
- if (player4[4].value == player4[i].value && i != 4 && player4[4].value != checked[3] && player4[4].value != checked[2] && player4[4].value != checked[1] && player4[4].value != checked[0]) {
- sameCount++;
- if (sameCount == 1) {
- pairCount++;
- }
- else if (sameCount == 2) {
- pairCount = 0;
- threeCount++;
- }
- else if (sameCount == 3) {
- fourCount++;
- pairCount = 0;
- threeCount = 0;
- }
- }
- }
- sameCount = 0;
- checked[4] = player4[4].value;
- for (int i = 0; i < 6; i++) {
- if (player4[5].value == player4[i].value && i != 5 && player4[5].value != checked[4] && player4[5].value != checked[3] && player4[5].value != checked[2] && player4[5].value != checked[1] && player4[5].value != checked[0]) {
- sameCount++;
- if (sameCount == 1) {
- pairCount++;
- }
- else if (sameCount == 2) {
- pairCount = 0;
- threeCount++;
- }
- else if (sameCount == 3) {
- fourCount++;
- pairCount = 0;
- threeCount = 0;
- }
- }
- }
- }
- // Tres pares
- if (confirm == 1) {
- if (pairCount == 3) {
- win = 1;
- cout << "EL JUGADOR " << currentPlayer << "HA GANADO.";
- }
- // 1 tercia y 1 par
- else if (pairCount == 1 && threeCount == 1) {
- winturn = 1;
- }
- // Poker
- else if (pairCount == 2) {
- winturn = 1;
- }
- // Escalera
- if (currentPlayer == 1) {
- for (int i = 0; i < 5; i++) {
- num[i] = player[i].value;
- playerPoints += player[i].value;
- }
- sort(num, num + 5);
- if (num[0] < num[1] < num[2] < num[3] < num[4]) {
- winturn = 1;
- }
- }
- else if (currentPlayer == 2) {
- for (int i = 0; i < 5; i++) {
- num[i] = player2[i].value;
- }
- sort(num, num + 5);
- if (num[0] < num[1] < num[2] < num[3] < num[4]) {
- winturn = 1;
- }
- }
- else if (currentPlayer == 3) {
- for (int i = 0; i < 5; i++) {
- num[i] = player3[i].value;
- }
- sort(num, num + 5);
- if (num[0] < num[1] < num[2] < num[3] < num[4]) {
- winturn = 1;
- }
- }
- else if (currentPlayer == 4) {
- for (int i = 0; i < 5; i++) {
- num[i] = player4[i].value;
- }
- sort(num, num + 5);
- if (num[0] < num[1] < num[2] < num[3] < num[4]) {
- winturn = 1;
- }
- }
- }
- if ((pairCount == 1 && threeCount == 1) || pairCount == 2 || num[0] < num[1] < num[2] < num[3] < num[4])
- possiblePlay = 1;
- return possiblePlay;
- }
- void shiftcards() {
- if (currentPlayer == 1) {
- for (int i = 0; i < 6; i++) {
- if (player[i].value == 0) {
- player[i].num = player[i + 1].num;
- player[i].palo = player[i + 1].palo;
- player[i].value = player[i + 1].value;
- if (i < 5) {
- player[i + 1].num = "0";
- player[i + 1].palo = "non";
- player[i + 1].value = 0;
- }
- }
- }
- player[5].num = "0";
- player[5].palo = "non";
- player[5].value = 0;
- }
- else if (currentPlayer == 2) {
- for (int i = 0; i < 6; i++) {
- if (player2[i].value == 0) {
- player2[i].num = player2[i + 1].num;
- player2[i].palo = player2[i + 1].palo;
- player2[i].value = player2[i + 1].value;
- if (i < 5) {
- player2[i + 1].num = "0";
- player2[i + 1].palo = "non";
- player2[i + 1].value = 0;
- }
- }
- }
- player2[5].num = "0";
- player2[5].palo = "non";
- player2[5].value = 0;
- }
- else if (currentPlayer == 3) {
- for (int i = 0; i < 6; i++) {
- if (player3[i].value == 0) {
- player3[i].num = player3[i + 1].num;
- player3[i].palo = player3[i + 1].palo;
- player3[i].value = player3[i + 1].value;
- if (i < 5) {
- player3[i + 1].num = "0";
- player3[i + 1].palo = "non";
- player3[i + 1].value = 0;
- }
- }
- }
- player3[5].num = "0";
- player3[5].palo = "non";
- player3[5].value = 0;
- }
- else if (currentPlayer == 4) {
- for (int i = 0; i < 6; i++) {
- if (player4[i].value == 0) {
- player4[i].num = player4[i + 1].num;
- player4[i].palo = player4[i + 1].palo;
- player4[i].value = player4[i + 1].value;
- if (i < 5) {
- player4[i + 1].num = "0";
- player4[i + 1].palo = "non";
- player4[i + 1].value = 0;
- }
- }
- }
- player4[5].num = "0";
- player4[5].palo = "non";
- player4[5].value = 0;
- }
- }
- void drawcard() {
- if (currentPlayer == 1) {
- player[5].value = deck[numCards].value;
- player[5].num = deck[numCards].num;
- player[5].palo = deck[numCards].palo;
- }
- else if (currentPlayer == 2) {
- player2[5].value = deck[numCards].value;
- player2[5].num = deck[numCards].num;
- player2[5].palo = deck[numCards].palo;
- }
- else if (currentPlayer == 3) {
- player3[5].value = deck[numCards].value;
- player3[5].num = deck[numCards].num;
- player3[5].palo = deck[numCards].palo;
- }
- else if (currentPlayer == 4) {
- player4[5].value = deck[numCards].value;
- player4[5].num = deck[numCards].num;
- player4[5].palo = deck[numCards].palo;
- }
- else {
- cout << "DRAW?";
- }
- numCards++;
- }
- void showhand(int draw) {
- if (currentPlayer > numPlayers) {
- currentPlayer = 1;
- }
- cout << "TURNO JUGADOR " << currentPlayer;
- cout << "\t\t\tCARTAS EN BARAJA: " << 52 - numCards << endl;
- cout << "\t\t\t\tPOOL:" << pool.num << " de " << pool.palo << endl;
- if (winturn == 1)
- cout << "\t\t\t\tÚLTIMO TURNO" << pool.num << " de " << pool.palo << endl;
- if (currentPlayer == 1) {
- if (draw == 1) {
- for (int i = 0; i < 6; i++) {
- if (player[i].value == 0)
- cout << "" << endl;
- else
- cout << "(" << i + 1 << ") " << player[i].num << " de " << player[i].palo << endl;
- }
- }
- else if (draw == 0) {
- for (int i = 0; i < 6; i++) {
- if (player[i].value == 0)
- cout << "" << endl;
- else
- cout << " " << player[i].num << " de " << player[i].palo << endl;
- }
- }
- else
- cout << "xd";
- }
- else if (currentPlayer == 2) {
- if (draw == 1) {
- for (int i = 0; i < 6; i++) {
- if (player2[i].value == 0)
- cout << "";
- else
- cout << "(" << i + 1 << ") " << player2[i].num << " de " << player2[i].palo << endl;
- }
- }
- else if (draw == 0) {
- for (int i = 0; i < 6; i++) {
- if (player2[i].value == 0)
- cout << "";
- else
- cout << " " << player2[i].num << " de " << player2[i].palo << endl;
- }
- }
- else
- cout << "xd";
- }
- else if (currentPlayer == 3) {
- if (draw == 1) {
- for (int i = 0; i < 6; i++) {
- if (player3[i].value == 0)
- cout << "" << endl;
- else
- cout << "(" << i + 1 << ") " << player3[i].num << " de " << player3[i].palo << endl;
- }
- }
- else if (draw == 0) {
- for (int i = 0; i < 6; i++) {
- if (player3[i].value == 0)
- cout << "" << endl;
- else
- cout << " " << player3[i].num << " de " << player3[i].palo << endl;
- }
- }
- else
- cout << "xd";
- }
- else if (currentPlayer == 4) {
- if (draw == 1) {
- for (int i = 0; i < 6; i++) {
- if (player4[i].value == 0)
- cout << "";
- else
- cout << "(" << i + 1 << ") " << player4[i].num << " de " << player4[i].palo << endl;
- }
- }
- else if (draw == 0) {
- for (int i = 0; i < 6; i++) {
- if (player4[i].value == 0)
- cout << "";
- else
- cout << " " << player4[i].num << " de " << player4[i].palo << endl;
- }
- }
- else
- cout << "xd";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement