示例#1
0
  @Override
  public boolean summonFallBox(
      NpcInstance dieNpc, Summon summon, RoleInstance ownerInstance, RoleInstance summonInstance) {
    if (null == dieNpc || null == ownerInstance || null == ownerInstance.getMapInstance()) {
      return false;
    }
    String templateId = dieNpc.getNpc().getNpcid();
    OutputConsumeType ocType = OutputConsumeType.summon_monster_fall;
    List<GoodsOperateBean> npcLootList = this.getLootGoodsBeanMap(templateId);
    Collection<RoleInstance> sameMapMembers = ownerInstance.getMapInstance().getRoleList();

    if (null != summonInstance && !Util.isEmpty(npcLootList)) {
      this.npcDieFallBox(summonInstance, npcLootList, dieNpc, ocType);
      // 通知玩家个人获得的奖励
      sendSummonFall(sameMapMembers, npcLootList, summonInstance.getRoleName());
    }

    // 全员奖励
    List<GoodsOperateBean> allLootList = summon.getAllGainGoods();
    if (Util.isEmpty(allLootList)) {
      return true;
    }
    // 获得本地图内的玩家
    for (AbstractRole itemRole : ownerInstance.getMapInstance().getRoleList()) {
      // 给地图内玩家发放奖励
      this.npcDieFallBox((RoleInstance) itemRole, allLootList, dieNpc, ocType);
    }
    return true;
  }
  @Override
  public Message execute(ActionContext context, C2341_TitleListSelfReqMessage reqMsg) {
    RoleInstance role = this.getCurrentRole(context);
    if (null == role) {
      return null;
    }
    C2341_TitleListSelfRespMessage respMsg = new C2341_TitleListSelfRespMessage();
    Map<Integer, TitleRecord> titleMap = role.getTitleMap();
    if (Util.isEmpty(titleMap)) {
      return respMsg;
    }
    int titleNum = titleMap.size();

    Map<Integer, TitleCategory> categoryMap = GameContext.getTitleApp().getTitleCategoryMap();
    if (Util.isEmpty(categoryMap)) {
      return respMsg;
    }

    int titleNowNum = 0;
    List<TitleCategoryItem> itemList = new ArrayList<TitleCategoryItem>();
    for (TitleCategory c : categoryMap.values()) {
      List<GoodsTitle> titleList = c.getTitleList();
      if (Util.isEmpty(titleList)) {
        continue;
      }
      TitleCategoryItem citem = null;
      for (GoodsTitle title : titleList) {
        int titleId = title.getId();
        TitleRecord record = titleMap.get(titleId);
        if (null == record) {
          continue;
        }
        if (null == citem) {
          citem = new TitleCategoryItem();
          citem.setCategoryName(c.getCategoryName());
        }
        TitleItem titleItem = new TitleItem();
        titleItem.setTitleId(titleId);
        titleItem.setTitleName(title.getName());
        titleItem.setStatus(record.getActivateState());
        citem.getTitles().add(titleItem);
        titleNowNum++;
        // 提前结束循环
        if (titleNowNum >= titleNum) {
          break;
        }
      }
      if (null != citem) {
        itemList.add(citem);
      }
      // 提前结束循环
      if (titleNowNum >= titleNum) {
        break;
      }
    }
    respMsg.setItemList(itemList);
    return respMsg;
  }
 @Override
 public Message execute(ActionContext arg0, C10030_MailRecoupListReqMessage reqMsg) {
   C10030_MailRecoupListRespMessage resp = new C10030_MailRecoupListRespMessage();
   Collection<Recoup> collection = GameContext.getRecoupApp().getAllRecoup();
   if (Util.isEmpty(collection)) {
     return resp;
   }
   List<MailRecoupItem> recoupList = new ArrayList<MailRecoupItem>();
   for (Recoup recoup : collection) {
     if (null == recoup) {
       continue;
     }
     MailRecoupItem item = new MailRecoupItem();
     item.setId(recoup.getId());
     item.setSenderName(recoup.getSenderName());
     item.setTitle(recoup.getTitle());
     item.setContent(recoup.getContext());
     item.setBindMoney(recoup.getBindMoney());
     item.setSilverMoney(recoup.getGameMoney());
     item.setGoodsInfo(recoup.getGoodsInfo());
     item.setStartTime(recoup.getStartTime());
     item.setEndTime(recoup.getEndTime());
     recoupList.add(item);
   }
   resp.setRecoupList(recoupList);
   return resp;
 }
 private void notifyPass() {
   String passTips = this.copyLineConfig.getPassTips();
   if (!Util.isEmpty(passTips)) {
     GameContext.getChatApp()
         .sendSysMessage(ChatSysName.System, ChannelType.Map, passTips, null, this);
   }
 }
