int SpielstandEinrichten (unsigned short Auswahl, CSpieler &Spieler, CGame &Levelauswahl, CGame &Game)
{
ifstream InputSpielstand ("Spielstand.1sr", ios::binary);
if (!InputSpielstand)
{
// do while-Schleife
do
{
cout << "Es existiert noch kein Spielstand." << endl;
cout << endl;
cout << "SPIELSTAND ERSTELLEN?" << endl;
cout << "~~~~~~~~~~~~~~~~~~~~~" << endl;
cout << "1) Spielstand erstellen" << endl;
cout << "2) Nicht erstellen" << endl;
cout << "~~~~" << endl;
cout << "Deine Wahl: ";
cin >> Auswahl;
assert (Auswahl);
system ("cls");
// Spielstand erstellen
if (Auswahl == 1)
{
// Spielernamen eingeben
//
Spieler.SpielernamenEingeben ();
system ("cls");
ofstream OutputSpielstand ("Spielstand.1sr", ios::binary);
OutputSpielstand.write ((char*) &Spieler, sizeof (Spieler));
OutputSpielstand.close ();
ofstream OutputGame ("Spielstand.1sr", ios::binary | ios::app);
OutputGame.write ((char*) &Game, sizeof (Game));
OutputGame.close ();
ofstream OutputLevelauswahl ("Spielstand.1sr", ios::binary | ios::app);
OutputLevelauswahl.write ((char*) &Levelauswahl, sizeof (Levelauswahl));
OutputLevelauswahl.close ();
cout << "Spielstand wurde erstellt!" << endl;
system ("pause");
system ("cls");
}
// Spielstand nicht erstellen
else if (Auswahl == 2)
{
cout << "Es wurde kein Spielstand erstellt!" << endl;
system ("pause");
system ("cls");
}
// Fehlermeldung
else
{
Fehlermeldung ();
}
} while (Auswahl != 1 && Auswahl != 2);
} // if (!InputSpielstand)
else
{
// do while-Schleife
do
{
cout << "Es existiert bereits ein Spielstand." << endl;
cout << endl;
cout << "SPIELSTAND LADEN?" << endl;
cout << "~~~~~~~~~~~~~~~~~" << endl;
cout << "1) Spielstand laden" << endl;
cout << "2) Nicht laden" << endl;
cout << "~~~~" << endl;
cout << "Deine Wahl: ";
cin >> Auswahl;
assert (Auswahl);
system ("cls");
// Spielstand laden
if (Auswahl == 1)
{
ifstream InputSpielstand ("Spielstand.1sr", ios::binary);
InputSpielstand.read ((char*) &Spieler, sizeof (Spieler));
InputSpielstand.close ();
ifstream InputGame ("Spielstand.1sr", ios::binary | ios::app);
InputGame.read ((char*) &Game, sizeof (Game));
InputGame.close ();
ifstream InputLevelauswahl ("Spielstand.1sr", ios::binary | ios::app);
InputLevelauswahl.read ((char*) &Levelauswahl, sizeof (Levelauswahl));
InputLevelauswahl.close ();
cout << "Spielstand wurde erfolgreich geladen!" << endl;
system ("pause");
system ("cls");
}
// Spielstand nicht laden
else if (Auswahl == 2)
{
cout << "Spielstand wurde nicht geladen!" << endl;
system ("pause");
system ("cls");
}
// Fehlermeldung
else
{
Fehlermeldung ();
}
} while (Auswahl != 1 && Auswahl != 2);
} // else
return 0;
}