private TimelineLiveElement getBaseDiff(LiveElementBase curr)
    {
        var diff = new TimelineLiveElement()
        {
            id = curr.id
        };

        var diffExplains = new List <Explain>();

        foreach (var explain in curr.explain)
        {
            var diffExplain = new Explain()
            {
                fixture = explain.fixture
            };
            diff.explain.Add(diffExplain);
            var diffStats = new List <ExplainElement>();
            foreach (var stat in explain.stats)
            {
                if (stat.points != 0 || stat.value != 0)
                {
                    diffStats.Add(stat);
                }
            }
            if (diffStats.Count > 0)
            {
                diffExplain.stats = diffStats;
            }
        }
        diff.CalcScore();
        var anyStats = diff.explain.Any(ex => ex.stats.Count > 0);

        return(anyStats ? diff : null);
    }
    public async Task <TimelineLiveElement> Predict(TimelineLiveElement current)
    {
        var prediction = new TimelineLiveElement(current);

        foreach (var fixturePrediction in prediction.explain)
        {
            var fixtureId = fixturePrediction.fixture;
            var fixtures  = await _client.GetFixtures(_gameweek);

            var fixture = fixtures.FirstOrDefault(f => f.id == fixtureId);
            if (fixture != null)
            {
                MakePrediction(current, fixture, fixturePrediction);
            }

            // Ideas:

            /*
             *  If fixture is on:
             *      If player is playing: +1 (don't bother adding? since it gets added anyway)
             *      If player is playing, <60min and could possibly get to 60min, +1
             *      If gk/def still has CS (note: goals scored while player is out don't count... check CS rules): +4
             *      If mid still has CS: +1
             *      Mid/striker +avg, scale down based on time left in fixture, floor it on actual score
             *
             *      Potential subs???? Add sub pts (if sub is valid)
             *  "High" prediction:
             */
        }
        prediction.CalcScore();
        return(prediction);
    }
    private TimelineLiveElement Compare(LiveElementBase prev, LiveElementBase curr)
    {
        var diff = new TimelineLiveElement()
        {
            id = curr.id
        };

        for (var i = 0; i < curr.explain.Count; i++)
        {
            var allExplainIdentifiers = new HashSet <string>(curr.explain[i].stats.Select(s => s.identifier).ToHashSet());
            if (prev != null && prev.explain != null && prev.explain.Count > i)
            {
                foreach (var stat in prev.explain[i].stats)
                {
                    allExplainIdentifiers.Add(stat.identifier);
                }
            }

            var currFixtureExplain = curr.explain[i];
            var prevFixtureExplain = prev != null && prev.explain != null && prev.explain.Count > i ? prev.explain[i] : null;
            var diffExplain        = new Explain()
            {
                fixture = currFixtureExplain.fixture,
                stats   = new List <ExplainElement>()
            };
            diff.explain.Add(diffExplain);

            foreach (var explainIdentifier in allExplainIdentifiers)
            {
                var currStat = currFixtureExplain.stats.FirstOrDefault(e => e.identifier.Equals(explainIdentifier));
                var prevStat = prevFixtureExplain != null?prevFixtureExplain.stats.FirstOrDefault(s => s.identifier.Equals(explainIdentifier)) : null;

                if (prevStat == null)
                {
                    prevStat = new ExplainElement()
                    {
                        identifier = explainIdentifier
                    };
                }
                if (currStat == null)
                {
                    currStat = new ExplainElement()
                    {
                        identifier = explainIdentifier
                    };
                }
                var statDiff = GetExplainDiff(currStat, prevStat);
                if (statDiff != null)
                {
                    diffExplain.stats.Add(statDiff);
                }
            }
        }

        var saveDiff = diff.explain.Any(ex => ex.stats.Count > 0);

        if (saveDiff)
        {
            diff.CalcScore();
            return(diff);
        }

        return(null);
    }