Example #1
0
    public static PlayOutput ZagaToVol(Team team)
    {
        PlayOutput output = new PlayOutput();

        Player actor    = new Player();
        Player receiver = new Player();

        Player[] actorsAvailable    = Formation.GetActorsAvailable(team, 0);
        Player[] receiversAvailable = Formation.GetReceiversAvailable(team, 1);

        int higher = 0;

        for (int i = 0; i < actorsAvailable.Length; i++)
        {
            int currentHit = RollDice(6);
            if (currentHit > higher)
            {
                higher = currentHit;
                actor  = actorsAvailable[i];
            }
        }

        if (DontHit(actor.stats.pass + 10))
        {
            //Get the receiver
            higher = 0;
            for (int i = 0; i < receiversAvailable.Length; i++)
            {
                int currentHit = RollDice(6);
                // O Recebedor não pode receber dele mesmo
                if (currentHit > higher && receiversAvailable[i].number != actor.number)
                {
                    higher   = currentHit;
                    receiver = receiversAvailable[i];
                }
            }

            output.actor    = actor;
            output.receiver = receiver;
            output.success  = true;
            output.hasNext  = true;
        }
        else
        {
            output.actor   = actor;
            output.success = false;
            output.hasNext = false;
        }
        return(output);
    }