@@ -690,17 +690,14 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
690690 command_card = selectable_cards[id - BUTTON_CARD_0 + mainGame->scrCardList ->getPos () / 10 ];
691691 if (command_card->is_selected ) {
692692 command_card->is_selected = false ;
693- int i = 0 ;
694- while (selected_cards[i] != command_card) i++;
695- selected_cards.erase (selected_cards.begin () + i);
696- if (command_card->controler )
697- mainGame->stCardPos [id - BUTTON_CARD_0 ]->setBackgroundColor (0xffd0d0d0 );
698- else mainGame->stCardPos [id - BUTTON_CARD_0 ]->setBackgroundColor (0xffffffff );
693+ auto it = std::find (selected_cards.begin (), selected_cards.end (), command_card);
694+ if (it != selected_cards.end ())
695+ selected_cards.erase (it);
699696 } else {
700697 command_card->is_selected = true ;
701- mainGame->stCardPos [id - BUTTON_CARD_0 ]->setBackgroundColor (0xffffff00 );
702698 selected_cards.push_back (command_card);
703699 }
700+ SetCardListLabel (mainGame->stCardPos [id - BUTTON_CARD_0 ], command_card, true );
704701 int sel = selected_cards.size ();
705702 if (sel >= select_max) {
706703 SetResponseSelectedCards ();
@@ -724,13 +721,10 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
724721 command_card = selectable_cards[id - BUTTON_CARD_0 + mainGame->scrCardList ->getPos () / 10 ];
725722 if (command_card->is_selected ) {
726723 command_card->is_selected = false ;
727- if (command_card->controler )
728- mainGame->stCardPos [id - BUTTON_CARD_0 ]->setBackgroundColor (0xffd0d0d0 );
729- else mainGame->stCardPos [id - BUTTON_CARD_0 ]->setBackgroundColor (0xffffffff );
730724 } else {
731725 command_card->is_selected = true ;
732- mainGame->stCardPos [id - BUTTON_CARD_0 ]->setBackgroundColor (0xffffff00 );
733726 }
727+ SetCardListLabel (mainGame->stCardPos [id - BUTTON_CARD_0 ], command_card, true );
734728 selected_cards.push_back (command_card);
735729 if (selected_cards.size () > 0 ) {
736730 SetResponseSelectedCards ();
@@ -743,17 +737,14 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
743737 command_card = selectable_cards[id - BUTTON_CARD_0 + mainGame->scrCardList ->getPos () / 10 ];
744738 if (command_card->is_selected ) {
745739 command_card->is_selected = false ;
746- int i = 0 ;
747- while (selected_cards[i] != command_card) i++;
748- selected_cards.erase (selected_cards.begin () + i);
749- if (command_card->controler )
750- mainGame->stCardPos [id - BUTTON_CARD_0 ]->setBackgroundColor (0xffd0d0d0 );
751- else mainGame->stCardPos [id - BUTTON_CARD_0 ]->setBackgroundColor (0xffffffff );
740+ auto it = std::find (selected_cards.begin (), selected_cards.end (), command_card);
741+ if (it != selected_cards.end ())
742+ selected_cards.erase (it);
752743 } else {
753744 command_card->is_selected = true ;
754- mainGame->stCardPos [id - BUTTON_CARD_0 ]->setBackgroundColor (0xffffff00 );
755745 selected_cards.push_back (command_card);
756746 }
747+ SetCardListLabel (mainGame->stCardPos [id - BUTTON_CARD_0 ], command_card, true );
757748 ShowSelectSum (true );
758749 break ;
759750 }
0 commit comments