Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.19 KB | None | 0 0
  1. bool TurnContext::selectCard(const Interface::CardSelection& options, bool optional)
  2. {
  3.     if(!optional && options.empty())
  4.         throw Exception::LogicError("options cannot be empty if optional is false");
  5.     if(options.empty())
  6.         return false;
  7.     if(options.size() == 1 && !optional){
  8.         options.toggle(0);
  9.         return true;
  10.     }
  11.     self.selectCard(*this, options);//(const TurnContext&, const Interface::CardSelection&, bool = true)  = 0;
  12.     if(!optional && options.countSelected() != 1)
  13.         throw Exception::RuntimeError("!optional && options.countSelected() != 1");
  14.     return true;//something above is surely wrong
  15. }
  16.  
  17. size_t TurnContext::selectCards(const Interface::CardSelection& options, size_t min, size_t max)
  18. {
  19.     if(!options.validate())
  20.         throw Exception::LogicError("!options.validate()");
  21.     if(options.empty()){
  22.         min = max = 0;
  23.         return 0;
  24.     }
  25.     min = 1;
  26.     max = options.size();
  27.     self.selectCards(*this, options, min, max);//(,, size_t min = 0, size_t max = -1)
  28.     if(options.countSelected() == 0)
  29.         throw Exception::RuntimeError("the player selection is invalid");
  30.     return options.countSelected();
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement