diff --git a/Bonus.cpp b/Bonus.cpp index 5a4b0dfa4c26e1c5bb580710117011f7a0da489a..6a3ae77124805694ce87f74bfb41cab8e547adbe 100644 --- a/Bonus.cpp +++ b/Bonus.cpp @@ -12,6 +12,8 @@ void Bonus::action_on_display() { } void Bonus::action_on_take(Ball *ball) { + if(ball->sender->bonus) + return; ball->sender->bonus = this; state = IN_USE; } @@ -184,9 +186,12 @@ LifeAddBonus::LifeAddBonus() : Bonus(LIFE_ADD_BONUS_LENGTH, LIFE_ADD_BONUS_PROBA void LifeAddBonus::action_on_take(Ball *ball) { ball->sender->life_points++; - if(!ball->bonus) + if(ball->bonus) { + state = NONE; + } else { ball->bonus = this; - state = IN_USE; + state = IN_USE; + } } bool LifeAddBonus::can_be_added() { diff --git a/Game.cpp b/Game.cpp index 8c17fb5f2a3cc849f9fb7eb099ba901531679265..4b2ce81e1983e7b3b6c2db6e8943bfe081f91df7 100644 --- a/Game.cpp +++ b/Game.cpp @@ -87,7 +87,7 @@ void Game::pingpong() { ball->display(); - if(!ball->sender->bonus && ball->sender->pressing) + if(ball->sender->pressing) check_for_bonus(ball); if(ball->receiver->send_back(ball)) {