Mehrere Nicht-POD Instanzen in eine Datei schreiben



  • Was willst du denn noch wissen? Alles Andere ich anderer Programmcode und über 2500 Zeilen lang. Ausrufshirachie versichert aber korrekten Aufruf.

    Ausgabe

    Malark
    100  // <- Eine Variable
    130  // <- Gleiche Variable+ 30. Wird danach in Datei geschrieben
    1
    Nympth
    100  // <- Das gleiche Spiel nochmal
    130
    1
    

    Eigentlich sollte dann beim Laden dann auch dieser Wert 130 wieder ausgegeben werden.

    Hier die nach dem Schließen des Programms wieder geladene Ausgabe beim Laden:

    Malark // <- Name der Instanz
    100   // <-- Wert, der eigentlich 130 seien sollte
    1
    Nympth
    100  // <--- Hier auch
    1
    

    Gespeichert wird bei Programmende, geladen am Start.



  • Hier einfach mal der ganze Code. Da wird dann ja wohl Alles drinstehen.
    Spoiler oder soetwas habe ich nicht gefunden.

    main

    /*
    Spieler verwaltet über ein Dorf. Dieses besitzt folgende Rohstoffe: Eisen, Stein, Holz, Nahrung und Geld.
    Diese können durch bestimmte Tätigkeiten aufgefüllt bzw verringert werden, wie zb. Holzfällen oder Steinabbauen.
    Der Spieler soll Gebäude bauen und ausbauen können. Später soll der Spieler außerdem Kriege gegen zufallsgenerierte Gegner führen können. 
    Dazu kann der SPieler in einer Kaserne Krieger ausbilden.
    Jedes Dorf hat ein Einwohnersystem. Einwohner kommen proportional zum Ruhm der Stadt und der Anzahl gebauter Wohnhäuser.
    Einwohner dienen als Steuerquelle und sind für Krieger notwendig. 
    
    Funktionen:
    
    getRessources(bool dialog_or_not)
    	-Ressorucen anzeigen []
    setRessources(float gold, float food, float iron, float wood, float stone)
    	-Ressorucen ändern
    getInhabitants(bool dialog_or_not)
    	-Einwohner Anzahl anzeigen + Laune
    	bool i = rückgabe per return oder im Dialog ausgeben? 1 = return / 0 = dialog
    setInhabitants(int Inhabitants, bool delete_or_create)
    	-Neue Einwohner / Einwohner löschen
    build(int init, int number)
    	-Gebäude bauen. Greift auf setRessource zu.
    	-Greift über int init auf Gebäude zu, dass gebaut werden soll.
    bool checkRessources(float gold, float food, float iron, float wood, float stone)
    	-Überprüft, ob Ressourcen ausreichen um Aktion durchzuführen
    interactRessource(int init, int param0, int param1, int param2)
    	-Interaktionen, wie Rohstoffe abbauen etc.
    	-int init => Flag des Rohstoffes. Param0-2 => Weitere, optionale Informationen)
    initBulidings(int init)
    	-Initialisiert Gebäude. Int init = int init von build(int init, int number);
    
    	Kampfsystem:
    
    	-Spieler kann Tatik-Punkte für Angriff, Verteidigung, Durchhaltevermögen etc...
    	-Diese bestimmen das Verhalten der Einheiten im Kampf
    	-Kampf:
    		-Zufallsgenerierter Gegner, der je nach Erfahrung des Spielers (Noch einbauen) stärker ist.
    		-Zufallszahlen ermitteln, die die einzelnen variierungen bestimmen (Für jede Kampfeinheit extra).
    		-Bei Gewinn werden die ebenfalls zufallsgenerierten Einheiten des Gegners dem Spieler gutgeschrieben
    		-Bei Niederlage sind 80-100% der eigenen Truppen tot und Ruhm sinkt.
    		-In Menue's eine Zufallszahl einbauen, die mit einer Wahrscheinlichkeit X einen Gegner kommen lässt, der das Dorf angreift.
    			-Counter, wie lange der Angriff noch bevor steht. 
    			-Bei Niederlage, 20-80% der eigenen Ressorucen weg.
    			-Bei Sieg: Ruhm. 
    
    	-Konkurrenz- und Marktsystem:
    
    		-Desto mehr von Etwas gekauft wird: Desto teurer wird es (danach oder währenddessen?)
    		-Man kann Angebote von Anderen Königstümern erhalten.
    		-Handelt man mit einem Königstum, so verbessert sich die Beziehung zu dem Königtum. 
    		-Ist die Beziehung zu einem Königtum sehr schlecht, ist die Wahrscheinlichkeit höher, dass es angreift.
    		-Lehtn man oft Handelsangebote ab, so verschlechtert sich der Ruf zu anderen Königstümern. 
    
    	*************************************************NOTIZEN*************************************************
    				Zentrale Aktualisierungsfunktion einbauen, die jedes mal, wenn das Menü betreten wird, alle berechnungsfunktionen aufruft, die angefallen sind! 
    				-Desto mehr Truppen der Spieler hat, desto mehr Respekt erntet er von den Gegenspielern
    				-Das Dorf kann zu einer Siedlung, Stadt, Imperium etc heranwachsen...
    				-Ruhmeshalle mit verschiedenen Awards einbauen 
    				-Angriffe dauern eine gewisse Zeit. je weiter ein Gegner weg ist, umso länger. (Jeden gegner auf einer Char-Map platzieren);
    				-Bei Angriff kann der Spieler Transportkutschen mitschicken. Desto mehr Transportkisten er mitschcikt, desto mehr ressorucen kann er bei Gewinn mit nach Hause bringen
    				*/
    #pragma comment( lib, "winmm.lib" )
    #include <string>
    #include <iostream>
    #include <fstream>
    #include <sstream>
    #include <windows.h>
    #include <vector>
    #include <direct.h>
    #include <time.h>
    
    #include "build.h"
    #include "player.h"
    
    using namespace std;
    
    //FUNKTIONEN//
    
    void getRessources();
    void setRessources(float gold, float food, float iron, float wood, float stone);
    int getInhabitants();
    void setInhabitants(int inhabitants, bool delete_or_create);
    void build(int init, int number);
    buildings initBuildings(int init);
    bool checkRessources(buildings marketplace);
    
    void eventFunction();
    void playerEvents();
    
    void menue();
    void buildingMenue();
    void fightMenue();
    
    void taxes(clock_t &tTaxes);
    
    void market();
    void diplomatiemenue();
    void management();
    
    void relationships();
    void earnRessources(int init, int amount);
    void fight(player &enemy, int attackOrDefend, int swords, int bows, int horses);
    bool save();
    bool load();
    
    void dialogs(int dialog, int _event, int _eventinfo);	// int dialog -> Häufigkeit des Menüaufrufes) int _event -> Spezielles Event.
    
    // GEBÄUDE //
    buildings marketplace, farm, woodmine, stonemine, ironmine, kaserne, diplomatie;
    //Königreiche//
    player tammo("Tammo");
    player ariana("Ariana"), gregor("Gregor"), malark("Malark"), skott("Skott"), finmor("Finmor"), tresla("Tresla"), isabell("Isabell"), nympth("Nympth");
    // BOOLS //
    
    bool bMarketplace,
    	bIronmine,
    	bWoodmine,
    	bStonemine,
    	bKaserne,
    	bFarm,
    	bDiplomatie;
    bool soundOnOff = false;
    // INT //
    
    float wood = 750;
    float iron = 750;
    float stone = 750;
    float food = 750;
    float gold = 750;
    float prestige = 0;
    float experience = 0;
    float humor = 1.2f;				// <<<<- Speichern und in die GetRessources einbauen!
    bool ende = false;
    
    clock_t tTaxes, insg, tPlayer;
    
    float xWood = 1, 
    	xIron = 1,
    	xStone = 1,
    	xGold = 1,
    	xFood = 1;
    
    int inhabitants = 3000;
    int fighter = 0;
    int swordfighter = 0,
    	bowfighter = 0,
    	horsefighter = 0,
    	transporter = 1,
    	sessionCounter = 0;
    
    string dorfname = "Unser Dorf hat noch keinen Namen!";
    
    bool const_dialogBools[20];
    bool session_dialogBools[20];
    bool isFirstCall = true;
    string inline boolToStatement(int _bool, int _bool_);
    
    void inline typewriter(string t, int sleep)
    {
    
    	for(int i = 0; i<t.size(); i++)
    	{
    		if(t[i]!='§')
    		{
    			cout << t[i];
    			Sleep(sleep);
    		}
    		else
    			Sleep(300);
    	}
    }
    int main()
    {
    	SetConsoleTitle ("TheVillage");
    	_mkdir("thevillage");
    
    	char jn2;
    	cout << "Intro ueberspringen? [J]a oder [N]ein?" << endl;
    	cin >> jn2;
    
    	if(jn2 == 'n' || jn2 == 'N' )
    	{
    		system("cls");
    		PlaySound(MAKEINTRESOURCE(1001), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC | SND_LOOP | SND_NODEFAULT);
    		Sleep(12000);
    		typewriter("Maerz§§.12§§.§1588\n",150);
    		Sleep(4000);
    		typewriter("\nDer Wind weht...",100);
    		Sleep(1000);
    		typewriter("\nAn unseren Klingen klebt Blut.",100);
    		Sleep(2000);
    		typewriter("\nDoch wir haben verloren.§§§§§",100); 
    		Sleep(2000);
    		typewriter("\nUnsern Besitz!",100);
    		Sleep(2000);
    		typewriter("\nUnsere Ehre! §§§§Und...",100);
    		typewriter("§§§§§§§§§§§ \n\n\n\t\t\t\tUnser Dorf!\n\n\n",150);
    		Sleep(2000);
    		typewriter("Hilf uns, unser Dorf wiederaufzubauen!§§§§§§§ \nHilf uns, unsere Ehre wiederzuer§langen! \nHilf uns,§§§§§ uns zu§§§§ raechen!\n",100);
    		Sleep(3000);
    		typewriter("\nFolgst du uns auf unserem Weg?\n\n",100);
    		Sleep(700);
    
    		typewriter("\t\t\t||==============================||\n",30);
    		typewriter("\t\t\t||                              ||\n",0);
    		typewriter("\t\t\t||      Herzlich Willkommen     ||\n",30);
    		typewriter("\t\t\t||              in              ||\n",30);
    		typewriter("\t\t\t||          TheVillage          ||\n",30);
    		typewriter("\t\t\t||                              ||\n",0);
    		typewriter("\t\t\t||==============================||\n",30);
    		cin.ignore();
    
    	}
    
    	system("cls");
    	char c_load; // Spielstand laden? // 
    	cout << "Letzten Spielstand laden? J = JA" << endl;
    	cin >> c_load;
    	if(c_load == 'j' || c_load == 'J')
    	{
    		if(load()==true)
    		{
    			cout << "Spielstand erfolgreich geladen!" << endl;	
    		}
    
    		else
    		{
    			cout << "Spielstand konnte nicht geladen werden!" << endl;	// Fehler beim Laden
    			Sleep(1000);
    		}
    
    	}
    
    	menue();
    	return 0;
    
    }
    
    void menue()
    {
    
    	tTaxes = clock();		// Mist die Zeit seit letzten Steuern
    	insg = clock();			// Mist die Zeit seit Beginn
    
    	PlaySound(MAKEINTRESOURCE(1002), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC | SND_LOOP | SND_NODEFAULT);
    	soundOnOff=!soundOnOff;
    
    	bool end = false;
    	do
    	{
    		if(::isFirstCall==false)
    			::eventFunction();
    		::isFirstCall = false;
    
    		system("cls");
    		int choice = 0;			
    
    		////////////////
    		cout << "=========================" << endl;
    		cout << "[1] - Rohstoffe einsehen \t\t||" << endl;
    		cout << "[2] - Baumenue \t\t\t\t||" << endl;
    		cout << "[3] - Holz abbauen \t\t\t||" << endl;
    		cout << "[4] - Stein abbauen \t\t\t||" << endl;
    		cout << "[5] - Eisen abbauen \t\t\t||" << endl;
    		cout << "[6] - Nahrung ernten \t\t\t||" << endl;
    		cout << "[7] - Kampfmenue \t\t\t||" << endl;
    		cout << "[8] - Verwaltung \t\t\t||" << endl;
    		cout << "[9] - Marktplatz \t\t\t||" << endl;
    		cout << "[10]- Diplomatie \t\t\t||" << endl;
    		cout << "=========================" << endl;
    		cout << "[0] - Spiel speichern & verlassen \t||" << endl;
    		cout << "[100] Ton aus/an \t\t\t||" << endl;
    		cout << "=========================\n" << endl;
    		/////////////////
    
    		dialogs(1,0,0);
    
    		cin >> choice;
    
    		if (cin.fail() )		// Wenn falsche Eingabe, bleibe in der do-Schleife!
    		{
    			cin.clear(); 
                cin.sync(); 
    		}
    		else				// Wenn richtige Eingabe, werte sie aus
    		{
    			switch(choice)
    			{
    			case 0:
    				{
    
    					int save_or_not;
    					cout << "Spielstand speichern? [1] -> JA" << endl;
    					cin >> save_or_not;
    					if(save_or_not == 1)
    					{
    						if(save() == true)
    						{
    							cout << "Spielstand gespeichert!" << endl;
    							cin.sync();
    							cin.get();
    
    						}
    
    						else
    						{
    							cout << "Spielstand konnte nicht gespeichert werden!" << endl;
    							cin.sync();
    							cin.get();
    
    						}
    					}
    
    					end = true;
    					break;
    				}
    			case 1:
    				{
    					::getRessources();
    
    					cin.get();
    					break;
    				}
    			case 2:
    				{
    					buildingMenue();
    					break;
    				}
    			case 3:
    				{
    					if(bWoodmine == true)
    						earnRessources(1,1);
    					else
    					{
    						cout << "Sie muessen erst eine Holzfaellerhuette bauen!" << endl;
    						cin.sync();
    						cin.get();
    					}
    
    					break;
    				}
    			case 4:
    				{
    					if(bStonemine == true)
    						earnRessources(2,1);
    					else
    					{
    						cout << "Sie muessen erst eine Steinmine bauen!" << endl;
    						cin.sync();
    						cin.get();
    					}
    					break;
    				}
    			case 5:
    				{
    					if(bIronmine == true)
    						earnRessources(3,1);
    					else
    					{
    						cout << "Sie muessen erst eine Eisenmine bauen!" << endl;
    						cin.sync();
    						cin.get();
    					}
    					break;
    				}
    			case 6:
    				{
    					if(bFarm == true)
    						earnRessources(4,1);
    					else
    					{
    						cout << "Sie muessen erst eine Farm bauen!" << endl;
    						cin.sync();
    						cin.get();
    
    					}
    					break;
    				}
    			case 7:
    				{
    					if(bKaserne == true)
    						fightMenue();
    					else
    					{
    						cout << "Sie muessen erst eine Kaserne bauen!" << endl;
    						cin.sync();
    						cin.get();
    
    					}
    					break;
    				}
    			case 8:
    				{
    					management();
    					cout << "Verwaltung" << endl;
    					cin.get();
    					break;
    				}
    			case 9:
    				{
    					market();
    					break;
    				}
    			case 10:
    				{
    					if(bDiplomatie == true)
    						::diplomatiemenue();
    					else
    					{
    
    						cout << "Sie muessen erst noch ein Diplomatiegebaeude bauen! " << endl;
    					}
    					break;
    				}
    			case 100:
    				{
    					if(soundOnOff == true)
    					{
    						PlaySound(MAKEINTRESOURCE(1003), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC | SND_NODEFAULT);
    						soundOnOff = !soundOnOff;
    					}
    					else
    					{
    						PlaySound(MAKEINTRESOURCE(1002), GetModuleHandle(NULL), SND_RESOURCE | SND_ASYNC | SND_LOOP | SND_NODEFAULT);
    						soundOnOff = !soundOnOff;
    					}
    
    					break;
    				}
    
    			}
    		}
    
    }while(end==false);
    
    }
    
    void market()
    {
    	if(::bMarketplace == true) // ///////////////////////////////////////////////// !!!!!!!!!!!!!!!!!!!
    	{
    	system("cls");
    	cout << "<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>" << endl;
    	cout << "|               Marktplatz                  |" << endl;
    	cout << "<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>" << endl;
    
    	cin.sync();
    	cin.get();
    	}
    
    	else
    	{
    		cout << "Wir haben noch keinen Marktplatz..." << endl;
    		cin.sync();
    		cin.get();
    	}
    }
    void buildingMenue()
    {
    	system("cls");
    	bool end = false;
    	int choice = 0;
    
    	::dialogs(2,0,0);
    	do
    	{
    		int a;
    		cout << "=========================" << endl;
    		cout << "[0] - Zurueck zum Obermenue " << endl;
    		a = marketplace.getLevel();
    		cout << "[1] - Marktplatz bauen \t\t/ Level " << a << endl;
    		a = ironmine.getLevel();
    		cout << "[2] - Eisenmine bauen \t\t/ Level " << a << endl;
    		a = woodmine.getLevel();
    		cout << "[3] - Holzfaellerhuette bauen \t\t/ Level " << a<< endl;
    		a = stonemine.getLevel();
    		cout << "[4] - Steinmine bauen \t\t/ Level " << a<< endl;
    		a = farm.getLevel();
    		cout << "[5] - Farm bauen \t\t/ Level " << a<< endl;
    		a = kaserne.getLevel();
    		cout << "[6] - Kaserne bauen \t\t/ Level " << a<< endl;
    		cout << "[7] - Wohnhaueser bauen " << endl;
    		cout << "[8] - Diplomatiegebäude bauen \t\t/ Level " << a << endl;
    		cout << "=========================" << endl;
    
    		cin >> choice;
    		if (cin.fail() )
    			{
    				cin.clear(); 
    				cin.sync(); 
    			}
    		else
    		{
    			switch (choice)
    			{
    			case 1:
    				{
    						build(1,0);
    					break;
    				}
    			case 2:
    				{
    
    						build(2,0);
    
    					break;
    				}
    			case 3:
    				{
    
    						build(3,0);
    
    					break;
    				}
    			case 4:
    				{
    
    						build(4,0);
    
    					break;
    				}
    			case 5:
    				{
    					build(5,0);
    
    					break;
    				}
    			case 6:
    				{
    					build(6,0);
    
    					break;
    				}
    
    			case 7:
    				{
    					dialogs(3,0,0);
    					if(wood>15 && stone > 5)
    					{
    						cin.sync();
    						cin.get();
    						inhabitants+= 10;
    						wood-=15;
    						stone-=5;
    					}
    					else
    					{
    						cout << "Nicht genug Rohstoffe!" << endl;
    						cin.sync();
    						cin.get();
    					}
    
    					break;
    
    				}
    
    			case 8:
    				{
    					build(7,0);
    					break;
    				}
    			case 0:
    				{
    					end = true;
    					break;
    				}
    			}
    
    		}
    
    		system("cls");
    
    	}while(end == false);
    }
    
    void fightMenue()
    {
    	system("cls");
    	bool end = false;
    	int choice;
    
    	dialogs(4,0,0);
    
    	do
    	{
    		system("cls");
    		cout << "[0] - Zuruck zum Obermenue " << endl;
    		cout << "[1] - Leute ausbilden! " << endl;
    		cout << "[2] - Rekrutieren! " << endl;
    		cout << "[3] - IN DIE SCHLACHT! " << endl;
    		cout << "[4] - Taktische Besprechung! " << endl;
    		cin.sync();
    		cin >> choice;
    		if (cin.fail() )
    		{
    			cout << "Falsche Eingabe!" << endl;
    			cin.clear(); 
                cin.sync(); 
    			cin.get();
    		}
    		else
    		{
    			switch(choice)
    			{
    			case 0:
    				{
    					end = true;
    					break;
    				}
    
    			case 1:
    				{
    
    					int t = 0;
    					cout << "Wir haben " << inhabitants << " ausbildbare Einwohner!" << endl;
    					cout << "Wie viele sollen wir ausbilden lassen? (Kosten: 1 Gold & 1 Eisen" << endl;
    					cin >> t;
    					if(t<inhabitants && t*1 < gold && t*1 < iron)
    					{
    						gold -=1*t;
    						iron -=1*t;
    						fighter +=t;
    						inhabitants -=t;
    					}
    					else
    						cout << "Nicht genug Rohstoffe oder Einwohner!" << endl;
    					cin.sync();
    					cin.get();
    					break;
    				}
    
    			case 2:
    				{
    					bool end = false;
    					do
    					{
    						system("cls");
    						int choice;
    						cout << "=========================" << endl;
    						cout << "|| Ausbildbar: " << ::fighter << endl;
    						cout << "|| Kavellerie: " << horsefighter << endl;
    						cout << "|| Schwertkaempfer: " << swordfighter << endl;
    						cout << "|| Bogenschuetzen: " << bowfighter << endl;
    						cout << "=========================\n" << endl;
    						cout << "[0] - Zurueck zum Obermenue " << endl;
    						cout << "[1] - Schwertkaempfer ausbilden! \t \t [3 Eisen & 3 Gold] " << endl;
    						cout << "[2] - Leichte Kavellerie ausbilden! \t \t [7 Eisen & 4 Gold] " << endl;
    						cout << "[3] - Bogenschuetzen ausbilden! \t \t [5 Eisen & 1 Gold] " << endl;
    
    						cin.sync();
    						cin >> choice;
    						if (cin.fail() )
    						{
    							cout << "Falsche Eingabe!" << endl;
    							cin.clear(); 
    							cin.sync(); 
    							cin.get();
    
    						}
    
    						else
    						{
    							switch(choice)
    							{
    							case 0:
    								{
    									end = true;
    									break;
    								}
    							case 1:
    								{
    									int number;
    									cout << "Anzahl der Einheiten angeben!" << endl;
    									cin >> number; 
    									if(number>fighter || 3*number>gold || 3*number > iron)
    									{
    										cout << "Sie haben zu wenige Kaempfer oder Rohstoffe!" << endl;
    										cin.sync();
    										cin.get();
    									}
    
    									else
    									{
    										cout << number << " Schwertkaempfer ausgebildet!" << endl;
    										swordfighter+=number;
    										fighter-=number;
    										gold-=number*3;
    										iron-=number*3;
    										cin.sync();
    										cin.get();
    									}
    
    									break;
    								}
    							case 2:
    								{
    									int number;
    									cout << "Anzahl der Einheiten angeben!" << endl;
    									cin >> number; 
    									if(number>fighter || 4*number>gold || 7*number > iron)
    									{
    										cout << "Sie haben zu wenige Kaempfer oder Rohstoffe!" << endl;
    										cin.sync();
    										cin.get();
    									}
    
    									else
    									{
    										cout << number << " Kavellerie ausgebildet!" << endl;
    										horsefighter+=number;
    										fighter-=number;
    										gold-=number*4;
    										iron-=number*7;
    										cin.sync();
    										cin.get();
    									}
    
    									break;
    								}
    							case 3:
    								{
    									int number;
    									cout << "Anzahl der Einheiten angeben!" << endl;
    									cin >> number; 
    									if(number>fighter || 1*number>gold || 5*number > iron)
    									{
    										cout << "Sie haben zu wenige Kaempfer oder Rohstoffe!" << endl;
    										cin.sync();
    										cin.get();
    									}
    
    									else
    									{
    										cout << number << " Bogenschuetzen ausgebildet!" << endl;
    										bowfighter+=number;
    										fighter-=number;
    										gold-=number*1;
    										iron-=number*5;
    										cin.sync();
    										cin.get();
    									}
    
    									break;
    								}
    							}
    						}
    
    					}while(end == false);
    
    					break;
    				}
    
    			case 3:
    					{
    						int attackWho;
    						cout << "Wen sollen wir angreifen?" << endl;
    						cout << "[1] Nymph " << endl;
    						cout << "[2] Isabell " << endl;
    						cin>>attackWho;
    						if(attackWho == 1)
    						{
    							::fight(nympth,1,swordfighter, bowfighter, horsefighter);
    						}
    						if(attackWho == 2)
    							::fight(isabell,1,swordfighter, bowfighter, horsefighter);
    
    						cin.sync();
    						cin.get();
    						break;
    					}
    			}
    		}
    	}while(end==false);
    }
    
    void build(int init, int number)
    {
    
    		switch(init)
    		{
    		case 1:
    			{
    				if(bMarketplace == false)
    				{
    					marketplace.InitValues(20,10,20,20,15,0.2f,0.2f,0.2f,0.2f,0.2f,15,1);
    
    				}
    				else
    				{
    					marketplace.setKosten();
    				}
    				if(checkRessources(marketplace) == true)
    				{
    					char bauen;
    					marketplace.getKosten( wood, iron,  stone,  gold,  food);
    					cout << "Wollen sie wirklich bauen? [J]a oder [N]ein?" << endl;
    					cin >> bauen;
    					if(bauen=='J' || bauen == 'j')
    					{
    						marketplace.build(&wood, &iron, &stone, &gold, &food, &prestige, &experience, &xWood, &xIron, &xStone, &xGold, &xFood, &humor);
    						marketplace.setLevel(0);
    						cout << "Marktplatz gebaut!" << endl;
    						bMarketplace = true;
    					}
    					else
    						cout << "Es wurde nicht gebaut!" << endl;
    					cin.get();
    					break;
    
    				}
    
    				else 
    				{
    					cout << "Nicht genuegend Rohstoffe verfuegbar!" << endl;
    					cin.get();
    				}
    
    				break;
    
    			}
    
    		case 2:
    			{
    				if(bIronmine == false)
    				{
    					ironmine.InitValues(10,10,10,10,10,0.0f,0.25f,0.0f,0,0,0,0.5f);
    
    				}
    				else
    				{
    					ironmine.setKosten();
    				}
    				if(checkRessources(ironmine) == true)
    				{
    					char bauen;
    					ironmine.getKosten( wood, iron, stone,  gold,  food);
    
    					cout << "Wollen sie wirklich bauen? [J]a oder [N]ein?" << endl;
    					cin >> bauen;
    
    					if(bauen=='J' || bauen=='j')
    					{
    						ironmine.build(&wood, &iron, &stone, &gold, &food, &prestige, &experience, &xWood, &xIron, &xStone, &xGold, &xFood, &humor);
    						ironmine.setLevel(0);
    						cout << "Eisenmine gebaut!" << endl;
    						bIronmine = true;
    					}
    					else
    						cout << "Es wurde nicht gebaut!" << endl;
    					cin.get();
    
    				}
    
    				else 
    				{
    					cout << "Nicht genuegend Rohstoffe verfuegbar!" << endl;
    					cin.get();
    				}
    
    				break;
    
    			}
    
    		case 3:
    			{
    				if(bWoodmine == false)
    					woodmine.InitValues(10,10,10,10,10,0.25,0,0,0,0,0,0.5f);
    
    				else
    					woodmine.setKosten();
    
    				if(checkRessources(woodmine) == true)
    				{
    					char bauen;
    
    					woodmine.getKosten(wood, iron,  stone,  gold, food);
    					cout << "Wollen sie wirklich bauen? [J]a oder [N]ein?" << endl;
    
    					cin >> bauen;
    
    					if(bauen =='J' || bauen == 'j')
    					{
    						woodmine.build(&wood, &iron, &stone, &gold, &food, &prestige, &experience, &xWood, &xIron, &xStone, &xGold, &xFood, &humor);
    						woodmine.setLevel(0);
    						cout << "Holzfaellerhuette gebaut!" << endl;
    						bWoodmine = true;
    					}
    
    					else
    						cout << "Es wurde nicht gebaut!" << endl;
    
    					cin.get();
    
    				}
    
    				else 
    				{
    					cout << "Nicht genuegend Rohstoffe verfuegbar!" << endl;
    					cin.get();
    				}
    
    				break;
    
    			}
    
    		case 4:
    			{
    				if(bStonemine == false)
    					stonemine.InitValues(10,10,10,10,10,0,0,0.25,0,0,5,0.5f);
    
    				else
    					stonemine.setKosten();
    
    				if(checkRessources(stonemine) == true)
    				{
    					char bauen;
    
    					stonemine.getKosten(wood, iron, stone,  gold, food);
    					cout << "Wollen sie wirklich bauen? [J]a oder [N]ein?" << endl;
    
    					cin >> bauen;
    					if(bauen=='J' || bauen=='j')
    					{
    						stonemine.build(&wood, &iron, &stone, &gold, &food, &prestige, &experience, &xWood, &xIron, &xStone, &xGold, &xFood, &humor);
    						stonemine.setLevel(0);
    						cout << "Steinmine gebaut!" << endl;
    						bStonemine = true;
    					}
    					else
    						cout << "Es wurde nicht gebaut!" << endl;
    
    					cin.get();
    
    				}
    
    				else 
    				{
    					cout << "Nicht genuegend Rohstoffe verfuegbar!" << endl;
    					cin.get();
    				}
    
    				break;
    
    			}
    
    		case 5:
    			{
    				if(bFarm == false)
    					farm.InitValues(10,10,10,10,10,0,0,0,0,0.25,10,1);
    
    				else
    					farm.setKosten();
    
    				if(checkRessources(farm) == true)
    				{
    					char bauen;
    
    					farm.getKosten( wood,  iron,  stone,  gold,  food);
    					cout << "Wollen sie wirklich bauen? [J]a oder [N]ein?" << endl;
    
    					cin >> bauen;
    					if(bauen=='J' || bauen=='j')
    					{
    						farm.build(&wood, &iron, &stone, &gold, &food, &prestige, &experience, &xWood, &xIron, &xStone, &xGold, &xFood, &humor);
    						farm.setLevel(0);
    						cout << "Farm gebaut!" << endl;
    						bFarm = true;
    					}
    
    					else
    						cout << "Es wurde nicht gebaut!" << endl;
    
    					cin.get();
    
    				}
    
    				else 
    				{
    					cout << "Nicht genuegend Rohstoffe verfuegbar!" << endl;
    					cin.get();
    				}
    
    				break;
    
    			}
    
    		case 6:
    			{
    				if(bKaserne == false)
    				{
    					kaserne.InitValues(20,30,50,50,50,0,0,0,0,0,30,2.0f);
    
    				}
    				else
    				{
    					kaserne.setKosten();
    				}
    				if(checkRessources(kaserne) == true)
    				{
    					char bauen;
    					kaserne.getKosten( wood, iron,  stone,  gold, food);
    					cout << "Wollen sie wirklich bauen? [J]a oder [N]ein?" << endl;
    					cin >> bauen;
    					if(bauen=='J' || bauen == 'j')
    					{
    						kaserne.build(&wood, &iron, &stone, &gold, &food, &prestige, &experience, &xWood, &xIron, &xStone, &xGold, &xFood, &humor);
    						kaserne.setLevel(0);
    						cout << "Kaserne gebaut!" << endl;
    						bKaserne = true;
    					}
    					else
    						cout << "Es wurde nicht gebaut!" << endl;
    					cin.get();
    
    				}
    
    				else 
    				{
    					cout << "Nicht genuegend Rohstoffe verfuegbar!" << endl;
    					cin.get();
    				}
    
    				break;
    
    			}
    		case 7:
    			{
    				if(bDiplomatie == false)
    				{
    					diplomatie.InitValues(20,30,50,50,50,0,0,0,0,0,30,2.0f);
    
    				}
    				else
    				{
    					diplomatie.setKosten();
    				}
    				if(checkRessources(diplomatie) == true)
    				{
    					char bauen;
    					diplomatie.getKosten( wood, iron,  stone,  gold, food);
    					cout << "Wollen sie wirklich bauen? [J]a oder [N]ein?" << endl;
    					cin >> bauen;
    					if(bauen=='J' || bauen == 'j')
    					{
    						diplomatie.build(&wood, &iron, &stone, &gold, &food, &prestige, &experience, &xWood, &xIron, &xStone, &xGold, &xFood, &humor);
    						diplomatie.setLevel(0);
    						cout << "Diplomatiegebaeude gebaut!" << endl;
    						bDiplomatie = true;
    					}
    					else
    						cout << "Es wurde nicht gebaut!" << endl;
    					cin.get();
    
    				}
    
    				else 
    				{
    					cout << "Nicht genuegend Rohstoffe verfuegbar!" << endl;
    					cin.get();
    				}
    
    				break;
    
    			}
    
    		}
    
    }
    
    void getRessources()
    {
    	system("cls");
    	dialogs(0,1,0);
    			//////////////////////
    			cout << "Dorfname: " << dorfname << endl;
    			cout << "=========================" << endl;
    			cout << "||" << wood << " Holz" << endl;
    			cout <<"||" << iron << " Eisen" << endl;
    			cout <<"||" << stone << " Stein" << endl;
    			cout <<"||" << food << " Nahrung" << endl;
    			cout <<"||" << gold << " Gold" << endl;
    			cout << "=========================" << endl;
    			cout <<"Unser Dorf hat " << inhabitants << " Einwohner " << endl;
    			cout << "und " << fighter << " Kaempfer. " << endl;
    			if(humor<1)
    				cout << "Das Volk hat keine gute Laune! Somit arbeitet es auch nicht so produktiv!" << endl;
    			if(humor>1 && humor<5)
    				cout << "Das Volk ist ruhig. Doch es koennte weissgott besser sein!" << endl;
    			if(humor>5 && humor < 10)
    				cout << "Das Volk ist guter Dinge!" << endl;
    			if(humor>10)
    				cout << "Das Volk ist bester Laune!" << endl;
    
    			cout << "Kampfeinheiten findet ihr im Kampfmenue!\n" << endl;
    			////////////////////////
    			dialogs(0,1,1);
    			cin.get();
    
    }
    
    bool checkRessources(buildings building)
    {
    	if(building.check(wood, iron, stone, gold, food) == true)
    		return true;
    	else 
    		return false;
    }
    
    void earnRessources(int init, int amount)
    {
    	float xHumor;
    	if(humor<1)
    		xHumor = 1.0f;
    	if(humor>1 && humor<5)
    		xHumor = 1.25f;
    	if(humor>5 && humor < 10)
    	    xHumor = 1.6f;
    	if(humor>10)
    		xHumor = 2.0f;
    
    	switch(init)
    	{
    	case 1: // Holz abbauen
    		{
    			char choice;
    			cout << "Wirklich Holz abbauen?" << endl
    				<< "Dies kostet sie 10 Nahrung und 5 Gold und bringt " << (10*xWood)*xHumor << " Holz!" << endl;
    			cin >> choice;
    			if(cin.fail())
    			{
    				cout << "Falsche Eingabe!" << endl; 
    
    			}
    			if(choice == 'J' || choice == 'j')
    			{
    				if(food > 10 && gold > 5)
    				{
    					typewriter("<Die Arbeiter> Wir machen uns ans Werk!",30);
    					cin.get();
    					wood += (10*xWood)*xHumor;
    					food-=10;
    					gold-=5;
    				}
    				else
    				{
    					cout << "Nicht genuegend Rohstoffe zum Abbauen vorhanden!" << endl;
    					cin.get();
    				}
    			}
    			break;
    		}
    	case 2: // Stein abbauen
    		{
    			char choice;
    			cout << "Wirklich Stein abbauen?" << endl
    				<< "Dies kostet sie 10 Nahrung und 5 Gold und bringt " << (10*xStone)*xHumor << " Stein!" << endl;
    			cin >> choice;
    			if(cin.fail())
    			{
    				cout << "Falsche Eingabe!" << endl; 
    
    			}
    			if(choice == 'J' || choice == 'j')
    			{
    			if(food > 10 && gold > 5)
    				{
    					typewriter("<Die Arbeiter> Wir machen uns ans Werk!",30);
    					cin.get();
    					stone += (10*xStone)*xHumor;
    					food-=10;
    					gold-=5;
    				}
    				else
    				{
    					cout << "Nicht genuegend Rohstoffe zum Abbauen vorhanden!" << endl;
    					cin.get();
    				}
    			}
    			break;
    		}
    	case 3: // Eisen abbauen
    		{
    			char choice;
    			cout << "Wirklich Eisen abbauen?" << endl
    				<< "Dies kostet sie 10 Nahrung und 5 Gold und bringt " << (10*xIron)*xHumor << " Eisen!" << endl;
    			cin >> choice;
    			if(cin.fail())
    			{
    				cout << "Falsche Eingabe!" << endl; 
    
    			}
    			if(choice == 'J' || choice == 'j')
    			{
    				if(food > 10 && gold > 5)
    				{
    					typewriter("<Die Arbeiter> Wir machen uns ans Werk!",30);
    					cin.get();
    					food-=10;
    					gold-=5;
    					iron += (10*xIron)*xHumor;
    				}
    				else
    				{
    					cout << "Nicht genuegend Rohstoffe zum Abbauen vorhanden!" << endl;
    					cin.get();
    				}
    			}
    			break;
    		}
    	case 4: // Nahrung abbauen
    		{
    			char choice;
    			cout << "Wirklich Nahrung ernten?" << endl
    				<< "Dies kostet sie 7 Gold und bringt " << (10*xFood)*xHumor << " Nahrung!" << endl;
    			cin >> choice;
    			if(cin.fail())
    			{
    				cout << "Falsche Eingabe!" << endl; 
    
    			}
    			if(choice == 'J' || choice == 'j')
    			{
    
    				if(gold > 5)
    				{
    					typewriter("<Die Arbeiter> Wir machen uns ans Werk!",30);
    					cin.get();
    					gold-=7;
    					food += (10*xFood)*xHumor;
    				}
    				else
    				{
    					cout << "Nicht genuegend Rohstoffe zum Abbauen vorhanden!" << endl;
    					cin.get();
    				}
    			}
    			break;
    		}
    
    	}
    }
    
    ostream& operator<<(ostream &Stream, player& B)
    {
    	cout << B.name << endl;
    	cout << B.aiFood << endl;
    	B.aiFood += 30;
    	cout << B.aiFood << endl;
    	cout << B.aiHumor << endl;
    	cin.get();
    	Stream << B.aiGold << B.aiFood << B.aiIron << B.aiStone << B.aiWood<< B.development << B.forceStrength << B.aiHumor << B.aiInhabitants<< B.prosperty<< B.timesPlayerRejectedOffer << B.timesTradedWithPlayer  << B.bStatusToPlayer << B.bStatusToPlayerAlly;
    	return Stream;
    }
    
    istream& operator>>(istream &Streamm, player& B)
    {
    
    	Streamm >> B.aiGold >> B.aiFood >> B.aiIron >> B.aiStone >> B.aiWood >> B.development >> B.forceStrength >> B.aiHumor >> B.aiInhabitants >> B.prosperty >> B.timesPlayerRejectedOffer >> B.timesTradedWithPlayer >> B.bStatusToPlayer >> B.bStatusToPlayerAlly;
    	cout << B.name << endl;
    	cout << B.aiFood << endl;
    	cout << B.aiHumor << endl;
    	cin.get();
    	return Streamm;
    }
    
    bool save()
    {
    	fstream playeroutput;
    	playeroutput.open("pl.dat", ios::out | ios::trunc);
    
    	playeroutput << ::malark;
    	playeroutput << ::nympth;
    	playeroutput << ::isabell;
    	playeroutput << ::finmor;
    	playeroutput << ::ariana;
    	playeroutput << ::skott;
    	playeroutput << ::gregor;
    	playeroutput << ::tammo;
    	playeroutput << ::tresla;
    	playeroutput.close();
    
    	fstream f;
        f.open("thevillage/values.dat", ios::out);
    	if(f)
    	{
    
    		f << wood << endl;
    		f << iron << endl;
    		f << stone << endl;
    		f << food << endl;
    		f << gold << endl;
    		f <<experience << endl;
    		f <<prestige << endl;
    		f <<xWood << endl;
    		f <<xStone << endl;
    		f <<xIron << endl;
    		f <<xGold << endl;
    		f <<xFood << endl;
    		f <<inhabitants << endl;
    		f <<::bWoodmine << endl;
    		f <<::bIronmine << endl;
    		f <<::bStonemine << endl;
    		f <<::bFarm << endl;
    		f <<::bMarketplace << endl;
    		f <<::bKaserne << endl;
    		f <<::bDiplomatie << endl;
    		f <<::fighter << endl;
    		f <<::horsefighter << endl;
    		f <<::swordfighter << endl;
    		f <<::bowfighter << endl;
    		f <<::tTaxes << endl;
    		f <<::insg << endl;
    		f <<::humor << endl;
    		f <<::transporter << endl;
    		f.close();
    
    		fstream boolsout;
    		boolsout.open("thevillage/bools.dat", ios::out);
    		for (int i = 0; i<20; i++)
    		{
    			if(::const_dialogBools[i] != true)
    			{
    				boolsout << '0';
    			}
    			else
    			{
    				boolsout << '1';
    			}
    		}
    		boolsout << endl;
    
    		boolsout.close();
    
    		fstream buildings;
    		buildings.open("buildings.dat",ios::out);
    		buildings.write((char *)&marketplace, sizeof(class buildings));
    		buildings.write((char *)&ironmine, sizeof(class buildings));
    		buildings.write((char *)&woodmine, sizeof(class buildings));
    		buildings.write((char *)&stonemine, sizeof(class buildings));
    		buildings.write((char *)&farm, sizeof(class buildings));
    		buildings.write((char *)&kaserne, sizeof(class buildings));
    		buildings.close();
    
    	return true;
    	}
    	else
    		return false;
    
    	::const_dialogBools[5] = true;
    	return true;
    }
    
    bool load()
    {
    	fstream input;
    	input.open("pl.dat", ios::in);
    
    	input >> ::malark;
    	input >> ::nympth;
    	input >> ::isabell;
    	input >> ::finmor;
    	input >> ::ariana;
    	input >> ::skott;
    	input >> ::gregor;
    	input >> ::tammo;
    	input >> ::tresla;
    input.close();
    
    	fstream f2;
    	string s;
        f2.open("thevillage/values.dat", ios::in);
    	if(f2.good())
    	{
    		stringstream ss1;
    		getline(f2,s);
    		ss1 << s;
    		ss1 >> wood;
    		cin.get();
    
    		stringstream ss2;
    		getline(f2,s);
    		ss2 << s;
    		ss2 >> iron;
    
    		stringstream ss3;
    		getline(f2,s);
    		ss3 << s;
    		ss3 >> stone;
    
    		stringstream ss4;
    		getline(f2,s);
    		ss4 << s;
    		ss4 >> food;
    
    		stringstream ss5;
    		getline(f2,s);
    		ss5 << s;
    		ss5 >> gold;
    
    		stringstream ss6;
    		getline(f2,s);
    		ss6 << s;
    		ss6 >> experience;
    
    		stringstream ss7;
    		getline(f2,s);
    		ss7 << s;
    		ss7 >> prestige;
    
    		stringstream ss8;
    		getline(f2,s);
    		ss8 << s;
    		ss8 >> xWood;
    
    		stringstream ss9;
    		getline(f2,s);
    		ss9 << s;
    		ss9 >> xStone;
    
    		stringstream ss10;
    		getline(f2,s);
    		ss10 << s;
    		ss10 >> xIron;
    		cin.get();
    
    		stringstream ss11;
    		getline(f2,s);
    		ss11 << s;
    		ss11 >> xGold;
    
    		stringstream ss12;
    		getline(f2,s);
    		ss12 << s;
    		ss12 >> xFood;
    
    		stringstream ss13;
    		getline(f2,s);
    		ss13 << s;
    		ss13 >> inhabitants;
    
    		stringstream ss14;
    		getline(f2,s);
    		ss14 << s;
    		ss14 >> bWoodmine;
    
    		stringstream ss15;
    		getline(f2,s);
    		ss15 << s;
    		ss15 >> bIronmine;
    
    		stringstream ss16;
    		getline(f2,s);
    		ss16 << s;
    		ss16 >> bStonemine;
    
    		stringstream ss17;
    		getline(f2,s);
    		ss17 << s;
    		ss17 >> bFarm;
    
    		stringstream ss18;
    		getline(f2,s);
    		ss18 << s;
    		ss18 >> bMarketplace;
    
    		stringstream ss19;
    		getline(f2,s);
    		ss19 << s;
    		ss19 >> bKaserne;
    
    		stringstream ss19_1;
    		getline(f2,s);
    		ss19_1 << s;
    		ss19_1>> bDiplomatie;
    
    		stringstream ss20;
    		getline(f2,s);
    		ss20 << s;
    		ss20 >> fighter;
    
    		stringstream ss21;
    		getline(f2,s);
    		ss21 << s;
    		ss21 >> horsefighter;
    
    		stringstream ss22;
    		getline(f2,s);
    		ss22 << s;
    		ss22 >> swordfighter;
    
    		stringstream ss23;
    		getline(f2,s);
    		ss23 << s;
    		ss23 >> bowfighter;
    
    		stringstream ss24;
    		getline(f2,s);
    		ss24 << s;
    		ss24 >> ::tTaxes;
    
    		stringstream ss25;
    		getline(f2,s);
    		ss25 << s;
    		ss25 >> ::insg;
    
    		stringstream ss26;
    		getline(f2,s);
    		ss26 << s;
    		ss26 >> ::humor;
    
    		stringstream ss27;
    		getline(f2,s);
    		ss27 << s;
    		ss27 >> ::transporter;
    
    		f2.close();
    
    		fstream bools;
    		bools.open("thevillage/bools.dat", ios::in);
    		string z;
    		getline(bools,z);
    		for (int i = 0; i<20; i++)
    		{
    
    			if(z.at(i) == '0')
    			{
    				::const_dialogBools[i] = false;
    			}
    			if(z.at(i) == '1')
    			{
    				::const_dialogBools[i] = true;
    			}
    		}
    
    		fstream input;
    		input.open("buildings.dat",ios::in);
    		input.read((char *)&marketplace, sizeof(class buildings));
    		input.read((char *)&ironmine, sizeof(class buildings));
    		input.read((char *)&woodmine, sizeof(class buildings));
    		input.read((char *)&stonemine, sizeof(class buildings));
    		input.read((char *)&farm, sizeof(class buildings));
    		input.read((char *)&kaserne, sizeof(class buildings));
    		input.close();
    
    		return true;
    
    	}
    
    return true;
    }
    
    int ::getInhabitants()
    {
    	return inhabitants;
    }
    
    void ::dialogs(int dialog, int _event, int _eventinfo)
    {
    
    	if(dialog!=0)
    	{
    
    		switch(dialog)
    		{
    		case 1:				// Bei Aufruf des HauptMenüs
    			{
    				if(::const_dialogBools[0]==false)
    				{
    					Sleep(500);
    					typewriter("<Mia> Sei gegruesst, Fremder!\n",50);
    					Sleep(1500);
    					typewriter("<Mia> Sieh dich ruhig um. Viel ist nicht mehr da.",50);
    					typewriter("\n<Mia> Solltest du Fragen haben, sag es mir! §Ich stehe dir zur Verfuegung... ",50);
    					cin.get();
    					::const_dialogBools[0] = true;
    					::session_dialogBools[3] = true;
    				}
    
    				else
    				{
    					if(::session_dialogBools[2]==false && ::session_dialogBools[3] ==false)
    					{
    						typewriter("<Mia> Willkommen zurueck! Wie geht es dir?",50);
    						::session_dialogBools[2]= true;
    					}
    				}
    				break;
    			}
    		case 2:
    			{
    				if(::const_dialogBools[1]==false)
    				{
    					Sleep(500);
    					typewriter("\n<Mikon> Hallo! Mein Name ist Mikon. Ich bin der Baumeister.\n",50);
    					typewriter("<Mikon> Nicht mal den Marktplatz haben sie unverwuestet gelassen. §§ Eine Schande, oder?\n§§§§",50);
    					typewriter("<Mikon> Was sollten wir wohl als erstes bauen?\n",50);
    					cin.get();
    					::const_dialogBools[1]= true;
    				}
    				else
    				{
    					Sleep(500);
    					typewriter("<Mikon> Hallo!\n",50);
    				}
    				break;
    			}
    		case 3:
    			{
    				if(::const_dialogBools[2]==false)
    				{
    					Sleep(500);
    					typewriter("<Mia> Das duerfte eine gute Idee sein! §§Desto mehr Einwohner wir haben,\n",50);
    					typewriter("<Mia> desto mehr Steuern bekommen wir auch!",50);
    					cin.sync();
    					cin.get();
    					::const_dialogBools[2]= true;
    				}
    				else
    				{
    					typewriter("<Mia> Unser Dorf hat sich um 10 Einwohner vergroessert!",30);
    				}
    				break;
    			}
    		case 4:
    			{
    				if(::const_dialogBools[3]==false)
    				{
    					Sleep(500);
    					typewriter("<Hargon> Hrhm...§§§§ Du siehst nich aus §§als ob du kaempfen koenntest§§§\n",50);
    					typewriter("<Hargon> Aber so lange du walten kannst: Sag mir was ich tun soll!\n",50);
    					Sleep(800);
    					::const_dialogBools[3]= true;
    				}
    				else
    				{
    					Sleep(500);
    					typewriter("<Hargon> Du wieder...\n",50);
    				}
    				break;
    			}
    		}
    	}
    	else
    	{
    		switch(_event)
    		{
    		case 1:	// GET_Ressources 
    			{
    				if(_eventinfo!=1)
    				{
    					typewriter("<Mia> Wir haben noch \n",50);
    				}
    
    				if(_eventinfo==1)
    				{
    					if(::wood<100 && ::stone < 100 && ::iron < 100 && ::gold < 100 && ::food < 100)
    					{
    						Sleep(500);
    						typewriter("<Mia> Die Lager sind fast leer!",50);
    
    					}
    
    					float resArray[] = {wood, stone, iron, gold, food};
    					float min = resArray[0];
    					float max = resArray[0];
    					for(int i = 0; i<sizeof(resArray); i++)
    					{
    						if(resArray[i]<min)
    						min=resArray[i];
    					}
    
    					if(min>0)
    					{
    						string t("Am ehesten braeuchten wir ");
    						if(min==wood)
    							t.append(" Holz.");
    						if(min==stone)
    							t.append(" Stein.");
    						if(min==iron)
    							t.append(" Eisen.");
    						if(min==food)
    							t.append(" etwas zu Essen.");
    						if(min==gold)
    							t.append(" wieder etwas Gold.");
    						typewriter(t,100);
    							}
    				}
    				break;
    			}
    		}
    	}
    }
    
    void taxes(clock_t &tTaxes)
    {
    	if(((clock() - tTaxes)  / (double) CLOCKS_PER_SEC > 120))
    	{
    
    		typewriter("<Mia> Heute gab es wieder Steuern! Die Einnahmen waren ", 50);
    		cout << inhabitants*1.5f << endl;
    		gold+=(inhabitants*1.5f);
    		cin.sync();
    		cin.get();
    		tTaxes = clock();
    	}
    
    }
    
    void ::eventFunction()
    {
    	time_t t;
    		time(&t);
    		srand((unsigned int)t);   
    
    		int luck[9];
    		for(int i = 0; i<9; i++)
    		{
    			luck[i] = rand() % 77;
    		}
    		taxes(tTaxes);
    		system("cls");
    	nympth.tradeWithPlayer(wood, stone, food, iron, gold, luck[0]);
    	isabell.tradeWithPlayer(wood, stone, food, iron, gold, luck[1]);
    	malark.tradeWithPlayer(wood, stone, food, iron, gold, luck[2]);
    	tresla.tradeWithPlayer(wood, stone, food, iron, gold, luck[3]);
    	skott.tradeWithPlayer(wood, stone, food, iron, gold, luck[4]);
    	gregor.tradeWithPlayer(wood, stone, food, iron, gold, luck[5]);
    	tammo.tradeWithPlayer(wood, stone, food, iron, gold, luck[6]);
    	ariana.tradeWithPlayer(wood, stone, food, iron, gold,  luck[7]);
    	finmor.tradeWithPlayer(wood, stone, food, iron, gold, luck[8]);
    
    	if(((clock() - tPlayer)  / (double) CLOCKS_PER_SEC > 20))
    	{
    
    		if(::bMarketplace==true)
    		{
    			::nympth.calculateAll();
    			::isabell.calculateAll();
    			::malark.calculateAll();
    			::tresla.calculateAll();
    			::skott.calculateAll();
    			::gregor.calculateAll();
    			::tammo.calculateAll();
    			::ariana.calculateAll();
    			::finmor.calculateAll();
    		}
    		tPlayer = clock();
    	}
    
    }
    
    void ::diplomatiemenue()
    {
    	int choice;
    	bool choiceOK = false;
    	if(::bDiplomatie == true)
    	{
    		do
    		{
    			cout << "[1] - Aktuelle Beziehungen " << endl;
    			cout << "[2] - Krieg erklären " << endl;
    			cout << "[3] - Friedensverhandlungen " << endl;
    			cout << "[4] - Allianzverhandlungen " << endl;
    			cout << "[0] - Zurueck zum Obermenue " << endl;
    			cin>>choice;
    			if(!cin.fail())
    			{
    				choiceOK = true;
    
    				switch(choice)
    				{
    				case 1:
    					{
    						relationships();
    						break;
    					}
    				}
    			}
    
    		}while(choiceOK == false);
    	}
    
    	else
    	{
    		typewriter("<Mia> Wir haben noch kein Diplomatiegebaeude!",50);
    		cin.sync();
    		cin.get();
    	}
    }
    
    void ::relationships()
    {
    	string temp;
    	cout << "Aktuelle Beziehungen " << endl;
    	cout << "=========================" << endl;
    	temp = ::boolToStatement(nympth.bStatusToPlayer, nympth.bStatusToPlayerAlly);
    	cout << "-Nympth's Status zu dir: \t\t" << temp << endl;
    	temp = ::boolToStatement(isabell.bStatusToPlayer, isabell.bStatusToPlayerAlly);
    	cout << "-Isabell's Status zu dir: \t\t" << temp << endl;
    	temp = ::boolToStatement(malark.bStatusToPlayer, malark.bStatusToPlayerAlly);
    	cout << "-Malark's Status zu dir: \t\t" << temp << endl;
    	temp = ::boolToStatement(tresla.bStatusToPlayer, tresla.bStatusToPlayerAlly);
    	cout << "-Tresla's Status zu dir: \t\t" << temp << endl;
    	temp = ::boolToStatement(skott.bStatusToPlayer, skott.bStatusToPlayerAlly);
    	cout << "-Skott's Status zu dir: \t\t" << temp << endl;
    	temp = ::boolToStatement(gregor.bStatusToPlayer, gregor.bStatusToPlayerAlly);
    	cout << "-Gregor's Status zu dir: \t\t" << temp << endl;
    	temp = ::boolToStatement(tammo.bStatusToPlayer, tammo.bStatusToPlayerAlly);
    	cout << "-Tammo's Status zu dir: \t\t" << temp << endl;
    	temp = ::boolToStatement(ariana.bStatusToPlayer, ariana.bStatusToPlayerAlly);
    	cout << "-Ariana's Status zu dir: \t\t" << temp << endl;
    	temp = ::boolToStatement(finmor.bStatusToPlayer, finmor.bStatusToPlayerAlly);
    	cout << "-Finmor's Status zu dir: \t\t" << temp << endl;
    	cout << "=========================" << endl;
    	cin.sync();
    	cin.get();
    }
    
    string inline ::boolToStatement(int _bool, int _bool_)
    	{
    		if(_bool_ == 1)
    			return "Verbündeter!";
    		if(_bool == 1)
    			return "Neutral!";
    		if(_bool == 0)
    			return "Feind!";
    	}
    
    void management()
    {
    	system("cls");
    
    	if(::const_dialogBools[4] == false)
    	{
    		Sleep(800);
    		typewriter("<Gustav>Ich bin geehrt! Darf ich mich vorstellen? §§\n<Gustav>Mein Name ist Gustav. Folgen sie mir, hier ist ihr, §zugegebenden \n<Gustav> noch recht bescheidener §§ Arbeitsplatz!\n",50);
    		::const_dialogBools[4] = true;
    	}
    
    	int choice;
    		bool choiceOK = false;
    
    	do
    	{
    		cout<<"======================="<<endl;
    		cout<<"[1] - Namen des Dorfes aendern " << endl;
    		cout<<"[2] - Tipps" << endl;
    		cin >> choice;
    	if(!cin.fail())
    	{
    		choiceOK = true;
    		switch(choice)
    		{
    		case 1:
    			{
    				if(::humor<0)
    				{
    					Sleep(500);
    					typewriter("<Gustav>Ich glaube, das Volk ist nicht gut genug gestimmt,\n <Gustav>um einen anderen Dorfnamen zu akzeptieren!",30);
    					cin.sync();
    					cin.get();
    				}
    
    				else
    				{
    					cout << "Dorfnamen eingeben: " << endl;
    					cin >> dorfname;
    					typewriter("Unser Dorf heisst nun ",50); 
    					cout << dorfname;
    					cin.sync();
    					cin.get();
    				}
    				break;
    			}
    		}
    	}
    	}while(choiceOK == false);
    }
    
    void fight(player &enemy, int attackOrDefend, int swords, int bows, int horses)
    {
    	int luck, aiLuck;
    	int _aiAttack, _aiDefend;
    	_aiAttack = enemy.getAttack();
    	_aiDefend = enemy.getDefend();
    	int _swords = swords, _bows = bows, _horses = horses;
    	luck = rand() % 500;
    	luck %= 100;
    	aiLuck = rand() % 500;
    	aiLuck %= 100;
    	cout << "aiAttack: " << _aiAttack << endl;
    	cout << "aiDefend: " << _aiDefend << endl;
    	int attack1, defend1;
    
    	attack1 = (horses*15)+(bows*4)+(swords*8)*humor;
    	defend1 = (horses*9)+(bows*16)+(swords*8)*humor;
    
    	if(attackOrDefend == 1)
    	{
    		if((attack1*luck)-(_aiDefend*aiLuck) > 0)
    		{
    			typewriter("<Die Kaempfer> WIR HABEN GEWONNEN!",50);
    			horses-= (horses/100)*-(attack1-_aiDefend);
    			swords-= (swords/100)*-(attack1-_aiDefend);
    			bows-= (bows/100)*-(attack1-_aiDefend);
    			horsefighter -= (_horses-horses);
    			swordfighter -= (_swords-swords);
    			bowfighter -= (_bows-bows);
    			cout << "\n" << enemy.name << " hat ihnen den Krieg erklaert!" << endl;  
    			enemy.setStatusToPlayer(1);
    			cin.sync();
    			cin.get();
    
    			int aiWood, aiIron, aiStone, aiGold, aiFood;
    			aiWood = enemy.getAiWood();
    			aiIron = enemy.getAiIron();
    			aiStone = enemy.getAiStone();
    			aiGold = enemy.getAiGold();
    			aiFood = enemy.getAiFood();
    
    			int maxAmount = rand() % 9+1;
    			maxAmount *= 10;
    
    			int stolenRessources = aiWood + aiIron + aiStone + aiFood + aiGold;
    
    			if(stolenRessources > ::transporter*100)
    			{
    				wood += (transporter*100)/5;
    				iron += (transporter*100)/5;
    				stone += (transporter*100)/5;
    				gold += (transporter*100)/5;
    				food += (transporter*100)/5;
    
    				enemy.setRessources(wood,iron,stone,gold,food);
    			}
    		}
    
    		else
    		{
    			cout << "Ihre Truppen haben sich seit Tagen nicht gemeldet. Wir muessen davon ausgehen, dass \nsie vollkommen vernichtet wurden!" << endl;
    			horsefighter -= horses;
    			swordfighter -= swords;
    			bowfighter -= bows;
    			::humor = humor/2;
    			cout << "\n" << enemy.name << " hat ihnen den Krieg erklaert!" << endl; 
    			enemy.setStatusToPlayer(1);
    			cin.sync();
    			cin.get();
    		}
    	}
    }
    

    player cpp

    #include "player.h"
    #include <time.h>
    #include <string>
    using namespace std;
    
        time_t t;
    
    void player::calculateDevelopment()
    {
    
    	int i1 = 0, i2 = 0, i3 = 0, m, biggest;
    
        time(&t);
        srand((unsigned int)t);   
    
    	i1 = rand() % 2;
    	biggest = i1;
    
    	if(i1+1==2)
    	{
    		i2=rand() % 5;
    		biggest = i2;
    
    	}
    	if(i2+1==5)
    	{
    		i3=rand() % 10;
    		biggest = i3;
    
    	}
    
    	m = rand() % 2+ 1;
    
    	if(m == 1)
    		biggest *= -1.0f;
    
    	if(biggest != 0)
    		development += biggest;
    
    }
    
    void player::calculateRessources()
    {
    /*	cout << "Vorher Humor " << aiHumor << endl;
    	cout << "vorher Holz : " << aiWood << endl;
    	cout << "vorher Eisen : " << aiIron << endl;
    	cout << "vorher Gold : " << aiGold << endl;
    	cout << "vorher Food : " << aiFood << endl;
    	cout << "vorher Stein : " << aiStone << endl; */
    	this->aiWood += (aiWood/100)*(development);
    	this->aiIron += (aiIron/100)*(development);
    	this->aiStone += (aiStone/100)*(development);
    	this->aiFood += (aiFood/100)*(development);
    	this->aiGold += (aiGold/100)*(development);
    	/* cout << "Nachher Holz : " << aiWood << endl;
    	cout << "Nachher Eisen : " << aiIron << endl;
    	cout << "Nachher Gold : " << aiGold << endl;
    	cout << "Nachher Food : " << aiFood << endl;
    	cout << "Nachher Stein : " << aiStone << endl;
    	cin.sync();
    	cin.get();*/
    
    }
    
    void player::calculateForceStrengthAndHumor()
    {
    	int i1 = 0, i2 = 0, i3 = 0, m, biggest;
    
        time(&t);
        srand((unsigned int)t);   
    
    	i1 = rand() % 2;
    	biggest = i1;
    	if(i1==2)
    	{
    		i2=rand() % 6+1;
    		biggest = i2;
    	}
    
    	m = rand() % 2;
    
    	if(m == 2)
    		biggest *= -1;
    
    	if(biggest != 0)
    		this->forceStrength += (forceStrength/100)*biggest;
    		this->aiHumor += (aiHumor/100)*biggest;
    	if(aiHumor == 0)
    		aiHumor = -0.1f;
    
    	//this->aiAttack += (aiAttack/100)*forceStrength;
    	//this->aiDefend += (aiDefend/100)*forceStrength;
    }
    
    void player::checkEvents()
    {
    	if(this->timesTradedWithPlayer > 4)
    	{
    		cout << "<" << name << "> Ich erfreue mich sehr über unsere gute Handelsbeziehung!" << endl;
    		cin.get();
    	}
    
    	if(this->timesTradedWithPlayer-this->timesPlayerRejectedOffer < -4)
    	{
    
    		cout << "<" << name << "> Sie sind mir nicht gerade sympatisch!" << endl;
    		cin.sync();
    		cin.get();
    	}
    
    	int enemy = rand() % 20;
    
    	if(this->timesTradedWithPlayer-this->timesPlayerRejectedOffer < -4)
    	{
    		this->bStatusToPlayer = true;
    		cout << "|| -> " << name << "hat ihnen den Krieg erklaert!" << endl;
    		cin.sync();
    		cin.get();
    	}
    }
    
    void player::calculateAll()
    {
    	calculateDevelopment();
    	calculateForceStrengthAndHumor();
    	calculateRessources();
    	//this->calculateStatusToAi();
    	//this->calculateStatusToPlayer();
    	checkEvents();
    	//tradeWithPlayer(lWood, lStone, lFood, lIron, lGold, luck);
    }
    
    void player::tradeWithPlayer(float &lWood, float &lStone, float &lFood, float &lIron, float &lGold, int luck)
    {
    	string str1, str2;
    
    	float *ptr1, *ptr2;
    
    	if(luck == 1)
    	{
    		int item1;
    		int item2;
    		int itemMaxGive, itemMaxTake;
    		int numbersGive, numbersTake;
    
    	do
    	{
    			item1 = rand() % 5;
    			item2 = rand() % 5;
    		if(item1==0)
    			item1++;
    		if(item2==0)
    			item2++;
    
    		switch(item1)
    		{
    		case 1:
    			{
    				itemMaxTake = lWood;
    				str1 = "Holz";
    				ptr1 = &lWood;
    				break;
    			}
    		case 2:
    			{
    				itemMaxTake = lIron;
    				str1 = "Eisen";
    				ptr1 = &lIron;
    				break;
    			}
    		case 3:
    			{
    				itemMaxTake = lStone;
    				str1 = "Stein";
    				ptr1 = &lStone;
    				break;
    			}
    		case 4: 
    			{
    				itemMaxTake = lGold;
    				str1 = "Gold";
    				ptr1 = &lGold;
    				break;
    			}
    		case 5:
    			{
    				itemMaxTake = lFood;
    				str1 = "Nahrung";
    				ptr1 = &lFood;
    				break;
    			}
    
    		}
    
    		switch(item2)
    		{
    		case 1:
    			{
    				itemMaxGive = aiWood;
    				str2 = "Holz";
    				ptr2 = &lWood;
    				break;
    			}
    		case 2:
    			{
    				itemMaxGive = aiIron;
    				str2 = "Eisen";
    				ptr2 = &lIron;
    				break;
    			}
    		case 3:
    			{
    				itemMaxGive = aiStone;
    				str2 = "Stein";
    				ptr2 = &lStone;
    				break;
    			}
    		case 4: 
    			{
    				itemMaxGive = aiGold;
    				str2 = "Gold";
    				ptr2 = &lGold;
    				break;
    			}
    		case 5:
    			{
    				itemMaxGive = aiFood;
    				str2 = "Nahrung";
    				ptr2 = &lFood;
    				break;
    			}
    
    		}
    
    	}while(itemMaxGive == 0);
    		numbersGive = rand() % itemMaxGive;
    		numbersTake = rand() % itemMaxGive*2;
    
    		char choice;
    		bool choiceOK = false;
    		while(choiceOK == false)
    		{
    			cout << name  << " macht ihnen ein Handelsangebot: " << endl;
    			cout << " Er gibt ihnen " << numbersGive << " " << str2 << " gegen " << numbersTake << " " << str1 << endl;
    			cout << "Moechten sie annehmen? [J]a oder [N]ein" << endl;
    			cin >> choice;
    			if(!cin.fail())
    			{
    
    				if(choice == 'J' || choice == 'j' )
    				{
    					if(*ptr1>=numbersTake)
    					{
    							*ptr1 -= numbersTake;
    							*ptr2 += numbersGive;
    							this->timesTradedWithPlayer++;
    							cout << "<" << name << "> Es freut mich, mit ihnen gehandelt zu haben!" << endl;
    							cin.sync();
    							cin.get();
    					}
    
    					else
    					{
    						cout << "Du hast nicht genug Rohstoffe fuer diesen Handel!" << endl;
    						cin.sync();
    						cin.get();
    					}
    					choiceOK = true;
    				}
    				if(choice == 'N' || choice == 'n')
    				{
    					this->timesPlayerRejectedOffer++;
    					cout << "<" << name << "> Jedem das Seine..." << endl;
    					cin.sync();
    					cin.get();
    					choiceOK = true;
    				}
    			}
    		}
    
    	}
    
    }
    
    int player::getAttack()
    {
    	return aiAttack;
    }
    int player::getDefend()
    {
    	return aiDefend;
    }
    
    void player::setStatusToPlayer(int i)
    {
    	if(i == 1)
    		this->bStatusToPlayer = 0; 
    	if(i == 2)
    		this->bStatusToPlayer = 1;
    
    }
    
    int player::getAiFood()
    {
    	return aiFood;
    }
    int player::getAiIron()
    {
    	return aiIron;
    }
    int player::getAiStone()
    {
    	return aiStone;
    }
    int player::getAiGold()
    {
    	return aiGold;
    }
    int player::getAiWood()
    {
    	return aiWood;
    }
    
    int player::getProsperty()
    {return prosperty;}
    int player::getForceStrength()
    {return forceStrength;}
    int player::getTimesTradedWithPlayer()
    {return this->timesTradedWithPlayer;}
    int player::getTimesPlayerRejectedOffer()
    {return this->timesPlayerRejectedOffer;}
    int player::getDevelopment()
    {return development;}
    int player::getInhabitants()
    {return this->aiInhabitants;}
    int player::getHumor()
    {return aiHumor;}
    
    void player::setRessources(int wood, int iron, int stone, int gold, int food)
    {
    	aiWood -= wood;
    	aiIron -= iron;
    	aiGold -= gold;
    	aiStone -= stone;
    	aiFood -= food;
    }
    

    player.h

    #include <iostream>
    #include <fstream>
    using namespace std;
    class player
    {
    
    private:
    	// DEKLARATIONEN //
    
    	int initNumber;
    	int iStatusToPlayer;
    	int iStatusToAi[12];
    	int prosperty;
    	int forceStrength;
    	int development;
    	int timesTradedWithPlayer;
    	int timesPlayerRejectedOffer; 
    	int bStatusToPlayer;		//Enemy or Friend? True = Feind False = Neutral
    	int bStatusToPlayerAlly;	
    
    	float aiWood,
    		aiStone,
    		aiIron,
    		aiGold,
    		aiFood,
    		aiHumor;
    
    	int aiDefend,
    		aiAttack;
    	int
    		aiInhabitants;
    
    		// True = Verbündet / False = /
    
    public:
    	friend istream& operator>> (istream& Stream, player& B);
    	friend ostream& operator<< (ostream &Stream, player& B);
    	friend void relationships();
    	char *name;// Verbündeter?	
    
    	// KONSTRUKTOR //
    	player(char* _name)  : name(_name)
    	{
    
    		this->prosperty = 0;
    		this->forceStrength = 0;
    		this->aiWood = 100;
    		this->aiStone = 100;
    		this->aiIron = 199;
    		this->aiFood = 100;
    		this->aiGold = 100;
    		this->aiHumor = 1.0f;
    		this->aiInhabitants = 100;
    		this->development = 5.000f;
    		this->timesTradedWithPlayer = 0;
    		this->timesPlayerRejectedOffer = 0;
    		this->aiAttack = 100;
    		this->aiDefend = 100;
    		this->bStatusToPlayer = 1;// 1 = Neutral // 0 == Feind
     		this->bStatusToPlayerAlly = 0;// 0 Neutral // 1 ==´Verbündeter
    
    }
    
    	// DO //
    	void calculateDevelopment();
    	void calculateRessources();
    	void calculateStatusToAi();
    	void calculateStatusToPlayer();
    	void calculateForceStrengthAndHumor();
    	void calculateAll();
    	void checkEvents();	 
    	void tradeWithPlayer(float &lWood, float &lStone, float &lFood, float &lIron, float &lGold, int luck);
    
    	// SET //
    	void setStatusToPlayer(int i);
    	void setRessources(int wood, int iron, int stone, int gold, int food);
    
    	//   GET    //
    	int getProsperty();
    	int getForceStrength();
    	int getTimesTradedWithPlayer();
    	int getTimesPlayerRejectedOffer();
    	int getDevelopment();
    	int getInhabitants();
    	int getHumor();
    	int getAttack();
    	int getDefend();
    	int getAiWood();
    	int getAiIron();
    	int getAiStone();
    	int getAiGold();
    	int getAiFood();
    
    };
    

    build.h

    #include <iostream>
    
    using namespace std;
    
    class buildings
    {
    private:
    	float c_wood,
    		c_iron,
    		c_stone,
    		c_food,
    		c_gold;
    	float
    		m_wood,
    		m_iron,
    		m_stone,
    		m_gold,
    		m_food,
    		m_prestige,
    		m_experience,
    		m_humor;
    
    	float level;
    
    public:
    
    	void build(float *wood, 
    				float *iron, 
    				float *stone, 
    				float *gold, 
    				float *food, 
    				float *m_prestige, 
    				float *experience,
    				float *m_wood, 
    				float *m_iron, 
    				float *m_stone,
    				float *m_gold, 
    				float *m_food,
    				float *m_humor);
    
    		 buildings();
    	void setKosten();
    	void getKosten(float wood, 
    				float iron, 
    				float stone, 
    				float gold,
    				float food);
    
    	bool check(float wood, 
    				float iron, 
    				float stone, 
    				float gold,
    				float food);
    
    	float getLevel();
    	float setLevel(float _level_);
    
    	void InitValues(float c_wood,
    					float c_iron,
    					float c_stone,
    					float c_food,
    					float c_gold,
    					float m_wood,
    					float m_iron,
    					float m_stone,
    					float m_gold,
    					float m_food,
    					float m_prestige,
    					float m_humor);
    
    };
    

    build.cpp

    [cpp]#include "build.h"

    buildings::buildings()
    {

    c_wood = 0;
    c_iron = 0;
    c_stone = 0;
    c_food = 0;
    c_gold = 0;

    m_wood = 0;
    m_iron = 0;
    m_stone = 0;
    m_gold = 0;
    m_food = 0;
    m_prestige = 0;
    m_experience = 0;

    }

    void buildings::InitValues(float _c_wood,
    float _c_iron,
    float _c_stone,
    float _c_food,
    float _c_gold,
    float _m_wood,
    float _m_iron,
    float _m_stone,
    float _m_gold,
    float _m_food,
    float _m_prestige,
    float _m_humor)
    {
    this->c_food= _c_food;
    this->c_gold= _c_gold;
    this->c_iron= _c_iron;
    this->c_stone= _c_stone;
    this->c_wood= _c_wood;
    this->m_food= _m_food;
    this->m_gold= _m_gold;
    this->m_iron= _m_iron;
    this->m_prestige= _m_prestige;
    this->m_stone= _m_stone;
    this->m_wood= _m_wood;
    this->m_humor = _m_humor;
    }

    void buildings::setKosten()
    {
    this->c_food= c_iron1.5f;
    this->c_gold= c_gold
    1.5f;
    this->c_iron= c_iron1.5f;
    this->c_stone= c_stone
    1.5f;
    this->c_wood= c_wood1.5f;
    this->m_food= m_food
    1.5f;
    this->m_gold= m_gold1.5f;
    this->m_iron= m_iron
    1.5f;
    this->m_prestige= m_prestige1.5f;
    this->m_stone= m_stone
    1.5f;
    this->m_wood= m_wood1.5f;
    this->m_humor = m_humor
    1.5f;
    }

    float buildings::getLevel()
    {
    return level;
    }

    float buildings::setLevel(float _level_)
    {
    if(_level_ == 0)
    level += 1;

    else
    level += _level_;

    return level;
    }

    void buildings::build(float *_wood,
    float *_iron,
    float *_stone,
    float *_gold,
    float *_food,
    float *_m_prestige,
    float *_experience,
    float *_m_wood,
    float *_m_iron,
    float *_m_stone,
    float *_m_gold,
    float *_m_food,
    float *_m_humor)
    {
    *_wood -= c_wood;
    *_iron -= c_iron;
    *_stone -= c_stone;
    *_gold -= c_gold;
    *_food -= c_food;
    *_experience += m_experience;
    *_m_prestige += m_prestige;
    *_m_wood += m_stone;
    *_m_gold += m_gold;
    *_m_iron += m_iron;
    *_m_wood += m_wood;
    *_m_stone += m_stone;
    *_m_humor += m_humor;

    cin.get();
    }

    bool buildings::check(float kwood, float kiron, float kstone, float kgold, float kfood)
    {
    if(kwood > this->m_wood && kiron > this->c_iron && kstone > this->c_stone && kgold > this->c_gold && kfood > this->c_food)
    return true;
    else
    return false;
    }

    void buildings::getKosten(float wood,
    float iron,
    float stone,
    float gold,
    float food)
    {
    system("cls");
    cout << "\nEin(e) " << " kostet / Sie besitzen: " << endl;
    cout << "=========================" << endl;
    cout << "|| Holz " << this->c_wood << " / " << wood << endl;
    cout << "|| Stein " << this->c_stone << " / " << stone << endl;
    cout << "|| Eisen " << this->c_iron << " / " << iron << endl;
    cout << "|| Nahrung " << this->c_food << " / " << food << endl;
    cout << "|| Gold " << this->c_gold << " / " << gold << endl;
    cout << "=========================\n" << endl;
    cout << "\nEin(e)" << " bringt" << en



  • EiGelbb schrieb:

    Hier einfach mal der ganze Code. Da wird dann ja wohl Alles drinstehen.

    Meinst du es interessiert jemanden sich das alles anzusehen?



  • EiGelbb schrieb:

    Hier einfach mal der ganze Code. Da wird dann ja wohl Alles drinstehen.

    Ja, bestimmt. Das wird dann ja wohl auch jeder lesen, die 2000 Zeilen.
    Dir wurde doch schon mehrmals gesagt, ein einfaches, gekürztes, kompilierbares Beispiel vorzuzeigen.


  • Administrator

    2655 Zeilen Code ... lol 😃

    http://www.c-plusplus.net/forum/200753

    Reduziere Codebeispiele auf das Wesentliche. Niemand wird sich 300 Zeilen Code durchlesen, wenn du dein Problem eigentlich auch an 20 Zeilen deutlich machen könntest. Und je weniger du den Leuten zumutest desto wahrscheinlicher ist es, dass sie es sich durchlesen (und evtl. eine Antwort haben). Am Sinnvollsten ist es, den vorhandenen Code zu nehmen und Stück für Stück in eine neue Sourcecode-Datei zu kopieren, so dass er möglichst kurz bleibt und dennoch den Fehler beinhaltet. Häufig stolpert man beim Erstellen dieses minimalen Codebeispiels selbst über die Fehlerursache.

    Grüssli



  • Dravere schrieb:

    2655 Zeilen Code ... lol 😃

    Du hast das doch nicht ernsthaft zusammengezählt? 🙄
    Egal.

    Zum Test addiere ich vor dem Speichern zu einer Variable +30. Beim Laden flattert mir jedoch wieder der Anfangswert entgegen.

    BITTE - EIN - BEISPIEL. Warte, ich lade gleich ein von mir produziertes Code-Beispiel hoch, dass funktionieren wird.

    Edit:

    #include <iostream>
    
    template<typename type>
    class TWrapper
    {
          type value;
    
    public:
    
          TWrapper(type const& v):
          value(v) {}
    
          friend std::ostream& operator<<(std::ostream& os, TWrapper const& inst)//Hier muss BTW eine konstante Referenz übergeben werden (sollte)
          {
                return os << inst.getValue();
          }
    
          type &getValue()
          {
                return value;
          }
    
          type const& getValue() const
          {
                return value;
          }
    
          void setValue(type const& v)
          {
                value = v;
          }
    };
    
    int main()
    {
          TWrapper<int> a(5);
          a.setValue(a.getValue() + 30);//Verändere den Wert zu einem anderen
          std::cout << a << '\n';//Große Überraschung (?)
    }
    


  • Ja, was wollt ihr denn? Auf Seite 1 hab ich doch Alle relevanten Codes zusammengefasst gepostet. Ich kann ja nicht elementare Bestandteile des Fehlercodes rauslassen. Könnte sich ja immerhin um den Fehler handeln!

    Was versteht ihr denn unter einem Beispiel?! Wenn da der Code zum Speichern steht, da der zum Laden, zwischen den Aufrufen nichts mehr passiert, wird es ja wohl mehr als wahrscheinlich einen Fehler in einer dieser Funktionen geben.

    Nun gut, hier also nochmal die Codes, aber fast genauso wie auf der vorherigen Seite. MMn kann man da nicht viel kürzen, ohne dass man eventuell den Fehler rauskürzt:

    Hier Alles, in einem kurzen Code.

    #include <iostream>
    #include <fstream>
    using namespace std;
    
    class player // KLASSE
    {
    
    private:
    	// DEKLARATIONEN //
            int TEST1,
                 TEST2;
    public:
    
    	friend istream& operator>> (istream& Stream, player& B);
    	friend ostream& operator<< (ostream &Stream, player& B);
    
    };
    
    ostream& operator<<(ostream &Stream, player& B){
    	Stream << B.TEST1 << B.TEST2;
    	return Stream;
    }
    
    istream& operator>>(istream &Streamm, player& B) {
    
    	Streamm >> B.TEST1 >> B.TEST2;
    	return Streamm;
    }
    
    bool save() // FUNKTION ZUM SPEICHERN{
    	fstream playeroutput;
    	playeroutput.open("pl.dat", ios::out | ios::trunc);
    	playeroutput << ::malark;
    	playeroutput.close();
    }
    
    bool load(){
    	fstream input;
    	input.open("pl.dat", ios::in);
    	input >> ::malark;
            input.close();
    }
    
    int main(){
    
    Player malark("Malark");
    
    save();
    load();
    
    return 0:
    }
    


  • fstream playeroutput;
        playeroutput.open("pl.dat", ios::out | ios::trunc);
        playeroutput << ::malark;
        playeroutput.close();
    
    fstream input;
        input.open("pl.dat", ios::in);
        input >> ::malark;
            input.close();
    

    Aua. Lässt sich vereinfachen zu

    ofstream playeroutput("pl.dat", ios::trunc);
        playeroutput << ::malark;
    
    ifstream playeroutput("pl.dat");
        playeroutput >> ::malark;
    

    Und was soll ::malark ? Der Scope-Operator wird so bei globalen Variablen verwendet. malark ist eine scope-lokale Variable von main() . Eher *this .

    Edit(³): Eigentlich muss der ausgabe-Operator ja eine konstante Referenz haben, genau wie die save() -Funktion (die du als Methode hinzufügen solltest) den const -qualifier.



  • Ach, und nochwas. Zwischen den Ausgaben des Ausgabe-Operators muss ein Leerzeichen, da sonst so geschrieben wird (mit zwei ints 3 und 45):

    a << b; -> ab ->"345" und nicht "3 45"



  • Und wo steckt nun der Fehler? Ich weiß sehr wohl, dass der Code nicht ansatzweise professionell ist und das soll er auch gar nicht sein. Das ist nur zum Spaß. Aber auch zum Spaß sollte es schon funktionieren. Also könnt ihr mir nun bitte den Fehler nennen oder meine eine Methode aufzeigen, wie man Klasseninstanzen sonst sinnvoll speichern kann?



  • Das fehlende Leerzeichen wäre schon mal ein Anfang.



  • Gut, muss mich wohl entschuldigen. Der Code an dem ich groß gemeckert hab war ja nur ein Skript 😃 .

    Also mach das hier:

    ostream& operator<<(ostream &Stream, player& B)
    {
        Stream << B.TEST1 << ' ' << B.TEST2;
        return Stream;
    }
    

    Dannn sollte es bei dir klappen.



  • Gut, dass hab ich jetzt drinnen. Jedoch wirft er mir beim Laden immernoch ständig Variablen durcheinander.

    ostream& operator<<(ostream &Stream, player const& B)
    {
    	cout << B.aiStone << endl;
    	Stream << B.aiGold << ' ' << B.aiFood << ' ' << B.aiIron << ' ' << B.aiStone << ' '<< B.aiWood<< ' '<< B.development<< ' ' << B.forceStrength<< ' ' << B.aiHumor << ' ' << B.aiInhabitants<< ' ' << B.prosperty<< ' ' << B.timesPlayerRejectedOffer<< ' '  << B.timesTradedWithPlayer << ' '  << B.bStatusToPlayer << ' ' << B.bStatusToPlayerAlly;
    	cout << B.aiStone << endl;
    	return Stream;
    }
    
    istream& operator>>(istream &Streamm, player& B)
    {
    	B.aiStone += 30;
    	cout << "Vorher : " <<  B.aiStone << endl;
    	Streamm >> B.aiGold >> B.aiFood >> B.aiIron >> B.aiStone >> B.aiWood >> B.development >> B.forceStrength >> B.aiHumor >> B.aiInhabitants >> B.prosperty >> B.timesPlayerRejectedOffer >> B.timesTradedWithPlayer >> B.bStatusToPlayer >> B.bStatusToPlayerAlly;
    	cout << "Nachher : " << B.aiStone << endl;
    	return Streamm;
    }
    

    Sorry, diesmalmit allen Variablen, denn da wird dann ja wohl irgendwo der Fehler stecken. Testweise inkrementiere ich eine der Variablen vor dem Laden um 30 und gebe sie danach aus. Jedoch kommen da immer Werte von anderen Variablen raus. 😞

    Muss vielleicht zwischen die einzelnen Instanzen auch noch eine Art Trennmittel, wie so ein '[LEERZEICHEN]'?

    playeroutput << ::malark;
    playeroutput << ' ';
    playeroutput << ::nympth;
    

    vielleicht?



  • Yayy... Das war die Lösung 🙂

    Danke für eure Mithilfe!!!



  • Besser wäre einfach ein newline am Ende von der Ausgabe hinzufügen:

    ostream& operator<<(ostream &Stream, player const& B) 
    { 
        Stream << B.aiGold << ' ' << B.aiFood << ' ' << B.aiIron << ' ' << B.aiStone << ' '<< B.aiWood<< ' '<< B.development<< ' ' << B.forceStrength<< ' ' << B.aiHumor << ' ' << B.aiInhabitants<< ' ' << B.prosperty<< ' ' << B.timesPlayerRejectedOffer<< ' '  << B.timesTradedWithPlayer << ' '  << B.bStatusToPlayer << ' ' << B.bStatusToPlayerAlly << '\n'; 
        return Stream; 
    }
    


  • Besser wären Zeilenumbrüche im Code. Aber im Grunde ist es okay dem Aufrufer zu überlassen, wie er die Ausgabe trennen will.



  • 15 Member sind zu viel.


Anmelden zum Antworten