Esempio n. 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);
      }
    }
  }
Esempio n. 2
0
 /* (non-Javadoc)
  * @see com.fullmetalgalaxy.model.persist.AnAction#unexec()
  */
 @Override
 public void unexec(Game p_game) throws RpcFmpException {
   super.unexec(p_game);
   EbRegistration registration = getMyRegistration(p_game);
   if (registration != null) {
     registration.setPtAction(registration.getPtAction() + getCost());
     // registration.setLastUpdate( getOldUpdate() );
   }
 }
Esempio n. 3
0
 /**
  * set player AND account
  *
  * @param p_registration
  */
 public void setRegistration(EbRegistration p_registration) {
   if (p_registration == null) {
     m_registrationId = 0;
     return;
   }
   m_registrationId = p_registration.getId();
   if (p_registration.getAccount() == null) {
     setAccountId(0);
   } else {
     setAccountId(p_registration.getAccount().getId());
   }
 }
Esempio n. 4
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()));
     }
   }
 }