public static DbPick ToDbPick(PickResponse pickResponse) { return(new DbPick { Choice = pickResponse.Choice, Value = pickResponse.Value }); }
public ActionResult <PickResponse> Pick([FromBody] CellCoordinates value, string token) { //middleware checks token if (string.IsNullOrEmpty(token)) { return(BadRequest()); } // validate coordinates if (!PickValidation.IsPickValid(value)) { return(BadRequest()); } MineRepository repository = new MineRepository(); MineMatrix mineMatrix = repository.Load(token); if (mineMatrix == null) { return(StatusCode(500)); } // evaluate if bomb, number or zero MineSweeper core = new MineSweeper(mineMatrix); Cell cell = core.ProcessPoint(value.X, value.Y); PickResponse pr = new PickResponse(); if (core.IsGameOver()) { pr.GameStatus = GameStatus.GAME_OVER.ToString(); } else { pr.GameStatus = GameStatus.PLAYING.ToString(); } pr.TimeLapsed = DateTime.Now.Subtract(mineMatrix.StartedTime).Minutes; return(pr); }