public async Task <ActionResult <RoundModel> > PostRoundModel(RoundModel roundModel) { _context.Rounds.Add(roundModel); await _context.SaveChangesAsync(); return(CreatedAtAction("GetRoundModel", new { id = roundModel.Id }, roundModel)); }
private static void CreateOtherRounds(TournamentModel model, int numRounds) { RoundModel previousRound = model.Rounds[0]; RoundModel currentRound = new RoundModel() { Number = 2, Active = null }; MatchupModel matchup = new MatchupModel(); while (currentRound.Number <= numRounds) { foreach (MatchupModel m in previousRound.Matchups) { matchup.Entries.Add(new MatchupEntryModel { ParentMatchup = m }); if (matchup.Entries.Count > 1) { matchup.MatchupRound = currentRound.Number; currentRound.Matchups.Add(matchup); matchup = new MatchupModel(); } } model.Rounds.Add(currentRound); previousRound = currentRound; currentRound = new RoundModel() { Number = previousRound.Number + 1, Active = null }; } }
private void undoButton_Click(object sender, EventArgs e) { RoundModel round = new RoundModel(); int index = AllRounds.Count - 2; if (index > 0) { round = AllRounds[index]; } if (AllRounds.Count > 0) { NumberLogic.UndoNumberProperties(AllRounds.Last().WinningNumber, this); } DisplayCurrentRound(round); ReverseTextboxes(); if (AllRounds.Count > 0) { AllRounds.RemoveAt(AllRounds.Count - 1); } }
private void WireUpTournamentOrder() { if (finishedTournament.IsLeague) { List <LeagueParticipantModel> leagueParticipants = SqlDataHandler.GetLeagueParticipantsForDisplay(finishedTournament.Id); _champion = new TeamModel(leagueParticipants.First().TeamName); _runnerUp = new TeamModel(leagueParticipants[1].TeamName); _thirdPlaced.Add(new TeamModel(leagueParticipants[2].TeamName)); } else { RoundModel finalRound = finishedTournament.Rounds.Last(); List <TeamModel> roundWinners = SqlDataHandler.GetRoundWinners(finalRound.Id); _champion = roundWinners.First(); _runnerUp = new TeamModel(finalRound.Games[0].Competitors.Find(team => team.CupRoundWinner == false).TeamName); RoundModel secondToLastRound = finishedTournament.Rounds[finalRound.RoundNumber - 2]; List <GameModel> semiFinalGames = SqlDataHandler.GetGamesByRound(secondToLastRound); List <GameParticipantModel> semiFinalLosers = new List <GameParticipantModel>(); foreach (GameModel game in semiFinalGames) { semiFinalLosers.Add(game.Competitors.Find(team => team.CupRoundWinner == false)); } _thirdPlaced.Add(new TeamModel(semiFinalLosers[0].TeamName)); _thirdPlaced.Add(new TeamModel(semiFinalLosers[1].TeamName)); } }
public ActionResult SetupRound(int holeId) { var teeId = Convert.ToInt32(TempData["teeId"]); var tees = _context.TeeModels.FirstOrDefault(c => c.Id == teeId); var course = tees.CourseModelId; var holePar = _context.HoleModels.FirstOrDefault(c => c.Id == holeId).HolePar; var roundModel = new RoundModel { CourseModelId = course, TeeModelId = teeId, HoleModelId = holeId, }; var viewModel = new NewRoundViewModel { HoleModels = _context.HoleModels.Where(c => c.TeeModelId == teeId), RoundModel = roundModel, }; TempData["courseId"] = course; TempData["teeId"] = teeId; TempData["holeId"] = holeId; TempData["holeCount"] = 1; if (holePar == 3) { return(RedirectToAction("Green", "NewRound")); } return(RedirectToAction("Fairway", "NewRound")); }
private static RoundModel CreateFirstRound(int numberOfByes, List <TeamModel> teams) { RoundModel output = new RoundModel() { Number = 1, Active = true }; List <MatchupModel> matchups = new List <MatchupModel>(); var matchup = new MatchupModel(); foreach (TeamModel team in teams) { matchup.Entries.Add(new MatchupEntryModel { TeamCompeting = team }); if (numberOfByes > 0 || matchup.Entries.Count > 1) { if (numberOfByes > 0) { matchup.Winner = team; numberOfByes--; } matchup.MatchupRound = 1; output.Matchups.Add(matchup); matchup = new MatchupModel(); } } return(output); }
public RoundModel CreateOrUpdateRound(RoundModel model) { Round round; if (model.Id == 0) { round = new Round(); _db.Rounds.Add(round); } else { round = _db.Rounds.FirstOrDefault(x => x.Id == model.Id); if (round == null) { throw new ObjectNotFoundException($"Round with Id: {model.Id} does not exist"); } } round.TeeTime = model.TeeTime; _db.SaveChanges(); return(new RoundModel() { Id = round.Id, TeeTime = round.TeeTime }); }
public override void Execute(object data) { EndLevelArgs e = data as EndLevelArgs; GameModel gm = GetModel <GameModel>(); RoundModel rModel = GetModel <RoundModel>(); //停止出怪 rModel.StopRound(); //停止游戏 //gm.EndLevel(e.IsSuccess); if (e.IsSuccess) { gm.Gold += GetView <UI_Game2>().Money * 2 + 300; } else { int m = GetView <UI_Game2>().Money - 40; m = m < 0 ? 0 : m; gm.Gold += m; } int s = PlayerPrefs.GetInt("ElectricEnergy", -1); if (s != -1) { PlayerPrefs.SetInt("ElectricEnergy", s + gm.Gold); } Debug.Log("本局金币为:" + gm.Gold); }
public void Show() { gameObject.SetActive(true); RoundModel rm = GetModel <RoundModel>(); UpdateRoundInfo(rm.RoundIndex + 1, rm.RoundTotal); }
//*********************************************************** //* FAIRWAY * //*********************************************************** public ActionResult Fairway() { var holeCount = Convert.ToInt32(TempData["holeCount"]); TempData["holeCount"] = holeCount; var courseId = Convert.ToInt32(TempData["courseId"]); TempData["courseId"] = courseId; var teeId = Convert.ToInt32(TempData["teeId"]); TempData["teeId"] = teeId; var holeId = Convert.ToInt32(TempData["holeId"]); TempData["holeId"] = holeId; var roundModel = new RoundModel { CourseModelId = courseId, TeeModelId = teeId, HoleModelId = holeId, }; var viewModel = new NewRoundViewModel { HoleModels = _context.HoleModels.Where(c => c.Id == roundModel.HoleModelId), RoundModel = roundModel, }; return(View(viewModel)); }
private void NumberButton_Click(object sender, EventArgs e) { Button button = (Button)sender; byte digit = byte.Parse(button.Text); RoundModel round = new RoundModel(); round.Spin = AllRounds.Count() + 1; round = UserInputHelper.EnterNumber(digit, round, this, sessionStartForm); AllRounds.Add(round); NumberLogic.UpdateNumberProperties(digit, this); UserInputHelper.CheckIfUserHasWon(round, CurrentUser, this, userWonForm); CascadeTextboxes(); DisplayCurrentRound(round); tickSound.Play(); }
public override void Execute(object data) { Monster monster = data as Monster; RoundModel roundModel = GetModel <RoundModel>(); roundModel.End.Damage(null, monster.damage); }
public async Task <IActionResult> PutRoundModel(int id, RoundModel roundModel) { if (id != roundModel.Id) { return(BadRequest()); } _context.Entry(roundModel).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RoundModelExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public static List <RoundModel> ConvertToRoundModels(this List <string> lines) { List <RoundModel> output = new List <RoundModel>(); List <MatchupModel> matchups = GlobalConfig.MatchupsFile.GetFullFilePath().LoadFile().ConvertToMatchupModels(); foreach (string line in lines) { string[] cols = line.Split(','); RoundModel round = new RoundModel(); round.Id = int.Parse(cols[0]); round.Number = int.Parse(cols[1]); round.Active = cols[2] == "" ? null : (bool?)bool.Parse(cols[2]); string[] matchupIds = cols[3].Split('|'); foreach (string matchupId in matchupIds) { round.Matchups.Add(matchups.First(m => m.Id == int.Parse(matchupId))); } output.Add(round); } return(output); }
/// <summary> /// Retrieves games of the specific round /// </summary> /// <param name="round">Round you want games from</param> /// <returns>List of games of the given round</returns> public static List <GameModel> GetGamesByRound(RoundModel round) { List <GameModel> games = new List <GameModel>(); DynamicParameters parameters = new DynamicParameters(); parameters.Add("@RoundId", round.Id); using (IDbConnection connection = new SqlConnection(DatabaseAccess.GetConnectionString())) { games = connection.Query <GameModel>("dbo.SP_GetGamesByRound", parameters, commandType: CommandType.StoredProcedure).ToList(); } foreach (GameModel game in games) { parameters = new DynamicParameters(); parameters.Add("@GameId", game.Id); using (IDbConnection connection = new SqlConnection(DatabaseAccess.GetConnectionString())) { game.Competitors = connection.Query <GameParticipantModel>("dbo.SP_GetGameParticipantsByGame", parameters, commandType: CommandType.StoredProcedure).ToList(); } } return(games); }
//HU void enemy_Dead(Role enemy) { //回收自己 Enemy m = (Enemy)enemy; int Bonus = m.Bonus; Vector3 ps = enemy.transform.position; Game.Instance.ObjectPool.Unspawn(enemy.gameObject); // string prefabName = "Money" ; // GameObject money = Game.Instance.ObjectPool.Spawn(prefabName); // money.transform.position = ps; //游戏失败判断 GameModel gm = GetModel <GameModel> (); gm.Score += Bonus; RoundModel rm = GetModel <RoundModel> (); GameObject[] enemys = GameObject.FindGameObjectsWithTag("Enemy"); if (!m_Hero.IsDead && enemys.Length <= 0 && rm.AllRoundsComplete) //萝卜没死,场景里已没有怪物,所有怪物已出完 { SendEvent(Consts.E_EndLevel, new EndLevelArgs() { LevelID = gm.PlayLevelID, IsWin = true }); } }
/// <summary> /// Create the primitives to be drawed /// Z ---- length /// </summary> public override void Initialize( ) { if (roundMesh != null) { roundMesh.Dispose(); } model = source as RoundModel; //Create the mesh roundMesh = new AutoMesh(d3d, Mesh.Cylinder(d3d.Dx, model.Radius, model.Radius, 0.0f, Direct3dRender.DefaultSlices, Direct3dRender.DefaultStacks)); //Get the bounding box roundMesh.BoundingBox(out minVector3, out maxVector3); minVector3.TransformCoordinate(model.WorldMatrix); maxVector3.TransformCoordinate(model.WorldMatrix); Vector3 minClone = minVector3; Vector3 maxClone = maxVector3; minVector3.X = minClone.X < maxClone.X ? minClone.X : maxClone.X; minVector3.Y = minClone.Y < maxClone.Y ? minClone.Y : maxClone.Y; minVector3.Z = minClone.Z < maxClone.Z ? minClone.Z : maxClone.Z; maxVector3.X = minClone.X < maxClone.X ? maxClone.X : minClone.X; maxVector3.Y = minClone.Y < maxClone.Y ? maxClone.Y : minClone.Y; maxVector3.Z = minClone.Z < maxClone.Z ? maxClone.Z : minClone.Z; model.MinVector3 = minVector3; model.MaxVector3 = maxVector3; }
public override void Execute(object data) { EndLevelArgs e = data as EndLevelArgs; GameModel gm = GetModel <GameModel>(); RoundModel rModel = GetModel <RoundModel>(); //停止出怪 rModel.StopRound(); //停止游戏 gm.EndLevel(e.IsSuccess); //胜利 /*if (e.IsSuccess) * { * //显示胜利面板 * GetView<UIWin>().Show(); * } * else * { * //显示失败面板 * GetView<UILost>().Show(); * }*/ }
private void inputTextBox_KeyDown(object sender, KeyEventArgs e) { RoundModel round = new RoundModel(); round.Spin = AllRounds.Count() + 1; if (e.KeyCode == Keys.Enter) { if (InputValueAllowed()) { byte currentNumber = byte.Parse(inputTextBox.Text); foreach (NumberModel number in AllRouletteNumbers) { if (currentNumber == number.Digit) { round = UserInputHelper.EnterNumber(currentNumber, round, this, sessionStartForm); } } AllRounds.Add(round); NumberLogic.UpdateNumberProperties(currentNumber, this); UserInputHelper.CheckIfUserHasWon(round, CurrentUser, this, userWonForm); } inputTextBox.Clear(); CascadeTextboxes(); DisplayCurrentRound(round); tickSound.Play(); } }
private void DisplayCurrentRound(RoundModel round) { spinsLabel.Text = round.Spin.ToString(); textBox1.Text = round.WinningNumber.ToString(); goalLabel.Text = $"Goal: {Goal.ToString("0.00")}"; moneyLabel.Text = $"Money: {round.Money.ToString("0.00")}"; betUnitLabel.Text = $"Bet Unit: {round.BetUnit.ToString("0.00")}"; if (round.Spin >= SessionStart) { outputRichTextBox.Clear(); outputRichTextBox.SelectionAlignment = HorizontalAlignment.Center; if (round.ExpectedNumbers != null) { outputRichTextBox.AppendText($"Place {round.BetUnit.ToString("0.00")} on the {round.ExpectedNumbers.Count} expected numbers: " + $"\n\n\n" + String.Join(", ", round.ExpectedNumbers)); } } else { outputRichTextBox.Clear(); outputRichTextBox.SelectionAlignment = HorizontalAlignment.Center; outputRichTextBox.AppendText($"Expected numbers: \n\n\n ???"); } }
public async Task <RoundModel> SaveRound(RoundModel roundModel) { var round = _mapper.Map <Round>(roundModel); await _repository.Save(round); return(_mapper.Map <RoundModel>(round)); }
private void ReverseTextboxes() { textBox1.Text = textBox2.Text; textBox2.Text = textBox3.Text; textBox3.Text = textBox4.Text; textBox4.Text = textBox5.Text; textBox5.Text = textBox6.Text; textBox6.Text = textBox7.Text; textBox7.Text = textBox8.Text; textBox8.Text = textBox9.Text; textBox9.Text = textBox10.Text; textBox10.Text = textBox11.Text; textBox11.Text = textBox12.Text; if (AllRounds.Count > 0) { int index = AllRounds.Count() - 13; if (AllRounds.Count > 12) { RoundModel round = AllRounds[index]; textBox12.Text = round.WinningNumber.ToString(); } else { textBox12.Clear(); } } }
public async Task <IActionResult> Edit([FromBody] RoundModel model) { if (!ModelState.IsValid) { return(ReturnError(StatusCodes.Status400BadRequest, "Invalid round edit request", GetModelStateMessages())); } if (!model.Id.HasValue) { return(ReturnError(StatusCodes.Status400BadRequest, "Invalid round edit request", "Please send a valid round id to edit a round")); } var round = await _dataStore.GetAsync <Round>(model.Id.Value); if (round == null) { return(ReturnError(StatusCodes.Status404NotFound, "Invalid round edit request", $"Round {model.Id} not found")); } if (!round.CanUpdateRound(User)) { return(ReturnError(StatusCodes.Status403Forbidden, "Invalid had round request", $"You are not allowed to update this round")); } round = await model.UpdateRound(round, _dataStore); if (!model.IsRoundValid || round == null) { return(ReturnError(StatusCodes.Status400BadRequest, "Invalid round edit request", model.AllValidationMessages)); } round = await _dataStore.UpdateAsync(round); return(Accepted(RoundSummaryModel.FromRound(round))); }
public override void Execute(object data) { //开始出怪 RoundModel rModel = GetModel <RoundModel>(); rModel.StartRound(); }
public override void Execute(object data) { EndLevelArgs e = data as EndLevelArgs; //保存游戏状态 GameModel gm = GetModel <GameModel>(); RoundModel rModel = GetModel <RoundModel>(); //停止出怪 rModel.StopRound(); //停止游戏 gm.StopLevel(e.IsWin); Debug.Log("游戏结束" + gm.IsPlaying); //弹出UI //胜利 if (e.IsWin) { //显示胜利面板 GetView <UIWin>().Show(); } else { //显示失败面板 GetView <UILost>().Show(); } }
public RoundController(RoundModel model, RoundView view) { _model = model; _view = view; _model.CurrentRound = 1; _view.Model = _model; }
public void Show() { gameObject.SetActive(true); RoundModel roundModel = GetModel <RoundModel>(); SetRoundInfo(roundModel.RoundIndex + 1, roundModel.RoundTotal); }
void Update() { RoundModel rm = GetModel <RoundModel>(); GameModel gm = GetModel <GameModel>(); UpdateRoundInfo(rm.RoundIndex + 1, rm.RoundTotal); UpdateScore(gm.Gold); }
public ActionResult DeleteConfirmed(int id) { RoundModel roundmodel = db.RoundModels.Find(id); db.RoundModels.Remove(roundmodel); db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <IActionResult> FetchRound(int id, [FromQuery(Name = "h")] string[] highlight) { var result = await _rounds.GetRound(id); if (result == null) { var l = highlight?.ToList(); var missingModel = new RoundModel { CurrentRound = new ScrubbyRound() { Id = id }, NextID = await _rounds.GetNext(id, true, l), LastID = await _rounds.GetNext(id, false, l), HightlightedCkeys = l }; return(View("RoundNotFound", missingModel)); } RoundModel toGive; if (highlight != null) { var l = highlight.ToList(); toGive = new RoundModel { CurrentRound = result, NextID = await _rounds.GetNext(id, true, l), LastID = await _rounds.GetNext(id, false, l), HightlightedCkeys = l }; } else { toGive = new RoundModel { CurrentRound = result, NextID = await _rounds.GetNext(id), LastID = await _rounds.GetNext(id, false) }; } var connections = (await _connections.GetConnectionsForRound(id)).ToList(); var nonPlayers = new List <CKey>(); if (connections.Count != 0 && toGive.CurrentRound.Players != null) { nonPlayers = connections.Select(x => x.CKey) .Except(toGive.CurrentRound.Players.Select(x => new CKey(x.Ckey))).ToList(); } toGive.NonPlaying = nonPlayers.OrderBy(x => x.Cleaned).ToList(); return(View("View", toGive)); }