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; }
private void FindedWinner(IArea area) { if (area == BigArea) { SetWinnerUser(BigArea.State); SetWinner?.Invoke(BigArea.State); } }
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); } }); }