HandsOff/Models/Match.cs
/// <summary>
/// Decides what happens to BallPosition and ball owner based on the output of the
/// method AttemptAdvance(). Together, TakeTurn() and AttemptAdvance() calculate each turn.
/// </summary>
Decides what happens to BallPosition and ball owner based on the output of the
method AttemptAdvance(). Together, TakeTurn() and AttemptAdvance() calculate each turn.
Decides what happens to BallPosition and ball owner based on the output of the method AttemptAdvance () . Together TakeTurn () and AttemptAdvance () calculate each turn .
private void TakeTurn()
        {
            if (BallOwner == 1) 
            {
                if (BallPosition == 8) 
                {
                    if (AttemptAdvance(1, 1) == 1)
                    {
                        Team1Score++;
                        BallOwner = 2;
                        BallPosition = 4;
                    }
                    else if (AttemptAdvance(1, 1) == 0)
                    {
                        BallPosition--; 
                    }
                    else 
                    {
                        BallOwner = 2;
                        BallPosition = 5;
                    }
                }
                else if (BallPosition == 7) 
                {
                    if (AttemptAdvance(3, 4) == 1) 
                    {
                        BallPosition++;
                    }
                    else if (AttemptAdvance(3, 4) == 0)
                    {
                        BallPosition--; 
                    }
                    else 
                    {
                        BallOwner = 2;
                    }
                }
                else
                {
                    if (AttemptAdvance(3, 3) == 1) 
                    {
                        BallPosition++;
                    }
                    else if (AttemptAdvance(3, 3) == 0)
                    {
                        BallPosition--; 
                    }
                    else 
                    {
                        BallOwner = 2;
                    }
                }
            }
            else 
            {
                if (BallPosition == 0) 
                {
                    if (AttemptAdvance(1, 1) == 1)
                    {
                        Team2Score++;
                        BallOwner = 1;
                        BallPosition = 4;
                    }
                    else if (AttemptAdvance(1, 1) == 0)
                    {
                        BallPosition++; 
                    }
                    else 
                    {
                        BallOwner = 1;
                        BallPosition = 4;
                    }
                }
                else if (BallPosition == 1) 
                {
                    if (AttemptAdvance(3, 4) == 1) 
                    {
                        BallPosition--;
                    }
                    else if (AttemptAdvance(3, 4) == 0)
                    {
                        BallPosition++; 
                    }
                    else 
                    {
                        BallOwner = 1;
                    }
                }
                else
                {
                    if (AttemptAdvance(3, 3) == 1) 
                    {
                        BallPosition--;
                    }
                    else if (AttemptAdvance(3, 3) == 0)
                    {
                        BallPosition++; 
                    }
                    else 
                    {
                        BallOwner = 1;
                    }
                }
            }
        }
private void TakeTurn ( ) { if ( BallOwner == 1 ) { if ( BallPosition == 8 ) { if ( AttemptAdvance ( 1 , 1 ) == 1 ) { Team1Score ++ ; BallOwner = 2 ; BallPosition = 4 ; } else if ( AttemptAdvance ( 1 , 1 ) == 0 ) { BallPosition -- ; } else { BallOwner = 2 ; BallPosition = 5 ; } } else if ( BallPosition == 7 ) { if ( AttemptAdvance ( 3 , 4 ) == 1 ) { BallPosition ++ ; } else if ( AttemptAdvance ( 3 , 4 ) == 0 ) { BallPosition -- ; } else { BallOwner = 2 ; } } else { if ( AttemptAdvance ( 3 , 3 ) == 1 ) { BallPosition ++ ; } else if ( AttemptAdvance ( 3 , 3 ) == 0 ) { BallPosition -- ; } else { BallOwner = 2 ; } } } else { if ( BallPosition == 0 ) { if ( AttemptAdvance ( 1 , 1 ) == 1 ) { Team2Score ++ ; BallOwner = 1 ; BallPosition = 4 ; } else if ( AttemptAdvance ( 1 , 1 ) == 0 ) { BallPosition ++ ; } else { BallOwner = 1 ; BallPosition = 4 ; } } else if ( BallPosition == 1 ) { if ( AttemptAdvance ( 3 , 4 ) == 1 ) { BallPosition -- ; } else if ( AttemptAdvance ( 3 , 4 ) == 0 ) { BallPosition ++ ; } else { BallOwner = 1 ; } } else { if ( AttemptAdvance ( 3 , 3 ) == 1 ) { BallPosition -- ; } else if ( AttemptAdvance ( 3 , 3 ) == 0 ) { BallPosition ++ ; } else { BallOwner = 1 ; } } } }
Decides what happens to BallPosition and ball owner based on the output of the
method AttemptAdvance().
Decides what happens to BallPosition and ball owner based on the output of the method AttemptAdvance () .
// team 1 owns the ball // first check if a goal attempt is possible, if failed return the ball to the other team // Goal attempt is made by just one attacker // if goal is not possible, then team 1 trying to advance forwards // Ball has reached the bottom of the field and a goal attempt can be made // stalemate. Ball position goes back one but team 2 gets to try another time to break the defense. // failed! Team 2 gets the ball now // Attempt to get through the defense players // in all other cases, the attackers are trying to advance through the mid-fielders // stalemate. Ball position goes back one but team 2 gets to try another time to break the defense. // failed! Team 2 gets the ball now // in all other cases, the attackers are trying to advance through the mid-fielders // stalemate. Ball position goes back one but team 2 gets to try another time to break the defense. // failed! Team 2 gets the ball now // team 2 owns the ball // first check if a goal attempt is possible, if failed return the ball to the other team // Goal attempt is made by just one attacker // if goal is not possible, then team 1 trying to advance forwards // Ball has reached the bottom of the field and a goal attempt can be made // stalemate. Ball position goes back one but team 2 gets to try another time to break the defense. // failed! Team 1 gets the ball now // Attempt to get through the defense players // in all other cases, the attackers are trying to advance through the mid-fielders // stalemate. Ball position goes back one but team 2 gets to try another time to break the defense. // failed! Team 1 gets the ball now // in all other cases, the attackers are trying to advance through the mid-fielders // stalemate. Ball position goes back one but team 2 gets to try another time to break the defense. // failed! Team 1 gets the ball now