Пример #1
0
        /// <summary>
        /// Metoda wyjmuje okreslona ilosc kostek z planszy i dodaje je do tabliczki
        /// </summary>
        /// <param name="Container"></param>
        /// <param name="StartIndex"></param>
        /// <param name="Word"></param>
        /// <param name="Rack"></param>
        public void RemoveTiles(Container Container, int StartIndex, int Number, Rack Rack)
        {
            for(int i = 0; i < Number; ++i)
            {
                Cell TempCell = Container.Get(StartIndex + i);

                if(!TempCell.IsVisited())
                {
                    Tile TempTile = TempCell.GetTile();
                    if(TempTile != null)
                    {
                        if(TempTile.IsBlank())
                        {
                            Rack.Add(new Tile(' ', true));
                        }
                        else
                        {
                            Rack.Add(TempTile);
                        }
                    }
                    TempCell.SetTile(null);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Metoda zwracajaca informacje o slowie, ktore przechodzi przez pole o indeksie Index w kontenerze podanym 
        /// w argumencie wywolania.
        /// </summary>
        /// <param name="Container">Plaszyzna z ktorej odczytujemy slowo</param>
        /// <param name="Index">Indeks, na ktorym nie ma jeszcze ulozonej kostki</param>
        /// <returns>tuple zawierajacy dlugosc slowa oraz indeks od ktorego slowo sie zaczyna w kontenerze Container</returns>
        public Tuple<int, int> GetWordInfo(Container Container, int Index)
        {
            Cell TempCell;
            int StartIndex = 0;
            int NewWordLength = 0;

            for(int i = 0; i < Container.Count; ++i)
            {
                TempCell = Container.Get(i);

                if(TempCell.IsVisited() || i == Index)
                {
                    ++NewWordLength;
                }
                else if(i > Index)
                {
                    return Tuple.Create(NewWordLength, StartIndex);
                }
                else
                {
                    NewWordLength = 0;
                    StartIndex = i + 1;
                }
            }
            return Tuple.Create(NewWordLength, StartIndex);
        }
Пример #3
0
        /// <summary>
        /// Metoda wstawia kostki w odpowiednie miejsce na planszy i usuwa je z tabliczki gracza
        /// </summary>
        /// <param name="Container"></param>
        /// <param name="StartCell"></param>
        /// <param name="Word"></param>
        /// <param name="Rack"></param>
        public void PutTiles(Container Container, int StartIndex, Dictionary.Dictionary.WordFound Word, Rack Rack)
        {
            String NewWord = Word.GetWord();

            for(int i = 0; i < NewWord.Length; ++i)
            {
                Cell TempCell = Container.Get(StartIndex + i);

                if(!TempCell.IsVisited())
                {
                    TempCell.SetTile(Rack.Contains(NewWord[i]) ? new Tile(NewWord[i]) : new Tile(NewWord[i], true));

                    Rack.Remove(NewWord[i]);
                }
            }
        }
Пример #4
0
        /// <summary>
        /// Metoda zwraca slowo, ktore przechodzi przez index podany w argumecnie wywolania
        /// </summary>
        /// <param name="Container"></param>
        /// <param name="Index"></param>
        /// <returns></returns>
        public String GetWord(Container Container, int Index, bool Vertical)
        {
            String NewWord = String.Empty;

            if(Vertical)
            {
                foreach(Cell TempCell in Container)
                {
                    if(TempCell.GetTile() != null)
                    {
                        NewWord += TempCell.GetTile().GetLetter();
                    }
                    else if(TempCell.GetYRowCoordinate() > Index) //Ulozone zostalo cale slowo
                    {
                        if(NewWord.Length > 1)
                        {
                            return NewWord;
                        }
                        break;
                    }
                    else
                    {
                        NewWord = String.Empty;
                    }
                }
                if(NewWord.Length > 1) //Jesli slowo konczy sie przy krawedzi planszy
                {
                    return NewWord;
                }
            }
            else
            {
                foreach(Cell TempCell in Container)
                {
                    if(TempCell.GetTile() != null)
                    {
                        NewWord += TempCell.GetTile().GetLetter();
                    }
                    else if(TempCell.GetXColumnCoordinate() > Index) //Ulozone zostalo cale slowo
                    {
                        if(NewWord.Length > 1)
                        {
                            return NewWord;
                        }
                        break;
                    }
                    else
                    {
                        NewWord = String.Empty;
                    }
                }
                if(NewWord.Length > 1) //Jesli slowo konczy sie przy krawedzi planszy
                {
                    return NewWord;
                }
            }

            return NewWord;
        }
Пример #5
0
        /// <summary>
        /// Metoda napelniajaca klase AlreadySetLetters literami znajdujacymi sie na planszy.
        /// </summary>
        /// <param name="ASL"></param>
        /// <param name="ConsideredContainer"></param>
        /// <param name="FirstIndex"></param>
        public void FillAlreadySetLetters(Dictionary.Dictionary.AlreadySetLetters ASL, Container ConsideredContainer, int FirstIndex)
        {
            int LettersLeft = Configuration.MaxLetterNumber;

            for(int i = 0; LettersLeft != 0; ++i)
            {
                Cell TempCell = ConsideredContainer.Get(FirstIndex + i);

                if(TempCell == null)
                {
                    return;
                }

                if(TempCell.IsVisited())
                {
                    ASL.Set(i, TempCell.GetTile().GetLetter());
                }
                else
                {
                    --LettersLeft;
                }
            }
        }
Пример #6
0
        /// <summary>
        /// Metoda zliczajaca ile punktow warte jest slowo
        /// </summary>
        /// <param name="Container"></param>
        /// <param name="StartIndex"></param>
        /// <returns></returns>
        public int CountWord(Container Container, int StartIndex)
        {
            int Points = 0;
            int WordMultiplier = 1;
            Cell TempCell;
            int i = 0;
            int LettersUsed = 0; //Licznik dolozonych w tej turze kostek

            while((TempCell = Container.Get(StartIndex + i++)) != null)
            {
                Tile TempTile = TempCell.GetTile();

                if(TempTile == null)
                {
                    break;
                }

                Char Letter = TempTile.GetLetter();
                int Value = TempTile.IsBlank() ? GameLanguage.GetLetterValue(' ') : GameLanguage.GetLetterValue(Letter);

                if(TempCell.IsVisited())
                {
                    Points += Value;
                }
                else
                {
                    ++LettersUsed;
                    WordMultiplier *= TempCell.GetWordMultiplier();
                    Points += Value * TempCell.GetLetterMultiplier();
                }
            }

            if(LettersUsed == Configuration.MaxLetterNumber)
            {
                return Points * WordMultiplier + Configuration.SpecialBonus;
            }
            return Points * WordMultiplier;
        }
Пример #7
0
 /// <summary>
 /// Metoda sprawdzajaca czy pomiedzy indeksami przekazanymi w argumencie wywolania nie ma pustego pola
 /// </summary>
 /// <param name="Container"></param>
 /// <param name="StartIndex"></param>
 /// <param name="EndIndex"></param>
 /// <returns></returns>
 private bool IsOneWord(Container Container, int StartIndex, int EndIndex)
 {
     for(; StartIndex < EndIndex; ++StartIndex)
     {
         if(Container.Get(StartIndex).GetTile() == null)
         {
             return false;
         }
     }
     return true;
 }
Пример #8
0
        /// <summary>
        /// Zliczanie odleglosci od wskazanego indeksu w kontenerze do pierwszego indeksu na ktorym znajduje sie kostka. 
        /// </summary>
        /// <param name="Container"></param>
        /// <param name="Index"></param>
        /// <returns>Odleglosc do pierwszego zajetego pola lub rozmiar boku planszy + 1 jesli takie pole nie istnieje</returns>
        private int GetFirstLetterDistance(Container Container, int Index)
        {
            int Distance = 1;

            if(Container != null)
            {
                for(int i = 0; i < Configuration.MaxLetterNumber; ++i)
                {
                    Cell TempCell = Container.Get(Index + i);

                    if(TempCell == null)
                    {
                        break;
                    }

                    if(TempCell.IsVisited())
                    {
                        return Distance;
                    }
                    ++Distance;
                }
            }
            return GameBoard.GetBoardSide() + 1;
        }