예제 #1
0
 /** 领取年费黄钻每日礼包 */
 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);
 }
예제 #2
0
 /** 领取黄钻新手礼包 */
 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);
 }
예제 #3
0
 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);
 }
  @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);
  }
  @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);
  }
예제 #6
0
  @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, "");
  }