Exemple #1
0
  @Override
  public void handleReceived(LlpMessage msg) {
    // ======数据重置======
    result = 0;
    reason = "挑战成功";

    if (online.getLevel() < 40) {
      result = 1;
      reason = "等级不足40级,不能挑战";
      return;
    }
    if (!online.getMapInfo().getBaseMap().getType().equals(EMapType.common)) {
      result = 1;
      reason = "此地图不能挑战";
      return;
    }
    int currentFloorId = msg.readInt("currentFloorId");

    if (online.isBattle()) {
      result = 1;
      reason = "已战斗";
      return;
    }

    if (online.isPrBattle()) {
      result = 1;
      reason = "已申请战斗";
      return;
    }
    online.setPrBattle(true);

    if (online.getTeam() != null) {
      result = 1;
      reason = "组队状态时不能挑战千层塔";
      return;
    }

    if (currentFloorId > QiancengtaJson.instance().getQiancengtas().size()) {
      result = 1;
      reason = "已经全部挑战完成";
      return;
    }

    if (online.getCurrentFloorId() != currentFloorId) {
      result = 1;
      reason = "不能挑战";
      return;
    }

    QiancengtaInfo qiancengtaInfo =
        QiancengtaJson.instance().getQiancengtaMap().get(currentFloorId);
    MonsterGroup monsterGroup = MonsterJson.instance().getMonsterGroup(qiancengtaInfo.getGroupId());
    battleInfo =
        BattleServer.preBattle(online, monsterGroup, 5, online.getMapInfo().getBaseMap(), false);
    battleInfo.setCurrentFloorId(currentFloorId);
  }
Exemple #2
0
  @Override
  public void handleReceived(LlpMessage msg) {

    // ======重置数据======
    result = 0;
    reason = "遇怪成功";

    if (online.isBattle()) {
      result = 1;
      reason = "已战斗";
      return;
    }

    if (online.isPrBattle()) {
      result = 1;
      reason = "已申请战斗";
      return;
    }
    online.setPrBattle(true);
    // ======获取参数======
    int trialsId = msg.readInt("trialsId");
    int position = msg.readInt("position");

    if (online.getTeam() != null) {
      result = 1;
      reason = "组队状态时不能试炼";
      return;
    }

    if (!online.getMapInfo().getBaseMap().getType().equals(EMapType.common)) {
      result = 1;
      reason = "此地图不能试炼";
      return;
    }

    TrialsInfo trialsInfo = RaidsJson.instance().getTrialsMap().get(trialsId);
    if (trialsInfo == null) {
      result = 1;
      reason = "本层试练已经全部击杀完毕!";
      return;
    }
    if (!trialsInfo.getMonsterMap().containsKey(position)) {
      result = 1;
      reason = "本层试练已经全部击杀!";
      return;
    }
    int monsterGroupId = trialsInfo.getMonsterMap().get(position);
    MonsterGroup monsterGroup = MonsterJson.instance().getMonsterGroup(monsterGroupId);
    battleInfo =
        BattleServer.preBattle(online, monsterGroup, 3, online.getMapInfo().getBaseMap(), false);

    battleInfo.setTrialsId(trialsId);

    LogManager.trials(online, trialsId, position); // 试炼日志
  }
Exemple #3
0
  @Override
  public void handleReply() throws Exception {
    LlpMessage llpMessage = null;
    try {
      llpMessage = LlpJava.instance().getMessage("s_kill");
      llpMessage.write("result", result);
      llpMessage.write("reason", reason);
      channel.write(llpMessage);
    } finally {
      if (llpMessage != null) {
        llpMessage.destory();
      }
    }

    if (result == 0) {
      online.setBattle(true);
      BattleManager.instance().addBattleProcessor(new BattleProcessorCenter(battleInfo));
      online.setBattleId(battleInfo.getBattleId()); // 设置战斗编号
      FightMessage.sendEncounterResult(battleInfo, online);
    }
    online.setPrBattle(false);
  }