/// <summary> /// Get facts about a side's performance in the game. /// </summary> /// <param name="side">The side to get facts about.</param> /// <returns>The game facts.</returns> public GameFacts GetGameFacts(MatchSide side) { //Create the game facts instance. GameFacts facts = new GameFacts(null); facts.MatchSide = side; //See which side to get data from. if (side == MatchSide.Home) { //Fill the facts instance with data. facts.Profile = (Profile)cmbHomeProfile.SelectedItem; facts.Team = facts.Profile.Team; facts.Shots = (int)nmrHomeShots.Value; facts.ShotsOnTarget = (int)nmrHomeShotsOnTarget.Value; facts.ShotAccuracy = facts.ShotsOnTarget == 0 ? 0 : (int)(100 * (float)facts.ShotsOnTarget / (float)facts.ShotsOnTarget); facts.PassAccuracy = (int)nmrHomePassAccuracy.Value; facts.Corners = (int)nmrHomeCorners.Value; facts.Possession = (100 - trkbPossession.Value); //The goals scored and the goals conceded. foreach (ListViewItem item in lstvHomeGoals.Items) { //Find out which goals facts.GoalsScored.Add((Goal)item.Tag); } foreach (ListViewItem item in lstvAwayGoals.Items) { facts.GoalsConceded.Add((Goal)item.Tag); } } else { //Fill the facts instance with data. facts.Profile = (Profile)cmbAwayProfile.SelectedItem; facts.Team = facts.Profile.Team; facts.Shots = (int)nmrAwayShots.Value; facts.ShotsOnTarget = (int)nmrAwayShotsOnTarget.Value; facts.ShotAccuracy = facts.ShotsOnTarget == 0 ? 0 : (int)(100 * (float)facts.ShotsOnTarget / (float)facts.ShotsOnTarget); facts.PassAccuracy = (int)nmrAwayPassAccuracy.Value; facts.Corners = (int)nmrAwayCorners.Value; facts.Possession = trkbPossession.Value; //The goals scored and the goals conceded. foreach (ListViewItem item in lstvAwayGoals.Items) { facts.GoalsScored.Add((Goal)item.Tag); } foreach (ListViewItem item in lstvHomeGoals.Items) { facts.GoalsConceded.Add((Goal)item.Tag); } } //Return the facts. return facts; }
/// <summary> /// Initialize the game. /// </summary> /// <param name="id">The id of the game.</param> protected void Initialize(int id) { //Initialize some stuff. _Id = id; _FIFAVersion = Summary.Instance.CurrentFIFAVersion; _Date = DateTime.Now; _ExtraTime = false; _HomeFacts = new GameFacts(null); _AwayFacts = new GameFacts(null); //Get an id. if (_Id == -1) { Summary.Instance.GrantGameId(this); } }