示例#5
0
 private void loadBuffConfig() {
   // 加载擂台赛配置
   String fileName = XlsSheetNameType.arena_buff_config.getXlsName();
   String sheetName = XlsSheetNameType.arena_buff_config.getSheetName();
   try {
     String sourceFile = GameContext.getPathConfig().getXlsPath() + fileName;
     List<ArenaBuffConfig> list =
         XlsPojoUtil.sheetToList(sourceFile, sheetName, ArenaBuffConfig.class);
     if (Util.isEmpty(list)) {
       return;
     }
     for (ArenaBuffConfig config : list) {
       if (null == config) {
         continue;
       }
       int arenaType = config.getArenaType();
       if (!buffConfigMap.containsKey(arenaType)) {
         buffConfigMap.put(arenaType, new ArrayList<ArenaBuffConfig>());
       }
       buffConfigMap.get(arenaType).add(config);
     }
   } catch (Exception ex) {
     Log4jManager.checkFail();
     Log4jManager.CHECK.error(
         "loadExel error : sourceFile = " + fileName + " sheetName =" + sheetName, ex);
   }
 }
示例#6
0
 /**
  * 根据ID结构判断点类型
  *
  * @param entryId
  * @return
  */
 public PointType getPointType(String entryId) {
   PointType def = PointType.Unknow;
   if (sacred.alliance.magic.util.Util.isEmpty(entryId) || entryId.indexOf(Cat.underline) <= 0) {
     return def;
   }
   int type = Integer.parseInt(entryId.split(Cat.underline)[0]);
   return PointType.get(type);
 }
示例#7
0
 public String getUnionName(String unionId) {
   if (Util.isEmpty(unionId)) {
     return "";
   }
   Union union = GameContext.getUnionApp().getUnion(unionId);
   if (null == union) {
     return "";
   }
   return union.getUnionName();
 }
示例#8
0
  @Override
  public AddGoodsBeanResult pickupAction(
      String entryId, RoleInstance role, int itemId, List<FallItem> fallList, int outputType) {

    AddGoodsBeanResult result = new AddGoodsBeanResult();
    if (Util.isEmpty(fallList)) {
      result.setResult(Result.FAIL);
      return result;
    }

    List<GoodsOperateBean> pickupList = new ArrayList<GoodsOperateBean>();
    for (Iterator<FallItem> it = fallList.iterator(); it.hasNext(); ) {
      FallItem item = it.next();
      GoodsLiteNamedItem goodsItem = item.getGoodsItem();
      // 全部拾取
      if (itemId <= 0) {
        pickupList.add(
            GoodsOperateBean.createAddGoodsBean(
                goodsItem.getGoodsId(), goodsItem.getNum(), goodsItem.getBindType()));
        continue;
      }
      // 单个拾取
      if (goodsItem.getGoodsId() == itemId) {
        pickupList.add(
            GoodsOperateBean.createAddGoodsBean(
                goodsItem.getGoodsId(), goodsItem.getNum(), goodsItem.getBindType()));
        break;
      }
    }

    if (Util.isEmpty(pickupList)) {
      result.setResult(Result.FAIL);
      return result;
    }

    result =
        GameContext.getUserGoodsApp()
            .addSomeGoodsBeanForBag(role, pickupList, OutputConsumeType.getType(outputType));
    result.setResult(Result.SUCCESS);

    return result;
  }
