public GameManager(IPlayerManager playerManager, IMessagesRepository messagesRepository, IManageDb manageDb, IHiddenWordManager hiddenWordManager) { _playerManager = playerManager; _messagesRepository = messagesRepository; _manageDb = manageDb; _hiddenWordManager = hiddenWordManager; _topics = _manageDb.GetAllTopics(); }
public void Begin() { var userName = _messageFactory.LoginMessage(); var user = _playerManager.GetByUserName(userName); if (user == null) { var key = _playerManager.Add(new Player { Name = userName }); user = _playerManager.Get(key); } _messageFactory.PlayerStatisticsMessage(user); bool kartoti = true; List <Words> PanaudotiZodziai = new List <Words>() { null }; while (kartoti) { Console.Clear(); var tema = RenkuosiTema(); var zodis = RandomZodzioParinkimas(tema, PanaudotiZodziai); if (zodis == null) { Console.WriteLine("Temoje nebera zodziu, ar norite rinktis kita tema t/n"); } else { _hiddenWordManager = new HiddenWordManager(zodis); bool leidziamaSpeti = true; panaudotiZodziai.Add(zodis); _messageFactory.KartuvesPictureMessage(0); Console.WriteLine(); Console.WriteLine(_hiddenWordManager.GetHiddenWordsStructure()); while (leidziamaSpeti) { string spejimas = _messageFactory.WordInputMessage(); bool arSpetasZodis = ArSpetasZodis(spejimas); if (arSpetasZodis) { bool arTeisinga = ArZodisTeisingas(zodis.Text, spejimas); if (arTeisinga) { _messageFactory.WinMessage(zodis.Text); guessWholeWord = _hiddenWordManager.HiddenWords.HiddenLetterCount; } else { _messageFactory.KartuvesPictureMessage(gyvybiuKiekis); _messageFactory.LostMessage(zodis.Text); } leidziamaSpeti = false; } else { bool arBuvoSpeta = _hiddenWordManager.HiddenWords.IncorrectGuesses.Contains(spejimas); if (!arBuvoSpeta) { _hiddenWordManager.CheckLetter(spejimas); } if (_hiddenWordManager.HiddenWords.IncorrectGuesses.Count == gyvybiuKiekis) { _messageFactory.KartuvesPictureMessage(gyvybiuKiekis); _messageFactory.LostMessage(zodis.Text); leidziamaSpeti = false; } else { Console.Clear(); _messageFactory.KartuvesPictureMessage(_hiddenWordManager.HiddenWords.IncorrectGuesses.Count); _messageFactory.IncorrectLettersListMessage(_hiddenWordManager.HiddenWords.IncorrectGuesses); Console.WriteLine(_hiddenWordManager.GetHiddenWordsStructure()); if (_hiddenWordManager.HiddenWords.HiddenLetterCount == 0) { _messageFactory.WinMessage(zodis.Text); _messageFactory.PlayerStatisticsMessage(user); leidziamaSpeti = false; } } } } _playerManager.AddScoreBoards(GetScoreBoard(zodis, user.PlayerId)); //nors ir atnaujinu duomenu baze cia } guessWholeWord = 0; //bet visada atspauzdina senos duomenu bazes duomenis, neissiaiskinau kodel taip yra _messageFactory.PlayerStatisticsMessage(user); kartoti = _messageFactory.RepeatGameMessage(); } }
public void StartHangMan() { bool replay = true; while (replay) { Console.Clear(); var topic = TopicSelection(); var word = _manageDb.SelectWordsListToRandom(topic, topicNumber); if (word == null) { _messagesRepository.NoWordLeftMessage(); } else { _hiddenWordManager = new HiddenWordManager(ltName, ltCity, country, furniture); bool guessingAllowed = true; _messagesRepository.HangmanPictureMessage(beginLives); Console.WriteLine(); Console.WriteLine(_hiddenWordManager.GetHiddedWordStructure()); while (guessingAllowed) { _guess = new Guess(_messagesRepository.WordInputMessage(), _hiddenWordManager); if (_guess.IsWordGuessed) { SelectedWordGuessMechanics(topicNumber); guessingAllowed = false; } else { _guess.CheckSelectedWordIsCorrect(topicNumber); if (_hiddenWordManager.IncorrectGuesesCount == maxLives) { _messagesRepository.HangmanPictureMessage(maxLives); _messagesRepository.LostGameMessage(word.Text); guessingAllowed = false; } else { Console.Clear(); _messagesRepository.HangmanPictureMessage(_hiddenWordManager.IncorrectGuesesCount); _messagesRepository.IncorrectLettersListMessage(_hiddenWordManager.HiddenWord.IncorrectGueses); Console.WriteLine(_hiddenWordManager.GetHiddedWordStructure()); if (!_hiddenWordManager.HasHiddenLetters) { _messagesRepository.WinGameMessage(word.Text); guessingAllowed = false; } } } } } _manageDb.RemoveWordFromSeletedWordsList(topicNumber); SelectPlayerScoreBoard(topicNumber); _playerManager.AddPlayerScore(SelectPlayerScoreBoard(topicNumber)); replay = _messagesRepository.RepeatGameMessage(); } }
public virtual void CreateHiddenWordInstance(Word word) { _hiddenWordManager = new HiddenWordManager(word); }
public void Begin() { var userName = _massageFactory.LoginMesage(); var user = _playerManager.GetByUserName(userName); if (user == null) { var key = _playerManager.Add(new Player { Name = userName }); user = _playerManager.Get(key); } _massageFactory.PlayerStatisticsMessage(user); bool kartoti = true; while (kartoti) { Console.Clear(); var tema = SelectSubject(); var zodis = AtsitiktinisZodzioPasirinkimas(tema); if (zodis == null) { Console.WriteLine("Temoje nebėra žodžiu, ar norite rinktis kitą temą T/N"); } else { _hiddenWordManager = new HiddenWordManager(zodis); bool leidziamaSpeti = true; panaudotiZodziai.Add(zodis); _massageFactory.HangmanPictureMessage(0); Console.WriteLine(); Console.WriteLine(_hiddenWordManager.GetHiddedWordStructure()); while (leidziamaSpeti) { string spejimas = _massageFactory.WordInputMessage(); bool arSpetasZodis = ArSpetasZodis(spejimas); if (arSpetasZodis) { bool arTeisinga = ArZodisTeisingas(zodis.Text, spejimas); if (arTeisinga) { _massageFactory.WinGameMessage(zodis.Text); } else { _massageFactory.HangmanPictureMessage(gyvybiuKiekis); _massageFactory.LostGameMessage(zodis.Text); } leidziamaSpeti = false; } else { bool arBuvoSpeta = _hiddenWordManager.HiddenWord.IncorrectGuesses.Contains(spejimas); if (!arBuvoSpeta) { _hiddenWordManager.CheckLetter(spejimas); } if (_hiddenWordManager.HiddenWord.IncorrectGuesses.Count == gyvybiuKiekis) { _massageFactory.HangmanPictureMessage(gyvybiuKiekis); _massageFactory.LostGameMessage(zodis.Text); leidziamaSpeti = false; } else { Console.Clear(); _massageFactory.HangmanPictureMessage(_hiddenWordManager.HiddenWord.IncorrectGuesses.Count); _massageFactory.IncorrectLettersListMessage(_hiddenWordManager.HiddenWord.IncorrectGuesses); Console.WriteLine(_hiddenWordManager.GetHiddedWordStructure()); if (_hiddenWordManager.HiddenWord.HiddenLetterCount == 0) { _massageFactory.WinGameMessage(zodis.Text); leidziamaSpeti = false; } } } } } _playerManager.AddScoreBoard(GetScoreBoard(zodis, user.PlayerId)); kartoti = _massageFactory.RepeatGameMessage(); } }
public Guess(string guess, IHiddenWordManager hiddenWordManager) { _guess = guess; _hiddenWordManager = hiddenWordManager; }