示例#1
0
  /**
   * 装备手动技能
   *
   * @author hzw
   * @date 2014-9-11上午11:23:00
   * @param msgMap
   * @param channelId
   * @throws Exception @Description
   */
  @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
  public void use(Map<String, Object> msgMap, String channelId) throws Exception {

    MessageData syncMsgData = new MessageData();
    // 参数
    int instPlayerId = getInstPlayerId(channelId);

    if (instPlayerId == 0) {
      MessageUtil.sendFailMsg(channelId, msgMap, StaticCnServer.fail_PlayerIdVerfy);
      return;
    }

    int instPlayerManualSkillId = (Integer) msgMap.get("instPlayerManualSkillId");
    int position = (Integer) msgMap.get("position");
    InstPlayer instPlayer = getInstPlayerDAL().getModel(instPlayerId, instPlayerId);
    // 验证参数
    InstPlayerManualSkill instPlayerManualSkill =
        getInstPlayerManualSkillDAL().getModel(instPlayerManualSkillId, instPlayerId);
    if (instPlayerManualSkill.getInstPlayerId() != instPlayerId) {
      MessageUtil.sendFailMsg(channelId, msgMap, StaticCnServer.fail_differentPlayers);
      return;
    }

    List<InstPlayerManualSkill> instPlayerManualSkillList =
        getInstPlayerManualSkillDAL()
            .getList(
                "instPlayerId = "
                    + instPlayerId
                    + " and manualSkillId = "
                    + instPlayerManualSkill.getManualSkillId()
                    + " and isUse > 0 ",
                instPlayerId);
    instPlayerManualSkill.setIsUse(position);
    // 是否已在阵上
    if (instPlayerManualSkillList.size() > 0) {
      MessageUtil.sendFailMsg(channelId, msgMap, StaticCnServer.fail_notManualSkillRepeat);
      return;
    }

    if (instPlayer.getLevel() < FormulaUtil.manualSkillPosition(position)) {
      MessageUtil.sendFailMsg(channelId, msgMap, StaticCnServer.fail_levelNotUp);
      return;
    }

    ManualSkillUtil.addInstPlayerManualSkillLine(
        instPlayerId, instPlayerManualSkillId, position, syncMsgData);

    getInstPlayerManualSkillDAL().update(instPlayerManualSkill, instPlayerId);
    OrgFrontMsgUtil.orgSyncMsgData(
        StaticSyncState.update,
        instPlayerManualSkill,
        instPlayerManualSkill.getId(),
        instPlayerManualSkill.getResult(),
        syncMsgData);

    MessageUtil.sendSyncMsg(channelId, syncMsgData);
    MessageUtil.sendSuccMsg(channelId, msgMap);
  }
示例#2
0
  /**
   * 吃技能/升级
   *
   * @author hzw
   * @date 2014-9-11下午2:26:39
   * @param msgMap
   * @param channelId
   * @throws Exception @Description
   */
  @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
  public void eatManualSkill(Map<String, Object> msgMap, String channelId) throws Exception {

    MessageData syncMsgData = new MessageData();

    int instPlayerId = getInstPlayerId(channelId);

    if (instPlayerId == 0) {
      MessageUtil.sendFailMsg(channelId, msgMap, StaticCnServer.fail_PlayerIdVerfy);
      return;
    }

    int instPlayerManualSkillId = (Integer) msgMap.get("instPlayerManualSkillId");
    String instPlayerManualSkillIdList = (String) msgMap.get("instPlayerManualSkillIdList");
    String[] paramList = instPlayerManualSkillIdList.split(";");
    int expsum = 0;

    InstPlayerManualSkill instPlayerManualSkill =
        getInstPlayerManualSkillDAL().getModel(instPlayerManualSkillId, instPlayerId);
    if (instPlayerId != instPlayerManualSkill.getInstPlayerId()) {
      MessageUtil.sendFailMsg(channelId, msgMap, StaticCnServer.fail_differentPlayers);
      return;
    }

    for (String str : paramList) {
      InstPlayerManualSkill obj =
          getInstPlayerManualSkillDAL().getModel(ConvertUtil.toInt(str), instPlayerId);
      if (instPlayerId != obj.getInstPlayerId()) {
        MessageUtil.sendFailMsg(channelId, msgMap, StaticCnServer.fail_differentPlayers);
        return;
      }
      if (obj.getIsUse() > 0) {
        MessageUtil.sendFailMsg(channelId, msgMap, StaticCnServer.fail_manualSkillIsUse);
        return;
      }
      DictManualSkill dictManualSkill = DictMap.dictManualSkillMap.get(obj.getManualSkillId() + "");
      expsum +=
          FormulaUtil.eatManualSkillExp(obj.getLevel()) + dictManualSkill.getExp() + obj.getExp();
    }

    // 等级,经验计算
    Map<String, Integer> retMap =
        FormulaUtil.calcManualSkillLevel(
            instPlayerManualSkill.getLevel(), instPlayerManualSkill.getExp() + expsum);
    int level = retMap.get("level");
    int exp = retMap.get("exp");

    instPlayerManualSkill.setLevel(level);
    instPlayerManualSkill.setExp(exp);
    getInstPlayerManualSkillDAL().update(instPlayerManualSkill, instPlayerId);
    OrgFrontMsgUtil.orgSyncMsgData(
        StaticSyncState.update,
        instPlayerManualSkill,
        instPlayerManualSkill.getId(),
        instPlayerManualSkill.getResult(),
        syncMsgData);

    // 删除被吃技能
    for (String str : paramList) {
      InstPlayerManualSkill obj =
          getInstPlayerManualSkillDAL().getModel(ConvertUtil.toInt(str), instPlayerId);
      getInstPlayerManualSkillDAL().deleteById(obj.getId(), instPlayerId);
      OrgFrontMsgUtil.orgSyncMsgData(StaticSyncState.delete, obj, obj.getId(), "", syncMsgData);
    }

    MessageUtil.sendSyncMsg(channelId, syncMsgData);
    MessageUtil.sendSuccMsg(channelId, msgMap);
  }