public string FindCommentary(MatchEventType Ev, MatchStatus ms) { string retVal = ""; List <MatchEventCommentary> PossComment = (from C in CommentaryList where C.EventType == Ev && (C.Segment == MatchSegment.None || C.Segment == ms.Segment) select C).ToList(); retVal = PossComment[0].RawText; return(retVal); }
public void PopulatePlayerStatuses(MatchStatus ms, Fixture f) { List <PlayerStatus> StatusList; for (int t = 0; t <= 1; t++) { ms.OverallPlayerEffectiveRating[t] = 0; TeamAdapter ta = new TeamAdapter(); Team Team = ta.GetTeam(f.TeamIDs[t]); PlayerAdapter pa = new PlayerAdapter(); StatusList = new List <PlayerStatus>(); TacticEvaluation Eval = new TacticEvaluation(); int selected = 0; int totalEffectiveRating = 0; const double HealthDeteriorationPower = 4; foreach (KeyValuePair <int, TeamPlayer> kvp in Team.Players) { Player p = pa.GetPlayer(kvp.Value.PlayerID); PlayerStatus ps = new PlayerStatus(); ps.PlayerID = kvp.Value.PlayerID; ps.Playing = kvp.Value.Selected; ps.CurrentHealth = p.Health; ps.CurrentHealthDeterioration = Math.Pow(1 - (Convert.ToDouble(p.Fitness) / 100), HealthDeteriorationPower); if (ps.Playing == PlayerSelectionStatus.Starting) { selected++; PlayerPosition pos = GridLengthToPosition(kvp.Value); ps.EffectiveRating = CalculatePlayerEffectivenessInPosition(kvp.Value); totalEffectiveRating += ps.EffectiveRating; Eval.AddRatingForPosition(pos, ps.EffectiveRating); StatusList.Add(ps); } ps = null; } ms.OverallPlayerEffectiveRating[t] = (selected > 0 ? totalEffectiveRating / selected : 0); ms.PlayerStatuses[t] = StatusList; ms.Evaluation[t] = Eval; StatusList = null; } }
public void UpdatePlayerHealthForWorld(MatchStatus ms) { PlayerAdapter pa = new PlayerAdapter(); for (int t = 0; t <= 1; t++) { for (int s = 0; s < ms.PlayerStatuses[t].Count; s++) { PlayerStatus stat = ms.PlayerStatuses[t][s]; Player p = pa.GetPlayer(stat.PlayerID); p.Health = stat.CurrentHealth; pa.UpdatePlayer(p); } } }
public void UpdatePlayerHealthForMatch(MatchStatus ms) { for (int t = 0; t <= 1; t++) { for (int s = 0; s < ms.PlayerStatuses[t].Count; s++) { PlayerStatus stat = ms.PlayerStatuses[t][s]; if (stat.Playing == PlayerSelectionStatus.Starting) { stat.CurrentHealth -= stat.CurrentHealthDeterioration; if (stat.CurrentHealth < 0) { stat.CurrentHealth = 0; } ms.PlayerStatuses[t][s] = stat; } } } }
public void StartMatch() { mps = new MatchPlayerSupport(Interactive); if (Fixture == null) { throw new ArgumentNullException("Fixture not set"); } if (Interactive == true && MatchCallback == null) { throw new ArgumentNullException("MatchCallback not set"); } MatchStatus = new MatchStatus(); MatchCallback.MatchStarting(Fixture, Interactive); for (int h = 1; h <= 2; h++) { MatchStatus.Segment = (h == 1 ? MatchSegment.FirstHalf : MatchSegment.SecondHalf); mps.PopulatePlayerStatuses(MatchStatus, Fixture); MatchStatus.BallX = BALLXCENTRE; MatchStatus.BallY = BALLYCENTRE; MatchStatus.PossessionTeam = h - 1; // TODO: Randomise for the start, but opposite team for second half. RaiseEvent(MatchEventType.KickOff); // TODO: Just in case we change the grid, this may need to change. But gets us whole numbers. //MatchStatus.BallX = (PossessionHome() ? Math.Floor(MatchStatus.BallX) : Math.Ceiling(MatchStatus.BallX)); for (int s = 0; s <= Constants.MinsPerHalf * 60 - Constants.EventIntervalSecs; s += Constants.EventIntervalSecs) { MatchStatus.TotalTimeUnits++; MatchStatus.SegmentTimeSeconds = s; MatchStatus.MatchTimeSeconds += Constants.EventIntervalSecs; DetermineNextEvent(); mps.UpdatePlayerHealthForMatch(MatchStatus); } MatchStatus.BallX = BALLXCENTRE; MatchStatus.BallY = BALLYCENTRE; if (h == 1) { RaiseEvent(MatchEventType.HalfTime); } else { RaiseEvent(MatchEventType.FullTime); } RaiseEvent(h == 1 ? MatchEventType.HalfTime : MatchEventType.FullTime); } Fixture.Score[0] = MatchStatus.Score[0]; Fixture.Score[1] = MatchStatus.Score[1]; Fixture.Played = true; FixtureAdapter fa = new FixtureAdapter(); fa.UpdateFixture(Fixture); mps.UpdatePlayerHealthForWorld(MatchStatus); MatchCallback.MatchFinished(Fixture, Interactive); }