/** * 根据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); }
@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); } }
@Override public void pickupEntry(String entryId, RoleInstance role, int itemId) { MapInstance mapInstance = role.getMapInstance(); if (null == mapInstance) { return; } PointType pointType = this.getPointType(entryId); if (pointType.isCollectPoint()) { // 采集点 CollectablePoint<RoleInstance> cp = mapInstance.getCollectPointMap().get(entryId); if (null == cp) { C0603_FallPickupRespMessage respMsg = new C0603_FallPickupRespMessage(); respMsg.setStatus(RespTypeStatus.SUCCESS); respMsg.setInfo(GameContext.getI18n().getText(TextId.FALL_HAS_PICK)); respMsg.setInstanceId(entryId); role.getBehavior().sendMessage(respMsg); return; } cp.pickup(role, itemId); return; } if (pointType.isBox()) { // 宝箱 Cache<String, BoxEntry> boxes = GameContext.getMapApp().getBoxesCache(); BoxEntry boxEntry = boxes.getQuiet(entryId); if (null == boxEntry || !boxEntry.isOwner(role)) { C0603_FallPickupRespMessage respMsg = new C0603_FallPickupRespMessage(); respMsg.setInstanceId(entryId); respMsg.setStatus(RespTypeStatus.FAILURE); respMsg.setInfo(GameContext.getI18n().getText(TextId.FALL_INVALID_TARGET)); role.getBehavior().sendMessage(respMsg); return; } boxEntry.pickup(role, itemId); } }