public PrintViewModel(IEnumerable <ResultScore> scores, string group) : this() { Group = group; int lastposition = 0; int count = 1; ResultScore lastItem = null; int color = 0; foreach (var score in scores.OrderByDescending(s => s.FirstScore).ThenByDescending(s => s.SecondScore).ThenBy(s => s.Player)) { string position; if (score.Compare(lastItem)) { count++; position = string.Empty; } else { lastposition += count; position = lastposition.ToString(); count = 1; } Scores.Add(new PrintViewModelItem(position, score, color % 2 == 0 ? Colors.White : Colors.AliceBlue)); lastItem = score; color++; } }
/// <summary> /// Saves high scores /// </summary> /// <param name="playerWins"></param> /// <returns></returns> public void saveHighScores(bool playerWins) { String filename = @"../../scores.txt"; bool found = false; List <string> scoresString = new List <String>(); for (int i = 0; i < Scores.Count; i++) { if (Scores[i].Name == playerName && Scores[i].GameMode == GameMode) { if (playerWins) { Scores[i].Wins++; } else { Scores[i].Losses++; } found = true; } scoresString.Add(Scores[i].SaveString()); } if (!found) { Scores.Add(new Score($"{playerName} {(playerWins ? 1 : 0)} {(playerWins ? 0 : 1)} {GameMode}")); scoresString.Add(Scores[Scores.Count - 1].SaveString()); } File.WriteAllLines(filename, scoresString); }
public void AddScore() { if (GuestScoreToggle.isOn) { Debug.Log("Add Score (for Guest). Click to see source."); var scoreValue = ScoreValueField.text != string.Empty ? int.Parse(ScoreValueField.text) : 0; var tableId = TableField.text != string.Empty ? int.Parse(TableField.text) : 0; Scores.Add(scoreValue, ScoreTextField.text, GuestNameField.text, tableId, "", success => { AddConsoleLine("Score Add (for Guest) {0}.", success ? "Successful" : "Failed"); }); } else { Debug.Log("Add Score (for Guest). Click to see source."); var scoreValue = ScoreValueField.text != string.Empty ? int.Parse(ScoreValueField.text) : 0; var tableId = TableField.text != string.Empty ? int.Parse(TableField.text) : 0; Scores.Add(scoreValue, ScoreTextField.text, tableId, "", success => { AddConsoleLine("Score Add {0}.", success ? "Successful" : "Failed"); }); } }
public void PostToHighscoresAsGuest() { int randomNumber = Random.Range(0, 10000); // There's a parameter for specifying a guest name. Scores.Add(randomNumber, randomNumber.ToString(), SystemInfo.deviceModel + "@" + SystemInfo.batteryLevel); }
public void RegisterAndShowScores() { Scene currentScene = SceneManager.GetActiveScene(); if (m_tableDic.ContainsKey(currentScene.name)) { int tableID = m_tableDic[currentScene.name]; //int tableID = 381463; // Set it to 0 for main highscore table. string text = "Time (ms)"; // A string representing the score to be shown on the website. Action <bool> addScore = s => { OnScoreAdded?.Invoke(s); Scores.Get(OnScoreShow, table: tableID, limit: 10); }; int milliseconds = (int)(Timer * 1000); if (GameJoltAPI.Instance.HasSignedInUser) { Scores.Add(milliseconds, text, tableID, "", addScore); } else { // Guest Scores.Add(milliseconds, text, GuestName, table: tableID, callback: addScore); } } else { Debug.LogError("Table " + currentScene.name + " not found."); } }
//Gets the high scores from a file and sorts them based on score. public void GetHighScores() { StreamReader reader; string filename = "HighScores.txt"; if (File.Exists(filename)) { using (reader = new StreamReader(filename)) { string entry = reader.ReadLine(); while (entry != null) { string[] score = entry.Split(':'); score[1].Trim(' '); HighScore highscore = new HighScore(score[0], Convert.ToInt32(score[1])); Scores.Add(highscore); entry = reader.ReadLine(); } } Scores.Sort(); Scores.Reverse(); } else { File.Create(filename); } }
//Adds a score to the Scores list and sorts the list. //Adds the score to the score file. public void AddHighScore(HighScore score) { Scores.Add(score); Scores.Sort(); Scores.Reverse(); SaveHighScores(); }
public Scores GetScores() { /* * [ * {"playerID":"mickey","highscore":"48"}, * {"playerID":"12","highscore":"32"}, * {"playerID":"sdfsdf","highscore":"2"} * ] */ var scores = new Scores(); string url = uri + gameID + @"/rankedlist"; HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest; request.Accept = "application/json"; using (HttpWebResponse response = request.GetResponse() as HttpWebResponse) { if (response.StatusCode != HttpStatusCode.OK) { throw new System.Exception(string.Format( "Server error (HTTP {0}: {1}).", response.StatusCode, response.StatusDescription)); } else { using (var sr = new StreamReader(response.GetResponseStream())) { var text = sr.ReadToEnd(); var jsonDic = MiniJSON.Json.Deserialize(text) as List <object>; if (jsonDic != null) { int c = 1; foreach (var k in jsonDic) { var dict = k as Dictionary <string, object>; string name = (string)dict["playerID"]; int score = int.Parse((string)dict["highscore"]); scores.Add(new Score(name, score, c++)); if (c > 10) { break; } } return(scores); } } } } return(null); }
public void MergeLastDarts(bool discard, Leg leg, int currentTurn) { if (!discard) { foreach (var dart in LastDarts) { dart.ScoredInLeg = leg; dart.TurnNumber = currentTurn; Scores.Add(dart); } var scoreToAdd = new Score { TurnNumber = currentTurn, ScoredInLeg = leg, Value = CurrentScore, DartScore = LastDarts.Sum(m => m.Value) }; TurnScores.Insert(0, scoreToAdd); } else { CurrentDartCount -= LastDarts.Count; } LastDarts.Clear(); }
public void OnTileSelected(Tile selected) { List <Tile> adjacentTiles = GetAdjacentTiles(selected); if (_previousTile == null) { _previousTile = selected; } else { _previousTile.Deselect(); if (adjacentTiles.Contains(_previousTile)) { _scores.Add(10); SwapDots(selected, _previousTile); StartCoroutine(ShiftTiles(_previousTile, selected)); selected.Deselect(); _previousTile = null; } else { _previousTile = selected; } } }
public void AddScore(ScoreInformation info) { if (!manager.StopScore) { Scores.Add(info); } }
public void AddPointTo(Player p) { if (Scores.ContainsKey(p)) { Scores[p].Score++; } else { Scores.Add(p, new PlayerScore() { Score = 1 }); } if (Scores.ContainsKey(p)) { if (p.Token == Token.Black) { GetCountScorePlayerBlack++; } else { GetCountScorePlayerWhite++; } } MovesCount++; }
public void AddScore(int score) { Scores.Add(score); var scoreIndex = Scores.Count - 1; if (score == PerfectScore) { var prevIndex = scoreIndex - 1; if (prevIndex >= 0) { if (_spareIndex == prevIndex || _strikeIndexes.Contains(prevIndex)) { AddStrike(scoreIndex); } else { AddSpare(scoreIndex); } } else { AddStrike(scoreIndex); } } if (!IsSpare && Scores.Count >= 2) { var last2 = Scores.Skip(Math.Max(0, Scores.Count - 2)); if (last2.Sum() == PerfectScore) { AddSpare(scoreIndex); } } }
public void SwapTeams() { string AuxTeamID = Team1ID; Team1ID = Team2ID; Team2ID = AuxTeamID; SoccerTeam auxTeam = Team1; Team1 = Team2; Team2 = auxTeam; Teams.Clear(); Teams.Add(Team1ID, Team1); Teams.Add(Team2ID, Team2); Scores.Clear(); Scores.Add(Team1ID, 0); Scores.Add(Team2ID, 0); Fouls.Clear(); Fouls.Add(Team1ID, 0); Fouls.Add(Team2ID, 0); PlayingTeamID = Team1ID; AwaitingTeamID = Team2ID; }
private void CalculateScore(List <ScoreFormula> scoreFormulas) { if (scoreFormulas == null) { return; } Scores.Clear(); var filteredScoreFormulas = scoreFormulas .Where(s => s.Grade == Grade).ToList(); if (filteredScoreFormulas.Count == 0) { filteredScoreFormulas = scoreFormulas; } foreach (var formula in filteredScoreFormulas) { var score = formula.BasePoint + formula.Coefficients .Select(c => c.Coefficient * Sections.FirstOrDefault(s => s.LessonName == c.Lesson)?.Net ?? 0) .Sum(); Scores.Add(formula.ScoreName.ToUpper(), (float)Round(score * 100) / 100); } }
public HighScoreModel(List <ScoreDTO> highscore) { this.Scores = new List <ScoreModel>(); foreach (var s in highscore) { Scores.Add(new ScoreModel(s)); } }
public void PostToHighscoresAsUser() { int randomNumber = Random.Range(0, 10000); // First parameter is number value, second is what is seen // Example: 100, "100 jumps" Scores.Add(randomNumber, randomNumber.ToString()); }
//Hides the form so that data can still be retrived, button returns an OK dialog result private void BtnOK_Click(object sender, EventArgs e) { foreach (var item in lstScores.Items) { Scores.Add((int)item); } Hide(); }
public void Construct(IScoreViewManager scoreViewManager) { this.Scores = new Dictionary <Players, int>(); this.scoreViewManager = scoreViewManager; foreach (Players p in System.Enum.GetValues(typeof(Players))) { Scores.Add(p, 0); } }
public Form1() { InitializeComponent(); Scores.Add(new PScore() { PlayerName = "babs", Punten = points }); ScoreBoard.DataSource = Scores; }
public Score GetScore(Difficulty difficulty) { if (!Scores.ContainsKey(difficulty)) { var score = new Score(this, difficulty); Scores.Add(difficulty, score); } return(Scores[difficulty]); }
public void RefreshList() { Scores.Clear(); foreach (var score in _gameRepository.Score) { Scores.Add(score); } }
public void Begin() { Player.Name = SetPlayersName(); Console.WriteLine($"Hi {Player.Name}!"); PrintAvailableMovements(); DisplayMoveDialog(); Scores.Add(Player); SortedScores = Scores.OrderByDescending(o => o.Score).Take(10).ToList(); DisplayScore(); }
public static void Connect(Scores scoreboard, Player player) { var r = HommRules.Current; var id = player.Name; player.UnitsAdded += (unit, count) => scoreboard.Add(id, r.Units.Scores[unit] * count, $"{count} {unit} {(count == 1 ? "is" : "are")} hired.", "Military", "Main"); player.ResourcesGained += (res, count) => scoreboard.Add(id, r.ResourcesGainScores, $"Got {count} {res}.", "Economics", "Main"); player.OwnMineForOneDay += _ => scoreboard.Add(id, r.MineOwningDailyScores, "Mine is owned.", "Domination", "Main"); player.VictoryAchieved += (opponent, army) => scoreboard.Add(id, GetArmyDefeatBonus(army), "Victory is achieved in combat.", "War", "Main"); scoreboard.Add(id, 0, "Initial score", "Military", "Economics", "Domination", "War", "Main"); }
public Scores GetScores() { /* * [ * {"playerID":"mickey","highscore":"48"}, * {"playerID":"12","highscore":"32"}, * {"playerID":"sdfsdf","highscore":"2"} * ] */ var scores = new Scores(); string url = uri + gameID + @"/rankedlist"; HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest; request.Accept = "application/json"; using (HttpWebResponse response = request.GetResponse() as HttpWebResponse) { if (response.StatusCode != HttpStatusCode.OK) throw new System.Exception(string.Format( "Server error (HTTP {0}: {1}).", response.StatusCode, response.StatusDescription)); else { using (var sr = new StreamReader(response.GetResponseStream())) { var text = sr.ReadToEnd(); var jsonDic = MiniJSON.Json.Deserialize(text) as List<object>; if (jsonDic != null) { int c = 1; foreach (var k in jsonDic) { var dict = k as Dictionary<string, object>; string name = (string)dict["playerID"]; int score = int.Parse((string)dict["highscore"]); scores.Add(new Score(name, score, c++)); if (c > 10) break; } return scores; } } } } return null; }
public void FilterCommand() { Scores.Clear(); foreach (var score in myScores) { if (score.StudentName == StudentName) { Scores.Add(score); } } }
//Adds new score to list and displays updated list private void BtnAddScore_Click(object sender, EventArgs e) { int score; int.TryParse(txtScore.Text, out score); if (score > 0 && score <= 100) { Scores.Add(score); DisplayScores(); txtScore.Text = ""; } }
public PrintDayViewModel(IEnumerable <ResultScore> scores) { Group = "Tagessieger"; int color = 0; foreach (var score in scores.OrderBy(s => s.Date)) { Scores.Add(new PrintViewModelItem(score.Date.ToString("dd.MM.yyyy"), score, color % 2 == 0 ? Colors.White : Colors.AliceBlue)); color++; } }
public bool Add(Tuple <int, int> score) { if (score.Item1 + score.Item2 < 0) { return(false); } if (score.Item1 + score.Item2 > 10) { return(false); } if (Scores.Count == NbMaxManche) { Tuple <int, int> last = Scores.Last(); if (IsStrike(last)) { Scores.Add(score); return(true); } else if (IsSpare(last)) { if (score.Item2 == 0) { Scores.Add(score); return(true); } else { return(false); } } return(false); } else if (Scores.Count == NbMaxManche + 1) { Tuple <int, int> last = Scores.Last(); if (IsStrike(last)) { Scores.Add(score); return(true); } else { return(false); } } else if (Scores.Count > NbMaxManche + 2) { return(false); } Scores.Add(score); return(true); }
public ClassifyArea Process(long cnt, AreaSentiExtract post) { // find areas var pt = new LatLong(post.Xloc, post.Yloc); var regions = Sad.WhatRegions(pt); var score = new LocatedAreaScore(post, regions); Scores.Add(score); return(this); }
public Classify Process(long cnt, GeoSentimentParameters post) { // find areas var pt = new LatLong(post.Xloc, post.Yloc); var regions = Sad.WhatRegions(pt); var score = new LocatedScore(post, regions); Scores.Add(score); return(this); }