示例#9
0
  @Override
  public void listEntry(String entryId, RoleInstance caller) {
    if (null == caller || Util.isEmpty(entryId)) {
      return;
    }
    MapInstance mapInstance = caller.getMapInstance();
    if (null == mapInstance) {
      return;
    }

    // 采集点情况
    PointType pointType = GameContext.getFallApp().getPointType(entryId);
    if (pointType.isCollectPoint()) {
      CollectablePoint<RoleInstance> cp = mapInstance.getCollectPointMap().get(entryId);
      if (null == cp) {
        return;
      }
      // 采集点条件
      String info = cp.isSatisfyCond(caller);
      if (!Util.isEmpty(info)) {
        caller
            .getBehavior()
            .sendMessage(new C0602_FallListRespMessage(FallRespType.error.getType(), info));
        return;
      }
      // 触发采集点
      try {
        cp.trigger(caller);
      } catch (ServiceException e) {
        logger.error("", e);
      }
      return;
    }
    // box情况
    if (pointType.isBox()) {
      C0602_FallListRespMessage respMsg = new C0602_FallListRespMessage();
      respMsg.setType(FallRespType.fall.getType());
      respMsg.setFallItemList(this.getBoxFallItemList(entryId, caller));
      respMsg.setInstanceId(entryId);
      caller.getBehavior().sendMessage(respMsg);
    }
  }
 private boolean hasEnemy(Collection<NpcInstance> npcList) {
   if (Util.isEmpty(npcList)) {
     return false;
   }
   for (NpcInstance npc : npcList) {
     if (npc.getNpc().getNpctype() == NpcType.monster.getType()) {
       return true;
     }
   }
   return false;
 }
 private boolean hasBoss(Collection<NpcInstance> npcList, String npcId) {
   if (Util.isEmpty(npcList)) {
     return false;
   }
   for (NpcInstance npc : npcList) {
     if (npc.getNpcid().equals(npcId)) {
       return true;
     }
   }
   return false;
 }
示例#12
0
  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;
  }
示例#13
0
 /**
  * npc死亡时的掉落(npc本身、世界)
  *
  * @param templateId
  * @return
  */
 private List<GoodsOperateBean> getLootGoodsBeanMap(String templateId) {
   if (Util.isEmpty(templateId)) {
     return null;
   }
   NpcTemplate npcTemplate = GameContext.getNpcApp().getNpcTemplate(templateId);
   LootList npcLootList = npcLootListMap.get(npcTemplate.getLootNpc() + "");
   LootList worldLootList = worldLootListMap.get(npcTemplate.getLootWorld() + "");
   // npc掉落的物品Map
   // 世界与npc掉落合并
   return this.mergerGoodsBeanMap(
       this.getGoodsBean(npcLootList), this.getGoodsBean(worldLootList));
 }
示例#14
0
 private void broadcast(String roleName, String npcId, List<GoodsOperateBean> itemList) {
   try {
     if (Util.isEmpty(itemList)) {
       return;
     }
     for (GoodsOperateBean bean : itemList) {
       if (null == bean) {
         continue;
       }
       int goodsId = bean.getGoodsId();
       GameContext.getBroadcastApp().broadCast(roleName, goodsId, npcId, BroadcastType.loot);
     }
   } catch (Exception e) {
     logger.error("FallApp.broadcast error:", e);
   }
 }
示例#15
0
 private boolean npcDieFallBox(
     RoleInstance role,
     List<GoodsOperateBean> itemList,
     NpcInstance dieNpc,
     OutputConsumeType ocType) {
   if (Util.isEmpty(itemList)) {
     return false;
   }
   boolean result = this.fallBox(role, itemList, ocType, dieNpc.getMapX(), dieNpc.getMapY(), true);
   // 广播
   broadcast(role.getRoleName(), dieNpc.getNpcid(), itemList);
   if (dieNpc.getNpc().npcIsBoss()) {
     // 如果是boss,打印日志
     GameContext.getStatLogApp().goodsFallLog(role, dieNpc.getNpc(), itemList);
   }
   return result;
 }
