예제 #1
0
        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);
        }
예제 #2
0
        public MatchEvent(Match match, uint index, MatchEventType type, uint minute, string text, int teamId, int playerId, int otherPlayerId)
        {
            if (match == null || text == null)
            {
                throw new ArgumentNullException("match or text");
            }

            Match         = match;
            Index         = index;
            Type          = type;
            Minute        = minute;
            Text          = text;
            TeamId        = teamId;
            PlayerId      = playerId;
            OtherPlayerId = otherPlayerId;
        }
예제 #3
0
        public static string ToCustomString(this MatchEventType eventType)
        {
            switch (eventType)
            {
            case MatchEventType.AscendedEvent:
                return("ASCENDED_EVENT");

            case MatchEventType.BuildingKill:
                return("BUILDING_KILL");

            case MatchEventType.CapturePoint:
                return("CAPTURE_POINT");

            case MatchEventType.ChampionKill:
                return("CHAMPION_KILL");

            case MatchEventType.EliteMonsterKill:
                return("ELITE_MONSTER_KILL");

            case MatchEventType.ItemDestroyed:
                return("ITEM_DESTROYED");

            case MatchEventType.ItemPurchased:
                return("ITEM_PURCHASED");

            case MatchEventType.ItemSold:
                return("ITEM_SOLD");

            case MatchEventType.ItemUndo:
                return("ITEM_UNDO");

            case MatchEventType.SkillLevelUp:
                return("SKILL_LEVEL_UP");

            case MatchEventType.WardKill:
                return("WARD_KILL");

            case MatchEventType.WardPlaced:
                return("WARD_PLACED");

            default:
                return(string.Empty);
            }
        }
    public static MatchEvent createMatchEvent(DateTime time, MatchEventType type, Footballer footballer, int number, int scoreDiff)
    {
        var ev = new MatchEvent();

        ev.type = type;
        if (footballer != null)
        {
            ev.footballerName = footballer.web_name;
            ev.footballerId   = footballer.id;
        }
        else
        {
            ev.footballerName = "";
            ev.footballerId   = 0;
        }
        ev.dateTime        = timeToString(time);
        ev.typeString      = type.ToString();
        ev.pointDifference = scoreDiff;
        ev.number          = number;
        return(ev);
    }
예제 #5
0
    public void DecideEvent(MatchState matchState)
    {
        this.matchState = matchState;
        int team1Dead = matchState.Team1CurrentlyDead();
        int team2Dead = matchState.Team2CurrentlyDead();

        if (Mathf.Abs(team1Dead - team2Dead) >= 3)
        {
            if (matchState.timeToRushan < 0 && matchState.matchMinutes >= 15)
            {
                // RuSHAAAN
                if (team1Dead > team2Dead)
                {
                    // enemy rushan
                    eventType = MatchEventType.ENEMY_RUSHAN;
                    Dialog dialog = getEnemyRushanDialog();
                    DialogManagerScript.Instance.ShowDialog(dialog, dialogResolved);
                }
                else
                {
                    // our rushan
                    eventType = MatchEventType.OWN_RUSHAN;
                    Dialog dialog = getOwnRushanDialog();
                    DialogManagerScript.Instance.ShowDialog(dialog, dialogResolved);
                }
            }
        }
        else if (matchState.team1Wards <= 0)
        {
            // wardeeeei
            eventType = MatchEventType.WARDS;
            Dialog dialog = getWardsDialog();
            DialogManagerScript.Instance.ShowDialog(dialog, dialogResolved);
        }
        else if (Random.Range(0, 100) < 5)
        {
            // what to buy
        }
    }
