/** 领取黄钻每日礼包 */
 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);
 }
 @Override
 public void execute(CGShowEscortTab message) {
   Human human = message.getPlayer().getHuman();
   // 判断功能是否开启
   if (!GameServerAssist.getGameFuncService().gameFuncIsOpen(human, GameFuncType.ESCORT, true)) {
     return;
   }
   GlobalEscortManager globalEscortManager = GameServerAssist.getGlobalEscortManager();
   EscortInfo escortInfo = globalEscortManager.getEscortInfo(message.getEscortId());
   if (escortInfo == null) {
     return;
   }
   generateEscortInfo(human, escortInfo);
   GCShowEscortTab msg = new GCShowEscortTab();
   msg.setEscortInfo(escortInfo);
   human.sendMessage(msg);
 }
 @Override
 public void onChallengerLose(Human challenger, IBattleUnit beChallenged) {
   HumanWarriorManager warriorManager = challenger.getHumanWarriorManager();
   warriorManager.refreshOpponent(true);
   warriorManager.sendUpdateOpponentMessage();
   int damage = orignalHp - beChallenged.getBattleContext().getBattleProperty().getHp();
   warriorManager.updateQuestCounter(damage / (orignalHp * 1f));
 }
 @Override
 public void onChallengerWin(Human challenger, IBattleUnit beChallenged) {
   HumanWarriorManager warriorManager = challenger.getHumanWarriorManager();
   warriorManager.refreshOpponent(true);
   warriorManager.sendUpdateOpponentMessage();
   warriorManager.addWarriorHeartNum(winRewardWarriorHeartNum);
   warriorManager.updateQuestCounter(1);
 }
  @Override
  public void execute(CGGemPunchConfirm message) {
    Player player = message.getPlayer();
    if (player == null) {
      return;
    }

    Human human = player.getHuman();
    if (human == null) {
      return;
    }

    // 判断功能是否开放
    if (!gameFuncService.gameFuncIsOpen(human, GameFuncType.GEM_EMBED, true)) {
      return;
    }

    HumanBagManager bagManager = human.getBagManager();
    BagType equipBagType = BagType.indexOf(message.getEquipBagType());
    int equipBagIndex = message.getEquipBagIndex();
    Item equipItem = bagManager.getItem(equipBagType, equipBagIndex);

    // 判断选中装备的合法性
    if (equipItem == null || !equipItem.isEquip()) {
      return;
    }

    if (!equipItem.canGemPunch()) {
      human.sendErrorMessage(LangConstants.MAX_HOLE);
      return;
    }

    EquipItemFeature itemFeature = (EquipItemFeature) equipItem.getFeature();
    int itemId = itemFeature.getNextGemPunchItemId();
    SimpleCommonItem commonItem = CommonItemBuilder.genSimpleCommonItem(itemId);
    if (commonItem == null) {
      return;
    }
    int itemNum = itemFeature.getNextGemPunchItemNum();

    GCGemPunchConfirm gcMsg = new GCGemPunchConfirm();
    gcMsg.setItemName(commonItem.getName());
    gcMsg.setItemNum(itemNum);
    human.sendMessage(gcMsg);
  }
 private HumanYellowVipRewardStateEntity convertToEntity() {
   HumanYellowVipRewardStateInfo.Builder builder = HumanYellowVipRewardStateInfo.newBuilder();
   builder.setHumanGuid(human.getHumanGuid());
   builder.setDailyRewardState(dailyRewardState);
   builder.setYearVipDailyRewardState(yearVipDailyRewardState);
   builder.setOnceRewardState(onceRewardState);
   for (Integer state : levelUpRewardState) {
     builder.addLevelUpRewardState(state);
   }
   return new HumanYellowVipRewardStateEntity(builder);
 }
