Exemple #1
0
    private PlayInfo GetShotRolls(PlayInfo _currentPlay)
    {
        PlayerData attacker = _currentPlay.Attacker;
        PlayerData defender = _currentPlay.Defender;

        if (defender != null)
        {
            _currentPlay.DefensiveAction      = PlayerAction.Block;
            _currentPlay.DefenderRoll         = ActionRoll.Block(defender);
            _currentPlay.DefendingBonusChance = GetPlayerAttributeBonus(defender.Blocking);
        }

        _currentPlay.AttackerRoll         = ActionRoll.Shoot(attacker);
        _currentPlay.AttackingBonusChance = GetPlayerAttributeBonus(attacker.Shooting);
        if (_currentPlay.Marking == MarkingType.Close)
        {
            _currentPlay.AttackerRoll *= 0.75f;
        }

        return(ApplyBuffs(_currentPlay));
    }
Exemple #2
0
    public PlayInfo GetShotResults(PlayInfo _currentPlay, PlayInfo _lastPlay)
    {
        PlayerData attacker         = _currentPlay.Attacker;
        PlayerData defender         = _currentPlay.Defender;
        Zone       zone             = attacker.Team.GetTeamZone(_currentPlay.Zone);
        float      distanceModifier = DistanceModifiers.ShotModifier(zone);

        if (_currentPlay.OffensiveAction == PlayerAction.Shot)
        {
            if (_lastPlay.Event == MatchEvent.Fault)
            {
                _currentPlay.AttackerRoll         = ActionRoll.Freekick(attacker);
                _currentPlay.AttackingBonusChance = GetPlayerAttributeBonus(attacker.Freekick);
            }
            else if (_lastPlay.Event == MatchEvent.PenaltyShot)
            {
                _currentPlay.AttackerRoll         = ActionRoll.Penalty(attacker);
                _currentPlay.AttackingBonusChance = GetPlayerAttributeBonus(attacker.Penalty);
            }
            else
            {
                _currentPlay.AttackerRoll         = ActionRoll.Shoot(attacker);
                _currentPlay.AttackingBonusChance = GetPlayerAttributeBonus(attacker.Shooting);
            }
        }
        else if (_currentPlay.OffensiveAction == PlayerAction.Header)
        {
            _currentPlay.AttackerRoll         = ActionRoll.Header(attacker);
            _currentPlay.AttackingBonusChance = GetPlayerAttributeBonus(attacker.Heading);
        }

        _currentPlay.AttackerRoll *= attacker.FatigueModifier();
        _currentPlay.AttackerRoll *= distanceModifier;
        _currentPlay.AttackerRoll *= _currentPlay.AttackingBonus;

        if (_currentPlay.Marking == MarkingType.Close)
        {
            _currentPlay.AttackerRoll *= 0.5f;
        }

        _currentPlay.DefenderRoll  = ActionRoll.Keeper(defender);
        _currentPlay.DefenderRoll *= defender.FatigueModifier();

        //Roll dice for shooter and keeper
        _currentPlay = playDiceRolls.GetShotOnGoalResult(_currentPlay);

        //CHECK ATTACKING X DEFENDING
        if (_currentPlay.AttackerRoll <= _currentPlay.DefenderRoll)
        {
            int roll = Dice.Roll(20);
            if (_currentPlay.DefenseExcitment == 0 && roll < 5)
            {
                _currentPlay.Event = MatchEvent.CornerKick;
            }
            else
            {
                _currentPlay.Event = _lastPlay.Event == MatchEvent.PenaltyShot ? MatchEvent.PenaltySaved : MatchEvent.ShotSaved;
                if (_currentPlay.OffensiveAction == PlayerAction.Shot)
                {
                    _currentPlay.Attacker.MatchStats.ShotsOnGoal++;
                }
                else if (_currentPlay.OffensiveAction == PlayerAction.Header)
                {
                    _currentPlay.Attacker.MatchStats.HeadersOnGoal++;
                }
            }
            _currentPlay.IsActionSuccessful = false;
            if (_currentPlay.Event == MatchEvent.CornerKick)
            {
                if (_currentPlay.OffensiveAction == PlayerAction.Shot)
                {
                    _currentPlay.Attacker.MatchStats.ShotsMissed++;
                    _currentPlay.Attacker.Team.MatchStats.ShotsMissed++;
                }
                else if (_currentPlay.OffensiveAction == PlayerAction.Header)
                {
                    _currentPlay.Attacker.MatchStats.HeadersMissed++;
                    _currentPlay.Attacker.Team.MatchStats.HeadersMissed++;
                }
            }
        }
        else
        {
            _currentPlay.IsActionSuccessful = true;
            _currentPlay.Event = MatchEvent.Goal;
        }

        return(_currentPlay);
    }