Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include "karta.h"
- #include "talia.h"
- #include "gracz.h"
- #include "gra.h"
- #include "plansza.h"
- #include <iostream>
- #include <string>
- #include <Windows.h>
- #include <cstdlib>
- #include <conio.h>
- using namespace std;
- void gotoxy(const int x, const int y)
- {
- COORD coord = { x, y };
- SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
- }
- void Plansza::statystyki(Gracz *tab)
- {
- cout << ("imie: ") << tab->zwroc_imie() << (" wynik: ") << tab->zwroc_wynik() << (" ilosc ruchow: ") << tab->zwroc_ilosc_ruchow() << endl;
- cout << ("-------------------------------------------------------------------------------------------------") << endl << endl;
- }
- void Plansza::wpisz_karty(Karta *tab)
- {
- int nr_rzedu = 0;
- for (int x = 0; x < 104; x++)
- {
- if (x < 54)
- {
- if (x > 43)
- {
- tab[x].zmien_widocznosc();
- }
- karty[nr_rzedu].push_back(tab[x]);
- nr_rzedu++;
- if (nr_rzedu == 10)
- {
- nr_rzedu = 0;
- }
- }
- if (x > 53)
- {
- tab[x].zmien_widocznosc();
- dobieranie.push_back(tab[x]);
- }
- }
- }
- void Plansza::wypisz_karty(int poziom,int pion)
- {
- int g_x = 0;
- int g_y = 2;
- for (int x = 0; x < 10; x++)
- {
- g_y = 2;
- for (int y = 0; y < (karty[x].size()); y++)
- {
- gotoxy(g_x, g_y);
- cout << zwroc_karta(x, y,poziom,pion);
- g_y += 1;
- }
- g_x += 10;
- }
- }
- void Plansza::dobierz_karty()
- {
- for (int x = 0; x < 10; x++)
- {
- karty[x].push_back(dobieranie.back());
- dobieranie.pop_back();
- }
- }
- string Plansza::zwroc_karta(int x,int y,int poziom,int pion)
- {
- string a;
- string tablica_figur[13] = { "2 ","3 ","4 ","5 ","6 ","7 ","8 ","9 ","10","J ","D ","K ","A " };
- string tablica_kolor[4] = {"\x3","\x4","\x5","\x6"};
- HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
- if ((karty[x][y].zwroc_widocznosc() == 1)&&(x==poziom)&&(y==pion))
- {
- SetConsoleTextAttribute(hOut, FOREGROUND_RED);
- a = "|-" + tablica_figur[karty[x][y].zwroc_figura()] + tablica_kolor[karty[x][y].zwroc_kolor()] + "-|";
- return a;
- }
- else if ((karty[x][y].zwroc_widocznosc() == 1) && (x != poziom) && (y != pion))
- {
- SetConsoleTextAttribute(hOut, FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN);
- a = "|-" + tablica_figur[karty[x][y].zwroc_figura()] + tablica_kolor[karty[x][y].zwroc_kolor()] + "-|";
- return a;
- }
- else if ((karty[x][y].zwroc_widocznosc() == 0) && (x == poziom) && (y == pion))
- {
- SetConsoleTextAttribute(hOut, FOREGROUND_RED);
- a = "|-----|";
- return a;
- }
- else if ((karty[x][y].zwroc_widocznosc() == 0) && (x == poziom) && (y == pion))
- {
- SetConsoleTextAttribute(hOut, FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN);
- a = "|-----|";
- return a;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment