void WolfAction::perform(Table &table, Player *playerList, QueryResult queryResult) { int currentPlayer = gameInfo.currentPlayer; int x, y; queryResult.getCoordinates(x, y); shared_ptr<AnimalCard> chosenCard; // Repeat the query until we get a valid position while (true) { try { chosenCard = table.pickAt(y, x); } catch (...) { cout << "Invalid location, try again." << endl; queryResult = query(); queryResult.getCoordinates(x, y); continue; } break; } playerList[currentPlayer].yourHand += chosenCard; }