示例#1
0
 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);
 }
示例#2
0
        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();
            }
        }
示例#3
0
        static void Main(string[] args)
        {
            EventData   e           = new EventData();
            BaseEmpire  B           = new BaseEmpire(); //Base empire type class
            GameHandler gameHandler = new GameHandler(e, B);

            gameHandler.MainLoop();
        }
示例#4
0
        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;
        }
示例#5
0
        public BaseEmpire gameIntro(BaseEmpire bEmpire) //Contains the basic tutorial presented in the beginning of the program
        {
            Console.Clear();
            Console.WriteLine("Welcome to project kingdom!\n###Instructions###\nIn project kingdom you will play as a leader of an empire. You will be faced with different events, you can either choose to act on the event or refuse to act. Keep in mind that your action will have consequences on your empire's status. Press ENTER to continue the tutorial");
            Console.ReadKey();
            Console.WriteLine("Your empire has 4 parameters, church, population, treasury and army. Your actions will either increase or decrease the value of each paramter, if one value goes below 0 your empire will fail. Good luck! \n###End of instructions###\n Press ENTER to continue");
            Console.ReadKey();
            Console.Clear();
            Console.WriteLine("Choose empire type\n0.Exit program\n1. Kingdom \n2. Republic");
            int userInput = int.Parse(Console.ReadLine());
            int menu      = userInput;

            switch (menu) //Let's the user choose either a kingdom start or republic start, only change is in starting values
            {
            case 0:
                Console.Clear();
                System.Environment.Exit(0);
                break;

            case 1:

                bEmpire = new Kingdom();
                break;

            case 2:

                bEmpire = new Republic();
                break;

            default:
                Console.Clear();
                Console.WriteLine("Ooga booga, nu blev det fel. Programmet stängs ned.");
                Console.ReadKey();
                System.Environment.Exit(0);
                break;
            }
            return(bEmpire); //return chosoen baseEmpire type
        }
示例#6
0
 public GameHandler(EventData e, BaseEmpire b) //Constryctor used to create necesary objects to be able for GameHandler to be created as a new object in main.
 {
     eventD  = e;
     bEmpire = b;
 }