コード例 #1
0
ファイル: MatchService.cs プロジェクト: srog/FMS_Mvc
        // Primitive - also continuity errors!
        // updates playerstats if card
        private void CreateMatchEvent(Match match, int teamId, MatchEventTypesEnum type)
        {
            var playerId = type == MatchEventTypesEnum.Corner ? 0 : _playerService.GetRandomPlayerFromTeam(teamId, true);

            _matchEventService.Insert(new MatchEvent
            {
                MatchId   = match.Id,
                EventType = type.GetHashCode(),
                Minute    = Utilities.Utilities.GetRandomNumber(1, 90),
                PlayerId  = playerId,
                TeamId    = teamId
            });

            if (type == MatchEventTypesEnum.RedCard)
            {
                var playerStats = _playerStatsService.Get(playerId);
                playerStats.RedCards++;
                _playerStatsService.Update(playerStats);

                var player = _playerService.Get(playerId);
                player.SuspendedWeeks = 3;
                _playerService.Update(player);

                var news = new News
                {
                    GameDetailsId = match.GameDetailsId.Value,
                    DivisionId    = match.DivisionId.Value,
                    PlayerId      = player.Id,
                    SeasonId      = match.SeasonId.Value,
                    TeamId        = teamId,
                    Week          = match.Week.Value
                };

                _newsService.CreateSuspendedNewsItem(new PlayerNews
                {
                    News       = news,
                    PlayerName = _playerService.GetPlayerName(playerId),
                    TeamName   = _teamService.GetTeamName(teamId),
                    Weeks      = player.SuspendedWeeks
                }, true);
            }

            if (type == MatchEventTypesEnum.YellowCard)
            {
                var playerStats = _playerStatsService.Get(playerId);
                playerStats.YellowCards++;
                _playerStatsService.Update(playerStats);
            }
        }
コード例 #2
0
ファイル: PlayerStatsController.cs プロジェクト: srog/FMS
 public PlayerStats Get(int playerId)
 {
     return(_playerStatsService.Get(playerId));
 }