/** * 计算评分 * * @param role */ private void calculateScore(RoleInstance role) { try { // TODO: byte starScore = (byte) RandomUtil.randomInt(1, 5); GameContext.getCopyLineApp().disposeCopyPass(role, this.copyId, starScore); // 通关评分 C0273_CopyLinePassScoreNotifyMessage message = new C0273_CopyLinePassScoreNotifyMessage(); message.setConsumeHP(0); message.setHpStar((byte) 3); message.setPassStar(starScore); message.setTime(50); message.setTimeStar((byte) 3); role.getBehavior().sendMessage(message); } catch (Exception e) { logger.error(this.getClass().getName() + ".calculateScore error: ", e); } }
/** * 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; }