Exemplo n.º 1
0
        private MatchEventDto RandomRedCard(MatchPeriod matchPeriod, int minute)
        {
            var rnd = new Random();

            if (rnd.Next(1, 100) % 37 == 0)
            {
                var home        = rnd.Next(100) % 2 == 0;
                var playerIndex = rnd.Next(0, State.HomeTeam.Players.Count - 1);
                var player      = (home ? State.HomeTeam : State.AwayTeam).Players[playerIndex];
                return(new MatchEventDto
                {
                    Id = Guid.NewGuid().ToString(),
                    Home = home,
                    MatchPeriod = (int)matchPeriod,
                    MatchId = State.Id,
                    Minute = minute,
                    MatchEventType = (int)MatchEventType.RedCard,
                    PlayerId = player.Id
                });
            }

            return(null);
        }
Exemplo n.º 2
0
        public void Tick()
        {
            if (MatchPeriod == MatchPeriod.None)
            {
                _minute      = 0;
                _matchPeriod = MatchPeriod.FirstTime;
            }
            else if (MatchPeriod == MatchPeriod.FirstTime)
            {
                if (Minute < 45)
                {
                    _minute = Minute + 1;
                }
                else if (Minute == 45)
                {
                    _addedTime = _random.Next(1, 5);

                    _minute = Minute + 1;
                    _addedTime--;
                }
                else
                {
                    if (_addedTime > 0)
                    {
                        _minute = Minute + 1;
                        _addedTime--;
                    }

                    if (_addedTime == 0)
                    {
                        _minute        = 45;
                        _matchPeriod   = MatchPeriod.HalfTime;
                        _halfTimeBreak = 15;
                    }
                }
            }
            else if (MatchPeriod == MatchPeriod.HalfTime)
            {
                if (_halfTimeBreak > 0)
                {
                    _halfTimeBreak--;
                }

                if (_halfTimeBreak == 0)
                {
                    _matchPeriod = MatchPeriod.SecondTime;
                }
            }
            else if (MatchPeriod == MatchPeriod.SecondTime)
            {
                if (Minute < 90)
                {
                    _minute = Minute + 1;
                }
                else if (Minute == 90)
                {
                    _addedTime = _random.Next(1, 5);

                    _minute = Minute + 1;
                    _addedTime--;
                }
                else
                {
                    if (_addedTime > 0)
                    {
                        _minute = Minute + 1;
                        _addedTime--;
                    }

                    if (_addedTime == 0)
                    {
                        _minute      = 90;
                        _matchPeriod = MatchPeriod.FullTime;
                    }
                }
            }
        }
Exemplo n.º 3
0
 public void Time(MatchPeriod matchPeriod, int minute)
 {
     Minute      = minute;
     MatchPeriod = matchPeriod;
 }