public Event(SingleEvent singleEvent, BaseEmpire empirE) //Needs the event data and base emprie object as input { isRunning = true; eventName = singleEvent.headline; eventInfo = singleEvent.info; modifyState(singleEvent, empirE); }
public void MainLoop() { List <SingleEvent> incomingEventData = eventD.ReturnEvents(); //Imports data from EventData to be used by Event.cs to then be able to return the new empire state. bool introState = true; while (true) { if (introState) { try { bEmpire = gameIntro(bEmpire); //Start a new empire with the gameIntro method introState = false; } catch (FormatException) { Console.Clear(); Console.WriteLine("Only keys 1 and 2 are accepted! Press ENTER to retry!"); Console.ReadKey(); continue; } } Console.Clear(); Console.WriteLine("Current status"); bEmpire.PresentParameters(); Console.WriteLine("===============Event==============="); SingleEvent testRandom = RandomEventType(eventD.ReturnEvents()); //Takes one random event to be presented and randomly generated from the random generator. Event E = new Event(testRandom, bEmpire); bEmpire = E.Act(); if (bEmpire.church <= 0 || bEmpire.population <= 0 || bEmpire.treasure <= 0 || bEmpire.army <= 0) // Logic responsible for ending the empire if any of the empire values drop below zero. Kicks the player back to the beginning of the program. { Console.Clear(); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Watch out your kingdom is in RUINS!!!!!!!!!!!!!! Press ENTER to restart"); Console.ForegroundColor = ConsoleColor.White; Console.ReadKey(); introState = true; continue; } if (!E.isRunning)// Part of error correcting user input. Not working as intended, therefore it's not currently used { /* * Console.Clear(); * Console.WriteLine("If you want to quit, press q"); * string userInput2; * userInput2 = Console.ReadLine(); * if (userInput2 == "q") * { * break; * } */ } Console.WriteLine("=============================="); Console.WriteLine("New status"); bEmpire.PresentParameters(); Console.Write("Press enter to continue"); Console.ReadKey(); } }
public void modifyState(SingleEvent singleEvent, BaseEmpire empirE) { // Method used for manipulating the state of the empire starting parameters, each choice impacts the parameters differently Console.Write(eventName + "\n" + eventInfo + "\n\n1. Act " + "2. Dont act" + " \nUser choice: "); int menuState; try { int userInput = int.Parse(Console.ReadLine()); menuState = userInput; } catch (FormatException) // Part of error correcting if user types in an invalid letter/number { Console.Clear(); Console.WriteLine("Only keys 1, 2 and 0 are accepted! Press ENTER to continue."); Console.ReadKey(); menuState = 0; } switch (menuState) { case 0: isRunning = false; break; case 1: //Applies predefined act values (which are located in EvenData.cs/ListOfEvents) empirE.church += singleEvent.churchActVariable; empirE.army += singleEvent.armyActVariable; empirE.treasure += singleEvent.treasureActVariable; empirE.population += singleEvent.populationActVariable; break; case 2: //Applies predefined don't act values (which are located in EvenData.cs/ListOfEvent) empirE.church += singleEvent.churchDontActVariable; empirE.army += singleEvent.armyDontActVariable; empirE.treasure += singleEvent.treasureDontActVariable; empirE.population += singleEvent.populationDontActVariable; break; default: Console.WriteLine("Only keys 1 and 2 are accepted! Press ENTER to retry!"); //Error correction of invalid user input Console.ReadKey(); break; } newBaseEmpireState = empirE; }