Witam szukam kogoś kto pomoże mi zrobić ranking w mojej grze. Chciałbym aby każdy gracz który uruchomi grę zapisywał się z ilością monet którą wpiszę, chce aby ten ranking opierał się na tym jaki gracz wydał więcej monet na grę. Niestety oglądałem tutoriale, czytałem również jakieś poradniki i nic mi nie działa. Pomoże ktoś? Kod prezentuj się tak :
#include <iostream>
#include <conio.h>
#include <windows.h>
#include <cstdlib>
#include <ctime>
#include <string>
#include <fstream>
using namespace std;
void dolary()
{
HANDLE hOut;
hOut = GetStdHandle( STD_OUTPUT_HANDLE );
SetConsoleTextAttribute( hOut, FOREGROUND_GREEN | FOREGROUND_INTENSITY );
cout<<" $ $ $ $ $ $ $ $ "<<endl;
cout<<" $$$$$ $$$$$ $$$$$ $$$$$ "<<endl;
cout<<" $ $ $ $ $ $ $ $ $ $ $ $ "<<endl;
cout<<" $$$$$ $$$$$ $$$$$ $$$$$ "<<endl;
cout<<" $ $ $ $ $ $ $ $ $ $ $ $ "<<endl;
cout<<" $$$$$ $$$$$ $$$$$ $$$$$ "<<endl;
cout<<" $ $ $ $ $ $ $ $ "<<endl;
SetConsoleTextAttribute( hOut, 0 );
SetConsoleTextAttribute( hOut, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED );
}
void moneta()
{
cout<<" __ "<<endl;
cout<<" | |..... "<<endl;
cout<<" | .| . "<<endl;
cout<<" |. | . "<<endl;
cout<<" |. | . "<<endl;
cout<<" |. | . "<<endl;
cout<<" | .| . "<<endl;
cout<<" |__|..... "<<endl;
}
void nazwa()
{
HANDLE hOut;
hOut = GetStdHandle( STD_OUTPUT_HANDLE );
SetConsoleTextAttribute( hOut, FOREGROUND_RED | FOREGROUND_INTENSITY );
cout<<"|=================================|"<<endl;
cout<<"|R RRR OOOOO L L | "<<endl;
cout<<"|R R O O L L |" <<endl;
cout<<"|R R O O L L |" <<endl;
cout<<"|R RRR O O L L |"<<endl;
cout<<"|R R O O L L |"<<endl;
cout<<"|R R O O L L |" <<endl;
cout<<"|R R OOOOO L LLLL L LLLL|"<<endl;
cout<<"|=================================|"<<endl;
SetConsoleTextAttribute( hOut, 0 );
SetConsoleTextAttribute( hOut, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED );
}
int main(int argc, char** argv) {
HANDLE hOut;
hOut = GetStdHandle( STD_OUTPUT_HANDLE );
nazwa();
setlocale(LC_ALL, "");
srand(time(NULL));
int wybor;
string imie;
cout << "Podaj swój nick" << endl;
cin >> imie;
system("cls");
cout << "Witaj" << " " << imie << endl;
Sleep(2000);
system("cls");
fstream plik;
int papa=1;
do
{
int monety=0;
moneta();
cout << "Podaj ile chcesz wrzucić monet" << endl;
cin >> monety;
if (monety > 10)
{
cout << "Możesz wrzucić tylko 10 monet po nominale 1" << endl;
continue;
}
while (monety--)
{
int tabo[3] = {};
cout << "1.Nowa gra" << endl;
cout << "2.Ranking" << endl;
cout << "3.Koniec"<<endl;
cin >> wybor;
switch (wybor) {
case 1:
cout << "Losowanie!" << endl;
Sleep(1000);
system("cls");
for (int i = 0; i < 3; i++) {
tabo[i] = rand() % 9 + 1;
cout << tabo[i];
}
cout << endl;
if ((tabo[1] == tabo[0]) && (tabo[2] == tabo[0])) {
cout << "Wygrałeś!" << endl;
dolary();
}
else if (tabo[1] == tabo[0]) {
tabo[2] = rand() % 9 + 1;
cout << tabo[0] << tabo[1] << tabo[2] << endl;
if (tabo[2] == tabo[0]) {
cout << "Wygrałeś!" << endl;
dolary();
}
}
else if (tabo[2] == tabo[0]) {
tabo[1] = rand() % 9 + 1;
cout << tabo[0] << tabo[1] << tabo[2] << endl;
if (tabo[1] == tabo[0]) {
cout << "Wygrałeś!" << endl;
dolary();
}
}
else if (tabo[2] == tabo[1]) {
tabo[0] = rand() % 9 + 1;
cout << tabo[0] << tabo[1] << tabo[2] << endl;
if (tabo[0] == tabo[1]) {
cout << "Wygrałeś!" << endl;
dolary();
}
}else
break;
case 2:
ifstream plik;
plik.open("ranking.txt", ios::out | ios::app);
plik<<imie<<monety<<endl;
plik.close();
break;
case 3:
exit (0);
break;
}
if (monety<=0)
cout<<"Nie masz już więcej monet na grę"<<endl;
}
cout << "Czy chcesz zagrać ponownie ?"<<endl;
cout << "1.Tak" << endl << "2.Nie" << endl;
cin >> papa;
} while (papa == 1);
return 0;
}