Esempio n. 8
0
 /**
  * 单个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);
 }
 /** 生成押运信息 */
 private void generateEscortInfo(Human human, EscortInfo escortInfo) {
   // 拦截奖励,由等级差决定
   int robLevelDiff = human.getLevel() - escortInfo.getOwnerLevel();
   float robRewardCoinRate =
       GameServerAssist.getEscortTemplateManager().getRobRewardCoinRate(robLevelDiff);
   escortInfo.setRobRewardCoin((int) (escortInfo.getEscortRewardCoin() * robRewardCoinRate));
   // 押运剩余时间
   if (escortInfo.getEscortState() == EscortState.UNDERWAY.getIndex()) {
     escortInfo.setEscortRemainTime(
         (int) (escortInfo.getEndTime() - GameServerAssist.getSystemTimeService().now()));
   }
 }
 private void updateLevelUpRewardState() {
   if (this.getYellowVipLevel() > 0) {
     int[] levels = GameServerAssist.getYellowVipTemplateManager().getLevelUpRewardKeys();
     int humanLevel = human.getLevel();
     for (int i = 0; i < levels.length; i++) {
       if (humanLevel >= levels[i]
           && levelUpRewardState[i] != YellowVipRewardState.HAS_GOT.getIndex()) {
         levelUpRewardState[i] = YellowVipRewardState.CAN_GET.getIndex();
       }
     }
   }
 }
 @Override
 public void onEvent(IEvent event) {
   int[] levels = GameServerAssist.getYellowVipTemplateManager().getLevelUpRewardKeys();
   if (this.getYellowVipLevel() > 0) {
     int humanLevel = human.getLevel();
     boolean isUpdate = false;
     for (int i = 0; i < levels.length; i++) {
       if (humanLevel >= levels[i]
           && levelUpRewardState[i] != YellowVipRewardState.HAS_GOT.getIndex()) {
         levelUpRewardState[i] = YellowVipRewardState.CAN_GET.getIndex();
         isUpdate = true;
       }
     }
     if (isUpdate) {
       GCUpdateYellowVipRewardState gcMsg = new GCUpdateYellowVipRewardState();
       gcMsg.setRewardType(YellowVipRewardType.LEVEL_UP_REWARD.getIndex());
       gcMsg.setRewardState(levelUpRewardState);
       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);
 }
Esempio n. 13
0
  /** 下发cd信息 */
  public void snapCdQueueInfos() {
    List<CdQueueInfo> cdQueueInfos = new ArrayList<CdQueueInfo>();
    for (CdType cdType : cdInfoMap.keySet()) {
      CdQueueInfo cdQueueInfo = new CdQueueInfo();
      cdQueueInfo.setCdType(cdType.getIndex());
      cdQueueInfo.setTimeDiff((int) getDiffTime(getCdInfo(cdType).getEndTime()));
      cdQueueInfos.add(cdQueueInfo);
    }

    GCCdQueueInfos gcMsg = new GCCdQueueInfos();
    gcMsg.setCds(cdQueueInfos.toArray(new CdQueueInfo[0]));
    human.sendMessage(gcMsg);
  }
 @Override
 public void execute(CGBattleResourceLoaded message) {
   Human human = message.getPlayer().getHuman();
   if (human == null) {
     return;
   }
   IBattleContext context = human.getBattleContext();
   if (context == null) {
     return;
   }
   Battle battle = context.getBattle();
   if (battle == null) {
     return;
   }
   // 玩家就绪
   battle.unitReady(human);
   // 是否所有玩家都已经准备好?
   if (battle.allUnitReady()) {
     // 开始战斗
     battle.startBattle();
   }
 }
Esempio n. 15
0
 /**
  * 下发加速消除cd的确认信息
  *
  * @param cdType
  */
 public void snapCdSpeedUpInfo(CdType cdType) {
   long timeDiff = getDiffTime(getCdInfo(cdType).getEndTime());
   if (timeDiff > 0) {
     CdTemplate cdTemplate =
         GameServerAssist.getCdTemplateManager().getCdTemplate(cdType.getIndex());
     int currencyNum = getRemoveCdCost(cdType, timeDiff);
     GCCdSpeedUp gcCdSpeedUpMsg = new GCCdSpeedUp();
     gcCdSpeedUpMsg.setCdType(cdType.getIndex());
     gcCdSpeedUpMsg.setCurrencyType(cdTemplate.getCurrencyType());
     gcCdSpeedUpMsg.setCurrencyNum(currencyNum);
     human.sendMessage(gcCdSpeedUpMsg);
   }
 }
 /**
  * 获取年费黄钻每日礼包领取状态
  *
  * @return
  */
 public int getYearYellowVipRewardState() {
   IntPropertyCacheSet propertySet =
       human.getPropertyManager().getIntPropertySet(PropertyType.HUMAN_INT_PROPERTY);
   int yellowVipLevel = propertySet.getPropertyValue(HumanIntProperty.YELLOW_VIP_LEVEL);
   int isYearYellowVip = propertySet.getPropertyValue(HumanIntProperty.IS_YEAR_YELLOW_VIP);
   if (yearVipDailyRewardState == YellowVipRewardState.HAS_GOT.getIndex()) {
     return yearVipDailyRewardState;
   } else if (isYearYellowVip > 0 && yellowVipLevel > 0) {
     return YellowVipRewardState.CAN_GET.getIndex();
   } else {
     return YellowVipRewardState.CANNOT_GET.getIndex();
   }
 }
 @Override
 public void onLogin() {
   int yellowVipLevel = 0;
   int isYearYellowVip = 0;
   int isYellowHighVip = 0;
   String openId = "";
   IntPropertyCacheSet propertySet =
       human.getPropertyManager().getIntPropertySet(PropertyType.HUMAN_INT_PROPERTY);
   if (human.getPlayer().getLocalProperties() != null) {
     Object objYellowVipLevel =
         human.getPlayer().getLocalProperties().get(SharedConstants.YELLOW_VIP_LEVEL);
     yellowVipLevel =
         objYellowVipLevel != null && !StringUtils.isEmpty(objYellowVipLevel.toString())
             ? Integer.parseInt(objYellowVipLevel.toString())
             : 0;
     Object objIsYearVip =
         human.getPlayer().getLocalProperties().get(SharedConstants.IS_YELLOW_YEAR_VIP);
     isYearYellowVip =
         objIsYearVip != null && !StringUtils.isEmpty(objIsYearVip.toString())
             ? Integer.parseInt(objIsYearVip.toString())
             : 0;
     Object objIsYellowHighVip =
         human.getPlayer().getLocalProperties().get(SharedConstants.IS_YELLOW_HIGH_VIP);
     isYellowHighVip =
         objIsYellowHighVip != null && !StringUtils.isEmpty(objIsYellowHighVip.toString())
             ? Integer.parseInt(objIsYellowHighVip.toString())
             : 0;
     Object objOpenId = human.getPlayer().getLocalProperties().get(SharedConstants.OPEN_ID);
     openId = objOpenId != null ? objOpenId.toString() : "";
     if (yellowVipLevel <= 0) {
       isYearYellowVip = 0;
       isYellowHighVip = 0;
     }
   }
   propertySet.setPropertyValue(HumanIntProperty.YELLOW_VIP_LEVEL, yellowVipLevel);
   propertySet.setPropertyValue(HumanIntProperty.IS_YEAR_YELLOW_VIP, isYearYellowVip);
   propertySet.setPropertyValue(HumanIntProperty.IS_YELLOW_HIGH_VIP, isYellowHighVip);
   TencentUserInfo txUserInfo = new TencentUserInfo();
   txUserInfo.setId(human.getHumanGuid());
   txUserInfo.setPassportId(human.getPlayer().getPassportId());
   txUserInfo.setOpenId(openId);
   txUserInfo.setYellowVipLevel(yellowVipLevel);
   txUserInfo.setIsYearYellowVip(isYearYellowVip == 1);
   txUserInfo.setIsYellowHighVip(isYellowHighVip == 1);
   GameServerAssist.getTencentUserInfoManager().updateTencentUserInfo(txUserInfo);
   updateLevelUpRewardState();
 }
 @Override
 public void execute(CGOpenGodsoulPanel message) {
   if (message.getPlayer() == null) {
     return;
   }
   Human human = message.getPlayer().getHuman();
   if (human == null) {
     return;
   }
   // 判断功能是否开放
   if (!gameFuncService.gameFuncIsOpen(human, GameFuncType.GODSOUL, true)) {
     return;
   }
   // 获得装备位列表信息
   List<EquipBitInfo> equipBitInfoList = human.getHumanGodsoulManager().generateEquipBitInfoList();
   GCOpenGodsoulPanel gcMsg = new GCOpenGodsoulPanel();
   gcMsg.setEquipBitInfos(equipBitInfoList.toArray(new EquipBitInfo[0]));
   List<GodsoulBuffInfo> buffInfoList =
       human.getHumanGodsoulManager().generateEquipBitBuffInfoList();
   gcMsg.setGodsoulBuffInfos(buffInfoList.toArray(new GodsoulBuffInfo[0]));
   message.getPlayer().getHuman().sendMessage(gcMsg);
   // 新手引导
   human.getHumanGuideManager().showGuide(GuideType.OPEN_GODSOUL_PANEL.getIndex());
 }
 public void resetDailyData() {
   IntPropertyCacheSet propertySet =
       human.getPropertyManager().getIntPropertySet(PropertyType.HUMAN_INT_PROPERTY);
   int yellowVipLevel = propertySet.getPropertyValue(HumanIntProperty.YELLOW_VIP_LEVEL);
   int isYearYellowVip = propertySet.getPropertyValue(HumanIntProperty.IS_YEAR_YELLOW_VIP);
   if (yellowVipLevel > 0) {
     dailyRewardState = YellowVipRewardState.CAN_GET.getIndex();
   } else {
     dailyRewardState = YellowVipRewardState.CANNOT_GET.getIndex();
   }
   if (isYearYellowVip > 0 && yellowVipLevel > 0) {
     yearVipDailyRewardState = YellowVipRewardState.CAN_GET.getIndex();
   } else {
     yearVipDailyRewardState = YellowVipRewardState.CANNOT_GET.getIndex();
   }
 }
Esempio n. 20
0
  /**
   * 消除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);
    }
  }
 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);
 }
Esempio n. 22
0
 public long getLastResetTime() {
   return human
       .getHumanPropertiesManager()
       .getLongPropertyValue(HumanLongProperty.LAST_CD_RESET_TIME);
 }
  @Override
  public void execute(CGBuyHonourShopItem message) {
    Player player = message.getPlayer();
    if (player == null) {
      return;
    }

    Human human = player.getHuman();
    if (human == null) {
      return;
    }

    // 判断功能是否开放
    if (!gameFuncService.gameFuncIsOpen(human, GameFuncType.HONOUR_SHOP, true)) {
      return;
    }

    // 客户端参数校验
    int itemId = message.getItemId();
    if (itemId < 1) {
      return;
    }
    int num = message.getNum();
    if (num < 1) {
      return;
    }

    // 判断是否是荣誉商店出售物品
    HonourShopItemInfo honourShopItemInfo = templateManager.getHonourShopItemInfo(itemId);
    if (honourShopItemInfo == null
        || !templateManager.canSee(honourShopItemInfo, human.getLevel())) {
      return;
    }

    // 判断荣誉是否足够
    int totalHonorNum = honourShopItemInfo.getNeedHonour() * num;
    if (human.getArenaHonor() < totalHonorNum) {
      String honorDesc = GameServerAssist.getSysLangService().read(LangConstants.HONOR);
      human.sendWarningMessage(LangConstants.COMMON_NOT_ENOUGH, honorDesc);
      return;
    }

    // 判断背包是否可以放得下
    if (!human.getBagManager().canContain(itemId, num)) {
      human.sendWarningMessage(LangConstants.BAG_IS_FULL);
      return;
    }

    // 扣除荣誉
    human.setArenaHonor(human.getArenaHonor() - totalHonorNum);
    // 记录荣誉变更日志
    GameServerAssist.getLogService()
        .sendHonourLog(
            human,
            HonourLogReason.HONOR_SHOP_BUY_ITEM,
            "",
            honourShopItemInfo.getNeedHonour(),
            human.getArenaHonor());
    // 给物品
    human.getBagManager().putItems(BagType.MAIN_BAG, itemId, num, ItemLogReason.HONOUR_SHOP, "");

    GCBuyHonourShopItem gcMsg = new GCBuyHonourShopItem();
    gcMsg.setSuccess(true);
    gcMsg.setLeftHonour(human.getArenaHonor());
    human.sendMessage(gcMsg);
  }
Esempio n. 24
0
 public void setLastResetTime(long lastResetTime) {
   human
       .getHumanPropertiesManager()
       .setLongPropertyValue(HumanLongProperty.LAST_CD_RESET_TIME, lastResetTime);
 }
 /**
  * 获取黄钻等级
  *
  * @return
  */
 public int getYellowVipLevel() {
   return human
       .getPropertyManager()
       .getIntPropertySet(PropertyType.HUMAN_INT_PROPERTY)
       .getPropertyValue(HumanIntProperty.YELLOW_VIP_LEVEL);
 }
 private void sendCostNotifyInfo() {
   GCUpdateCostNotify gcMsg = new GCUpdateCostNotify();
   gcMsg.setCostNotifyInfos(_costNotifyInfoMap.values().toArray(new CostNotifyInfo[0]));
   _human.sendMessage(gcMsg);
 }
  @Override
  public void execute(CGSellShopItem message) {
    Player player = message.getPlayer();
    if (player == null) {
      return;
    }

    Human human = player.getHuman();
    if (human == null) {
      return;
    }

    // 判断功能是否开放
    if (!gameFuncService.gameFuncIsOpen(human, GameFuncType.SHOP, true)) {
      return;
    }

    BagType bagType = BagType.indexOf(message.getBagType());
    int bagIndex = message.getBagIndex();
    Item item = human.getBagManager().getItem(bagType, bagIndex);
    if (item == null) {
      return;
    }

    // 判断物品是否可以出售
    ItemTemplate itemTemplate = templateManager.getItemTemplate(item.getItemId());
    if (itemTemplate == null || !itemTemplate.canSell()) {
      human.sendErrorMessage(LangConstants.CAN_NOT_SELL_ITEM);
      return;
    }

    int num = message.getNum();
    if (num < 1) {
      return;
    }

    if (item.getOverlapNum() < num) {
      return;
    }
    int sellPrice = item.getSellCurrencyNum();
    if (item.isEquip()) {
      EquipItemFeature feature = (EquipItemFeature) item.getFeature();
      if (feature.isEquiped()) {
        human.sendErrorMessage(LangConstants.CAN_NOT_SELL);
        return;
      }
      EquipUpgradeTemplate upgradeTemplate =
          GameServerAssist.getEquipUpgradeTemplateManager()
              .getEquipUpgradeTemplate(item.getItemId(), feature.getLevel());
      if (upgradeTemplate != null) {
        sellPrice = upgradeTemplate.getSellPrice();
      }
    }

    human
        .getWallet()
        .addMoney(
            CurrencyType.indexOf(item.getSellCurrencyType()),
            sellPrice * num,
            true,
            MoneyLogReason.SHOP_SELL,
            "");

    human
        .getBagManager()
        .removeItem(item.getBagType(), item.getBagIndex(), num, ItemLogReason.SHOP_SELL, "");
  }