예제 #1
0
 public static void textCommand(string userInput) //Checks the users input text and then checks the starting letters
 {
     if (userInput.StartsWith("E:"))              //Equips items if it starts with E:
     {
         equipCommand(userInput);
     }
     if (userInput.StartsWith("U:"))//Unequips items if it starts with U:
     {
         unequipCommand(userInput);
     }
     if (userInput.StartsWith("I:"))//Displays the characters inventory if it starts with I:
     {
         ConsoleSpecificTextDisplay.writeInventory();
     }
     if (userInput.StartsWith("EQ:"))//Displays the characters equipment if it starts with EQ:
     {
         ConsoleSpecificTextDisplay.writeEquipmentInventory();
     }
     if (userInput.StartsWith("EI:"))//Displays the characters equipment if it starts with EQ:
     {
         ConsoleSpecificTextDisplay.writeEquipedEquipment();
     }
     if (userInput.StartsWith("P:"))//Displays the characters attributes if it starts with P:
     {
         ConsoleSpecificTextDisplay.displayCharacterStats();
     }
     if (userInput.StartsWith("A:"))//Displays the characters abilities if it starts with A:
     {
         ConsoleSpecificTextDisplay.displayCharacterAbilities();
     }
 }
        }                                //Turns to true once the job is set


        public void characterCreation()// Main method for creating the character
        {
            //Initializes the bool values signaling a new character
            charCreated   = false;
            jobUnassigned = true;
            nameSet       = false;
            jobSet        = false;

            writeCharCreationSB("Welcome to a new game. Please type in your name\n" +
                                "-Your name may only contain up to 12 characters\n\n"); //Writes the text for setting a character name
            while (nameSet == false)                                                    //If the character has not set a valid name the game will keep replaying this part of the code
            {
                player.name = Console.ReadLine();                                       //Allows the player to enter a name
                if (player.name.Length < 13)                                            // then checks the length on the name and if it is under 13 characters
                {
                    nameSet = true;                                                     // set the name to the character
                }
            }
            writeCharCreationSB("Welcome " + player.name + " you have a great journey ahead of you.\n"
                                + "But first, what is your profesion?\n");//Asks the player to choose a job
            writeCharCreationSB("CHOICES: Warrior\n"
                                + "         Cleric\n"
                                + "         Wizard"); //Shows the player the jobs they can pick
            while (jobSet == false)                   //Sets teh players job and keeps trying while the player is not assigned a job
            {
                player.job = Console.ReadLine();      //Gets the player input for which job they would like to use for their main character
                switch (player.job.ToUpper())
                {
                case "WARRIOR":                          //If player input is warrior
                    player.characterJob = new Warrior(); //Sets the player job to warrior
                    jobSet = true;                       //and sets the jobset trigger to true
                    break;

                case "CLERIC":                          //If player input is cleric
                    player.characterJob = new Cleric(); //sets the player job to cleric
                    jobSet = true;                      //and sets the jobset trigger to true
                    break;

                case "WIZARD":                          //If player input is wizard
                    player.characterJob = new Wizard(); //sets the player job to wizard
                    jobSet = true;                      //and sets the jobset trigger to true
                    break;

                default:            //If the player input doesnt match any option this is the default
                    jobSet = false; //Sets tje jobset trigger to false
                    break;
                }
            }
            createCharacter();//Calls the character creations method

            writeCharCreationSB("\n\nWelcome to the game " + PlayerCharacter.theCharacter.name
                                + "\nYour Stats are as follows:\n"); //Writes the welcome message to the player
            ConsoleSpecificTextDisplay.displayCharacterStats();      //Writes the character stats to the screen
            writeCharCreationSB("\nYour abilities are:\n");
            foreach (iAbility ability in PlayerCharacter.theCharacter.playerAbilities.Values)
            {
                writeCharCreationSB(ability.name + "\n");//Writes all the characters abilities to the screen
            }
            //Writes the obtained items and equipment to the game screen
            writeCharCreationSB("Here is your item and equipment starter pack:\n" +
                                "ITEMS:\n");
            ObtainItemorEquipment.obtainItem("Potion", 5);
            ObtainItemorEquipment.obtainItem("Antidote", 5);
            ObtainItemorEquipment.obtainItem("Ether", 5);
            writeCharCreationSB("EQUIPMENT:");
            ObtainItemorEquipment.obtainEquipment("Iron Ring", 1);
            ObtainItemorEquipment.obtainEquipment("Iron Helmet", 1);
            ObtainItemorEquipment.obtainEquipment("Iron Breastplate", 1);
        }