private static void AddPreviousGameweekToInput(ModelInput input, ElementHistory elementHistory, Fixture fixture, int currentEventId) { Type inputType = typeof(ModelInput); if (elementHistory.Round >= currentEventId) { return; } int gameweekLessIndex = currentEventId - elementHistory.Round; PropertyInfo isValidProperty = inputType.GetProperty($"Isvalidgw_less_{gameweekLessIndex}"); PropertyInfo minutesProperty = inputType.GetProperty($"Minutesgw_less_{gameweekLessIndex}"); PropertyInfo pointsProperty = inputType.GetProperty($"Pointsgw_less_{gameweekLessIndex}"); PropertyInfo influenceProperty = inputType.GetProperty($"Influencegw_less_{gameweekLessIndex}"); PropertyInfo creativityProperty = inputType.GetProperty($"Creativitygw_less_{gameweekLessIndex}"); PropertyInfo threatProperty = inputType.GetProperty($"Threatgw_less_{gameweekLessIndex}"); PropertyInfo atHomeProperty = inputType.GetProperty($"Athomegw_less_{gameweekLessIndex}"); PropertyInfo difficultyProperty = inputType.GetProperty($"Difficultygw_less_{gameweekLessIndex}"); SetValueByAnyMeans(input, isValidProperty, 1f); SetValueByAnyMeans(input, minutesProperty, elementHistory.Minutes); SetValueByAnyMeans(input, pointsProperty, elementHistory.TotalPoints); SetValueByAnyMeans(input, influenceProperty, float.Parse(elementHistory.Influence)); SetValueByAnyMeans(input, creativityProperty, float.Parse(elementHistory.Creativity)); SetValueByAnyMeans(input, threatProperty, float.Parse(elementHistory.Threat)); float atHome = elementHistory.WasHome ? 1 : 0; float difficulty = elementHistory.WasHome ? fixture.HomeTeamDifficulty : fixture.AwayTeamDifficulty; SetValueByAnyMeans(input, atHomeProperty, atHome); SetValueByAnyMeans(input, difficultyProperty, difficulty); }
private PreviousMatch BuildPreviousMatch(ElementHistory history, Fixture fixture) { var previousMatch = new PreviousMatch(); if (history != null || fixture != null) { previousMatch.IsValid = 1; previousMatch.Minutes = history.Minutes; previousMatch.Points = history.TotalPoints; previousMatch.Influence = double.Parse(history.Influence); previousMatch.Creativity = double.Parse(history.Creativity); previousMatch.Threat = double.Parse(history.Threat); previousMatch.AtHome = history.WasHome ? 1 : 0; previousMatch.Difficulty = history.WasHome ? fixture.HomeTeamDifficulty : fixture.AwayTeamDifficulty; } else { previousMatch.IsValid = 0; previousMatch.Minutes = 0; previousMatch.Points = 0; previousMatch.Influence = 0; previousMatch.Creativity = 0; previousMatch.Threat = 0; previousMatch.AtHome = 0; previousMatch.Difficulty = 0; } return(previousMatch); }