예제 #1
0
        private void SetState(ICell cell)
        {
            var state = CurrenUser.Fraction;

            if (BigArea.State != States.Empty)
            {
                throw new ApplicationException("Невозможно продолжить игру!" +
                                               "\nИгра завершина.");
            }
            if (cell.State != States.Empty)
            {
                throw new ApplicationException("Невозможно изменить заполненное поле");
            }
            cell.State = state;
            var area = cell.ParentArea;

            if (area == null)
            {
                return;
            }
            if (area.State == States.Empty)
            {
                CheckStateInArea(area, cell.State);
            }
            SetNextArea(cell);
            if (BigArea.State != States.Empty)
            {
                SetWinner?.Invoke(BigArea.State);
            }
            CurrenUser = CurrenUser == User1 ? User2 : User1;
        }
예제 #2
0
 private void FindedWinner(IArea area)
 {
     if (area == BigArea)
     {
         SetWinnerUser(BigArea.State);
         SetWinner?.Invoke(BigArea.State);
     }
 }
예제 #3
0
        private void TimerHandler(object obj)
        {
            ParallelLoopResult result = Parallel.ForEach(_liveAuctions,
                                                         (x) =>
            {
                x.Value.Ticks--;

                if (x.Value.Ticks >= 0)
                {
                    SendState?.Invoke(x.Value.AuctionId, x.Value.Ticks, x.Value.CurrentPrice, x.Value.LastUser);
                }
                else
                {
                    SetWinner?.Invoke(x.Value.AuctionId, x.Value.Ticks, x.Value.CurrentPrice, x.Value.LastUser);
                    _waitedAuctions.Remove(x.Value.AuctionId);
                }
            });
        }