@Override
  public Message execute(ActionContext context, C0540_GoodsStrengthenReqMessage reqMsg) {
    C0540_GoodsStrengthenRespMessage resp = new C0540_GoodsStrengthenRespMessage();
    resp.setStatus(RespTypeStatus.FAILURE);
    try {
      RoleInstance role = this.getCurrentRole(context);
      if (null == role) {
        return null;
      }

      byte positionType = reqMsg.getPositionType();
      String instanceId = reqMsg.getInstanceId();
      int targetId = reqMsg.getTargetId();

      StorageType storageType = StorageType.get(positionType);
      RoleGoods equipGoods =
          GameContext.getUserGoodsApp().getRoleGoods(role, storageType, instanceId, targetId);
      if (equipGoods == null) {
        resp.setInfo(this.getText(TextId.NO_GOODS));
        return resp;
      }

      GoodsType goodsType = GameContext.getGoodsApp().getGoodsType(equipGoods.getGoodsId());
      AbstractGoodsBehavior goodsBehavior =
          goodsType.getGoodsBehavior(GoodsBehaviorType.Strengthen);

      StrengthenParam param = new StrengthenParam(role);
      param.setEquipGoods(equipGoods);
      param.setOperateType(StrengthenParam.STRENGTHEN_INFO);
      param.setTargetId(targetId);

      Result result = goodsBehavior.operate(param);
      if (!result.isSuccess()) {
        resp.setInfo(result.getInfo());
        return resp;
      }

      StrengthenResult stResult = (StrengthenResult) result;
      // 构建-540
      return this.buildStrengthenRespMesage(role, equipGoods, stResult.getGoodsTemplate());
    } catch (Exception e) {
      logger.error("GoodsDeriveStrengthenAction ", e);
      resp.setStatus(RespTypeStatus.FAILURE);
      resp.setInfo(this.getText(TextId.SYSTEM_ERROR));
    }
    return resp;
  }
예제 #2
0
  @Override
  public AddGoodsBeanResult pickupAction(
      String entryId, RoleInstance role, int itemId, List<FallItem> fallList, int outputType) {

    AddGoodsBeanResult result = new AddGoodsBeanResult();
    if (Util.isEmpty(fallList)) {
      result.setResult(Result.FAIL);
      return result;
    }

    List<GoodsOperateBean> pickupList = new ArrayList<GoodsOperateBean>();
    for (Iterator<FallItem> it = fallList.iterator(); it.hasNext(); ) {
      FallItem item = it.next();
      GoodsLiteNamedItem goodsItem = item.getGoodsItem();
      // 全部拾取
      if (itemId <= 0) {
        pickupList.add(
            GoodsOperateBean.createAddGoodsBean(
                goodsItem.getGoodsId(), goodsItem.getNum(), goodsItem.getBindType()));
        continue;
      }
      // 单个拾取
      if (goodsItem.getGoodsId() == itemId) {
        pickupList.add(
            GoodsOperateBean.createAddGoodsBean(
                goodsItem.getGoodsId(), goodsItem.getNum(), goodsItem.getBindType()));
        break;
      }
    }

    if (Util.isEmpty(pickupList)) {
      result.setResult(Result.FAIL);
      return result;
    }

    result =
        GameContext.getUserGoodsApp()
            .addSomeGoodsBeanForBag(role, pickupList, OutputConsumeType.getType(outputType));
    result.setResult(Result.SUCCESS);

    return result;
  }
예제 #3
0
 @Override
 public boolean fallBox(
     RoleInstance role,
     List<GoodsOperateBean> itemList,
     OutputConsumeType ocType,
     int x,
     int y,
     boolean fullSendMail) {
   if (null == role || Util.isEmpty(itemList)) {
     return false;
   }
   MapInstance mapInstance = role.getMapInstance();
   if (null == mapInstance) {
     return false;
   }
   AddGoodsBeanResult result =
       GameContext.getUserGoodsApp().addSomeGoodsBeanForBag(role, itemList, ocType);
   if (fullSendMail) {
     result = this.fallMail(role, result.getPutFailureList(), ocType);
   }
   this.boxed(role, result.getPutFailureList(), x, y, ocType);
   return result.isSuccess();
 }