Пример #1
0
  public void nextTurn() throws FightException {
    if (state == FightStateEnum.FINISHED) {
      return;
    } else if (state != FightStateEnum.ACTIVE) {
      throw new FightException("Invalid request: fight's state doesn't allow this request.");
    }

    if (!challengers.isAlive() || !defenders.isAlive()) {
      stop();
    } else {
      onTurnStopped();

      Turn turn = turns.remove(0);
      if (!turn.hasAbandoned() && turn.getFighter().isAlive()) {
        turns.add(turn);
      }

      while (getCurrentTurn().hasAbandoned()) {
        turns.remove(0);
      }

      turns.get(0).begin();
    }
  }