示例#16
0
  private boolean boxed(
      RoleInstance role, List<GoodsOperateBean> goodsList, int x, int y, OutputConsumeType ocType) {
    if (Util.isEmpty(goodsList)) {
      return false;
    }
    // 未拾取完毕的物品直接掉落背包
    // 将未放入背包的物品(背包已满)放入box
    BoxEntry box = new BoxEntry(role, goodsList, this.getBoxId(), x, y, ocType.getType());
    box.cache();
    box.notifyOwner();

    C0003_TipNotifyMessage tipNotifyMsg = new C0003_TipNotifyMessage();
    tipNotifyMsg.setMsgContext(Status.GOODS_BACKPACK_FULL_TIPS.getTips());
    role.getBehavior().sendMessage(tipNotifyMsg);

    return true;
  }
示例#17
0
  @Override
  public short getBuffId(int arenaType) {
    List<ArenaBuffConfig> list = this.buffConfigMap.get(arenaType);
    if (Util.isEmpty(list)) {
      return 0;
    }
    int dateDiff = DateUtil.dateDiffDay(GameContext.gameStartDate, new Date());
    for (ArenaBuffConfig config : list) {
      if (null == config) {
        continue;
      }

      if (config.isSuitDay(dateDiff)) {
        return config.getBuffId();
      }
    }
    return 0;
  }
示例#18
0
 @Override
 public Message getArena3V3LevelDescMessage(RoleInstance role) {
   C3866_Arena3V3LevelDescRespMessage respMsg = new C3866_Arena3V3LevelDescRespMessage();
   if (Util.isEmpty(reward3V3List)) {
     return respMsg;
   }
   List<Arena3V3LevelDescItem> descList = Lists.newArrayList();
   for (Reward3V3Config config : this.reward3V3List) {
     if (null == config) {
       continue;
     }
     Arena3V3LevelDescItem item = new Arena3V3LevelDescItem();
     item.setName(config.getName());
     item.setValue(config.getArenaMinLevel());
     descList.add(item);
   }
   respMsg.setDescList(descList);
   return respMsg;
 }
示例#19
0
 private void loadReward3V3() {
   // 加载擂台赛配置
   String fileName = XlsSheetNameType.arena_reward_3v3.getXlsName();
   String sheetName = XlsSheetNameType.arena_reward_3v3.getSheetName();
   try {
     String sourceFile = GameContext.getPathConfig().getXlsPath() + fileName;
     reward3V3List = XlsPojoUtil.sheetToList(sourceFile, sheetName, Reward3V3Config.class);
   } catch (Exception ex) {
     Log4jManager.checkFail();
     Log4jManager.CHECK.error(
         "loadExel error : sourceFile = " + fileName + " sheetName =" + sheetName, ex);
   }
   if (Util.isEmpty(this.reward3V3List)) {
     Log4jManager.checkFail();
     Log4jManager.CHECK.error(
         "not any config: sourceFile = " + fileName + " sheetName =" + sheetName);
   }
   for (Reward3V3Config config : reward3V3List) {
     config.init();
   }
 }
示例#20
0
  private void sendSummonFall(
      Collection<RoleInstance> sameMapMembers, List<GoodsOperateBean> goodsList, String name) {
    try {
      if (Util.isEmpty(goodsList)) {
        return;
      }
      String mapStr = Wildcard.getChatGoodsName(goodsList, ChannelType.Map);

      C1802_ChatRouteRespMessage mapTrsMsg = new C1802_ChatRouteRespMessage();
      mapTrsMsg.setChannelType(ChannelType.Map.getType());
      mapTrsMsg.setMessage(name + GameContext.getI18n().getText(TextId.FALL_GAIN) + mapStr);
      mapTrsMsg.setContextList(null);
      mapTrsMsg.setSendRoleId(-1);
      mapTrsMsg.setSendRoleName(GameContext.getI18n().getText(TextId.SYSTEM));
      for (AbstractRole role : sameMapMembers) {
        role.getBehavior().sendMessage(mapTrsMsg);
      }
    } catch (Exception e) {
      logger.error("sendSummonFall error", e);
    }
  }
