public async Task <IActionResult> UpdateTeamScore([FromForm] TeamMatchScoredto model) { if (ModelState.IsValid) { foreach (var teamScore in model.TeamScore) { var teamScoreDbModel = new TeamScore { TeamScoreId = teamScore.TeamScoreId }; _context.TeamScores.Attach(teamScoreDbModel); teamScoreDbModel.TeamScoreId = teamScore.TeamScoreId; teamScoreDbModel.TeamId = teamScore.TeamId; teamScoreDbModel.MatchId = teamScore.MatchId; teamScoreDbModel.TotalScore = teamScore.TotalScore; teamScoreDbModel.Wickets = teamScore.Wickets; teamScoreDbModel.Wideballs = teamScore.Wideballs; teamScoreDbModel.NoBalls = teamScore.NoBalls; teamScoreDbModel.Byes = teamScore.Byes; teamScoreDbModel.LegByes = teamScore.LegByes; _context.TeamScores.Update(teamScoreDbModel); } await _context.SaveChangesAsync(); return(Json(ResponseHelper.UpdateSuccess())); } else { return(Json(ResponseHelper.UpdateUnSuccess())); } }
public async Task <IActionResult> Edit(int id, [Bind("ID,Score")] TeamScore teamScore) { if (id != teamScore.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(teamScore); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TeamScoreExists(teamScore.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(teamScore)); }
public void Awake() { instance = this; team1Score = new TeamScore(); team2Score = new TeamScore(); }
private void GenerateTeamScores() { int order = 1; foreach (Team team in _teams) { TeamScore teamScore = new TeamScore() { TeamID = team.TeamID, CurrentScore = 0, Order = order }; teamScore.TeamName = team.Players.Count % 2 == 0 ? string.Format("{0} / {1}", team.Players.Select(e => e.PlayerName).ToArray()) : team.Players.FirstOrDefault().PlayerName; foreach (PointValue pv in _pointValues) { PointValueHit pvh = new PointValueHit() { PointValueID = pv.PointValueID, Points = pv.Points, Completed = false, HitLastRound = false }; teamScore.PointValuesHit.Add(pvh); } _teamScores.Add(teamScore); order++; } }
public async Task <IActionResult> PutTeamScore([FromRoute] int id, [FromBody] TeamScore teamScore) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != teamScore.ScoreId) { return(BadRequest()); } _context.Entry(teamScore).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TeamScoreExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
private void Recalc() { DbContext.GameSet.Where(f => f.StageId == Stage.Id).Load(); DbContext.GameResultSet.Where(f => f.Game.StageId == Stage.Id).Load(); DbContext.GameResultValueSet.Where(f => f.GameResult.Game.StageId == Stage.Id).Load(); var result = new BindingList <TeamScore>(); foreach (var game in DbContext.GameSet.Local) { var gameValues = ScaleResult(GameService.GetGameResultValues(game)); var score = GameService.GetGameScore(game, gameValues, new StringBuilder()); if (!score.HasValue) { continue; } var item = new TeamScore() { Team = game.Team, Score = score.Value }; result.Add(item); } GridEX.DataSource = result; GridEX.Refetch(); }
private void CountScores() { TeamScore[] scores = new TeamScore[4]; for (int i = 0; i <= 3; i++) { Manager currentManager = GameObject.FindGameObjectWithTag("ManagerP" + i).GetComponent <Manager>(); scores[i].score = currentManager.Score; scores[i].name = currentManager.gameObject.tag; } }
void SetTeamScore(int team, int score) { teamScore [team] = score; TeamScore component = TeamScoreText [team].GetComponent <TeamScore>(); if (component) { component.SetScore(score); } }
public async Task <IActionResult> Create([Bind("ID,Score")] TeamScore teamScore) { if (ModelState.IsValid) { _context.Add(teamScore); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(teamScore)); }
public async Task <IActionResult> PostTeamScore([FromBody] TeamScore teamScore) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.TeamScore.Add(teamScore); await _context.SaveChangesAsync(); return(CreatedAtAction("GetTeamScore", new { id = teamScore.ScoreId }, teamScore)); }
private void OnTeamScore(TeamScore teamScore) { if (redTeamScore != teamScore.redTeam) { redTeamScore = teamScore.redTeam; redScoreFont.Scale = 2f; } if (blueTeamScore != teamScore.blueTeam) { blueTeamScore = teamScore.blueTeam; blueScoreFont.Scale = 2f; } }
public List <TeamScore> GetPlacement(int[] points) { List <TeamScore> teamScores = new List <TeamScore>(); for (int i = 0; i < points.Length; ++i) { TeamScore teamScore = new TeamScore(); teamScore.points = points[i]; teamScore.teamName = (TeamName)i; teamScores.Add(teamScore); } return(teamScores.OrderByDescending(x => x.points).ToList()); }
public async Task <bool> CreateTeamScoresForRound(RoundDto round) { var users = await _content.Users.ToListAsync(); foreach (var user in users) { // Need to create the TeamScore for the Round TeamScore ts = new TeamScore(); ts.RoundId = round.RoundNumber; ts.Total = 0; ts.UserId = user.Id; await _content.TeamScores.AddAsync(ts); } return(await _content.SaveChangesAsync() > 0); }
private void RefreshTeamScore(int teamID) { // Get the backend data objects Team team = _game.Teams.SingleOrDefault(e => e.TeamID == teamID); IEnumerable <RoundScore> teamRoundScores = _game.RoundScores.Where(e => e.TeamID == teamID).OrderBy(e => e.Round); // Get the Displayed Data Object TeamScore teamScore = _teamScores.SingleOrDefault(e => e.TeamID == teamID); // Set the current score teamScore.CurrentScore = teamRoundScores.Sum(e => e.Points); // Reset the points hit foreach (PointValueHit pvh in teamScore.PointValuesHit) { pvh.Completed = false; pvh.HitLastRound = false; } // Get the distinct points hit IEnumerable <int> pointsHit = teamRoundScores.Select(e => e.Points).Distinct(); foreach (int points in pointsHit) { PointValueHit pvh = teamScore.PointValuesHit.SingleOrDefault(e => e.Points == points); if (pvh != null) { pvh.Completed = true; } } // Get the points hit in the latest round if (teamRoundScores.Count() > 0) { int maxRound = teamRoundScores.Max(e => e.Round); IEnumerable <int> pointsHitLastRound = teamRoundScores.Where(e => e.Round == maxRound).Select(e => e.Points); foreach (int points in pointsHitLastRound) { PointValueHit pvh = teamScore.PointValuesHit.SingleOrDefault(e => e.Points == points); if (pvh != null) { pvh.HitLastRound = true; } } } }
public async Task <decimal> GetRoundScore(int id) { // Need to get the current round // DateTime dateTime = DateTime.UtcNow.Date; // string currentDate = dateTime.ToString("yyyyMMdd"); // int value = Convert.ToInt32(currentDate); int value = 20181016; Round round = _content.Rounds.FromSql("SELECT * FROM Rounds where CAST(startDate AS INT) <= {0} and CAST(endDate AS INT) >= {0}", value).FirstOrDefault(); if (round != null) { TeamScore ts = await _content.TeamScores.FromSql("SELECT * FROM TeamScores where RoundId = {0} and UserId = {1}", round.RoundNumber, id).FirstOrDefaultAsync(); return(ts.Total); } return(0); }
private void UpdateTeamScore(int teamID, int round) { TeamScore teamScore = _teamScores.SingleOrDefault(e => e.TeamID == teamID); List <RoundScore> roundScores = _game.RoundScores.Where(e => e.TeamID == teamID).ToList(); foreach (PointValueHit pv in teamScore.PointValuesHit) { pv.HitLastRound = false; } teamScore.CurrentScore = roundScores.Sum(e => e.Points); foreach (RoundScore rs in roundScores.Where(e => e.Round == round)) { PointValueHit pvh = teamScore.PointValuesHit.SingleOrDefault(e => e.Points == rs.Points); if (pvh != null) { pvh.Completed = true; pvh.HitLastRound = true; } } if (teamScore.CurrentScore == _scoreToWin) { System.Windows.Forms.MessageBox.Show(string.Format("{0} Win!", teamScore.TeamName)); } else if (teamScore.CurrentScore > _scoreToWin) { RoundScore negRoundScore = new RoundScore() { GameID = _game.GameID, TeamID = teamID, Round = round }; negRoundScore.Points = _fallbackScoreOnBust - teamScore.CurrentScore; _game.RoundScores.Add(negRoundScore); _dataManager.SaveChanges(); teamScore.CurrentScore = roundScores.Sum(e => e.Points) + negRoundScore.Points; } }
public async Task <bool> CreateNewTeamScores(int round) { List <int> allUsers = await _content.Users.Select(x => x.Id).Distinct().ToListAsync(); List <int> allTeamScoreUsers = await _content.TeamScores.Select(x => x.UserId).Distinct().ToListAsync(); // foreach (int idValue in allUsers) { var exists = allUsers.Except(allTeamScoreUsers).ToList(); // } // var firstNotSecond = list1.Except(list2).ToList(); foreach (int value in exists) { // Need to create a new TeamScore for the current round TeamScore ts = new TeamScore(); ts.RoundId = round; ts.Total = 0; ts.UserId = value; await _content.TeamScores.AddAsync(ts); } return(await _content.SaveChangesAsync() > 0); }
public static async Task <HttpResponseMessage> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "options", "post", Route = null)] HttpRequestMessage req, [Table("teampoints", Connection = "AzureWebJobsStorage")] CloudTable inTable, TraceWriter log) { log.Info("### Get Current Score Triggered ###"); dynamic data = await req.Content.ReadAsAsync <object>(); string teamId = data?.teamId; // Get only the records with the corresponding teamId TableQuery <TeamPoint> query = new TableQuery <TeamPoint>() .Where(TableQuery.GenerateFilterCondition("TeamId", QueryComparisons.Equal, teamId)); // Get the Score int scoreResult = inTable.ExecuteQuery(query).Count(); TeamScore ts = new TeamScore(teamId, scoreResult); // Return the Score return(req.CreateResponse(HttpStatusCode.OK, ts)); }
//public Color team3Color = Color.red; // Use this for initialization void Start() { UI = gameObject.transform.GetChild(0).GetChild(1).gameObject; UI.GetComponent <UIManager>().node = gameObject; scoreUI = Object.FindObjectOfType <TeamScore>(); if (team1 == true) { team = "team1"; } if (team2 == true) { team = "team2"; } if (team == "team1") { scoreUI.t1 += score; } if (team == "team2") { scoreUI.t2 += score; } }
static void Main(string[] args) { string key = Console.ReadLine(); var allTeams = new Dictionary <string, TeamScore>(); while (true) { string input = Console.ReadLine(); if (input == "final") { break; } string[] currentMatch = input.Split().ToArray(); string firtTeamName = currentMatch.First(); string secondTeamName = currentMatch.Skip(1).First(); string resultOfMatch = currentMatch.Last(); int startIndexFirst = firtTeamName.IndexOf(key); int lastIndexFirst = firtTeamName.LastIndexOf(key); int startIndexSecond = secondTeamName.IndexOf(key); int lastIndexSecond = secondTeamName.LastIndexOf(key); firtTeamName = firtTeamName.Substring(startIndexFirst + key.Length, lastIndexFirst - startIndexFirst - key.Length); firtTeamName = string.Join("", firtTeamName.ToUpper().ToCharArray().Reverse().ToArray()); secondTeamName = secondTeamName.Substring(startIndexSecond + key.Length, lastIndexSecond - startIndexSecond - key.Length); secondTeamName = string.Join("", secondTeamName.ToUpper().ToCharArray().Reverse().ToArray()); long[] parsedResult = resultOfMatch.Split(':') .Select(long.Parse) .ToArray(); long goalsFirstTeam = parsedResult.First(); long goalsSecondTeam = parsedResult.Last(); if (!allTeams.ContainsKey(firtTeamName)) { allTeams[firtTeamName] = new TeamScore(); allTeams[firtTeamName].Goals = goalsFirstTeam; allTeams[firtTeamName].Points = GetPointsOfMatch(goalsFirstTeam, goalsSecondTeam); } else { allTeams[firtTeamName].Goals += goalsFirstTeam; allTeams[firtTeamName].Points += GetPointsOfMatch(goalsFirstTeam, goalsSecondTeam); } if (!allTeams.ContainsKey(secondTeamName)) { allTeams[secondTeamName] = new TeamScore(); allTeams[secondTeamName].Goals = goalsSecondTeam; allTeams[secondTeamName].Points = GetPointsOfMatch(goalsSecondTeam, goalsFirstTeam); } else { allTeams[secondTeamName].Goals += goalsSecondTeam; allTeams[secondTeamName].Points += GetPointsOfMatch(goalsSecondTeam, goalsFirstTeam); } } var orderedTeamsByPoints = allTeams.OrderByDescending(x => x.Value.Points) .ThenBy(x => x.Key).ToDictionary(k => k.Key, v => v.Value); Console.WriteLine("League standings:"); int i = 0; foreach (var item in orderedTeamsByPoints) { Console.WriteLine($"{++i}. {item.Key} {item.Value.Points}"); } var orderedTeamsByGoals = allTeams.OrderByDescending(x => x.Value.Goals) .ThenBy(x => x.Key).ToDictionary(k => k.Key, v => v.Value); Console.WriteLine("Top 3 scored goals:"); int j = 0; foreach (var item in orderedTeamsByGoals) { if (j > 2) { return; } Console.WriteLine($"- {item.Key} -> {item.Value.Goals}"); j++; } }
void Start() { tScore = GetComponent <TeamScore>(); pInfo = GetComponent <PlayerInfo>(); }
// public async Task<bool> RunTeamScoresForDate(RunTeamDateDto value) // { // // Get the current round // var round = await _content.Rounds.FromSql("SELECT * FROM Rounds where CAST(startDate AS INT) <= {0} and CAST(endDate AS INT) >= {0}", value.RunDate).FirstOrDefaultAsync(); // // What will be happening is for each userId // var users = await _content.Users.ToListAsync(); // foreach(var user in users) { // decimal daysScore = 0; // // Need to get the current rounds score // // Their teamDetails are got // var teamdetails = await _content.TeamDetails.FromSql("SELECT * FROM TeamDetails where userId = {0}", user.Id).ToListAsync(); // // Then for each teamdetail record // foreach(var teamdetail in teamdetails) { // // Check to see if there is a score for the player for the gameDate of value // var playerScore = await _content.PlayerScores.FromSql("SELECT * FROM PlayerScores where PlayerId = {0} and GameDate = {1}", teamdetail.PlayerId, value.RunDate).ToListAsync(); // if(playerScore.Count > 0) { // // if yes add the score to the team score after applying any bonuses (C or 6) // if(teamdetail.Position <= 10) { // if(teamdetail.Position == teamdetail.Captain) { // daysScore = daysScore + (playerScore[0].Score * 2); // } else if (teamdetail.Position == teamdetail.SixthMan) { // decimal tempValue = (decimal) playerScore[0].Score; // daysScore = daysScore + tempValue; // } else { // daysScore = daysScore + playerScore[0].Score; // } // } // } // } // // once all teamDetails are completed for the user, then update entry to the TeamScore table for the day // var teamScore = await _content.TeamScores.FirstOrDefaultAsync(t => t.RoundId == round.RoundNumber && t.UserId == user.Id); // // TeamScore ts = new TeamScore(); // teamScore.UserId = user.Id; // teamScore.RoundId = round.RoundNumber; // teamScore.Total = daysScore / 100; // // Now need to update the TeamScore // _content.TeamScores.Update(teamScore); // } // return await _content.SaveChangesAsync() > 0; // } public async Task <bool> RunTeamScoresForDate(RunTeamDateDto value) { // Get the current round var round = await _content.Rounds.FromSql("SELECT * FROM Rounds where CAST(startDate AS INT) <= {0} and CAST(endDate AS INT) >= {0}", value.RunDate).FirstOrDefaultAsync(); // What will be happening is for each userId var users = await _content.Users.ToListAsync(); foreach (var user in users) { decimal daysScore = 0; // Need to get the current rounds score // Their teamDetails are got var teamdetails = await _content.TeamDetails.FromSql("SELECT * FROM TeamDetails where userId = {0}", user.Id).ToListAsync(); // Then for each teamdetail record foreach (var teamdetail in teamdetails) { // Check to see if there is a score for the player for the gameDate of value var playerScore = await _content.PlayerScores.FromSql("SELECT * FROM PlayerScores where PlayerId = {0} and GameDate = {1}", teamdetail.PlayerId, value.RunDate).ToListAsync(); if (playerScore.Count > 0) { // if yes add the score to the team score after applying any bonuses (C or 6) if (teamdetail.Position <= 10) { if (teamdetail.Position == teamdetail.Captain) { daysScore = daysScore + (playerScore[0].Score * 2); } else if (teamdetail.Position == teamdetail.SixthMan) { decimal tempValue = (decimal)playerScore[0].Score; daysScore = daysScore + tempValue; } else { daysScore = daysScore + playerScore[0].Score; } } } } // // once all teamDetails are completed for the user, then update entry to the TeamScore table for the day // var teamScore = await _content.TeamScores.FirstOrDefaultAsync(t => t.RoundId == round.RoundNumber && t.UserId == user.Id); // // TeamScore ts = new TeamScore(); // // teamScore.UserId = user.Id; // // teamScore.RoundId = round.RoundNumber; // // teamScore.Total = daysScore / 100; // // // Now need to update the TeamScore // // _content.TeamScores.Update(teamScore); var teamScore = _content.TeamScores.FirstOrDefault(t => t.RoundId == round.RoundNumber && t.UserId == user.Id); TeamScore ts = new TeamScore(); if (teamScore == null) { // ts.UserId = user.Id; // ts.RoundId = round.RoundNumber; // ts.Total = (int)daysScore; // // Create a new record // await _content.TeamScores.AddAsync(ts); } else { // ts.Id = teamScore.Id; teamScore.UserId = user.Id; teamScore.RoundId = round.RoundNumber; teamScore.Total = (int)daysScore; // Update _content.TeamScores.Update(teamScore); } } return(await _content.SaveChangesAsync() > 0); }
// Start is called before the first frame update void Start() { foreach (Transform t in Scores) { Destroy(t.gameObject); } winText.text = PlayerController.Instance.NumberOfWins + " required to win!"; minuteSuddendeathText.text = PlayerController.Instance.SuddenDeathTimerStart + "s to Suddendeath!"; List <PlayerData> playerDatas = PlayerController.Instance.Players; Dictionary <Teams, int> teamToScore = new Dictionary <Teams, int>(); foreach (PlayerData pd in playerDatas) { if (pd.Team == Teams.NoTeam) { continue; } if (teamToScore.ContainsKey(pd.Team)) { teamToScore[pd.Team] += pd.numberOfWins; } else { teamToScore[pd.Team] = pd.numberOfWins; } } if (teamToScore.Count > 0) { foreach (Teams t in teamToScore.Keys) { TeamScore TeamScore = Instantiate(TeamScorePrefab); TeamScore.Show(playerDatas.FindAll(x => x.Team == t).ToArray(), teamToScore[t]); TeamScore.transform.SetParent(Scores, false); } } foreach (PlayerData pd in playerDatas) { if (pd.Team != Teams.NoTeam) { continue; } PlayerScore PlayerScore = Instantiate(PlayerScorePrefab); PlayerScore.Show(pd.Character, pd.numberOfWins); PlayerScore.transform.SetParent(Scores, false); } string WonText = ""; GameWon = false; if (teamToScore.Count > 0) { foreach (Teams t in teamToScore.Keys) { if (teamToScore[t] == PlayerController.Instance.NumberOfWins) { WonText = t + " has won!"; GameWon = true; } } } else { foreach (PlayerData pd in PlayerController.Instance.Players) { if (pd.numberOfWins == PlayerController.Instance.NumberOfWins) { WonText = "Player " + pd.PlayerNumber + " (" + pd.Character + ")\n has won!"; GameWon = true; } } } if (GameWon) { winText.gameObject.transform.parent.gameObject.SetActive(false); hasWonText.gameObject.SetActive(true); hasWonText.text = WonText; GetComponent <AudioSource>().PlayOneShot(GameOverSound); PressSpaceContinue.onClick.AddListener(ReturnMenu); PressESCtoQuit.onClick.AddListener(ReturnMenu); } else { GetComponent <AudioSource>().PlayOneShot(WinSound); PressSpaceContinue.onClick.AddListener(NextRound); PressESCtoQuit.onClick.AddListener(ReturnMenu); } PlayerController.Instance.AdvanceNextMap(); }
/// <summary> /// Score the race. /// </summary> public virtual void ComputeScore() { if(IsScored || Results.Count == 0) { return; } ScoresCollection = new List<TeamScore>(); IDictionary<Team, TeamScore> scores = new Dictionary<Team, TeamScore>(); IEnumerable<Team> teams = (from result in Results.Values where result.Team != null select result.Team).Distinct(); foreach(Team team in teams) { scores[team] = new TeamScore(this, team); } // Add the runners to the school // Sort the results IEnumerable<Performance> results = Results.Values.Sorted(); foreach(Performance result in results.Where(r => r.Team != null)) { result.Points = 0; scores[result.Team].AddRunner(result); } //Tag runners on teams with fewer than five as scoreless //Tag runner 8 and beyond on each team as scorelss foreach(TeamScore score in scores.Values) { int runnerCount = score.Runners.Count(); IEnumerable<Performance> scorelessRunners = Enumerable.Empty<Performance>(); if(runnerCount < 5) { scorelessRunners = score.Runners; } else if(runnerCount > 7) { scorelessRunners = score.Runners.Skip(7); } foreach(Performance runner in scorelessRunners) { runner.Points = null; } } // Tag first runner on a complete team with a score as the winner Performance firstRunnerOnCompleteTeam = results.FirstOrDefault(r => r.HasPoints); if(firstRunnerOnCompleteTeam == default(Performance)) { return; } firstRunnerOnCompleteTeam.Points = 1; // Tag each runner with their points results.Where(result => result.HasPoints) .ForEachIndexedPair(2, (previous, runner, points) => { if(runner.Time != previous.Time) { runner.Points = points; } else { runner.Points = previous.Points; } }); // Create the final list ScoresCollection.Clear(); ScoresCollection.AddRange(scores.Values.Sorted()); IsScored = true; }
//Resets all outputs, scores, and game state to idle values (motors will continue until back to start position) public void Reset() { TeamGame.Reset(); TeamControl.Reset(); TeamScore.Reset(); }