Example #1
0
      /**
       * Called when the current state has finished and is ready to transition
       * into the next state
       */
      void StateComplete(int state = -1)
      {
        _round->BeforeStateTransition(); 
        Log tmp = _next_state_log;
        _next_state_log = Log();

        if((_cycle_state == GetCurrentState()->GetState()) && (state == -1)) {
          qDebug() << "In" << _round->ToString() << "ending phase";
          if(!_round->CycleComplete()) {
            return;
          }
          _log = Log();
          IncrementPhase();
        }

        if(state == -1) {
          qDebug() << "In" << _round->ToString() << "ending:" <<
            StateToString(GetCurrentState()->GetState()) <<
            "starting:" << StateToString(GetNextState()->GetState());
          _current_sm_state = GetNextState();
        } else {
          qDebug() << "In" << _round->ToString() << "ending:" <<
            StateToString(GetCurrentState()->GetState()) <<
            "starting:" << StateToString(_states[state]->GetState());
          _current_sm_state = _states[state];
        }

        (_round->*GetCurrentState()->GetTransitionCallback())();

        for(int idx = 0; idx < tmp.Count(); idx++) {
          QPair<QByteArray, Id> entry = tmp.At(idx);
          ProcessData(entry.second, entry.first);
        }
      }