示例#21
0
 private void loadAreanMapRule() {
   // 加载擂台赛配置
   String fileName = XlsSheetNameType.arena_map_rule.getXlsName();
   String sheetName = XlsSheetNameType.arena_map_rule.getSheetName();
   try {
     String sourceFile = GameContext.getPathConfig().getXlsPath() + fileName;
     mapRuleMap = XlsPojoUtil.sheetToGenericMap(sourceFile, sheetName, ArenaMapRule.class);
   } catch (Exception ex) {
     Log4jManager.checkFail();
     Log4jManager.CHECK.error(
         "loadExel error : sourceFile = " + fileName + " sheetName =" + sheetName, ex);
   }
   if (Util.isEmpty(this.mapRuleMap)) {
     Log4jManager.checkFail();
     Log4jManager.CHECK.error(
         "not any config: sourceFile = " + fileName + " sheetName =" + sheetName);
   }
   for (ArenaMapRule rule : mapRuleMap.values()) {
     if (null == rule) {
       continue;
     }
     String mapId = rule.getMapId();
     sacred.alliance.magic.app.map.Map map = GameContext.getMapApp().getMap(mapId);
     if (null == map) {
       Log4jManager.checkFail();
       Log4jManager.CHECK.error("The arena map is not exist.mapId = " + mapId);
       return;
     }
     if (!map.getMapConfig().changeLogicType(MapLogicType.arena3V3)) {
       Log4jManager.checkFail();
       Log4jManager.CHECK.error(
           "map not exist or change map:"
               + mapId
               + " to "
               + MapLogicType.arena3V3.getType()
               + " fail");
     }
     rule.init();
   }
 }
示例#22
0
 @Override
 public boolean fallBox(
     RoleInstance role,
     List<GoodsOperateBean> itemList,
     OutputConsumeType ocType,
     int x,
     int y,
     boolean fullSendMail) {
   if (null == role || Util.isEmpty(itemList)) {
     return false;
   }
   MapInstance mapInstance = role.getMapInstance();
   if (null == mapInstance) {
     return false;
   }
   AddGoodsBeanResult result =
       GameContext.getUserGoodsApp().addSomeGoodsBeanForBag(role, itemList, ocType);
   if (fullSendMail) {
     result = this.fallMail(role, result.getPutFailureList(), ocType);
   }
   this.boxed(role, result.getPutFailureList(), x, y, ocType);
   return result.isSuccess();
 }
  @Override
  public Message execute(ActionContext context, C1261_HeroExchangeListReqMessage reqMsg) {
    RoleInstance role = this.getCurrentRole(context);
    if (null == role) {
      return null;
    }
    List<Integer> heroIdList = GameContext.getHeroApp().getHeroExchangeList();
    C1261_HeroExchangeListRespMessage respMsg = new C1261_HeroExchangeListRespMessage();
    if (Util.isEmpty(heroIdList)) {
      return respMsg;
    }

    List<HeroExchangeGoodsItem> heroList = Lists.newArrayList();
    for (int goodsId : heroIdList) {
      GoodsHero hero = GameContext.getGoodsApp().getGoodsTemplate(GoodsHero.class, goodsId);
      if (null == hero) {
        continue;
      }
      RoleHero roleHero = GameContext.getUserHeroApp().getRoleHero(role.getRoleId(), goodsId);
      if (null != roleHero) {
        // 用户已经拥有的
        continue;
      }
      HeroExchangeGoodsItem item = new HeroExchangeGoodsItem();
      item.setGoodsId(goodsId);
      item.setName(hero.getName());
      item.setQuality(hero.getQualityType());
      item.setImageId(hero.getImageId());
      item.setShadowId(hero.getShadowId());
      item.setNeedShadowNum((short) hero.getShadowNum());
      item.setStar(hero.getBornStar());
      heroList.add(item);
    }
    respMsg.setHeroList(heroList);
    return respMsg;
  }
