Пример #1
0
    public async Task <ProcessedPlayer> process()
    {
        _previousData = await _playerProvider.getPlayer(_footballer.id);

        if (_currentExplains == null)
        {
            _log.Warn(string.Format("No explains: {0}\n", _footballer.web_name));
            return(_previousData);
        }

        ProcessedPlayer currentPlayerData = new ProcessedPlayer(_footballer, _currentExplains, _previousData);

        determineFixtureStatus(currentPlayerData);
        var prevElements = _previousData != null && _previousData.rawData != null ?_previousData.rawData.explain : new List <FootballerScoreDetailElement>();
        List <FootballerScoreDetailElement> currExplains = _currentExplains;

        for (var i = 0; i < currExplains.Count; i++)
        {
            FootballerScoreDetailElement prevExplain = i < prevElements.Count ? prevElements[i] : null;
            FootballerScoreDetailElement diff        = getPlayerDiff(currExplains[i], prevExplain);
            addNewEvents(currentPlayerData.events, diff, _footballer, currExplains[i]);
        }

        return(currentPlayerData);
    }
 private void setField(FootballerScoreDetailElement element, String fieldName, ScoreExplain explain)
 {
     try {
         var field = typeof(FootballerScoreDetailElement).GetProperty(fieldName);
         field.SetValue(element, explain);
     } catch (Exception e) {
         _log.Error(e);
     }
 }
    public static List <MatchEvent> createNewEvents(FootballerScoreDetailElement detailsDiff, Footballer footballer, FootballerScoreDetailElement currentDetail)
    {
        var      events = new List <MatchEvent>();
        DateTime time   = DateTime.Now;

        if (detailsDiff.assists.value != 0)
        {
            events.Add(createMatchEvent(time, MatchEventType.ASSIST, footballer, detailsDiff.assists.value, detailsDiff.assists.points));
        }
        if (detailsDiff.goals_scored.value != 0)
        {
            events.Add(createMatchEvent(time, MatchEventType.GOAL, footballer, detailsDiff.goals_scored.value, detailsDiff.goals_scored.points));
        }
        if (detailsDiff.minutes.points != 0)
        {
            events.Add(createMatchEvent(time, MatchEventType.MINUTES_PLAYED, footballer, currentDetail.minutes.value, detailsDiff.minutes.points));
        }
        if (detailsDiff.clean_sheets.value != 0)
        {
            events.Add(createMatchEvent(time, MatchEventType.CLEAN_SHEET, footballer, detailsDiff.clean_sheets.value, detailsDiff.clean_sheets.points));
        }
        if (detailsDiff.bonus.value != 0)
        {
            events.Add(createMatchEvent(time, MatchEventType.BONUS, footballer, detailsDiff.bonus.value, detailsDiff.bonus.points));
        }
        if (detailsDiff.yellow_cards.value != 0)
        {
            events.Add(createMatchEvent(time, MatchEventType.YELLOW_CARD, footballer, detailsDiff.yellow_cards.value, detailsDiff.yellow_cards.points));
        }
        if (detailsDiff.red_cards.value != 0)
        {
            events.Add(createMatchEvent(time, MatchEventType.RED_CARD, footballer, detailsDiff.red_cards.value, detailsDiff.red_cards.points));
        }
        if (detailsDiff.penalties_missed.value != 0)
        {
            events.Add(createMatchEvent(time, MatchEventType.PENALTY_MISS, footballer, detailsDiff.penalties_missed.value, detailsDiff.penalties_missed.points));
        }
        if (detailsDiff.goals_conceded.value != 0)
        {
            events.Add(createMatchEvent(time, MatchEventType.GOALS_CONCEDED, footballer, detailsDiff.goals_conceded.value, detailsDiff.goals_conceded.points));
        }
        if (detailsDiff.saves.value != 0)
        {
            events.Add(createMatchEvent(time, MatchEventType.SAVES, footballer, detailsDiff.saves.value, detailsDiff.saves.points));
        }
        if (detailsDiff.penalties_saved.value != 0)
        {
            events.Add(createMatchEvent(time, MatchEventType.PENALTY_SAVES, footballer, detailsDiff.penalties_saved.value, detailsDiff.penalties_saved.points));
        }
        if (detailsDiff.own_goals.value != 0)
        {
            events.Add(createMatchEvent(time, MatchEventType.OWN_GOALS, footballer, detailsDiff.own_goals.value, detailsDiff.own_goals.points));
        }
        printMatchEvents(events);
        return(events);
    }
Пример #4
0
 public void set(FootballerScoreDetailElement other)
 {
     minutes          = other.minutes;
     goals_scored     = other.goals_scored;
     bonus            = other.bonus;
     clean_sheets     = other.clean_sheets;
     assists          = other.assists;
     yellow_cards     = other.yellow_cards;
     red_cards        = other.red_cards;
     penalties_missed = other.penalties_missed;
     goals_conceded   = other.goals_conceded;
     saves            = other.saves;
     penalties_saved  = other.penalties_saved;
     own_goals        = other.own_goals;
 }
    public List <FootballerScoreDetailElement> getExplains()
    {
        var parsed = new List <FootballerScoreDetailElement>();
        FootballerScoreDetailElement parsedExplains = new FootballerScoreDetailElement();

        foreach (var singleExplain in explain)
        {
            foreach (var stat in singleExplain.stats)
            {
                var fieldName    = stat.identifier;
                var scoreExplain = new ScoreExplain();
                scoreExplain.name   = fieldName;
                scoreExplain.points = stat.points;
                scoreExplain.value  = stat.value;
                setField(parsedExplains, fieldName, scoreExplain);
            }
            parsed.Add(parsedExplains);
        }
        return(parsed);
    }
Пример #6
0
    public FootballerScoreDetailElement compare(FootballerScoreDetailElement other)
    {
        if (other == null)
        {
            return(this);
        }
        FootballerScoreDetailElement diff = new FootballerScoreDetailElement();

        diff.minutes          = minutes.diff(other.minutes);
        diff.goals_scored     = goals_scored.diff(other.goals_scored);
        diff.bonus            = bonus.diff(other.bonus);
        diff.clean_sheets     = clean_sheets.diff(other.clean_sheets);
        diff.assists          = assists.diff(other.assists);
        diff.yellow_cards     = yellow_cards.diff(other.yellow_cards);
        diff.red_cards        = red_cards.diff(other.red_cards);
        diff.penalties_missed = penalties_missed.diff(other.penalties_missed);
        diff.goals_conceded   = goals_conceded.diff(other.goals_conceded);
        diff.saves            = saves.diff(other.saves);
        diff.penalties_saved  = penalties_saved.diff(other.penalties_saved);
        diff.own_goals        = own_goals.diff(other.own_goals);

        return(diff);
    }
Пример #7
0
    private static void addNewEvents(List <MatchEvent> diff, FootballerScoreDetailElement detailsDiff, Footballer footballer, FootballerScoreDetailElement currentDetail)
    {
        List <MatchEvent> newEvents = PlayerEventGenerator.createNewEvents(detailsDiff, footballer, currentDetail);

        newEvents.ForEach(e => diff.Add(e));
    }
Пример #8
0
 private FootballerScoreDetailElement getPlayerDiff(FootballerScoreDetailElement currentExplain, FootballerScoreDetailElement prevExplain)
 {
     return(currentExplain.compare(prevExplain != null ? prevExplain : null));
 }