public void LetterCheck(char letter, SessionStorage <int[]> _iss, SessionStorage <GameState> _gs, SessionStorage <List <char> > _lcss) { int[] correctlyChosen = _iss.LoadOrCreate("CC"); GameState gs = _gs.LoadOrCreate("game"); string word = RemoveDiacritics(gs.Word.ToUpper()); char[] charArray = word.ToCharArray(); string strletter = RemoveDiacritics(letter.ToString()); char[] letterarr = strletter.ToUpper().ToCharArray(); letter = letterarr[0]; int i = 0; bool wrong = true; foreach (char x in charArray) { if (letter == x) { correctlyChosen[i] = 1; wrong = false; } i++; } if (wrong == true) { List <char> wrongLetters = _lcss.LoadOrCreate("wrongLetters"); wrongLetters.Add(letter); _lcss.Save("wrongLetters", wrongLetters); gs.LivesLeft--; } _gs.Save("game", gs); _iss.Save("CC", correctlyChosen); }
public bool WordDoneCheck(SessionStorage <int[]> _iss, SessionStorage <GameState> _gs, SessionStorage <List <char> > _lcss) { int[] correctlyChosen = _iss.LoadOrCreate("CC"); GameState gs = _gs.LoadOrCreate("game"); string word = gs.Word; int correctAmount = 0; foreach (int y in correctlyChosen) { if (y == 1) { correctAmount++; } } if (word.Length == correctAmount) { int[] emptyArray = { }; _iss.Save("CC", emptyArray); List <char> emptyCharList = new List <char>(); _lcss.Save("wrongLetters", emptyCharList); gs.AmountFinished++; _gs.Save("game", gs); _dc.AddWordUser(word); return(true); } return(false); }
public void Start(int category, SessionStorage <int[]> _iss, SessionStorage <GameState> _gs, SessionStorage <List <char> > _lcss) { string word = _dc.randomWordFromSet(category); int[] emptyArray = new int[word.Length]; _iss.Save("CC", emptyArray); GameState gs = new GameState { AmountFinished = 0, Category = category, LivesLeft = 8, Word = word }; _gs.Save("game", gs); List <char> emptyStringList = new List <char>(); _lcss.Save("wrongLetters", emptyStringList); }