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); }
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; } } } }
public void Time(MatchPeriod matchPeriod, int minute) { Minute = minute; MatchPeriod = matchPeriod; }