Skip to content

Commit 568d3a5

Browse files
Merge pull request rcsoccersim#126 from mroa4/fix_PenaltyMaxExtraKicks
Fix an issue in PenaltyRef
2 parents 99057d3 + 9227227 commit 568d3a5

File tree

1 file changed

+24
-27
lines changed

1 file changed

+24
-27
lines changed

src/referee.cpp

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3737,34 +3737,8 @@ PenaltyRef::penalty_check_score()
37373737
<< M_stadium.teamRight().penaltyPoint()
37383738
<< ((M_cur_pen_taker == RIGHT) ? "*" : " ") << " after "
37393739
<< M_pen_nr_taken << " penalties." << std::endl;
3740-
3741-
// if both players have taken more than nr_kicks penalties -> check for winner
3742-
if ( M_pen_nr_taken > 2 * ServerParam::instance().penNrKicks() )
3743-
{
3744-
if( M_pen_nr_taken % 2 == 0
3745-
&& ( M_stadium.teamLeft().penaltyPoint()
3746-
!= M_stadium.teamRight().penaltyPoint() ) )
3747-
{
3748-
std::cerr << "Final score: "
3749-
<< M_stadium.teamLeft().penaltyPoint() << "-"
3750-
<< M_stadium.teamRight().penaltyPoint() << std::endl;
3751-
if ( M_stadium.teamLeft().penaltyPoint()
3752-
> M_stadium.teamRight().penaltyPoint() )
3753-
{
3754-
M_stadium.sendRefereeAudio( "penalty_winner_l" );
3755-
}
3756-
else
3757-
{
3758-
M_stadium.sendRefereeAudio( "penalty_winner_r" );
3759-
}
3760-
//M_stadium.changePlayMode( PM_TimeOver );
3761-
M_timeover = true;
3762-
}
3763-
}
37643740
// if both players have taken nr_kicks and max_extra_kicks penalties -> quit
3765-
else if ( M_pen_nr_taken > 2 * ( ServerParam::instance().penMaxExtraKicks()
3766-
+ ServerParam::instance().penNrKicks() )
3767-
)
3741+
if (M_pen_nr_taken > 2 * (ServerParam::instance().penMaxExtraKicks() + ServerParam::instance().penNrKicks()))
37683742
{
37693743
std::cerr << "Final score: "
37703744
<< M_stadium.teamLeft().penaltyPoint() << "-"
@@ -3791,6 +3765,29 @@ PenaltyRef::penalty_check_score()
37913765
//M_stadium.changePlayMode( PM_TimeOver );
37923766
M_timeover = true;
37933767
}
3768+
// if both players have taken more than nr_kicks penalties -> check for winner
3769+
else if ( M_pen_nr_taken > 2 * ServerParam::instance().penNrKicks() )
3770+
{
3771+
if( M_pen_nr_taken % 2 == 0
3772+
&& ( M_stadium.teamLeft().penaltyPoint()
3773+
!= M_stadium.teamRight().penaltyPoint() ) )
3774+
{
3775+
std::cerr << "Final score: "
3776+
<< M_stadium.teamLeft().penaltyPoint() << "-"
3777+
<< M_stadium.teamRight().penaltyPoint() << std::endl;
3778+
if ( M_stadium.teamLeft().penaltyPoint()
3779+
> M_stadium.teamRight().penaltyPoint() )
3780+
{
3781+
M_stadium.sendRefereeAudio( "penalty_winner_l" );
3782+
}
3783+
else
3784+
{
3785+
M_stadium.sendRefereeAudio( "penalty_winner_r" );
3786+
}
3787+
//M_stadium.changePlayMode( PM_TimeOver );
3788+
M_timeover = true;
3789+
}
3790+
}
37943791
// during normal kicks, check whether one team cannot win anymore
37953792
else
37963793
{

0 commit comments

Comments
 (0)