コード例 #1
0
  /* (non-Javadoc)
   * @see com.fullmetalgalaxy.model.persist.AnAction#check()
   */
  @Override
  public void check(Game p_game) throws RpcFmpException {
    super.check(p_game);
    if (isAuto()) {
      // if event is auto generated, assume everything are correct
      return;
    }
    EbRegistration myRegistration = getMyRegistration(p_game);
    if (myRegistration == null) {
      // no i18n ?
      throw new RpcFmpException("you didn't join this game.", this);
    }
    if (myRegistration.getPtAction() < getCost() && p_game.getGameType() != GameType.Practice) {
      throw new RpcFmpException(errMsg().NotEnouthActionPt(), this);
    }
    if ((!p_game.isParallel() || (p_game.getCurrentTimeStep() <= 1))
        && (!p_game.getCurrentPlayerIds().contains(myRegistration.getId()))
        && p_game.getGameType() != GameType.Practice) {
      throw new RpcFmpException(errMsg().NotYourTurn(), this);
    }
    if ((p_game.getStatus() == GameStatus.Open || p_game.getStatus() == GameStatus.Pause)
        && p_game.getGameType() != GameType.Practice) {
      throw new RpcFmpException(errMsg().gameNotStarted(), this);
    }

    if (p_game.isParallel()
        && p_game.getCurrentTimeStep() > p_game.getEbConfigGameTime().getDeploymentTimeStep()) {
      EbTeam team =
          p_game.getOtherTeamBoardLocked(
              myRegistration, getLockedPosition(), SharedMethods.currentTimeMillis());
      if (team != null) {
        throw new RpcFmpException(errMsg().boardLocked(), this);
      }
    }
  }