//=============================================================================

#include <iostream>
#include <limits>
#include "board.h"
#include "human.h"
using std::cin;
using std::cout;
using std::numeric_limits;
using std::streamsize;

//-----------------------------------------------------------------------------

move human::next(const board& b)
{
   for (;;)
   {
      cout << "\nBitte machen Sie Ihren Zug (1..9): ";

      char c;
      cin >> c;
      if (cin.fail() || c < '1' || c>'9')
      {
         cout << "Fehlerhafte Eingabe!\n\n";
         cin.clear();
         cin.ignore(numeric_limits<streamsize>::max(), '\n');
         continue;
      }
      cin.ignore(numeric_limits<streamsize>::max(), '\n');

      move m(c - '0' - 1, color_);
      if (b.valid(m))
      {
         cout << '\n';
         return m;
      }
      cout << "Feld schon besetzt!\n\n";
   }
}