예제 #6
0
        private void RaiseEvent(MatchEventType Ev)
        {
            EventCountThisSecond++;

            if (!Interactive)
            {
                return; // If non-interactive, no point raising events or deciding on commentary for the UI
            }
            switch (Ev)
            {
            case MatchEventType.None:
                MatchCallback.Commentary = "";
                break;

            case MatchEventType.Goal:
            default:
                MatchCallback.Commentary = mps.FindCommentary(Ev, MatchStatus);
                break;
            }

            MatchCallback.MatchStatus = MatchStatus;
            MatchCallback.EventType   = Ev;
            MatchCallback.UpdateUI();
        }
        public async Task <IEnumerable <PersonMatchEventCountViewModel> > GetTopPersonCampaignEventTotalsByMatchEventType(Guid campaignKey, MatchEventType matchEventType, int topNumber = 5)
        {
            var query = from me in MatchEvents.Where(w => w.MatchEventType == matchEventType)
                        join mv in MatchVs.Where(w => w.CampaignStage.CampaignKey == campaignKey && w.IsActive) on me.MatchVPrimaryKey equals mv.PrimaryKey
                        group me by me.PersonPrimaryKey into meGroup
                        let count = meGroup.Count()
                                    let person = meGroup.FirstOrDefault().Person
                                                 orderby count descending
                                                 select new PersonMatchEventCountViewModel()
            {
                Person = person,
                Count  = count
            };

            return(await query.Take(topNumber).ToListAsync());
        }
 public async Task <IEnumerable <MatchEvent> > GetMatchEvents(Guid matchVKey, Guid teamKey, Guid personKey, MatchEventType matchEventType, short?minute, short?extra)
 {
     return(await MatchEvents.Where(f =>
                                    f.MatchVPrimaryKey == matchVKey &&
                                    f.TeamPrimaryKey == teamKey &&
                                    f.PersonPrimaryKey == personKey &&
                                    f.MatchEventType == matchEventType &&
                                    f.Minute == minute &&
                                    f.Extra == extra).ToListAsync());
 }
 public MatchEventChanceItem(MatchEventType evType, double Chance)
 {
     this.evType = evType;
     this.Chance = Chance;
 }
