public static void Main() { int width = 10; int height = 10; BoardEntry[,] board = new BoardEntry[width, height]; for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { // For each "cell" of the board, we create a new instance of // BoardEntry, holding the number for this cell and a possible ownage. board[x, y] = new BoardEntry() { number = x * width + y + 1, owner = ' ' }; } } // You can access each of those instances with `board[x,y].number` and `board[x,y].owner` System.Console.WriteLine("Number at x = 3 / y = 5: " + board[3, 5].number); System.Console.WriteLine("Current owner of x = 3 / y = 5: \"" + board[3, 5].owner + "\""); // Let's change the owner of x = 3 and y = 5 board[3, 5].owner = 'X'; System.Console.WriteLine("New owner at x = 3 / y = 5: \"" + board[3, 5].owner + "\""); }
public void SubscribeBoard(string board, string plan) { if (this.GetBoardInfo(board) != null) { this._Logger.Warn("Board " + board + " has been subscribed."); return; } var entry = new BoardEntry() { BoardName = board, Flag = BoardState.SELECTED, Plan = plan, ErrorCount = 0, }; int floor, number; this._posMapScheme.GetPosition(board, out floor, out number); IBoard controller = this._boardFactory.GenerateBoard(plan, board, floor, number); if (controller == null) { this._Logger.Error("create " + board + "'s controller error,subscribe board fail"); return; } entry.SetController(controller); this._boardSet.Add(entry); this._validBoardSet.Add(entry); this.BoardStateChanged?.Invoke(this, null); Utility.Dump(targetFile, this._boardSet); }
public async Task <ActionResult <BoardEntry> > PostNewBoardEntry([FromBody] NewBoardEntryModel model) { try { BoardEntry newLogicBoardEntry = new BoardEntry() { boardEntryID = Guid.NewGuid(), entryType = new EntryType() { entryTypeID = model.entryTypeID }, dateTimeEntered = DateTime.UtcNow, threadNumber = model.threadNumber, postNumber = model.postNumber, postDescription = model.postDescription }; await repository.CreateBoardEntryAsync(newLogicBoardEntry); await repository.SaveAsync(); return(Ok(await repository.GetBoardEntryByIDAsync(newLogicBoardEntry.boardEntryID))); } catch (Exception e) { return(StatusCode(StatusCodes.Status500InternalServerError, e.InnerException)); } }
private void Payout(GamePlayed game, Player winner) { if (game.GameComplete) { _context.SaveChanges(); var gamebetter = _context.GamesPlayed.Include(gp => gp.Winner).Include(gp => gp.Players).ThenInclude(gpp => gpp.Player).Single(g => g.Id == game.Id); var stake = gamebetter.Stake; foreach (var player in gamebetter.Players) { var be = new BoardEntry(); be.Game = gamebetter; be.Player = player.Player; if (gamebetter.Winner.Id == player.Player.Id) { var winnings = gamebetter.Players.Count() * stake; be.Difference = winnings - stake; } else { be.Difference = -stake; } _context.Board.Add(be); } _context.SaveChanges(); } }
public async Task <BoardEntryDto> Post(BoardEntryDto boardEntryDto) { if (!ModelState.IsValid) { throw new HttpResponseException(new HttpResponseMessage { ReasonPhrase = "Invalid data", StatusCode = HttpStatusCode.BadRequest }); } using (var dbContext = new LeaderboardContext()) { var boardEntry = new BoardEntry { Id = Guid.NewGuid(), Failed = boardEntryDto.Failed, Passed = boardEntryDto.Passed, Skipped = boardEntryDto.Skipped, Username = boardEntryDto.Username, Submitted = DateTime.UtcNow }; // remove existing entry before adding new one // should probably have a password or something dbContext.Leaderboard.RemoveRange(dbContext.Leaderboard.Where(l => l.Username == boardEntryDto.Username)); // add new entry var result = dbContext.Leaderboard.Add(boardEntry); await dbContext.SaveChangesAsync(); if (dbContext.TopTenEntries.Any(be => be.Id == result.Id)) { var clients = GlobalHost.ConnectionManager.GetHubContext <LeaderboardHub>().Clients; clients.All.leaderboardUpdate(await dbContext.TopTenEntries.Select(entry => new BoardEntryDto { Id = entry.Id, Failed = entry.Failed, Passed = entry.Passed, Skipped = entry.Skipped, Username = entry.Username, Submitted = entry.Submitted }).ToListAsync()); } return(new BoardEntryDto { Failed = result.Failed, Id = result.Id, Passed = result.Passed, Skipped = result.Skipped, Username = result.Username, Submitted = result.Submitted }); } }
public async Task <ActionResult <BoardEntry> > GetBoardEntryByPostNumber(int threadNumber, int postNumber) { try { BoardEntry logicBoardEntry = await repository.GetBoardEntryByThreadAndPostNumberAsync(threadNumber, postNumber); return(logicBoardEntry); } catch (Exception e) { return(StatusCode(StatusCodes.Status500InternalServerError, e.InnerException)); } }
public async Task <ActionResult <BoardEntry> > GetBoardEntryByID(Guid boardEntryID) { try { BoardEntry logicBoardEntry = await repository.GetBoardEntryByIDAsync(boardEntryID); return(logicBoardEntry); } catch (Exception e) { return(StatusCode(StatusCodes.Status500InternalServerError, e.InnerException)); } }
public MatchingThread Resolve(ChannelInfo channelInfo, bool ignoreMainThreadTitleKeywords) { MatchingThread getMatchingThread(ChannelEntry channel) { if (!ignoreMainThreadTitleKeywords) { return(this.boardDatabase.GetMatchingThread(channel)); } else { ThreadMappingRuleEntry ruleEntry = this.boardDatabase.GetMatchingThreadMappingRuleEntry(channel); if (ruleEntry == null) { return(null); } BoardEntry boardEntry = this.boardDatabase.GetBoardEntryById(ruleEntry.BoardId); if (boardEntry == null) { return(null); } return(new MatchingThread(boardEntry.Title, boardEntry.Uri, ruleEntry.ThreadTitleKeywords)); } } ushort networkId = channelInfo.NetworkId, serviceId = channelInfo.ServiceId; if (networkId == 0) { //録画ファイルなどではネットワークIDが分からないのでサービスIDだけで検索 //BSとCSの間ではサービスIDが重複する可能性があるがほとんどないので割り切る foreach (ChannelEntry channel in channelDatabase.GetByServiceId(serviceId)) { MatchingThread ret = getMatchingThread(channel); if (ret != null) { return(ret); } } return(null); } else { ChannelEntry channel = channelDatabase.GetByNetworkIdAndServiceId(networkId, serviceId);//channels.txtの登録チャンネルに解決 if (channel == null) { return(null); } return(getMatchingThread(channel)); } }
public async Task <ActionResult <BoardEntry> > PutPostDescription(Guid boardEntryID, [FromBody] EditPostDescriptionModel model) { try { BoardEntry newLogicBoardEntry = new BoardEntry() { boardEntryID = boardEntryID, postDescription = model.postDescription }; await repository.UpdateBoardEntryPostDescriptionAsync(newLogicBoardEntry); await repository.SaveAsync(); return(Ok(await repository.GetBoardEntryByIDAsync(boardEntryID))); } catch (Exception e) { return(StatusCode(StatusCodes.Status500InternalServerError, e.InnerException)); } }
private void _BindingSnOnBoard(string boardName, Dictionary <int, string> snSet) { if (snSet != null && snSet.Count != 0) { BoardEntry board = boardManager.GetBoardInfo(boardName); double OvenTargetTemperature = board.GetController().GetTargetOvenTemperature(); foreach (var seat in snSet.Keys) { string sn = snSet[seat]; boardManager.AddSeatToBoard(boardName, seat, sn); unitManager.SubscribeUnit(sn, board.Plan, OvenTargetTemperature, boardName, seat); } } if (unitManager.GetUnitSnSet(boardName).Any() == false) { log.Warn(boardName + " is Empty."); boardManager.ChangeBoardState(boardName, BoardState.UNSELECTED); boardManager.UnsubscribeBoard(boardName); } else { boardManager.ChangeBoardState(boardName, BoardState.LOADED); } }
private BoardEntry CreateBoardEntry(string boardName, Dictionary <int, string> snSet) { BoardEntry board = boardManager.GetBoardInfo(boardName); return(board); }