示例#24
0
 private void loadAreanMapConfig() {
   // 加载擂台赛配置
   String fileName = XlsSheetNameType.arena_map_config.getXlsName();
   String sheetName = XlsSheetNameType.arena_map_config.getSheetName();
   try {
     String sourceFile = GameContext.getPathConfig().getXlsPath() + fileName;
     mapConfigMap = XlsPojoUtil.sheetToGenericMap(sourceFile, sheetName, ArenaMapConfig.class);
   } catch (Exception ex) {
     Log4jManager.checkFail();
     Log4jManager.CHECK.error(
         "loadExel error : sourceFile = " + fileName + " sheetName =" + sheetName, ex);
   }
   if (Util.isEmpty(this.mapConfigMap)) {
     Log4jManager.checkFail();
     Log4jManager.CHECK.error(
         "not any config: sourceFile = " + fileName + " sheetName =" + sheetName);
   }
   for (ArenaMapConfig config : mapConfigMap.values()) {
     if (null == config) {
       continue;
     }
     config.init();
   }
 }
示例#25
0
  @Override
  public boolean fallBox(NpcInstance dieNpc, RoleInstance role, OutputConsumeType ocType) {
    // 1.获得npc掉落
    // 2.获得世界掉落
    // 3.获得任务掉落
    // 4.生成宝箱
    if (null == dieNpc || null == role || null == role.getMapInstance()) {
      return false;
    }
    String templateId = dieNpc.getNpc().getNpcid();
    Team team = role.getTeam();

    if (null == team || team.getOnlinePlayerNum() <= 1) {
      // 获得掉落物品
      List<GoodsOperateBean> npcLootList = this.getLootGoodsBeanMap(templateId);
      // 任务掉落
      List<GoodsOperateBean> questGoodsList = this.getQuestLootList(templateId, role);
      if (!Util.isEmpty(questGoodsList)) {
        if (null == npcLootList) {
          npcLootList = new ArrayList<GoodsOperateBean>();
        }
        npcLootList.addAll(questGoodsList);
      }
      return this.npcDieFallBox(role, npcLootList, dieNpc, ocType);
    }

    // 获得本地图内同队伍的玩家
    MapInstance mapInstance = role.getMapInstance();
    List<AbstractRole> sameMapMembers = new ArrayList<AbstractRole>();
    for (AbstractRole member : team.getMembers()) {
      MapInstance mi = member.getMapInstance();
      if (null == mi || !mi.getInstanceId().equals(mapInstance.getInstanceId())) {
        continue;
      }
      sameMapMembers.add(member);
    }

    NpcTemplate npcTemplate = GameContext.getNpcApp().getNpcTemplate(templateId);
    LootList lootList = npcLootListMap.get(npcTemplate.getLootNpc() + "");
    LootList worldLootList = worldLootListMap.get(npcTemplate.getLootWorld() + "");

    List<GoodsOperateBean> needRollList = null;
    List<GoodsOperateBean> allMapGoodsList = null;
    if (null != lootList && lootList.getLootType() == NpcLootType.NORMAL.getType()) {
      needRollList =
          this.mergerGoodsBeanMap(this.getGoodsBean(lootList), this.getGoodsBean(worldLootList));
    } else {
      needRollList = this.getGoodsBean(worldLootList);
      allMapGoodsList = this.getGoodsBean(lootList);
    }
    // roll点分配
    Map<String, List<GoodsOperateBean>> rollList = this.roll(needRollList, sameMapMembers);
    for (AbstractRole itemRole : sameMapMembers) {
      List<GoodsOperateBean> roleRollList = rollList.get(itemRole.getRoleId());
      List<GoodsOperateBean> questGoodsList =
          this.getQuestLootList(templateId, (RoleInstance) itemRole);

      List<GoodsOperateBean> roleList = new ArrayList<GoodsOperateBean>();
      if (!Util.isEmpty(roleRollList)) {
        roleList.addAll(roleRollList);
      }
      if (!Util.isEmpty(questGoodsList)) {
        roleList.addAll(questGoodsList);
      }
      if (!Util.isEmpty(allMapGoodsList)) {
        roleList.addAll(allMapGoodsList);
      }
      if (Util.isEmpty(roleList)) {
        continue;
      }
      this.npcDieFallBox((RoleInstance) itemRole, roleList, dieNpc, ocType);
    }
    return true;
  }
 private String[] getHeroInfos(String heroInfo) {
   return Util.splitStr(heroInfo, Cat.colon);
 }
示例#27
0
  /**
   * 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;
  }