예제 #10
0
        private async Task ImportPlayers(MatchV matchV, bool isTeam1, HtmlNode teamDiv, MatchEventType matchEventType)
        {
            var startersTbody = matchEventType == MatchEventType.Started
                ? teamDiv.Descendants("tbody").FirstOrDefault(d => d.Attributes.Contains("class") && d.Attributes["class"].Value == "firstTeam")
                : teamDiv.Descendants("tbody").FirstOrDefault(d => d.Attributes.Contains("class") && d.Attributes["class"].Value == "reserve");

            if (startersTbody != null)
            {
                foreach (var tr in startersTbody.Descendants("tr"))
                {
                    short?sentOffTime = null;
                    var   teamGuid    = isTeam1 ? matchV.Team1Guid : matchV.Team2Guid;

                    //Starters-Subs
                    var link = tr.Descendants("a").FirstOrDefault(t => t.Attributes.Contains("href"));

                    if (link == null)
                    {
                        break;
                    }

                    var lookupId = link.Attributes["href"].Value.GetTextAfter("player.sd?player_id=");

                    var positionString = tr.Descendants("td").ElementAt(isTeam1 ? 1 : 2).InnerText.GetTextBetween("(", ")");

                    var personKey = await ProcessPlayer(lookupId);

                    if (personKey == null)
                    {
                        continue;
                    }

                    await ProcessMatchEvent(matchV.PrimaryKey, teamGuid, (Guid)personKey, GetPositionType(positionString), matchEventType, null, null);

                    //Substitutions
                    var timeText = tr.Descendants("td").ElementAt(isTeam1 ? 0 : 3).InnerText.GetTextBetween("(", ")").Trim();

                    if (!string.IsNullOrWhiteSpace(timeText))
                    {
                        if (matchEventType == MatchEventType.Started)
                        {
                            // (s/o 90)
                            if (timeText.IndexOf("s/o") >= 0)
                            {
                                sentOffTime = timeText.GetTextAfter("s/o").Trim().ToNullableShort();
                            }
                            else
                            {
                                var substitutedTime = timeText.ToNullableShort();

                                if (substitutedTime != null)
                                {
                                    await ProcessMatchEvent(matchV.PrimaryKey, teamGuid, (Guid)personKey, null, MatchEventType.TakenOff, substitutedTime, null);
                                }
                            }
                        }

                        if (matchEventType == MatchEventType.Substitute)
                        {
                            // (85, s/o 85) brought on and sent off
                            // (77-89) brought on and substituted
                            if (timeText.IndexOf(",") >= 0)
                            {
                                var broughtOnTime = timeText.GetTextBefore(",").Trim().ToNullableShort();

                                if (broughtOnTime != null)
                                {
                                    await ProcessMatchEvent(matchV.PrimaryKey, teamGuid, (Guid)personKey, null, MatchEventType.BroughtOn, broughtOnTime, null);
                                }

                                var remainingText = timeText.GetTextAfter(",");

                                if (remainingText.IndexOf("s/o") >= 0)
                                {
                                    sentOffTime = remainingText.GetTextAfter("s/o").Trim().ToNullableShort();
                                }
                            }
                            else if (timeText.IndexOf("-") >= 0)
                            {
                                var broughtOnTime = timeText.GetTextBefore("-").Trim().ToNullableShort();

                                if (broughtOnTime != null)
                                {
                                    await ProcessMatchEvent(matchV.PrimaryKey, teamGuid, (Guid)personKey, null, MatchEventType.BroughtOn, broughtOnTime, null);
                                }

                                var remainingText = timeText.GetTextAfter("-").Trim();

                                var takenOffTime = remainingText.Trim().ToNullableShort();

                                if (takenOffTime != null)
                                {
                                    await ProcessMatchEvent(matchV.PrimaryKey, teamGuid, (Guid)personKey, null, MatchEventType.TakenOff, takenOffTime, null);
                                }
                            }
                            else
                            {
                                var broughtOnTime = timeText.Trim().ToNullableShort();

                                if (broughtOnTime != null)
                                {
                                    await ProcessMatchEvent(matchV.PrimaryKey, teamGuid, (Guid)personKey, null, MatchEventType.BroughtOn, broughtOnTime, null);
                                }
                            }
                        }
                    }

                    //Discipline
                    var image = tr.Descendants("td").ElementAt(isTeam1 ? 3 : 0).Descendants("img").FirstOrDefault();

                    if (image != null)
                    {
                        switch (image.Attributes["title"].Value)
                        {
                        case "Yellow card":
                            await ProcessMatchEvent(matchV.PrimaryKey, teamGuid, (Guid)personKey, null, MatchEventType.Booked, null, null);

                            break;

                        case "Red card":
                            await ProcessMatchEvent(matchV.PrimaryKey, teamGuid, (Guid)personKey, null, MatchEventType.SentOff, sentOffTime, null);

                            break;


                        case "Red and yellow cards":
                            await ProcessMatchEvent(matchV.PrimaryKey, teamGuid, (Guid)personKey, null, MatchEventType.Booked, null, null);
                            await ProcessMatchEvent(matchV.PrimaryKey, teamGuid, (Guid)personKey, null, MatchEventType.SentOff, sentOffTime, null);

                            break;

                        default:
                            throw new NotImplementedException();
                        }
                    }
                }
            }
        }
        private static async Task CreateEvent(IDbConnection c, IDbTransaction t, Match dbMatch, List <MatchEvent> events, Models.Db.Team team, Models.Db.Player player, MatchEventType type, int minuteOffset)
        {
            var ev = new MatchEvent
            {
                IdDay       = dbMatch.IdDay,
                IdMatch     = dbMatch.Id,
                IdTeam      = (team != null ? team.Id : 0),
                IdPlayer    = (player != null ? player.Id : 0),
                MatchMinute = new Random().Next(0 + minuteOffset, 45 + minuteOffset),
                Type        = (int)type,
            };

            ev.Id = await c.InsertAsync(ev, t);

            events.Add(ev);
        }
예제 #12
0
        protected async Task ProcessMatchEvent(Guid matchVKey, Guid teamKey, Guid personKey, PositionType?positionType, MatchEventType matchEventType, short?minute, short?extra)
        {
            var matchEventQuery = await Provider.GetMatchEvents(matchVKey, teamKey, personKey, matchEventType, minute, extra);

            if (matchEventQuery.Any())
            {
                return;
            }

            Provider.Add(new MatchEvent()
            {
                PrimaryKey       = Guid.NewGuid(),
                MatchVPrimaryKey = matchVKey,
                TeamPrimaryKey   = teamKey,
                PersonPrimaryKey = personKey,
                PositionType     = positionType,
                MatchEventType   = matchEventType,
                Minute           = minute,
                Extra            = extra
            });
        }
예제 #13
0
 public MatchEventCommentary(MatchEventType EventType, string RawText, MatchSegment Segment)
 {
     this.EventType = EventType;
     this.RawText   = RawText;
     this.Segment   = Segment;
 }