Пример #1
0
 /// <summary>
 /// Совершает ход
 /// </summary>
 /// <param name="parSourceCell">Исходная ячейка</param>
 /// <param name="parDestinationCell">Ячейка назначения</param>
 /// <param name="parCurrentPlayer">Текущий игрок</param>
 public void Move(Cell parSourceCell, Cell parDestinationCell, Player parCurrentPlayer)
 {
     if (IsMove(parSourceCell.I, parSourceCell.J, parDestinationCell.I, parDestinationCell.J) &&
         parSourceCell.Score > 1 &&
         parDestinationCell.IsCellFree())
     {
         parDestinationCell.Owner = parCurrentPlayer;
         parDestinationCell.Score = parSourceCell.Score - 1;
         parSourceCell.Score      = 1;
         parSourceCell.DisactiveCell();
         parDestinationCell.ActiveCell();
     }
     else if (IsMove(parSourceCell.I, parSourceCell.J, parDestinationCell.I, parDestinationCell.J) &&
              parSourceCell.Score > 1 &&
              IsCellOccupied(parDestinationCell, parCurrentPlayer))
     {
         if (parSourceCell.Score > parDestinationCell.Score)
         {
             parDestinationCell.Score = parSourceCell.Score - parDestinationCell.Score;
             parSourceCell.Score      = 1;
             parSourceCell.DisactiveCell();
             parDestinationCell.ActiveCell();
             parDestinationCell.Owner = parCurrentPlayer;
         }
         else if (parSourceCell.Score == parDestinationCell.Score)
         {
             parDestinationCell.Score = 1;
             parSourceCell.Score      = 1;
         }
         else
         {
             parDestinationCell.Score = parDestinationCell.Score - (parSourceCell.Score - 1);
             parSourceCell.Score      = 1;
         }
     }
 }