/** * 下线是否消失 * * @return */ public static boolean isOfflineDie(RoleGoods roleGoods) { GoodsBase goodsBase = GameContext.getGoodsApp().getGoodsBase(roleGoods.getGoodsId()); if (goodsBase == null) { return false; } return goodsBase.hasOfflineDie(); }
/** 永久物品 */ 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 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 GoodsType getGoodsType(RoleGoods roleGoods) { GoodsBase goodsBase = getGoodsBase(roleGoods); if (goodsBase == null) { return GoodsType.GoodsDefault; } return GoodsType.get(goodsBase.getGoodsType()); }
private BindingType getBindingType(int goodsId, int bindType) { if (bindType == DEF_BIND_TYPE) { GoodsBase gb = GameContext.getGoodsApp().getGoodsBase(goodsId); return gb.getBindingType(); } return BindingType.get(bindType); }
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; }
private AddGoodsBeanResult fallMail( RoleInstance role, List<GoodsOperateBean> addList, OutputConsumeType ocType) { if (role == null) { return new AddGoodsBeanResult().setInfo(GameContext.getI18n().getText(TextId.SYSTEM_ERROR)); } if (Util.isEmpty(addList)) { return new AddGoodsBeanResult().success(); } // 大于等于此品质发邮件 byte mailQualityType = GameContext.getParasConfig().getSendMailQualityType(); AddGoodsBeanResult result = new AddGoodsBeanResult(); List<GoodsOperateBean> sendMailList = new ArrayList<GoodsOperateBean>(); for (GoodsOperateBean bean : addList) { if (null == bean) { continue; } GoodsBase gb = GameContext.getGoodsApp().getGoodsBase(bean.getGoodsId()); if (null == gb) { continue; } if (gb.getQualityType() >= mailQualityType) { sendMailList.add(bean); continue; } result.getPutFailureList().add(bean); } if (Util.isEmpty(sendMailList)) { return result; } // 发送邮件 this.sendGoodsByMail(role, sendMailList, ocType); C0003_TipNotifyMessage tipNotifyMsg = new C0003_TipNotifyMessage(); tipNotifyMsg.setMsgContext(GameContext.getI18n().getText(TextId.FALL_MAIL_TIPS)); role.getBehavior().sendMessage(tipNotifyMsg); return result; }
/** * 统计镶嵌在装备身上等级超过level的个数 * * @param level * @return */ public static int countGemLevel(RoleGoods roleGoods, int level) { MosaicRune[] mosaicRunes = roleGoods.getMosaicRune(); if (null == mosaicRunes || 0 == mosaicRunes.length) { return 0; } int total = 0; for (MosaicRune hole : mosaicRunes) { if (null == hole || hole.getGoodsId() <= 0) { continue; } GoodsBase gb = GameContext.getGoodsApp().getGoodsBase(hole.getGoodsId()); if (null == gb) { continue; } if (gb.getLevel() < level) { continue; } total++; } return total; }
// 容错过期时间(单写一方法在此调用) 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(); } }
/** * roll点分配 * * @param itemList * @param sameMapMembers * @return */ public Map<String, List<GoodsOperateBean>> roll( List<GoodsOperateBean> itemList, List<AbstractRole> sameMapMembers) { Map<String, List<GoodsOperateBean>> result = Maps.newHashMap(); if (Util.isEmpty(itemList)) { return result; } int size = sameMapMembers.size(); if (1 == size) { result.put(sameMapMembers.get(0).getRoleId(), itemList); return result; } for (GoodsOperateBean agb : itemList) { try { int goodsId = agb.getGoodsId(); int goodsNum = agb.getGoodsNum(); GoodsBase goodsBase = GameContext.getGoodsApp().getGoodsBase(goodsId); if (null == goodsBase) { continue; } int[] points = new int[size]; int maxIndex = 0; int maxPoint = -1; int prePoint = -1; // 前一次随机分数 for (int index = 0; index < size; index++) { int point = 0; if (goodsBase.getCareer() < 0 || goodsBase.getCareer() == ((RoleInstance) sameMapMembers.get(index)).getCareer()) { // 职业匹配额外+50分,确保物品被匹配的职业roll到 point = 50; } int thisPoint = RandomUtil.randomIntWithoutZero(50) + point; if (prePoint == thisPoint) { // 随机的点数与上次相同,再随机一次 thisPoint = RandomUtil.randomIntWithoutZero(50) + point; } if (maxPoint < thisPoint) { maxPoint = thisPoint; maxIndex = index; } else if (maxPoint == thisPoint && RandomUtil.randomBoolean()) { // 点数相同,随机处理一下是否替换,否则一直是第一个分数相同的人 maxIndex = index; } points[index] = thisPoint; prePoint = thisPoint; } AbstractRole winner = sameMapMembers.get(maxIndex); String maxRoleId = winner.getRoleId(); if (!result.containsKey(maxRoleId)) { result.put(maxRoleId, new ArrayList<GoodsOperateBean>()); } result.get(maxRoleId).add(agb); // 蓝色(含)品质的物品需要发送roll结构 boolean sendRollResult = goodsBase.getQualityType() >= QualityType.blue.getType(); if (sendRollResult) { sendRollInfo(sameMapMembers, points, goodsBase, goodsNum, winner, maxIndex); } } catch (Exception ex) { logger.error("", ex); } } return result; }