예제 #1
0
        public void RevealCharacter(char letter)
        {
            letter = char.ToLower(letter);

            List <int> IndexList = new List <int>();

            for (int i = 0; i < Word.Length; i++)
            {
                if (letter == Word[i])
                {
                    IndexList.Add(i);
                }
            }

            if (IndexList.Count == 0)
            {
                NoOfTries = NoOfTries - 1;
                CheckVictoryCondition();
                return;
            }

            char[] temporary = PropertyMaskedWord.ToCharArray();

            for (int i = 0; i < IndexList.Count; i++)
            {
                temporary[IndexList[i]] = letter;
            }

            PropertyMaskedWord = new string(temporary);
            CheckVictoryCondition();
        }
예제 #2
0
 private void CheckVictoryCondition()
 {
     if (PropertyMaskedWord.Contains("*") && NoOfTries != 0)
     {
         HasWon = false;
     }
     else if (NoOfTries == 0)
     {
         HasLost = true;
     }
     else
     {
         HasWon = true;
     }
 }