コード例 #1
0
ファイル: Cell.cs プロジェクト: peku33/ScrabbleSolver
 public Cell(Coordinates CellCoordinates, int WordMultiplier, int LetterMultiplier, Tile Tile, bool Visited)
 {
     this.CellCoordinates = CellCoordinates;
     this.WordMultiplier = WordMultiplier;
     this.LetterMultiplier = LetterMultiplier;
     this.Tile = Tile;
     this.Visited = Visited;
 }
コード例 #2
0
ファイル: Cell.cs プロジェクト: peku33/ScrabbleSolver
 public Cell(Coordinates coordinates, int WordMultiplier, int LetterMultiplier)
 {
     this.CellCoordinates = coordinates;
     this.WordMultiplier = WordMultiplier;
     this.LetterMultiplier = LetterMultiplier;
     this.Tile = null;
     this.Visited = false;
 }
コード例 #3
0
ファイル: Cell.cs プロジェクト: peku33/ScrabbleSolver
 public Cell(Cell ToCopyCell)
 {
     this.CellCoordinates = new Coordinates(ToCopyCell.GetXColumnCoordinate(), ToCopyCell.GetYRowCoordinate());
     this.WordMultiplier = ToCopyCell.GetWordMultiplier();
     this.LetterMultiplier = ToCopyCell.GetLetterMultiplier();
     if(ToCopyCell.GetTile() != null)
     {
         this.Tile = new Tile(ToCopyCell.GetTile());
     }
     else
     {
         this.Tile = null;
     }
     this.Visited = ToCopyCell.IsVisited();
 }
コード例 #4
0
ファイル: GameForm.cs プロジェクト: peku33/ScrabbleSolver
        public void UpdateForm(UpdateViewEvent UpdateViewEvent)
        {
            foreach (Cell boardCell in UpdateViewEvent.BoardCells)
            {

                Coordinates coordinates = new Coordinates(boardCell.GetXColumnCoordinate(), boardCell.GetYRowCoordinate());
                CellValues.Remove(coordinates);
                CellValues.Add(coordinates, boardCell);

                if (boardCell.GetTile() != null)
                {
                    boardGridView[boardCell.GetXColumnCoordinate(), boardCell.GetYRowCoordinate()].Value =
                        boardCell.GetTile().GetLetter().ToString().ToUpper();
                }
                else
                {
                    boardGridView[boardCell.GetXColumnCoordinate(), boardCell.GetYRowCoordinate()].Value = "";
                }
            }

            for (int i = 0; i < 7; ++i)
            {
                FirstHeldCharactersDataGrid[i, FIRST_INDEX].Value = "";
                SecondHeldCharactersDataGrid[i, FIRST_INDEX].Value = "";

                FirstHeldCharactersDataGrid[i +8, FIRST_INDEX].Value = "";
                SecondHeldCharactersDataGrid[i+8, FIRST_INDEX].Value = "";
            }

            _GameInfo.Clear();
             _GameInfo = UpdateViewEvent.GameInfo;
            heldCharacters = UpdateViewEvent.HeldCharacters;
            _CurrentPlayer = UpdateViewEvent.CurrentPlayer;
            AddAllHeldCharacters();
            InitFormHelper.UpdateGameInfoBoard(GameInfoDataGrid, _GameInfo);
            UpdateHeldCharactersLabels();

            Invalidate();
            Update();
        }
コード例 #5
0
ファイル: GameForm.cs プロジェクト: peku33/ScrabbleSolver
        /// <summary>
        /// Metoda aktualizuje litere na danej komórce, lub jeśli nie istnieje komórka o danych współrzędnych - dodaje nową.
        /// </summary>
        private void UpdateLetter(Coordinates Coordinates, bool isBlank, string blankValue)
        {
            if (CellValues.ContainsKey(Coordinates)) //TODO bug: if we comprare two object with the same coordinates we get false....
            {
                if (CellValues[Coordinates].GetTile() != null)
                {
                    CellValues[Coordinates].GetTile()
                        .SetLetter(blankValue.ToCharArray()[FIRST_INDEX]);
                    CellValues[Coordinates].GetTile().SetIsBlank(isBlank);
                }
                else
                {
                    CellValues[Coordinates].SetTile(new Tile(blankValue.ToCharArray()[FIRST_INDEX], isBlank));
                }

            }
            else
            {
                Cell Cell = new Cell(Coordinates, 0, 0, new Tile(TemporaryCopingCharacter.ToCharArray()[FIRST_INDEX], isBlank), false);
                CellValues.Add(Coordinates, Cell);
            }
        }
コード例 #6
0
ファイル: GameForm.cs プロジェクト: peku33/ScrabbleSolver
 private void InitAllCellValues()
 {
     CellValues.Clear();
     for (int IndexYCoordinate = FIRST_INDEX; IndexYCoordinate < BOARD_SIZE; ++IndexYCoordinate)
     {
         for (int IndexXCoordinate = FIRST_INDEX; IndexXCoordinate < BOARD_SIZE; ++IndexXCoordinate)
         {
             Coordinates coordinates = new Coordinates(IndexXCoordinate, IndexYCoordinate);// test
             CellValues.Add(coordinates, new Cell(coordinates, 0, 0, new Tile(true), false));// test
         }
     }
 }
コード例 #7
0
ファイル: GameForm.cs プロジェクト: peku33/ScrabbleSolver
        private void boardGridView_CellMouseUp(object s, DataGridViewCellMouseEventArgs e)
        {
            DataGridView Sender = (DataGridView)s;

            DataGridViewCell CurrentCell = Sender.CurrentCell;

            if (TemporaryCopingCharacter != null)
            {
                bool IsBlank = TemporaryCopingCharacter == " ";

                if (IsBlank)
                {
                    CurrentCell.Value = String.Copy(OpenFormAndGetBlankValue());

                }
                else
                {
                    CurrentCell.Value = String.Copy(TemporaryCopingCharacter);
                }

                Coordinates Coordinates = new Coordinates(CurrentCell.ColumnIndex, CurrentCell.RowIndex);
                UpdateLetter(Coordinates, IsBlank, CurrentCell.Value.ToString().ToLower());

                TemporaryCopingCharacter = null;
            }
        }