예제 #1
0
        /// <summary>
        /// get a dalek using an ID
        /// </summary>
        /// <param name="ID">character ID</param>
        /// <returns>requested dalek object</returns>
        public Dalek GetDalekByID(int ID)
        {
            Dalek requestedDalek = null;

            //
            // run through the item list and grab the correct one
            //
            foreach (Dalek dalek in Daleks)
            {
                if (dalek.CharacterID == ID)
                {
                    requestedDalek = dalek;
                }
                ;
            }

            //
            // the specified ID was not found in the universe
            // throw and exception
            //
            if (requestedDalek == null)
            {
                string feedbackMessage = $"The dalek ID {ID} does not exist in the current Universe.";
                throw new ArgumentException(ID.ToString(), feedbackMessage);
            }

            return(requestedDalek);
        }
예제 #2
0
        /// <summary>
        /// display information about items and treasures in the current space-time location
        /// </summary>
        public void DisplayTalkTo()
        {
            int          currentSptID = _gameTraveler.SpaceTimeLocationID;
            int          dalekIDChoice;
            List <Dalek> dalecksInSpt  = new List <Dalek>();
            Dalek        dalekToTalkTo = new Dalek();

            dalecksInSpt = _gameUniverse.GetDaleksBySpaceTimeLocationID(currentSptID);

            ConsoleUtil.HeaderText = "Talk to the Daleks in Current Location";
            ConsoleUtil.DisplayReset();

            ConsoleUtil.DisplayMessage(_gameUniverse.GetSpaceTimeLocationByID(currentSptID).Name);

            if (dalecksInSpt != null)
            {
                ConsoleUtil.DisplayMessage("");
                ConsoleUtil.DisplayMessage("Daleks in current location.");
                DisplayDalekTable(dalecksInSpt);

                ConsoleUtil.DisplayPromptMessage(
                    "Enter the item number to view or press the Enter key to move on. "
                    ); // TODO code in validation


                if (int.TryParse(Console.ReadLine(), out dalekIDChoice))
                {
                    dalekToTalkTo = _gameUniverse.GetDalekByID(dalekIDChoice);

                    if (dalekToTalkTo.HasMessage)
                    {
                        ConsoleUtil.DisplayMessage(dalekToTalkTo.Message);
                    }
                    else
                    {
                        ConsoleUtil.DisplayMessage($"This Dalek has nothing to say {_gameTraveler.Race}.");
                    }

                    DisplayContinuePrompt();
                }
            }
        }
예제 #3
0
        /// <summary>
        /// display information about items and treasures in the current space-time location
        /// </summary>
        public Dalek DisplayGetDalekToBattle()
        {
            int          currentSptID = _gameTraveler.SpaceTimeLocationID;
            int          dalekIDChoice;
            List <Dalek> dalecksInSpt  = new List <Dalek>();
            Dalek        dalekToBattle = null;

            dalecksInSpt = _gameUniverse.GetDaleksBySpaceTimeLocationID(currentSptID);

            ConsoleUtil.HeaderText = "Battle Daleks in Current Location";
            ConsoleUtil.DisplayReset();

            ConsoleUtil.DisplayMessage(_gameUniverse.GetSpaceTimeLocationByID(currentSptID).Name);

            if (dalecksInSpt != null)
            {
                ConsoleUtil.DisplayMessage("");
                ConsoleUtil.DisplayMessage("Daleks in current location.");
                DisplayDalekTable(dalecksInSpt);

                ConsoleUtil.DisplayPromptMessage(
                    "Enter the item number to view or press the Enter key to move on. "
                    ); // TODO code in validation


                if (int.TryParse(Console.ReadLine(), out dalekIDChoice))
                {
                    dalekToBattle = _gameUniverse.GetDalekByID(dalekIDChoice);

                    DisplayContinuePrompt();
                }
            }
            else
            {
                ConsoleUtil.DisplayMessage("");
                ConsoleUtil.DisplayMessage("It appears there are not Daleks in here to battle.");
            }

            return(dalekToBattle);
        }
예제 #4
0
        /// <summary>
        /// perform the required tasks based on the battle results
        /// </summary>
        /// <param name="battleResult">result of the battle</param>
        /// <param name="daleckToBattle">dalek battled</param>
        private void ProcessBattleResult(BattleResult battleResult, Dalek daleckToBattle)
        {
            switch (battleResult)
            {
            case BattleResult.TravelerWins:
                daleckToBattle.SpaceTimeLocationID = 0;     // Daleck removed from game
                break;

            case BattleResult.NPCWins:
                _gameTraveler.Lives--;
                break;

            case BattleResult.TravelerRetreats:
            case BattleResult.NPCRetreats:
            case BattleResult.Draw:
            case BattleResult.BothRetreat:
                break;

            default:
                break;
            }
        }