Пример #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);
      }
    }
  }
Пример #2
0
 /* (non-Javadoc)
  * @see com.fullmetalgalaxy.model.persist.AnAction#exec()
  */
 @Override
 public void exec(Game p_game) throws RpcFmpException {
   super.exec(p_game);
   EbRegistration registration = getMyRegistration(p_game);
   if (registration != null) {
     registration.setPtAction(registration.getPtAction() - getCost());
     // registration.setLastUpdate( getLastUpdate() );
     if (p_game.isParallel()) {
       registration.getTeam(p_game).setLockedPosition(getLockedPosition());
       registration
           .getTeam(p_game)
           .setEndTurnDate(
               new Date(
                   SharedMethods.currentTimeMillis()
                       + p_game.getEbConfigGameTime().getLockGameInMillis()));
     }
   }
 }