/** 领取黄钻每日礼包 */ public void receiveDailyReward() { if (this.getYellowVipDailyRewardState() != YellowVipRewardState.CAN_GET.getIndex()) { return; } int yellowVipLevel = this.getYellowVipLevel(); if (yellowVipLevel <= 0) { return; } YellowVipDailyRewardTemplate template = GameServerAssist.getYellowVipTemplateManager() .getYellowVipDailyRewardTemplate(human.getLevel()); if (template == null) { return; } int maxRewardLevel = template.getVipCoin().size(); int rewardIndex = yellowVipLevel >= maxRewardLevel ? maxRewardLevel - 1 : yellowVipLevel - 1; human .getWallet() .addMoney( CurrencyType.COIN, template.getVipCoin().get(rewardIndex), true, MoneyLogReason.YELLOW_VIP_DAILY_REWARD, ""); dailyRewardState = YellowVipRewardState.HAS_GOT.getIndex(); cache.addUpdate(human.getHumanGuid(), convertToEntity()); GCUpdateYellowVipRewardState gcMsg = new GCUpdateYellowVipRewardState(); gcMsg.setRewardType(YellowVipRewardType.DAILY_REWARD.getIndex()); gcMsg.setRewardState(new int[] {dailyRewardState}); human.sendMessage(gcMsg); }
/** 领取黄钻新手礼包 */ public void receiveOnceReward() { if (getYellowVipOnceRewardState() != YellowVipRewardState.CAN_GET.getIndex()) { return; } int itemId = GameServerAssist.getYellowVipTemplateManager().getOnceRewardItemId(); Item rewardItem = ItemFactory.creatNewItem(human, itemId); if (rewardItem == null) { return; } int itemCount = 1; if (rewardItem.getType() == ItemDetailType.VIRTUAL_SPREE.getIndex()) { SpreeTemplate spreeTemplate = GameServerAssist.getSpreeTemplateManager().getSpreeTemplate(itemId); if (spreeTemplate == null) { return; } itemCount = spreeTemplate.getItems().size() < spreeTemplate.getItemCount() ? spreeTemplate.getItems().size() : spreeTemplate.getItemCount(); } if (human.getBagManager().getFreeSize(BagType.MAIN_BAG) < itemCount) { human.sendErrorMessage(LangConstants.BAG_FREE_UNIT_NOT_ENOUGH); return; } human .getBagManager() .putItems(BagType.MAIN_BAG, itemId, 1, ItemLogReason.YELLOW_VIP_ONCE_REWARD, ""); onceRewardState = YellowVipRewardState.HAS_GOT.getIndex(); cache.addUpdate(human.getHumanGuid(), convertToEntity()); GCUpdateYellowVipRewardState gcMsg = new GCUpdateYellowVipRewardState(); gcMsg.setRewardType(YellowVipRewardType.ONCE_REWARD.getIndex()); gcMsg.setRewardState(new int[] {onceRewardState}); human.sendMessage(gcMsg); }
/** 领取年费黄钻每日礼包 */ public void receiveYearVipDailyReward() { if (this.getYearYellowVipRewardState() != YellowVipRewardState.CAN_GET.getIndex()) { return; } YearYellowVipRewardTemplate template = GameServerAssist.getYellowVipTemplateManager().getYearYellowVipRewardTemplate(); if (human.getBagManager().getFreeSize(BagType.MAIN_BAG) < 2) { human.sendErrorMessage(LangConstants.BAG_FREE_UNIT_NOT_ENOUGH); return; } human .getBagManager() .putItems( BagType.MAIN_BAG, template.getItemId1(), template.getItemCount1(), ItemLogReason.YEAR_YELLOW_VIP_DAILY_REWARD, ""); human .getBagManager() .putItems( BagType.MAIN_BAG, template.getItemId2(), template.getItemCount2(), ItemLogReason.YEAR_YELLOW_VIP_DAILY_REWARD, ""); yearVipDailyRewardState = YellowVipRewardState.HAS_GOT.getIndex(); cache.addUpdate(human.getHumanGuid(), convertToEntity()); GCUpdateYellowVipRewardState gcMsg = new GCUpdateYellowVipRewardState(); gcMsg.setRewardType(YellowVipRewardType.YEAR_VIP_REWARD.getIndex()); gcMsg.setRewardState(new int[] {yearVipDailyRewardState}); human.sendMessage(gcMsg); }
/** 重置cd的疲劳度 */ public void resetCdTired() { for (CdInfo cdInfo : cdInfoMap.values()) { cdInfo.setTimes(0); cdInfoMap.put(CdType.indexOf(cdInfo.getCdType()), cdInfo); // 同步缓存 cdInfoCaches.addUpdate(CdType.indexOf(cdInfo.getCdType()), cdInfo); } }
/** * 减少CD时间 * * @param time 减少时间 */ public void reduceCdTime(CdType cdType, long time) { if (!cdInfoMap.containsKey(cdType)) { return; } CdInfo cdInfo = getCdInfo(cdType); cdInfo.setEndTime(cdInfo.getEndTime() - time); cdInfoMap.put(cdType, cdInfo); // 同步缓存 cdInfoCaches.addUpdate(cdType, cdInfo); }
/** * 单个cd信息下发 * * @param cdType */ public void snapCdQueueInfo(CdType cdType) { CdQueueInfo cdQueueInfo = new CdQueueInfo(); cdQueueInfo.setCdType(cdType.getIndex()); CdInfo cdInfo = getCdInfo(cdType); cdQueueInfo.setTimeDiff((int) getDiffTime(getCdInfo(cdType).getEndTime())); GCCdQueueInfo gcMsg = new GCCdQueueInfo(); gcMsg.setCd(cdQueueInfo); human.sendMessage(gcMsg); cdInfoMap.put(cdType, cdInfo); // 同步缓存 cdInfoCaches.addUpdate(cdType, cdInfo); }
/** * 免费消除cd * * @param cdType */ public void removeCdFree(CdType cdType) { if (!cdInfoMap.containsKey(cdType)) { return; } long now = GameServerAssist.getSystemTimeService().now(); CdInfo cdInfo = getCdInfo(cdType); cdInfo.setEndTime(now); cdInfoMap.put(cdType, cdInfo); // 同步缓存 cdInfoCaches.addUpdate(cdType, cdInfo); }
/** * 消除cdType的cd * * @param cdType */ public void removeCd(CdType cdType) { long now = GameServerAssist.getSystemTimeService().now(); // 获取cd时间 long cdInterval = getDiffTime(getCdInfo(cdType).getEndTime()); if (cdInterval <= 0) { return; } // 计算需要消耗的货币数量 CdTemplate cdTemplate = GameServerAssist.getCdTemplateManager().getCdTemplate(cdType.getIndex()); if (!cdTemplate.isCanRemove()) { return; } CurrencyType currencyType = CurrencyType.indexOf(cdTemplate.getCurrencyType()); int currencyNum = getRemoveCdCost(cdType, cdInterval); // 判断是否有足够的货币 if (!human.getWallet().isEnough(currencyType, currencyNum)) { human.sendWarningMessage(LangConstants.COMMON_NOT_ENOUGH, currencyType.getDesc()); return; } // 扣除货币 boolean cost = human.getWallet().costMoney(currencyType, currencyNum, MoneyLogReason.REMOVE_CD, ""); // 消除cd if (!cost) { logger.error( "消除cd时扣除对应货币失败。humanid" + human.getHumanGuid() + "; currencyType:" + currencyType.getDesc() + "; num:" + currencyNum); human.sendErrorMessage(LangConstants.SERVER_ERROR); return; } CdInfo cdInfo = getCdInfo(cdType); cdInfo.setEndTime(now); cdInfoMap.put(cdType, cdInfo); // 同步缓存 cdInfoCaches.addUpdate(cdType, cdInfo); // 押运CD特殊处理 if (cdType == CdType.ESCORT) { EscortInfo escortInfo = GameServerAssist.getGlobalEscortManager().getEscortInfo(human.getHumanGuid()); GameServerAssist.getGlobalEscortManager().endEscort(escortInfo); } }
/** * 增加CD时间 * * @param time 增加时间 */ public void addCdTime(CdType cdType, long time) { if (!cdInfoMap.containsKey(cdType)) { return; } CdInfo cdInfo = getCdInfo(cdType); long endTime = cdInfo.getEndTime(); long now = GameServerAssist.getSystemTimeService().now(); if (endTime < now) { endTime = now; } cdInfo.setEndTime(endTime + time); cdInfoMap.put(cdType, cdInfo); // 同步缓存 cdInfoCaches.addUpdate(cdType, cdInfo); }
public void receiveLevelUpReward(int rewardIndex) { if (rewardIndex < 0 || rewardIndex > levelUpRewardState.length - 1) { return; } if (levelUpRewardState[rewardIndex] != YellowVipRewardState.CAN_GET.getIndex()) { return; } int[] levels = GameServerAssist.getYellowVipTemplateManager().getLevelUpRewardKeys(); if (human.getLevel() < levels[rewardIndex]) { return; } if (human.getBagManager().getFreeSize(BagType.MAIN_BAG) < 1) { human.sendErrorMessage(LangConstants.BAG_FREE_UNIT_NOT_ENOUGH); return; } YellowVipLevelUpRewardTemplate template = GameServerAssist.getYellowVipTemplateManager() .getYellowVipLevelUpRewardTemplate(levels[rewardIndex]); human .getWallet() .addMoney( CurrencyType.COIN, template.getCoin(), true, MoneyLogReason.YELLOW_VIP_LEVEL_UP_REWARD, ""); human .getBagManager() .putItems( BagType.MAIN_BAG, template.getItemId(), template.getItemCount(), ItemLogReason.YELLOW_VIP_LEVEL_UP_REWARD, ""); levelUpRewardState[rewardIndex] = YellowVipRewardState.HAS_GOT.getIndex(); cache.addUpdate(human.getHumanGuid(), convertToEntity()); GCUpdateYellowVipRewardState gcMsg = new GCUpdateYellowVipRewardState(); gcMsg.setRewardType(YellowVipRewardType.LEVEL_UP_REWARD.getIndex()); gcMsg.setRewardState(levelUpRewardState); human.sendMessage(gcMsg); }
/** * 添加ms长的时间 * * @param cdType * @param ms */ public void addCd(CdType cdType, long ms) { // 出现ms小于零的情况肯定是非法情况 if (ms < 0) { return; } // 调用添加cd之前应该已经判断过,所以如果再次判断不能添加直接返回 if (!canAddCd(cdType, ms)) { return; } CdInfo cdInfo = getCdInfo(cdType); long now = GameServerAssist.getSystemTimeService().now(); if (cdInfo.getEndTime() < now) { cdInfo.setEndTime(now + ms); } else { cdInfo.setEndTime(cdInfo.getEndTime() + ms); } cdInfo.setTimes(cdInfo.getTimes() + 1); cdInfoMap.put(cdType, cdInfo); // 同步缓存 cdInfoCaches.addUpdate(cdType, cdInfo); }
/** * 更新某个消费通知的设置 * * @param costNotifyType * @param costNotifyInfo */ public void updateCostNotifyInfo(Integer costNotifyType, CostNotifyInfo costNotifyInfo) { _costNotifyInfoMap.put(costNotifyType, costNotifyInfo); _costNotifyInfoCaches.addUpdate(CostNotifyType.indexOf(costNotifyType), costNotifyInfo); }