コード例 #1
0
    private void postActionHook() {
      if (LOG.isTraceEnabled()) {
        LOG.trace("postActionHook()...  Task: " + mAction.getName() + "has completed");
      }

      persistActionRecord();

      // Check if the initiator of this action supports scoring...
      Object initiator = mContext.getMapObjectCollection().getObjectByGuid(mAction.getInitiator());
      if (initiator instanceof IScoringAbility) {
        ((IScoringAbility) initiator).score(mAction);
      }
    }
コード例 #2
0
    private boolean preActionHook() {
      if (LOG.isTraceEnabled()) {
        LOG.trace("preActionHook()...  Task: " + mAction.getName() + "starting");
      }

      /*
       * If this action was started by the SYSTEM_GUID, we don't do any
       * ability checking on the operation. We may want to expand this out
       * later to include different processes with different abilities,
       * but for now, let's just let the system do anything it wants.
       */
      if (!GuidManager.SYSTEM_GUID.equals(mAction.getInitiator())) {
        Object initiator =
            mContext.getMapObjectCollection().getObjectByGuid(mAction.getInitiator());
        if (initiator == null) {
          initiator = mContext.getRegionCollection().getRegion(mAction.getInitiator());
          if (null == initiator) {
            LOG.warn("Command action using the system guid...was this expected?");
          }
        }

        //  TODO:  This check may not be appropriate here.... How about AI objects?  Moving Zones?
        if (!(initiator instanceof IMapObject) && !(initiator instanceof IMapRegion)) {
          mResult = "FAIL: Initiator is not an IMapObject or IMapRegion";
          return false;
        }

        // Now verify that the initiator supports all of the IAction's
        // required abilities
        if (!supportsRequiredAbilities(
            mAction.getRequiredInitiatorAbilities(), ((IAbility) initiator).getObjectAbilities())) {
          mResult = "FAIL: Initiator doesn't support one of the required IAbilities";
          return false;
        }
      }

      /*
       * Now walk each of the receivers, verifying that they support all
       * of the required methods necessary to support the action. But,
       * recievers might not be in the trackableByGuidList. atm I am
       * trying to use a record that does implement the IAction And if it
       * is the system, just return.
       */
      Iterator<Long> itor = mAction.getReceiver().iterator();
      while (itor.hasNext()) {
        // Verify first that this receiver supports IAbility
        long next = itor.next();
        // if system, then continue to next itoration
        if (next == GuidManager.SYSTEM_GUID) {
          continue;
        }
        Object receiver = mContext.getMapObjectCollection().getObjectByGuid(next);

        // The recever might be found int the
        // m_context.getPlayerSignUpActionCollection.get(next);
        //                if (receiver == null)
        //                    receiver = m_context.getPlayerSignUpActionHashtable().get(next);

        if (!(receiver instanceof IAbility)) {
          mResult = "FAIL: Receiver doesn't support IAbility";
          return false;
        }

        // Now verify that the receiver supports all of the IAction's
        // required abilities
        if (!supportsRequiredAbilities(
            mAction.getRequiredReceiverAbilities(), ((IAbility) receiver).getObjectAbilities())) {
          mResult = "FAIL: Receiver doesn't support one of the required IAbilities";
          return false;
        }
      }
      return true;
    }