/** * 获得道具全部属性,包含模板属性 * * @return */ public static AttriBuffer getAttriBuffer(RoleGoods roleGoods) { AttriBuffer buffer = AttriBuffer.createAttriBuffer(); // 模板属性 int goodsId = roleGoods.getGoodsId(); GoodsBase goodsBase = GameContext.getGoodsApp().getGoodsBase(goodsId); if (goodsBase == null) { return buffer; } buffer.append(goodsBase.getAttriItemList()); if (GoodsType.GoodsRune.getType() == goodsBase.getGoodsType()) { buffer.append(buildRandomAttri(roleGoods)); return buffer; } if (!goodsBase.isEquipment()) { // 非装备 return buffer; } buffer.append( GameContext.getEquipApp() .getBaseAttriBuffer(goodsId, roleGoods.getQuality(), roleGoods.getStar())); // 获得强化属性 buffer.append( GameContext.getEquipApp() .getStrengthenAttriBuffer( goodsId, roleGoods.getQuality(), roleGoods.getStar(), roleGoods.getStrengthenLevel())); buffer.append(buildRandomAttri(roleGoods)); // 获得镶嵌宝石属性 buffer.append(getMosaicArrti(roleGoods)); return buffer; }
/** 永久物品 */ public static boolean isForever(RoleGoods roleGoods) { GoodsBase gb = GameContext.getGoodsApp().getGoodsBase(roleGoods.getGoodsId()); if (null == gb) { return false; } return gb.getDeadline() == 0; }
/** * 下线是否消失 * * @return */ public static boolean isOfflineDie(RoleGoods roleGoods) { GoodsBase goodsBase = GameContext.getGoodsApp().getGoodsBase(roleGoods.getGoodsId()); if (goodsBase == null) { return false; } return goodsBase.hasOfflineDie(); }
// 容错过期时间(单写一方法在此调用) public static void checkGoodsExpiredTime(RoleGoods roleGoods) { try { GoodsBase goodsBase = GameContext.getGoodsApp().getGoodsBase(roleGoods.getGoodsId()); if (null == goodsBase) { return; } if (goodsBase.isForever()) { return; } int bagType = roleGoods.getStorageType(); boolean on = bagType == StorageType.hero.getType(); boolean mustActive = (goodsBase.getActivateType() == 1) || (goodsBase.getActivateType() == 0 && on); if (mustActive) { if (!Util.isEmpty(roleGoods.getExpiredTime())) { return; } Date endDate = DateUtil.add(new Date(), Calendar.MINUTE, goodsBase.getDeadline()); roleGoods.setExpiredTime(endDate); return; } if (roleGoods.getDeadline() > 0) { return; } roleGoods.setDeadline(goodsBase.getDeadline()); } catch (Exception e) { e.printStackTrace(); } }
public static GoodsEquipment getGoodsEquipment(RoleGoods roleGoods) { GoodsBase gb = GameContext.getGoodsApp().getGoodsBase(roleGoods.getGoodsId()); if (null == gb || !(gb instanceof GoodsEquipment)) { return null; } return (GoodsEquipment) gb; }
public static int getEquipLocation(RoleGoods roleGoods) { int goodsId = roleGoods.getGoodsId(); GoodsBase goodsBase = GameContext.getGoodsApp().getGoodsBase(goodsId); if (goodsBase instanceof GoodsEquipment) { GoodsEquipment equipment = (GoodsEquipment) goodsBase; return equipment.getEquipslotType(); } return -1; }
public static int getEquipScore(RoleGoods roleGoods) { GoodsBase goodsBase = GameContext.getGoodsApp().getGoodsBase(roleGoods.getGoodsId()); if (null == goodsBase || !goodsBase.isEquipment()) { return 0; } AttriBuffer buffer = getAttriBuffer(roleGoods); if (null == buffer || buffer.isEmpty()) { return 0; } return GameContext.getAttriApp().getAttriBattleScore(buffer); }
/** 过期删除物品 */ public static boolean isExpiredDel(RoleGoods roleGoods) { try { GoodsBase gb = GameContext.getGoodsApp().getGoodsBase(roleGoods.getGoodsId()); if (null == gb) { return false; } return gb.getExpireType() == 1; } catch (Exception e) { logger.error("RoleGoodsHelper.isExpiredDel:", e); } return false; }
@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; }
/** 获得该物品模板信息 */ public static GoodsBase getGoodsBase(RoleGoods roleGoods) { return GameContext.getGoodsApp().getGoodsBase(roleGoods.getGoodsId()); }