Greasy Fork is available in English.

wsmud_V3

wsmud插件

このスクリプトは単体で利用できません。右のようなメタデータを含むスクリプトから、ライブラリとして読み込まれます: // @require https://greasyfork.org/scripts/380354-wsmud-v3/code/wsmud_V3.js?version=679777

質問やレビューの投稿はこちらへ、スクリプトの通報はこちらへどうぞ。
(function webpackUniversalModuleDefinition(root, factory) {
	if(typeof exports === 'object' && typeof module === 'object')
		module.exports = factory();
	else if(typeof define === 'function' && define.amd)
		define([], factory);
	else {
		var a = factory();
		for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
	}
})(window, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};
/******/
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/
/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId]) {
/******/ 			return installedModules[moduleId].exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			i: moduleId,
/******/ 			l: false,
/******/ 			exports: {}
/******/ 		};
/******/
/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ 		// Flag the module as loaded
/******/ 		module.l = true;
/******/
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/
/******/
/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;
/******/
/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;
/******/
/******/ 	// define getter function for harmony exports
/******/ 	__webpack_require__.d = function(exports, name, getter) {
/******/ 		if(!__webpack_require__.o(exports, name)) {
/******/ 			Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ 		}
/******/ 	};
/******/
/******/ 	// define __esModule on exports
/******/ 	__webpack_require__.r = function(exports) {
/******/ 		if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ 			Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ 		}
/******/ 		Object.defineProperty(exports, '__esModule', { value: true });
/******/ 	};
/******/
/******/ 	// create a fake namespace object
/******/ 	// mode & 1: value is a module id, require it
/******/ 	// mode & 2: merge all properties of value into the ns
/******/ 	// mode & 4: return value when already ns object
/******/ 	// mode & 8|1: behave like require
/******/ 	__webpack_require__.t = function(value, mode) {
/******/ 		if(mode & 1) value = __webpack_require__(value);
/******/ 		if(mode & 8) return value;
/******/ 		if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ 		var ns = Object.create(null);
/******/ 		__webpack_require__.r(ns);
/******/ 		Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ 		if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ 		return ns;
/******/ 	};
/******/
/******/ 	// getDefaultExport function for compatibility with non-harmony modules
/******/ 	__webpack_require__.n = function(module) {
/******/ 		var getter = module && module.__esModule ?
/******/ 			function getDefault() { return module['default']; } :
/******/ 			function getModuleExports() { return module; };
/******/ 		__webpack_require__.d(getter, 'a', getter);
/******/ 		return getter;
/******/ 	};
/******/
/******/ 	// Object.prototype.hasOwnProperty.call
/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "";
/******/
/******/
/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(__webpack_require__.s = "./src/func.js");
/******/ })
/************************************************************************/
/******/ ({

/***/ "./node_modules/css-loader/dist/runtime/api.js":
/*!*****************************************************!*\
  !*** ./node_modules/css-loader/dist/runtime/api.js ***!
  \*****************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


/*
  MIT License http://www.opensource.org/licenses/mit-license.php
  Author Tobias Koppers @sokra
*/
// css base code, injected by the css-loader
module.exports = function (useSourceMap) {
  var list = []; // return the list of modules as css string

  list.toString = function toString() {
    return this.map(function (item) {
      var content = cssWithMappingToString(item, useSourceMap);

      if (item[2]) {
        return '@media ' + item[2] + '{' + content + '}';
      } else {
        return content;
      }
    }).join('');
  }; // import a list of modules into the list


  list.i = function (modules, mediaQuery) {
    if (typeof modules === 'string') {
      modules = [[null, modules, '']];
    }

    var alreadyImportedModules = {};

    for (var i = 0; i < this.length; i++) {
      var id = this[i][0];

      if (id != null) {
        alreadyImportedModules[id] = true;
      }
    }

    for (i = 0; i < modules.length; i++) {
      var item = modules[i]; // skip already imported module
      // this implementation is not 100% perfect for weird media query combinations
      // when a module is imported multiple times with different media queries.
      // I hope this will never occur (Hey this way we have smaller bundles)

      if (item[0] == null || !alreadyImportedModules[item[0]]) {
        if (mediaQuery && !item[2]) {
          item[2] = mediaQuery;
        } else if (mediaQuery) {
          item[2] = '(' + item[2] + ') and (' + mediaQuery + ')';
        }

        list.push(item);
      }
    }
  };

  return list;
};

function cssWithMappingToString(item, useSourceMap) {
  var content = item[1] || '';
  var cssMapping = item[3];

  if (!cssMapping) {
    return content;
  }

  if (useSourceMap && typeof btoa === 'function') {
    var sourceMapping = toComment(cssMapping);
    var sourceURLs = cssMapping.sources.map(function (source) {
      return '/*# sourceURL=' + cssMapping.sourceRoot + source + ' */';
    });
    return [content].concat(sourceURLs).concat([sourceMapping]).join('\n');
  }

  return [content].join('\n');
} // Adapted from convert-source-map (MIT)


function toComment(sourceMap) {
  // eslint-disable-next-line no-undef
  var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))));
  var data = 'sourceMappingURL=data:application/json;charset=utf-8;base64,' + base64;
  return '/*# ' + data + ' */';
}

/***/ }),

/***/ "./src/func.js":
/*!*********************!*\
  !*** ./src/func.js ***!
  \*********************/
/*! no exports provided */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _module_Plugin__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./module/Plugin */ "./src/module/Plugin.js");



if (window.WebSocket) Object(_module_Plugin__WEBPACK_IMPORTED_MODULE_0__["main"])();else {
  if (document.body) {
    setTimeout(() => {
      location.reload();
    }, 500);
  }
}

/***/ }),

/***/ "./src/module/Const.js":
/*!*****************************!*\
  !*** ./src/module/Const.js ***!
  \*****************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* 常量模块 */

/**
 * 常量类
 */

const WSMUD = {
  families: {
    "武当派": {
      //首席
      senior: {
        npc: "武当派首席弟子",
        place: "武当派-太子岩"
      },
      //师门任务
      issuer: {
        npc: "谷虚道长",
        place: "武当派-三清殿"
      },
      //掌门
      leader: "jh fam 1 start;go west;go northup;go north;go west;go northup;go northup;go northup;go north;go north;go north;go north;go north;go north",
      //门派遍历
      journey: "jh fam 1 start;go north;go south;go west;go west;go east;go northup;go north;go east;go west;go west;go northup;go northup;go northup;go north;go north;go north;go north;go north;go north"
    },
    "少林派": {
      senior: {
        npc: "少林派大师兄",
        place: "少林派-练武场"
      },
      issuer: {
        npc: "清乐比丘",
        place: "少林派-广场"
      },
      leader: "jh fam 2 start;go north;go north;go northwest;go northeast;go north;go north",
      journey: "jh fam 2 start;go north;go east;go west;go west;go east;go north;go northup;go southdown;go northwest;go northeast;go southeast;go northwest;go north;go west;go east;go east;go west;go north;go west;go east;go east;go west;go north;go north;go north"
    },
    "华山派": {
      senior: {
        npc: "华山派首席弟子",
        place: "华山派-练武场"
      },
      issuer: {
        npc: "高根明",
        place: "华山派-镇岳宫"
      },
      leader: "jh fam 3 start;go westup;go north;go north",
      journey: "jh fam 3 start;go eastup;go southup;jumpdown;go southup;go south;go east;jh fam 3 start;go westup;go south;go southup;go southup;break bi;go enter;go westup;go westup;jh fam 3 start;go westup;go west;go east;go north;go east;go west;go north;go east;go west;go north"
    },
    "峨眉派": {
      senior: {
        npc: "峨眉大师姐",
        place: "峨嵋派-广场"
      },
      issuer: {
        npc: "苏梦清",
        place: "峨嵋派-庙门"
      },
      leader: "jh fam 4 start;go west;go south;go west;go south;go south",
      journey: "jh fam 4 start;go northup;go east;go west;go southdown;go west;go south;go east;go east;go west;go south;go north;go west;go south;go north;go west;go west;go east;go north;go north;go south;go south;go south;go south"
    },
    "逍遥派": {
      senior: {
        npc: "逍遥派首席弟子",
        place: "逍遥派-林间小道-1"
      },
      issuer: {
        npc: "苏星河",
        place: "逍遥派-青草坪"
      },
      leader: "jh fam 5 start;go west;go east;go down;go down",
      journey: "jh fam 5 start;go north;go north;go south;go south;go west;go south;go north;go east;go east;go north;go south;go south;go south;go north;go north;go west;go south;go south;go north;go north;go down;go down"
    },
    "丐帮": {
      senior: {
        npc: "丐帮首席弟子",
        place: "丐帮-破庙密室"
      },
      issuer: {
        npc: "左全",
        place: "丐帮-树洞下"
      },
      leader: "jh fam 6 start; go down; go east; go east; go east; go east; go east; go up",
      journey: "jh fam 6 start;go down;go east;go east;go east;go up;go down;go east;go east;go up"
    },
    "杀手楼": {
      senior: {
        npc: "金牌杀手",
        place: "杀手楼-练功房"
      },
      issuer: {
        npc: "何小二",
        place: "杀手楼-大厅"
      }
    },
    "无门无派": {
      issuer: {
        npc: "武馆教习",
        place: "扬州城-扬州武馆"
      }
    }
  },
  master: {
    "谷虚道长": "武当派-三清殿",
    "宋远桥": "武当派-三清殿",
    "张三丰": "武当派-后山小院",
    "清乐比丘": "少林派-广场",
    "道觉禅师": "少林派-天王殿",
    "慧合尊者": "少林派-般若堂",
    "澄净": "少林派-罗汉堂",
    "玄难": "少林派-方丈楼",
    "高根明": "华山派-镇岳宫",
    "岳不群": "华山派-客厅",
    "封不平": "华山派-林间小屋",
    "风清扬": "华山派-落雁峰",
    "苏梦清": "峨嵋派-庙门",
    "静心": "峨嵋派-大殿",
    "周芷若": "峨嵋派-小屋",
    "灭绝": "峨嵋派-清修洞",
    "薛慕华": "逍遥派-木屋",
    "苏星河": "逍遥派-青草坪",
    "逍遥子": "逍遥派-地下石室-1",
    "左全": "丐帮-树洞下",
    "简长老": "丐帮-土地庙",
    "鲁有脚": "丐帮-暗道-4",
    "洪七公": "丐帮-林间小屋",
    "何小二": "杀手楼-大厅",
    "李四": "杀手楼-银楼",
    "雾中楼": "杀手楼-书房"
  },
  dungeon: [{
    name: "树林",
    id: "yz/lw/shangu",
    auto: "shulin"
  }, {
    name: "财主家",
    id: "yz/cuifu/caizhu",
    auto: "caizhu",
    hard: true
  }, {
    name: "流氓巷",
    id: "yz/lmw/xiangzi1",
    auto: "lmw"
  }, {
    name: "丽春院",
    id: "yz/lcy/dating",
    auto: "lcy"
  }, {
    name: "兵营",
    id: "yz/by/damen",
    auto: "bingying"
  }, {
    name: "庄府",
    id: "bj/zhuang/xiaolu",
    auto: "zhuang"
  }, {
    name: "鳌拜府",
    id: "bj/ao/damen",
    auto: "aobai"
  }, {
    name: "天地会",
    id: "bj/tdh/hct",
    auto: "tiandihui"
  }, {
    name: "神龙教",
    id: "bj/shenlong/haitan",
    auto: "shenlong"
  }, {
    name: "关外",
    id: "bj/guanwai/damen",
    auto: "guanwai"
  }, {
    name: "温府",
    id: "cd/wen/damen",
    auto: "wen"
  }, {
    name: "五毒教",
    id: "cd/wudu/damen",
    auto: "wudu"
  }, {
    name: "恒山",
    id: "wuyue/hengshan/daziling",
    auto: "nop"
  }, {
    name: "青城山",
    id: "wuyue/qingcheng/shanlu",
    auto: "qingcheng"
  }, {
    name: "衡山",
    id: "wuyue/henshan/hengyang",
    auto: "henshan"
  }, {
    name: "泰山",
    id: "wuyue/taishan/daizong",
    auto: "taishan"
  }, {
    name: "嵩山",
    id: "wuyue/songshan/taishi",
    auto: "songshan"
  }, {
    name: "云梦沼泽",
    id: "cd/yunmeng/senlin",
    auto: "yunmeng"
  }, {
    name: "桃花岛",
    id: "taohua/haitan",
    auto: "nop",
    hard: true
  }, {
    name: "白驼山",
    id: "baituo/damen",
    auto: "baituo"
  }, {
    name: "星宿海",
    id: "xingxiu/xxh6",
    auto: "xingxiu"
  }, {
    name: "冰火岛",
    id: "mj/bhd/haibian",
    auto: "binghuodao",
    hard: true
  }, {
    name: "移花宫",
    id: "huashan/yihua/shandao",
    auto: "yihua",
    hard: true
  }, {
    name: "燕子坞",
    id: "murong/anbian",
    auto: "yanziwu",
    hard: true
  }, {
    name: "黑木崖",
    id: "heimuya/shangu",
    auto: "nop",
    hard: true
  }, {
    name: "缥缈峰",
    id: "lingjiu/shanjiao",
    auto: "nop",
    hard: true
  }, {
    name: "光明顶",
    id: "mj/shanmen",
    auto: "nop"
  }, {
    name: "天龙寺",
    id: "tianlong/damen",
    auto: "nop",
    hard: true
  }, {
    name: "血刀门",
    id: "xuedao/shankou",
    auto: "nop"
  }, {
    name: "古墓",
    id: "gumu/gumukou",
    auto: "gumu",
    hard: true
  }, {
    name: "华山论剑",
    id: "huashan/lunjian/leitaixia",
    auto: "huashanlunjian"
  }],

  getDungeonList() {
    let list = [];

    for (const dungeon of WSMUD.dungeon) {
      list.push(dungeon.name);
      if (dungeon.hard) list.push(dungeon.name + "困难");
    }

    return list;
  },

  path: {
    "住房-院子": "jh fam 0 start;go west;go west;go north;go enter",
    "住房-小花园": "jh fam 0 start;go west;go west;go north;go enter;go northeast",
    "住房-练功房": "jh fam 0 start;go west;go west;go north;go enter;go west",
    "扬州城-钱庄": "jh fam 0 start;go north;go west",
    "扬州城-大门": "jh fam 0 start;go west;go west;go north",
    "扬州城-武庙": "jh fam 0 start;go north;go north;go west",
    "扬州城-醉仙楼": "jh fam 0 start;go north;go north;go east",
    "扬州城-杂货铺": "jh fam 0 start;go east;go south",
    "扬州城-打铁铺": "jh fam 0 start;go east;go east;go south",
    "扬州城-药铺": "jh fam 0 start;go east;go east;go north",
    "扬州城-衙门正厅": "jh fam 0 start;go west;go north;go north",
    "扬州城-矿山": "jh fam 0 start;go west;go west;go west;go west",
    "扬州城-擂台": "jh fam 0 start;go west;go south",
    "扬州城-当铺": "jh fam 0 start;go south;go east",
    "扬州城-帮派": "jh fam 0 start;go south;go south;go east",
    "扬州城-扬州武馆": "jh fam 0 start;go south;go south;go west",
    "扬州城-福威镖局": "jh fam 0 start;go west;go west;go south",
    "扬州城-镖局正厅": "jh fam 0 start;go west;go west;go south;go south",
    "帮会-练功房": "jh fam 0 start;go south;go south;go east;go east;go east;go north",
    "武当派-广场": "jh fam 1 start",
    "武当派-三清殿": "jh fam 1 start;go north",
    "武当派-石阶": "jh fam 1 start;go west",
    "武当派-练功房": "jh fam 1 start;go west;go west",
    "武当派-太子岩": "jh fam 1 start;go west;go northup",
    "武当派-桃园小路": "jh fam 1 start;go west;go northup;go north",
    "武当派-舍身崖": "jh fam 1 start;go west;go northup;go north;go east",
    "武当派-南岩峰": "jh fam 1 start;go west;go northup;go north;go west",
    "武当派-乌鸦岭": "jh fam 1 start;go west;go northup;go north;go west;go northup",
    "武当派-五老峰": "jh fam 1 start;go west;go northup;go north;go west;go northup;go northup",
    "武当派-虎头岩": "jh fam 1 start;go west;go northup;go north;go west;go northup;go northup;go northup",
    "武当派-朝天宫": "jh fam 1 start;go west;go northup;go north;go west;go northup;go northup;go northup;go north",
    "武当派-三天门": "jh fam 1 start;go west;go northup;go north;go west;go northup;go northup;go northup;go north;go north",
    "武当派-紫金城": "jh fam 1 start;go west;go northup;go north;go west;go northup;go northup;go northup;go north;go north;go north",
    "武当派-林间小径": "jh fam 1 start;go west;go northup;go north;go west;go northup;go northup;go northup;go north;go north;go north;go north",
    "武当派-林间小径2": "jh fam 1 start;go west;go northup;go north;go west;go northup;go northup;go northup;go north;go north;go north;go north;go north",
    "武当派-后山小院": "jh fam 1 start;go west;go northup;go north;go west;go northup;go northup;go northup;go north;go north;go north;go north;go north;go north",
    "少林派-广场": "jh fam 2 start",
    "少林派-山门殿": "jh fam 2 start;go north",
    "少林派-东侧殿": "jh fam 2 start;go north;go east",
    "少林派-西侧殿": "jh fam 2 start;go north;go west",
    "少林派-天王殿": "jh fam 2 start;go north;go north",
    "少林派-大雄宝殿": "jh fam 2 start;go north;go north;go northup",
    "少林派-钟楼": "jh fam 2 start;go north;go north;go northeast",
    "少林派-鼓楼": "jh fam 2 start;go north;go north;go northwest",
    "少林派-后殿": "jh fam 2 start;go north;go north;go northwest;go northeast",
    "少林派-练武场": "jh fam 2 start;go north;go north;go northwest;go northeast;go north",
    "少林派-罗汉堂": "jh fam 2 start;go north;go north;go northwest;go northeast;go north;go east",
    "少林派-般若堂": "jh fam 2 start;go north;go north;go northwest;go northeast;go north;go west",
    "少林派-方丈楼": "jh fam 2 start;go north;go north;go northwest;go northeast;go north;go north",
    "少林派-戒律院": "jh fam 2 start;go north;go north;go northwest;go northeast;go north;go north;go east",
    "少林派-达摩院": "jh fam 2 start;go north;go north;go northwest;go northeast;go north;go north;go west",
    "少林派-竹林": "jh fam 2 start;go north;go north;go northwest;go northeast;go north;go north;go north",
    "少林派-藏经阁": "jh fam 2 start;go north;go north;go northwest;go northeast;go north;go north;go north;go west",
    "少林派-达摩洞": "jh fam 2 start;go north;go north;go northwest;go northeast;go north;go north;go north;go north;go north",
    "华山派-镇岳宫": "jh fam 3 start",
    "华山派-苍龙岭": "jh fam 3 start;go eastup",
    "华山派-舍身崖": "jh fam 3 start;go eastup;go southup",
    "华山派-峭壁": "jh fam 3 start;go eastup;go southup;jumpdown",
    "华山派-山谷": "jh fam 3 start;go eastup;go southup;jumpdown;go southup",
    "华山派-山间平地": "jh fam 3 start;go eastup;go southup;jumpdown;go southup;go south",
    "华山派-林间小屋": "jh fam 3 start;go eastup;go southup;jumpdown;go southup;go south;go east",
    "华山派-玉女峰": "jh fam 3 start;go westup",
    "华山派-玉女祠": "jh fam 3 start;go westup;go west",
    "华山派-练武场": "jh fam 3 start;go westup;go north",
    "华山派-练功房": "jh fam 3 start;go westup;go north;go east",
    "华山派-客厅": "jh fam 3 start;go westup;go north;go north",
    "华山派-偏厅": "jh fam 3 start;go westup;go north;go north;go east",
    "华山派-寝室": "jh fam 3 start;go westup;go north;go north;go north",
    "华山派-玉女峰山路": "jh fam 3 start;go westup;go south",
    "华山派-玉女峰小径": "jh fam 3 start;go westup;go south;go southup",
    "华山派-思过崖": "jh fam 3 start;go westup;go south;go southup;go southup",
    "华山派-山洞": "jh fam 3 start;go westup;go south;go southup;go southup;break bi;go enter",
    "华山派-长空栈道": "jh fam 3 start;go westup;go south;go southup;go southup;break bi;go enter;go westup",
    "华山派-落雁峰": "jh fam 3 start;go westup;go south;go southup;go southup;break bi;go enter;go westup;go westup",
    "华山派-华山绝顶": "jh fam 3 start;go westup;go south;go southup;go southup;break bi;go enter;go westup;go westup;jumpup",
    "峨嵋派-金顶": "jh fam 4 start",
    "峨嵋派-庙门": "jh fam 4 start;go west",
    "峨嵋派-广场": "jh fam 4 start;go west;go south",
    "峨嵋派-走廊": "jh fam 4 start;go west;go south;go east",
    "峨嵋派-休息室": "jh fam 4 start;go west;go south;go east;go south",
    "峨嵋派-厨房": "jh fam 4 start;go west;go south;go east;go east",
    "峨嵋派-练功房": "jh fam 4 start;go west;go south;go west;go west",
    "峨嵋派-小屋": "jh fam 4 start;go west;go south;go west;go north;go north",
    "峨嵋派-清修洞": "jh fam 4 start;go west;go south;go west;go south;go south",
    "峨嵋派-大殿": "jh fam 4 start;go west;go south;go south",
    "峨嵋派-睹光台": "jh fam 4 start;go northup",
    "峨嵋派-华藏庵": "jh fam 4 start;go northup;go east",
    "逍遥派-青草坪": "jh fam 5 start",
    "逍遥派-林间小道": "jh fam 5 start;go east",
    "逍遥派-林间小道-1": "jh fam 5 start;go west",
    "逍遥派-练功房": "jh fam 5 start;go east;go north",
    "逍遥派-木板路": "jh fam 5 start;go east;go south",
    "逍遥派-工匠屋": "jh fam 5 start;go east;go south;go south",
    "逍遥派-休息室": "jh fam 5 start;go west;go south",
    "逍遥派-木屋": "jh fam 5 start;go north;go north",
    "逍遥派-地下石室": "jh fam 5 start;go down",
    "逍遥派-地下石室-1": "jh fam 5 start;go down;go down",
    "丐帮-树洞内部": "jh fam 6 start",
    "丐帮-树洞下": "jh fam 6 start;go down",
    "丐帮-暗道": "jh fam 6 start;go down;go east",
    "丐帮-暗道-1": "jh fam 6 start;go down;go east",
    "丐帮-暗道-2": "jh fam 6 start;go down;go east;go east;",
    "丐帮-破庙密室": "jh fam 6 start;go down;go east;go east;go east",
    "丐帮-土地庙": "jh fam 6 start;go down;go east;go east;go east;go up",
    "丐帮-暗道-3": "jh fam 6 start;go down;go east;go east;go east;go east",
    "丐帮-暗道-4": "jh fam 6 start;go down;go east;go east;go east;go east;go east",
    "丐帮-林间小屋": "jh fam 6 start;go down;go east;go east;go east;go east;go east;go up",
    "杀手楼-大门": "jh fam 7 start",
    "杀手楼-大厅": "jh fam 7 start;go north",
    "杀手楼-暗阁": "jh fam 7 start;go north;go up",
    "杀手楼-铜楼": "jh fam 7 start;go north;go up;go up",
    "杀手楼-休息室": "jh fam 7 start;go north;go up;go up;go east",
    "杀手楼-暗阁2": "jh fam 7 start;go north;go up;go up;go up",
    "杀手楼-银楼": "jh fam 7 start;go north;go up;go up;go up;go up",
    "杀手楼-练功房": "jh fam 7 start;go north;go up;go up;go up;go up;go east",
    "杀手楼-暗阁3": "jh fam 7 start;go north;go up;go up;go up;go up;go up",
    "杀手楼-金楼": "jh fam 7 start;go north;go up;go up;go up;go up;go up;go up",
    "杀手楼-书房": "jh fam 7 start;go north;go up;go up;go up;go up;go up;go up;go west",
    "杀手楼-平台": "jh fam 7 start;go north;go up;go up;go up;go up;go up;go up;go up",
    "襄阳城-广场": "jh fam 8 start",
    "襄阳城-东北城墙": "jh fam 8 start;go north;go north;go north;go north;go east",
    "襄阳城-东南城墙": "jh fam 8 start;go east;go east;go east;go east;go south",
    "襄阳城-西南城墙": "jh fam 8 start;go west;go west;go west;go west;go south",
    "襄阳城-西北城墙": "jh fam 8 start;go north;go north;go north;go north;go west",
    "襄阳城-东门外": "jh fam 8 start;go east;go east;go east;go east;go east",
    "襄阳城-西门外": "jh fam 8 start;go west;go west;go west;go west;go west",
    "襄阳城-南门外": "jh fam 8 start;go south;go south;go south;go south;go south",
    "襄阳城-北门外": "jh fam 8 start;go north;go north;go north;go north;go north",
    "武道塔": "jh fam 9 start",
    "武道塔-入口": "jh fam 9 start"
  },
  path2: {
    "武当派-林间小径": "go north",
    "少林派-竹林": "go north",
    "峨嵋派-走廊": "go west;go west;go north;go north;go south;go south;go south;go south",
    "逍遥派-林间小道": "go west;go north;go south;go west;go east;go south;go north",
    "逍遥派-木屋": "go south;go south;go south;go south",
    "逍遥派-地下石室": "go down",
    "丐帮-暗道": "go east;go east;go east;go east"
  },
  shop: [{
    items: ["<wht>米饭</wht>", "<wht>包子</wht>", "<wht>鸡腿</wht>", "<wht>面条</wht>", "<wht>扬州炒饭</wht>", "<wht>米酒</wht>", "<wht>花雕酒</wht>", "<wht>女儿红</wht>", "<hig>醉仙酿</hig>", "<hiy>神仙醉</hiy>"],
    npc: "店小二",
    place: "扬州城-醉仙楼"
  }, {
    items: ["<wht>布衣</wht>", "<wht>钢刀</wht>", "<wht>木棍</wht>", "<wht>英雄巾</wht>", "<wht>布鞋</wht>", "<wht>铁戒指</wht>", "<wht>簪子</wht>", "<wht>长鞭</wht>"],
    npc: "杨永福",
    place: "扬州城-杂货铺"
  }, {
    items: ["<wht>铁剑</wht>", "<wht>钢刀</wht>", "<wht>铁棍</wht>", "<wht>铁杖</wht>"],
    npc: "铁匠",
    place: "扬州城-打铁铺"
  }, {
    items: ["<hig>金创药</hig>", "<hig>引气丹</hig>"],
    npc: "平一指",
    place: "扬州城-药铺"
  }],
  store_list: ["<hic>红宝石</hic>", "<hic>黄宝石</hic>", "<hic>蓝宝石</hic>", "<hic>绿宝石</hic>", "<hiy>精致的红宝石</hiy>", "<hiy>精致的黄宝石</hiy>", "<hiy>精致的蓝宝石</hiy>", "<hiy>精致的绿宝石</hiy>", "<hiz>完美的红宝石</hiz>", "<hiz>完美的黄宝石</hiz>", "<hiz>完美的蓝宝石</hiz>", "<hiz>完美的绿宝石</hiz>", "<wht>基本内功秘籍</wht>", "<wht>基本轻功秘籍</wht>", "<wht>基本招架秘籍</wht>", "<wht>基本剑法秘籍</wht>", "<wht>基本刀法秘籍</wht>", "<wht>基本拳脚秘籍</wht>", "<wht>基本暗器秘籍</wht>", "<wht>基本棍法秘籍</wht>", "<wht>基本鞭法秘籍</wht>", "<wht>基本杖法秘籍</wht>", "<wht>动物皮毛</wht>", "<wht>家丁服</wht>", "<wht>家丁鞋</wht>", "<hic>崔莺莺的手镯</hic>", "<hig>崔员外的戒指</hig>", "<hig>员外披肩</hig>", "<hig>流氓衣</hig>", "<hig>流氓鞋</hig>", "<hig>流氓护腕</hig>", "<hig>流氓短剑</hig>", "<hig>流氓闷棍</hig>", "<hig>五虎断门刀残页</hig>", "<hig>太祖长拳残页</hig>", "<hig>流氓巾</hig>", "<hig>黑虎单刀</hig>", "<hig>短衣劲装</hig>", "<hig>军服</hig>", "<hig>官服</hig>", "<hig>军刀</hig>", "<hic>将军剑</hic>", "<hig>拂尘</hig>", "进阶残页", "聚气丹", "喜宴"]
};
/* harmony default export */ __webpack_exports__["default"] = (WSMUD);

/***/ }),

/***/ "./src/module/Game.js":
/*!****************************!*\
  !*** ./src/module/Game.js ***!
  \****************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return Game; });
/* harmony import */ var _setting__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./setting */ "./src/module/setting.js");
/* harmony import */ var _Plugin__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Plugin */ "./src/module/Plugin.js");
/* harmony import */ var _Util__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Util */ "./src/module/Util.js");
/* harmony import */ var _Injector__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Injector */ "./src/module/Injector.js");
/* harmony import */ var _Const__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Const */ "./src/module/Const.js");
/* harmony import */ var _backman__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./backman */ "./src/module/backman.js");
/* harmony import */ var _daily__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./daily */ "./src/module/daily.js");
/* harmony import */ var _idle__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./idle */ "./src/module/idle.js");
/* harmony import */ var _dungeon__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./dungeon */ "./src/module/dungeon.js");


function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }










/*
监听游戏数据,获取游戏所有数据
 */

class GameData {
  constructor(game) {
    this.game = game;
    this.id = null;
    this.npcs = new Map();
    this.packs = []; //更新血量接口

    this.inject = _Injector__WEBPACK_IMPORTED_MODULE_3__["default"].getInstance();
    this.onShowHp = null;
    this.onNpcRemove = null;
    this.logger = _Plugin__WEBPACK_IMPORTED_MODULE_1__["log"];
    this.skills = {
      "force": "none",
      "dodge": "none",
      "parry": "none",
      "unarmed": "none",
      "sword": "none",
      "blade": "none",
      "club": "none",
      "staff": "none",
      "whip": "none",
      "throwing": "none"
    };
    this.ctrltarget = null; //控制目标

    this.dpstarget = null; //输出目标

    this.attackTarget = null; //当前目标
  }

  monitor(data) {
    if (!this[data.type]) return;
    this[data.type](data);
  }

  login(data) {
    this.id = data.id;
    _setting__WEBPACK_IMPORTED_MODULE_0__["default"].load(data.id, data.setting);

    let scoreListerner = data => {
      if (data.type == "dialog" && data.dialog == "score") {
        this.family = data.family;
        this.level = data.level;
        this.logger("<hiy>门派:" + this.family + "</hiy>");
        this.logger("开花分值:" + Math.floor(data.max_mp / 100 + data.con * data.con_add / 10), 2);
        setTimeout(() => {
          if ($(".dialog-score").is(":visible")) $(".dialog-close").click();
          $("span[command=skills]").click();
          setTimeout(() => {
            if ($(".dialog-skills").is(":visible")) $(".dialog-close").click();
          }, 500);
        }, 0);
        this.inject.removeListener(scoreListerner);
      }
    };

    this.inject.addListener(scoreListerner);
    this.inject.send("pack;score");
  }

  room(data) {
    let tmp = data.path.split("/");
    this.map_id = tmp[0];
    this.room_id = tmp[1];
    this.room_name = data.name;
  }

  items(data) {
    this.npcs = new Map();
    this.room_player = 0;

    for (var i = 0; i < data.items.length; i++) {
      let item = data.items[i];

      if (item.id) {
        let tmp = Object(_Util__WEBPACK_IMPORTED_MODULE_2__["nameSplit"])(item.name);
        let buffs = new Map();
        if (item.status) for (let i = 0; i < item.status.length; i++) {
          buffs.set(item.status[i].sid);
        }
        if (item.p) this.room_player++;
        this.npcs.set(item.id, {
          name: tmp.name,
          title: tmp.title,
          state: tmp.state,
          max_hp: item.max_hp,
          max_mp: item.max_mp,
          hp: item.hp,
          mp: item.mp,
          p: item.p,
          damage: 0,
          buffs: buffs
        });
        if (item.id == this.id) this.owner = this.npcs.get(item.id);
      }
    }

    this.onShowHp && this.onShowHp();
  }

  itemadd(data) {
    if (data.id) {
      let tmp = Object(_Util__WEBPACK_IMPORTED_MODULE_2__["nameSplit"])(data.name);
      let buffs = new Map();
      if (data.status) for (let i = 0; i < data.status.length; i++) {
        buffs.set(data.status[i].sid);
      }
      if (data.p && !this.npcs.has(data.id)) this.room_player++;
      this.npcs.set(data.id, {
        name: tmp.name,
        title: tmp.title,
        state: tmp.state,
        max_hp: data.max_hp,
        max_mp: data.max_mp,
        hp: data.hp,
        mp: data.mp,
        p: data.p,
        damage: 0,
        buffs: buffs
      });
      if (data.id == this.id) this.owner = this.npcs.get(data.id);
    }

    this.onShowHp && this.onShowHp(data.id);
  }

  itemremove(data) {
    let item = this.npcs.get(data.id);
    if (item && item.p) this.room_player--;

    if (item && item.damage) {
      this.logger(`总共对${item.name}造成伤害<hir>${item.damage}</hir>,占比<hiy>${item.dps_percent}%</hiy>`, 0, "战斗输出");
    }

    this.npcs.delete(data.id);
    this.onNpcRemove && this.onNpcRemove();
    if (data.id == this.ctrltarget) this.ctrltarget == undefined;
    if (data.id == this.dpstarget) this.dpstarget == undefined;
    this.onShowHp && this.onShowHp(data.id);
  }

  sc(data) {
    let npc = this.npcs.get(data.id);
    if (npc) if (data.max_hp !== undefined) {
      npc.max_hp = data.max_hp;
    }

    if (data.mp !== undefined) {
      npc.mp = data.mp;
    }

    if (data.hp !== undefined) {
      npc.hp = data.hp;
      this.scid = data.id; //伤害统计需要

      this.onShowHp && this.onShowHp(data.id);
    }

    if (data.damage !== undefined) {
      npc.damage = data.damage;
      this.attackTarget = data.id;
      npc.dps_percent = Math.floor(npc.damage / npc.max_hp * 100);
    }
  }

  status(data) {
    let npc = this.npcs.get(data.id);
    if (!npc) return;

    if (data.action == 'add') {
      npc.buffs.set(data.sid, data.name);
    } else if (data.action == 'remove') {
      npc.buffs.delete(data.sid);
    } else if (data.action == 'clear') {
      npc.buffs.clear();
    }
  }

  text(data) {
    //战利品检测
    if (data.content && (data.content.match(/^你从.*的尸体里拿出来.*。$/) || data.content.match(/^你获得了.*。$/))) {
      this.logger(data.content);
    } //战斗检测


    if (data.content && data.content.match(".*只能在战斗中使用。")) {
      this.onCombatEnd && onCombatEnd();
    }

    if (this.game.fight.fighting) {
      if (data.content.indexOf("造成<") > -1) this.attackTarget = this.scid;
    }
  }

  state(data) {
    if (data.state) {
      this.inState = data.state.substring(3, 5);
    } else {
      this.inState = "";
    }

    this.game.setTitle();

    if (!game.current && this.inState.match(/读书|练习|打坐|学习|领悟/)) {
      let id = Math.random().toString(36).substr(2);
      let c = `<div class="item-commands">当前状态为${this.inState}<span id="${id}">状态监测</span></div>`;
      this.logger(c);
      $("#" + id).on('click', function () {});
    }
  }

  dialog(data) {
    if (data.dialog == "pack") {
      if (data.items) {
        this.packs = data.items;
        this.eqs = data.eqs;
        return;
      } //处理装备


      if (data.eq != null) {
        for (let t = 0; t < this.packs.length; t++) if (this.packs[t].id == data.id) {
          this.eqs[data.eq] = this.packs[t], this.packs.splice(t, 1);
          break;
        }

        return;
      } //处理脱装备


      if (data.uneq != null) {
        let s = this.eqs[data.uneq];
        s.can_eq = 1;
        s.count = 1;
        this.packs.push(s);
        this.eqs[data.uneq] = null;
        return;
      } //处理物品移除


      if (data.remove) {
        let l = this.packs;

        for (let t = 0; t < l.length; t++) if (l[t].id == data.id) {
          data.remove >= l[t].count ? l.splice(t, 1) : l[t].count -= data.remove;
          break;
        }

        return;
      }

      if (data.name) {
        //处理物品获得
        let l = this.packs;
        let s = this.findPacksById(data.id);
        s ? (s.count = data.count, s.name = data.name) : this.packs.push(data);
      }
    }

    if (data.dialog == "list") {
      if (data.stores) {
        this.stores = data.stores;
        return;
      } //存取装备


      if (data.store) {
        let p = this.findPacksById(data.id);
        let s = this.findStoresById(data.storeid);
        p ? p.count -= data.store : ((p = _extends({}, s, {
          "id": data.id
        })).count -= data.store, this.packs.push(p)), s ? s.count += data.store : ((s = _extends({}, p, {
          "id": data.storeid
        })).count = data.store, this.stores.push(s));
        0 == s.count && this.stores.Remove(s), 0 == p.count && this.packs.Remove(p);
      }
    } //技能组记录


    if (data.dialog == "skills") {
      if (data.items) {
        for (const item of data.items) {
          if (this.skills[item.id] !== undefined) this.skills[item.id] = item.enable_skill || "none";
        }
      }

      if (data.id && this.skills[data.id] !== undefined) {
        if (data.enable) this.skills[data.id] = data.enable;
        if (data.enable == false) this.skills[data.id] = "none";
      }
    }
  }

  findPacksById(id) {
    return this.packs.find(t => t.id == id);
    let l = this.packs;

    for (let t = 0; t < l.length; t++) {
      if (l[t].id == id) return l[t];
    }
  }

  findPacksByName(name) {
    return this.packs.find(t => t.name == name);
    let l = this.packs;

    for (let t = 0; t < l.length; t++) {
      if (l[t].name == name) return l[t];
    }
  }

  findStoresById(id) {
    return this.stores.find(t => t.id == id);
    let l = this.stores;

    for (let t = 0; t < l.length; t++) if (l[t].id == id) {
      return l[t];
    }
  }

  findStoresByName(id) {
    return this.stores.find(t => t.name == name);
    let l = this.stores;

    for (let t = 0; t < l.length; t++) {
      if (l[t].name == name) return l[t];
    }
  }

} //战斗处理


class Fight {
  constructor(game) {
    this.game = game;
    /**@type {GameData} */

    this.data = game.data;
    this.cds = new Map();
    this.auto = true;
    this.gcd = false;
    this.fighting = false;
    this.waitAuto = false;
    this.dps_max_percent = 11;
    this.performWait = 0;
    this.performs = []; //更新血量接口

    this.inject = _Injector__WEBPACK_IMPORTED_MODULE_3__["default"].getInstance();
    this.logger = _Plugin__WEBPACK_IMPORTED_MODULE_1__["log"];
  }

  toggleAuto() {
    this.auto = !this.auto;

    if (this.auto) {
      this.inject.createMessage({
        type: "canpfm"
      }, this.performWait);
    }

    return this.auto;
  }

  monitor(data) {
    if (!this[data.type]) return;
    this[data.type](data);
  }

  perform(data) {
    this.dps_max_percent = 11;
    this.performs = data.skills;

    if (_setting__WEBPACK_IMPORTED_MODULE_0__["default"].auto_perform) {
      let tmp = _setting__WEBPACK_IMPORTED_MODULE_0__["default"].auto_perform.split(",");

      for (let i = 0; i < tmp.length; i++) {
        let r = tmp[i].match(/^k([\u4e00-\u9fa5]+)$/);

        if (r) {
          for (let perform of this.performs) {
            if (perform.name == r[1]) perform.ctrl = true;
          }

          ;
          continue;
        }

        r = tmp[i].match(/^b([\u4e00-\u9fa5]+)$/);

        if (r) {
          for (let perform of this.performs) {
            if (perform.name == r[1]) perform.fliter = true;
          }

          ;
          continue;
        }

        r = tmp[i].match(/^n([\u4e00-\u9fa5]+)$/);

        if (r) {
          for (let perform of this.performs) {
            if (perform.name == r[1]) perform.nocheck = true;
          }

          ;
          continue;
        }

        r = tmp[i].match(/^([\u4e00-\u9fa5]+)([a-zA-Z]+)$/);

        if (r) {
          for (let perform of this.performs) {
            if (perform.name == r[1]) perform.buff = r[2];
          }

          ;
          continue;
        }

        if (/^\d{1,2}$/.test(tmp[i])) this.dps_max_percent = parseInt(tmp[i]);
      }

      this.logger("已设置自动施法,输出锁定为" + this.dps_max_percent, 0, "自动施法");
    } else this.logger("未设置自动施法,所有技能自动释放", 0, "自动施法");
  }

  text(data) {
    if (data.content[0] == '【' && data.content.indexOf("只能在战斗中使用") > -1) {
      this.inject.createMessage({
        type: "combat",
        end: 1
      });
    }
  }

  combat(data) {
    if (data.start) {
      this.fighting = true;
      this.waitAuto = true;
      setTimeout(() => {
        this.waitAuto = false;
        if (this.gcd == false) this.inject.createMessage({
          type: "canpfm"
        }, this.performWait);
      }, 300);
      $(".combat-commands").addClass("red");
    }

    if (data.end) {
      this.fighting = false;
      $(".combat-commands").removeClass("red");
    }
  }

  dispfm(data) {
    if (data.id) {
      if (data.distime) {}

      this.cds.set(data.id, true);
      var _id = data.id;
      setTimeout(() => {
        this.cds.set(_id, false);
        this.inject.createMessage({
          type: "canpfm"
        }, this.performWait);
      }, data.distime);
    }

    if (data.rtime) {
      this.gcd = true;
      setTimeout(() => {
        this.gcd = false;
        this.inject.createMessage({
          type: "canpfm"
        }, this.performWait);
      }, data.rtime);
    } else {
      this.inject.createMessage({
        type: "canpfm"
      }, this.performWait);
      this.gcd = false;
    }
  }

  status(data) {
    if (this.fighting == false) return;

    if (data.action == "remove" && data.id == this.data.id) {
      this.inject.createMessage({
        type: "canpfm"
      }, this.performWait);
      return;
    }

    if (data.action == "remove" && (data.id == this.data.ctrltarget || data.id == this.data.attackTarget) && (data.sid == "busy" || data.sid == "faint")) {
      this.inject.createMessage({
        type: "canpfm"
      }, this.performWait);
      return;
    }
  }

  canpfm(data) {
    if (this.auto == false) return;
    if (this.fighting == false) return;
    if (this.waitAuto) return;
    if (this.gcd || this.data.owner.buffs.has("busy") || this.data.owner.buffs.has("faint") || this.data.owner.buffs.has("miss")) return;
    let attackitem = this.data.npcs.get(this.data.attackTarget);
    let ctrlitem = this.data.npcs.get(this.data.ctrltarget) || attackitem;
    let dps = true;

    if (this.data.dpstarget) {
      let item = this.data.npcs.get(this.data.dpstarget);
      ;
      if (item && item.dps_percent >= dps_max_percent) dps = false;
    }

    for (let perform of this.performs) {
      if (perform.fliter || this.cds.get(perform.id)) continue;

      if (perform.ctrl) {
        //控制技能,检测对手
        if (ctrlitem && (ctrlitem.buffs.has("busy") || ctrlitem.buffs.has("faint"))) continue;

        if (ctrlitem == attackitem) {
          this.inject.send("perform " + perform.id);
        } else {
          this.inject.send("kill " + this.data.ctrltarget);
          this.inject.send("perform " + perform.id);
          this.inject.send("kill " + this.data.attackTarget);
        }

        return;
      } else {
        if (dps == false) continue;
        if (perform.buff && this.game.data.owner.buffs.has(perform.buff)) continue;
        this.inject.send("perform " + perform.id);
        return;
      }
    }
  }

  die(data) {
    if (this._autoRelive && data.commands) {
      this.inject.send("relive");
      this.onRelive && this.onRelive();
    }
  }

  autoRelive(enable, callback) {
    this._autoRelive = enable;
    this.onRelive = this._autoRelive ? callback : null;
  }

  isFree() {
    let owner = game.data.owner;
    if (this.fighting) return false;
    if (owner.buffs.has("busy") || owner.buffs.has("rash") || owner.buffs.has("faint")) return false;
    return true;
  }

  isCooldown() {
    for (let skill of this.performs) {
      if (skill.nocheck) continue;
      if (this.cds.get(skill.id)) return true;
    }

    return false;
  }

  isWeak() {
    return game.data.owner.buffs.has("xuruo");
  }

}

class Game {
  constructor() {
    this.inject = _Injector__WEBPACK_IMPORTED_MODULE_3__["default"].getInstance();
    this.data = new GameData(this);
    this.fight = new Fight(this);
    this.inject.addListener(d => {
      this.data.monitor(d);
    });
    this.inject.addListener(d => {
      this.fight.monitor(d);
    });
    this.logger = _Plugin__WEBPACK_IMPORTED_MODULE_1__["log"];

    _setting__WEBPACK_IMPORTED_MODULE_0__["default"].onSetTrigger = (e, t) => {
      if (e == "item_hp") {
        this.show_hp();
      }
    };

    this.data.onShowHp = id => {
      this.show_hp(id);
    }; //页面事件获取姓名


    $("li[command=SelectRole]").on("click", () => this.onSelectRole());
    $("li[command=CreateRole]").on("click", () => this.onCreateRole());
    this.current = null;
    this.work = "";
  }
  /**
   * @returns { Game }
   */


  static getInstance() {
    if (!this.instance) {
      this.instance = new Game();
    }

    return this.instance;
  }

  show_hp(id) {
    if (_setting__WEBPACK_IMPORTED_MODULE_0__["default"].item_hp) {
      this.has_item_hp = true;

      if (id) {
        let npc = this.data.npcs.get(id);

        if (npc) {
          let s = $(".room-item[itemid=" + id + "] .item-hp");

          if (s.length == 0) {
            s = $(".room-item[itemid=" + id + "] .item-status").after("<span class='item-hp'></span>").next();
          }

          let html = "";
          if (npc.hp != undefined) html += "<hij>" + npc.hp + "(" + Math.floor(npc.hp / npc.max_hp * 100) + "%)</hij>";
          s.html(html);
        } else {
          $(".room-item[itemid=" + id + "] .item-hp").remove();
        }

        return;
      }

      for (let [id, npc] of this.data.npcs) {
        let s = $(".room-item[itemid=" + id + "] .item-hp");

        if (s.length == 0) {
          s = $(".room-item[itemid=" + id + "] .item-status").after("<span class='item-hp'></span>").next();
        }

        let html = "";
        if (npc.hp != undefined) html += "<hij>" + npc.hp + "(" + Math.floor(npc.hp / npc.max_hp * 100) + "%)</hij>";
        s.html(html);
      }
    } else {
      if (this.has_item_hp) {
        $(".item-hp").remove();
        this.has_item_hp = false;
      }
    }
  }

  onCreateRole() {
    this.role = $('#reg_name').val();
    this.setTitle();
    this.onReady();
  }

  onSelectRole() {
    this.role = $('.role-list .select').text().split(/[\s\n]/).pop();
    this.setTitle();
    this.onReady();
  }

  onReady() {
    this.backman = new _backman__WEBPACK_IMPORTED_MODULE_5__["default"]();
    this.idle = new _idle__WEBPACK_IMPORTED_MODULE_7__["default"]();
    this.daily = new _daily__WEBPACK_IMPORTED_MODULE_6__["default"]();
    this.dungeon = new _dungeon__WEBPACK_IMPORTED_MODULE_8__["default"]();

    this.backman.onStart = () => {
      if (this.current) this.current.stop();
      this.current = this.backman;
    };

    this.idle.onStart = () => {
      if (this.current) this.current.stop();
      this.current = this.idle;
    };

    this.daily.onStart = () => {
      if (this.current) this.current.stop();
      this.current = this.daily;
    };

    this.dungeon.onStart = () => {
      if (this.current) this.current.stop();
      this.current = this.dungeon;
    };

    this.daily.onComplete = () => this.idle.start();
  }

  stop() {
    if (this.current) {
      this.current.stop();
      this.current = undefined;
    }

    ;
    this.daily.stop();
  }

  setWork(work) {
    this.work = work;
    this.setTitle();
  }

  setTitle() {
    document.title = this.role + (this.data.inState ? "[" + this.data.inState + "]" : "") + (this.work && this.work.length > 0 ? "-" + this.work : "");
  }

  at(place) {
    return place.indexOf(this.data.room_name) == 0;
  }

  go(place) {
    let path = _Const__WEBPACK_IMPORTED_MODULE_4__["default"].path[place];
    if (path != undefined) this.inject.send(path);else {
      this.logger(place + "无法到达");
    }
  }

  getEqList() {
    let list = [];

    for (let key in _setting__WEBPACK_IMPORTED_MODULE_0__["default"].local.eq) {
      _setting__WEBPACK_IMPORTED_MODULE_0__["default"].local.eq[key] instanceof Array && list.push(key);
    }

    return list;
  }

  getSkillList() {
    let list = [];

    for (let key in _setting__WEBPACK_IMPORTED_MODULE_0__["default"].local.skill) {
      typeof _setting__WEBPACK_IMPORTED_MODULE_0__["default"].local.skill[key] == "string" && list.push(key);
    }

    return list;
  }

  equipSuit(suit, idx) {
    let eqs = _setting__WEBPACK_IMPORTED_MODULE_0__["default"].local.eq[suit];

    if (eqs && eqs instanceof Array) {
      if (idx) {
        if (eqs[i] && (this.data.eqs[i] == null || eqs[i].id != this.data.eqs[i].id)) this.inject.send(`eq ${eqs[i].id}`);
      } else {
        for (let i = 10; i >= 0; i--) {
          if (eqs[i] && (this.data.eqs[i] == null || eqs[i].id != this.data.eqs[i].id)) this.inject.send(`eq ${eqs[i].id}`);
        }
      }
    }
  }

  setSkill(skillsuit) {
    let skill = _setting__WEBPACK_IMPORTED_MODULE_0__["default"].local.skill[skillsuit];

    if (skill) {
      let skills = JSON.parse(skill);

      for (let id in skills) {
        if (this.data.skills[id] && skills[id] !== this.data.skills[id]) this.inject.send(`enable ${id}  ${skills[id]}`);
      }
    }
  }

  equipSuitSave(suit) {
    suit = suit || prompt("请输入要保存的装备名称");
    if (suit) _setting__WEBPACK_IMPORTED_MODULE_0__["default"].saveEq(suit, [...this.data.eqs]);
  }

  equipSuitDelete() {
    let suit = prompt("请输入要删除的装备名称");

    if (suit == "战斗" || suit == "练习") {
      this.logger("不能删除默认战斗和练习");
      return;
    }

    if (suit) _setting__WEBPACK_IMPORTED_MODULE_0__["default"].deleteEq(suit);
  }

  skillSuitSave(suit) {
    suit = suit || prompt("请输入要保存的技能名称");
    if (suit) _setting__WEBPACK_IMPORTED_MODULE_0__["default"].saveSkill(suit, JSON.stringify(this.data.skills));
  }

  skillSuitDelete() {
    let suit = prompt("请输入要删除的技能名称");

    if (suit == "战斗" || suit == "练习") {
      this.logger("不能删除默认战斗和练习");
      return;
    }

    if (suit) _setting__WEBPACK_IMPORTED_MODULE_0__["default"].deleteSkill(suit);
  }

  kill_all() {
    for (let [k, v] of this.data.npcs) {
      if (k == this.data.id) continue;
      if (v.max_hp > _setting__WEBPACK_IMPORTED_MODULE_0__["default"].kill_maxHp) continue;

      if (v.p) {
        if (_setting__WEBPACK_IMPORTED_MODULE_0__["default"].kill_player) this.inject.send("kill " + k);
      } else {
        this.inject.send("kill " + k);
      }
    }
  }

  get_all() {
    for (let [k, v] of this.data.npcs) {
      if (k == this.data.id) continue;

      if (v.name.match(/^(.+)的尸体$/)) {
        this.inject.send("get all from " + k);
      }
    }
  }

  dungeonDisplay(type) {
    let text, func, fbs;

    if (type == "single") {
      text = "自动副本:";

      func = (dungeonName, times) => {
        this.dungeon.single(dungeonName, times);
      };

      fbs = _Const__WEBPACK_IMPORTED_MODULE_4__["default"].dungeon.filter(a => a.auto != "nop");
    } else if (type == "swipe") {
      text = "扫荡副本:";

      func = (dungeonName, times) => {
        this.dungeon.swipe(dungeonName, times);
      };

      fbs = _Const__WEBPACK_IMPORTED_MODULE_4__["default"].dungeon;
    } else if (type == "fast") {
      text = "秒进荡副本:";

      func = (dungeonName, times) => {
        this.dungeon.fast(dungeonName, times);
      };

      fbs = _Const__WEBPACK_IMPORTED_MODULE_4__["default"].dungeon;
    } else return;

    let c = "<div id='displayFB' class='item-commands'>" + text;
    $("#displayFB").remove();

    for (let fb of fbs) {
      c += "<span class='fb_click'>" + fb.name + "</span>";
      if (fb.hard) c += "<span class='fb_click'>" + fb.name + "困难</span>";
    }

    Object(_Plugin__WEBPACK_IMPORTED_MODULE_1__["log"])(c + "</div>");
    $(".fb_click").on("click", function () {
      let t = parseInt(prompt($(this).text()));
      if (t > 0) func($(this).text(), t);
    });
  }

}

/***/ }),

/***/ "./src/module/Injector.js":
/*!********************************!*\
  !*** ./src/module/Injector.js ***!
  \********************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return Injector; });
 // 插件,监听及发送网络消息。

class Injector {
  constructor() {
    this.ws = null;
    this.messageCallback = null;
    this.listeners = [null];
    this.cmd_queue = [];
    this.cmd_busy = false;
    this.echo = false;
    this.dirdectCount = 0;
    this.manualCount = 0;
    this.print = console.log; //重载ws

    var _ws = window.WebSocket;
    var ws;
    var injector = this;

    var createWebSocket = uri => {
      ws = new _ws(uri);
      this.ws = ws;
      document.getElementsByClassName("signinfo")[0].innerHTML += "<HIR>插件已运行</HIR>";
    };

    var setMessageCallback = fn => {
      this.messageCallback = fn;

      ws.onmessage = msg => this.onServerMessage(msg);
    };

    unsafeWindow.WebSocket = function (uri) {
      createWebSocket(uri);
    };

    unsafeWindow.WebSocket.prototype = {
      CONNECTING: _ws.CONNECTING,
      OPEN: _ws.OPEN,
      CLOSING: _ws.CLOSING,
      CLOSED: _ws.CLOSED,

      get url() {
        return ws.url;
      },

      get protocol() {
        return ws.protocol;
      },

      get readyState() {
        return ws.readyState;
      },

      get bufferedAmount() {
        return ws.bufferedAmount;
      },

      get extensions() {
        return ws.extensions;
      },

      get binaryType() {
        return ws.binaryType;
      },

      set binaryType(t) {
        ws.binaryType = t;
      },

      get onopen() {
        return ws.onopen;
      },

      set onopen(fn) {
        ws.onopen = fn;
      },

      get onmessage() {
        return ws.onmessage;
      },

      set onmessage(fn) {
        setMessageCallback(fn);
      },

      get onclose() {
        return ws.onclose;
      },

      set onclose(fn) {
        ws.onclose = fn;
      },

      get onerror() {
        return ws.onerror;
      },

      set onerror(fn) {
        ws.onerror = fn;
      },

      send: function (text) {
        if (injector.echo) {
          injector._echo('<hiy>' + text + '</hiy>');
        }

        injector.manualCount++;
        setTimeout(() => {
          if (injector.manualCount > 0) {
            injector.manualCount--;
          }
        }, 3000);
        ws.send(text);
      },
      close: function () {
        ws.close();
      }
    };
  }
  /**
   * @returns { Injector }
   */


  static getInstance() {
    if (unsafeWindow.inject) return unsafeWindow.inject;
    if (window.WebSocket) if (!this.instance) {
      this.instance = new Injector();
    }
    return this.instance;
  }

  onServerMessage(msg) {
    if (!msg || !msg.data) return;
    let data;

    if (msg.data[0] == '{' || msg.data[0] == '[') {
      let func = new Function("return " + msg.data + ";");
      data = func();
    } else {
      data = {
        type: 'text',
        content: msg.data
      };
    }

    if (this.waylayer && this.waylayer(data)) {
      delete this.waylayer;
    } else {
      this.messageCallback.apply(this, arguments);
    }

    this.listeners.forEach(listener => {
      if (listener != null) {
        listener(data);
      }
    });
  }

  createMessage(msg, timeout) {
    timeout = timeout || 0;
    setTimeout(() => {
      this.onServerMessage({
        data: JSON.stringify(msg)
      });
    }, timeout);
  }

  setListener(listener, info) {
    this.print(info, listener == null ? 0 : 1);
    this.listeners[0] = listener;
  }

  addListener(listener) {
    this.listeners.push(listener);
  }

  removeListener(listener) {
    let index = this.listeners.indexOf(listener);

    if (index == 0) {
      this.listeners[0] = null;
    } else if (index > 0) {
      this.listeners.splice(index, 1);
    }
  }

  _send_cmd() {
    if (!this.ws || this.ws.readyState != 1) {
      this.cmd_busy = false;
      this.cmd_queue = [];
    } else if (this.cmd_queue.length > 0) {
      this.cmd_busy = true;
      let t = new Date().getTime();
      let t1 = t - 3000;
      let t2 = t - 300;
      let i;
      let del_i;

      for (i = 0, del_i = 0; i < this.cmd_queue.length; i++) {
        if (this.cmd_queue[i].timestamp == 0) {
          break;
        }

        if (this.cmd_queue[i].timestamp < t1) {
          del_i = i + 1;
        }
      }

      this.cmd_queue.splice(0, del_i);
      i = i - del_i;

      if (i == 0) {
        this.dirdectCount = this.manualCount > 10 ? 10 : this.manualCount;
        this.manualCount -= this.dirdectCount;
      }

      for (; i < this.cmd_queue.length; i++) {
        if (this.dirdectCount >= 10) {
          if (this.manualCount > 0) {
            this.manualCount--;
            break;
          }

          if (i && this.cmd_queue[i - 1].timestamp > t2) break;
        }

        try {
          if (this.echo) {
            this._echo('<hiy>' + this.cmd_queue[i].cmd + '</hiy>');
          }

          this.ws.send(this.cmd_queue[i].cmd);
          this.dirdectCount++;
          this.cmd_queue[i].timestamp = t;
        } catch (e) {
          this._echo(e);

          this.cmd_busy = false;
          this.cmd_queue = [];
          return;
        }

        if (this.dirdectCount >= 10) break;
      }

      if (!this.cmd_queue[this.cmd_queue.length - 1].timestamp) {
        setTimeout(() => {
          this._send_cmd();
        }, 250);
      } else {
        this.cmd_busy = false;
      }
    } else {
      this.cmd_busy = false;
    }
  }

  send(cmd, no_queue) {
    if (this.ws && this.ws.readyState == 1) {
      cmd = cmd instanceof Array ? cmd : cmd.split(';');

      if (no_queue) {
        for (var i = 0; i < cmd.length; i++) {
          if (this.echo) {
            this._echo('<hiy>' + cmd[i] + '</hiy>');
          }

          this.ws.send(cmd[i]);
        }
      } else {
        for (i = 0; i < cmd.length; i++) {
          this.cmd_queue.push({
            cmd: cmd[i],
            timestamp: 0
          });
        }

        if (!this.cmd_busy) {
          this._send_cmd();
        }
      }
    }
  }

  _echo(msg) {
    this.messageCallback({
      data: msg
    });
  }

  waylay(trigger) {
    this.waylayer = trigger;
  }

}
Injector.getInstance();

/***/ }),

/***/ "./src/module/Key.js":
/*!***************************!*\
  !*** ./src/module/Key.js ***!
  \***************************/
/*! exports provided: KEY */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KEY", function() { return KEY; });
 //为武神传说添加

class KEY {
  constructor() {
    this.keys = {};
    this.roomItemSelectIndex = -1;
  }

  init() {
    //添加快捷键说明
    $("span[command=stopstate] span:eq(0)").html("S");
    $("span[command=showcombat] span:eq(0)").html("A");
    $("span[command=showtool] span:eq(0)").html("C");
    $("span[command=pack] span:eq(0)").html("B");
    $("span[command=tasks] span:eq(0)").html("L");
    $("span[command=score] span:eq(0)").html("O");
    $("span[command=jh] span:eq(0)").html("J");
    $("span[command=skills] span:eq(0)").html("K");
    $("span[command=message] span:eq(0)").html("U");
    $("span[command=shop] span:eq(0)").html("P");
    $("span[command=stats] span:eq(0)").html("I");
    $("span[command=setting] span:eq(0)").html(",");
    $(document).on("keydown", e => this.onKeyDown(e));
    this.addKey(27, () => {
      this.dialog_close();
    });
    this.addKey(192, () => {
      $(".map-icon").click();
    });
    this.addKey(32, () => {
      this.dialog_confirm();
    });
    this.addKey(83, () => {
      this.do_command("stopstate");
    });
    this.addKey(13, () => {
      this.do_command("showchat");
    });
    this.addKey(65, () => {
      this.do_command("showcombat");
    });
    this.addKey(67, () => {
      this.do_command("showtool");
    });
    this.addKey(66, () => {
      this.do_command("pack");
    });
    this.addKey(76, () => {
      this.do_command("tasks");
    });
    this.addKey(79, () => {
      this.do_command("score");
    });
    this.addKey(74, () => {
      this.do_command("jh");
    });
    this.addKey(75, () => {
      this.do_command("skills");
    });
    this.addKey(73, () => {
      this.do_command("stats");
    });
    this.addKey(85, () => {
      this.do_command("message");
    });
    this.addKey(80, () => {
      this.do_command("shop");
    });
    this.addKey(188, () => {
      this.do_command("setting");
    });
    this.addKey(9, () => {
      this.onRoomItemSelect();
      return false;
    }); //方向

    this.addKey(102, () => {
      inject.send("go east");
      this.onChangeRoom();
    });
    this.addKey(39, () => {
      inject.send("go east");
      this.onChangeRoom();
    });
    this.addKey(100, () => {
      inject.send("go west");
      this.onChangeRoom();
    });
    this.addKey(37, () => {
      inject.send("go west");
      this.onChangeRoom();
    });
    this.addKey(98, () => {
      inject.send("go south");
      this.onChangeRoom();
    });
    this.addKey(40, () => {
      inject.send("go south");
      this.onChangeRoom();
    });
    this.addKey(104, () => {
      inject.send("go north");
      this.onChangeRoom();
    });
    this.addKey(38, () => {
      inject.send("go north");
      this.onChangeRoom();
    });
    this.addKey(99, () => {
      inject.send("go southeast");
      this.onChangeRoom();
    });
    this.addKey(97, () => {
      inject.send("go southwest");
      this.onChangeRoom();
    });
    this.addKey(105, () => {
      inject.send("go northeast");
      this.onChangeRoom();
    });
    this.addKey(103, () => {
      inject.send("go northwest");
      this.onChangeRoom();
    });
    this.addKey(49, () => {
      this.combat_commands(0);
    });
    this.addKey(50, () => {
      this.combat_commands(1);
    });
    this.addKey(51, () => {
      this.combat_commands(2);
    });
    this.addKey(52, () => {
      this.combat_commands(3);
    });
    this.addKey(53, () => {
      this.combat_commands(4);
    });
    this.addKey(54, () => {
      this.combat_commands(5);
    }); //alt

    this.addKey(49 + 512, () => {
      this.onRoomItemAction(0);
    });
    this.addKey(50 + 512, () => {
      this.onRoomItemAction(1);
    });
    this.addKey(51 + 512, () => {
      this.onRoomItemAction(2);
    });
    this.addKey(52 + 512, () => {
      this.onRoomItemAction(3);
    });
    this.addKey(53 + 512, () => {
      this.onRoomItemAction(4);
    });
    this.addKey(54 + 512, () => {
      this.onRoomItemAction(5);
    }); //ctrl

    this.addKey(49 + 1024, () => {
      this.room_commands(0);
    });
    this.addKey(50 + 1024, () => {
      this.room_commands(1);
    });
    this.addKey(51 + 1024, () => {
      this.room_commands(2);
    });
    this.addKey(52 + 1024, () => {
      this.room_commands(3);
    });
    this.addKey(53 + 1024, () => {
      this.room_commands(4);
    });
    this.addKey(54 + 1024, () => {
      this.room_commands(5);
    });
  }

  addKey(k, c) {
    this.keys[k] = c;
  }

  onKeyDown(event) {
    if ($(".channel-box").is(":visible")) {
      this.chatModeKeyEvent(event);
      return;
    }

    if ($(".dialog-custom").is(":visible") && (event.keyCode >= 48 && event.keyCode <= 57 || event.keyCode >= 96 && event.keyCode <= 105)) {
      return;
    }

    if ($(".dialog-custom").is(":visible") && event.keyCode != 27) return;
    let keyCode = (event.ctrlKey || event.metaKey ? 1024 : 0) + (event.altKey ? 512 : 0) + event.keyCode;

    if (this.keys[keyCode]) {
      this.keys[keyCode]();
    }
  }

  dialog_close() {
    $(".dialog-close").click();
  }

  dialog_confirm() {
    $(".dialog-btn.btn-ok").click();
  }

  do_command(name) {
    $("span[command=" + name + "]").click();
  }

  room_commands(index) {
    $("div.combat-panel div.room-commands span:eq(" + index + ")").click();
  }

  combat_commands(index) {
    $("div.combat-panel div.combat-commands span.pfm-item:eq(" + index + ")").click();
  }

  chatModeKeyEvent(event) {
    if (event.keyCode == 27) this.dialog_close();else if (event.keyCode == 13) {
      if ($(".sender-box").val().length) $(".sender-btn").click();else this.dialog_close();
    }
  }

  onChangeRoom() {
    this.roomItemSelectIndex = -1;
  }

  onRoomItemSelect() {
    if (this.roomItemSelectIndex != -1) {
      $(".room_items div.room-item:eq(" + this.roomItemSelectIndex + ")").css("background", "#000");
    }

    this.roomItemSelectIndex = (this.roomItemSelectIndex + 1) % $(".room_items div.room-item").length;
    var curItem = $(".room_items div.room-item:eq(" + this.roomItemSelectIndex + ")");
    curItem.css("background", "#444");
    curItem.click();
  }

  onRoomItemAction(index) {
    //NPC下方按键
    $(".room_items .item-commands span:eq(" + index + ")").click();
  }

}

/***/ }),

/***/ "./src/module/Plugin.js":
/*!******************************!*\
  !*** ./src/module/Plugin.js ***!
  \******************************/
/*! exports provided: log, setState, clearLog, main */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "log", function() { return log; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setState", function() { return setState; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clearLog", function() { return clearLog; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "main", function() { return main; });
/* harmony import */ var _Key__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Key */ "./src/module/Key.js");
/* harmony import */ var _Injector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Injector */ "./src/module/Injector.js");
/* harmony import */ var _Game__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Game */ "./src/module/Game.js");
/* harmony import */ var _Util__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Util */ "./src/module/Util.js");
/* harmony import */ var _setting__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./setting */ "./src/module/setting.js");
/* harmony import */ var _Const__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Const */ "./src/module/Const.js");
/* 插件接口 */








var log_line = 0;
var key = null;
/**@type {Injector} */

var inject = null;
/**@type {Game} */

var game = null;
const log = function (m, t = 0, name = undefined) {
  if (t == 1) {
    m = "<hiy>" + m + "</hiy>";
  } else if (t == 2) {
    m = "<hig>" + m + "</hig>";
  } else if (t == 3) {
    m = "<hiw>" + m + "</hiw>";
  } else if (t == 4) {
    m = "<hir>" + m + "</hir>";
  }

  if (name) m = "<hio>" + name + "</hio>" + m;
  100 < log_line && (log_line = 0, $(".plugin_log pre").empty());
  $(".plugin_log pre").append(m + "\n");
  log_line++;
  $(".plugin_log")[0].scrollTop = 99999;
};
const setState = function (m, t = 0) {
  if (t == 1) {
    m = "<hiy>" + m + "</hiy>";
  } else if (t == 2) {
    m = "<hig>" + m + "</hig>";
  } else if (t == 3) {
    m = "<hiw>" + m + "</hiw>";
  } else if (t == 4) {
    m = "<hir>" + m + "</hir>";
  }

  $(".plugin_state").html(m);
};
const clearLog = function () {
  log_line = 0;
  $(".plugin_log pre").empty();
};
const main = function () {
  console.log("【wsmud_plugins】启动"); //document.addEventListener("DOMContentLoaded", () => {

  GM_addStyle(__webpack_require__(/*! ./wsmud.css */ "./src/module/wsmud.css").toString());
  let isPC = !/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent);
  console.log(isPC);

  if (isPC) {
    key = new _Key__WEBPACK_IMPORTED_MODULE_0__["KEY"]();
    key.init();
  } //设置界面


  setwindow(isPC); //数据监听

  debug(); //});
};

function debug() {
  unsafeWindow.inject = inject = _Injector__WEBPACK_IMPORTED_MODULE_1__["default"].getInstance();
  unsafeWindow.game = game = _Game__WEBPACK_IMPORTED_MODULE_2__["default"].getInstance();
  unsafeWindow.setting = _setting__WEBPACK_IMPORTED_MODULE_4__["default"];
  unsafeWindow.wsmud = _Const__WEBPACK_IMPORTED_MODULE_5__["default"];
}

function selectItem(e) {
  let id = $(this).attr("itemid");
  let npc = game.data.npcs.get(id);

  if (npc.p == undefined) {
    let id1 = Math.random().toString(36).substr(2);
    let id2 = Math.random().toString(36).substr(2);
    let c = `<div class="item-commands" id="lock"><ORD>${npc.name}</ORD><span id="${id1}">控制锁定</span><span id="${id2}">输出锁定</span>`;
    $("#lock").remove();
    log(c);

    if (game.data.ctrltarget == id) {
      $("#" + id1).text("解除控制");
      $("#" + id1).on('click', function () {
        game.data.ctrltarget = undefined;
      });
    } else {
      $("#" + id1).on('click', function () {
        game.data.ctrltarget = id;
      });
    }

    if (game.data.dpstarget == id) {
      $("#" + id2).text("解除输出");
      $("#" + id2).on('click', function () {
        game.data.dpstarget = undefined;
      });
    } else {
      $("#" + id2).on('click', function () {
        game.data.dpstarget = id;
        $(this).text("解除输出");
        $(this).on('click', function () {
          game.data.dpstarget = undefined;
        });
      });
    }
  }
}

function setwindow(isPC) {
  if (document.querySelector(".plugin_log")) return;
  $("head").append("<link href='https://cdn.staticfile.org/jquery-contextmenu/3.0.0-beta.2/jquery.contextMenu.min.css' rel='stylesheet'>");
  let html = `
                <div class="plugin">
                <div class="plugin_left"></div>
                <div class="plugin_log"><pre></pre></div>
                </div>
                <div class="plugin_state">插件状态</div>
                <div class="plugin_bottom">
                <span class="zdy-item auto_perform" style="float:right;">关闭</span>
                </div>
                `;
  $(".content-message").after(html);
  $(".room-name").after(`<span class="backman_state">辅助功能</span>`);
  _Injector__WEBPACK_IMPORTED_MODULE_1__["default"].getInstance().print = setState;
  log(`插件版本: ${GM_info.script.version}`, 2); //插入右键

  if (!isPC) {
    $(".state-bar").before("<span class='zdy-item plugins_contextMenu'>插件</span>");
    $(".plugins_contextMenu").on("click", function () {
      $(".plugins_contextMenu").contextMenu();
    });
  }

  let menu_KJ = {
    "kj0": {
      name: "豪宅",
      callback: (key, opt) => {
        game.go("住房-院子");
      }
    },
    "kj1": {
      name: "仓库",
      callback: (key, opt) => {
        game.go("扬州城-钱庄");
        inject.send("store");
      }
    },
    "kj2": {
      name: "武庙",
      callback: (key, opt) => {
        game.go("扬州城-武庙");
        inject.send("liaoshang");
      }
    },
    "kj3": {
      name: "衙门",
      callback: (key, opt) => {
        game.go("扬州城-衙门正厅");
      }
    },
    "kj4": {
      name: "帮派",
      callback: (key, opt) => {
        game.go("扬州城-帮派");
      }
    },
    "kj5": {
      name: "擂台",
      callback: (key, opt) => {
        game.go("扬州城-擂台");
      }
    },
    "kj6": {
      name: "当铺",
      callback: (key, opt) => {
        game.go("扬州城-当铺");
      }
    },
    "kj7": {
      name: "杂货铺",
      callback: (key, opt) => {
        game.go("扬州城-杂货铺");
      }
    },
    "kj8": {
      name: "打铁铺",
      callback: (key, opt) => {
        game.go("扬州城-打铁铺");
      }
    },
    "kj9": {
      name: "药铺",
      callback: (key, opt) => {
        game.go("扬州城-药铺");
      }
    }
  };
  let menu_MP = {
    "mp1": {
      name: "武当",
      callback: (key, opt) => {
        game.go("武当派-广场");
      }
    },
    "mp2": {
      name: "少林",
      callback: (key, opt) => {
        game.go("少林派-广场");
      }
    },
    "mp3": {
      name: "华山",
      callback: (key, opt) => {
        game.go("华山派-镇岳宫");
      }
    },
    "mp4": {
      name: "峨嵋",
      callback: (key, opt) => {
        game.go("峨嵋派-金顶");
      }
    },
    "mp5": {
      name: "逍遥",
      callback: (key, opt) => {
        game.go("逍遥派-青草坪");
      }
    },
    "mp6": {
      name: "丐帮",
      callback: (key, opt) => {
        game.go("丐帮-树洞内部");
      }
    },
    "mp7": {
      name: "襄阳",
      callback: (key, opt) => {
        game.go("襄阳城-广场");
      }
    },
    "mp8": {
      name: "武道",
      callback: (key, opt) => {
        game.go("武道塔");
      }
    }
  };
  let menu_ZM = {
    "mpzm1": {
      name: "武当",
      callback: (key, opt) => {
        game.go("武当派-后山小院");
        if ($("span:contains('躺尸')").length) inject.send("perform sword.wu");
      }
    },
    "mpzm2": {
      name: "少林",
      callback: (key, opt) => {
        game.go("少林派-方丈楼");
        if ($("span:contains('躺尸')").length) inject.send("perform sword.wu");
      }
    },
    "mpzm3": {
      name: "华山",
      callback: (key, opt) => {
        game.go("华山派-客厅");
        if ($("span:contains('躺尸')").length) inject.send("perform sword.wu");
      }
    },
    "mpzm4": {
      name: "峨嵋",
      callback: (key, opt) => {
        game.go("峨嵋派-清修洞");
        if ($("span:contains('躺尸')").length) inject.send("perform sword.wu");
      }
    },
    "mpzm5": {
      name: "逍遥",
      callback: (key, opt) => {
        game.go("逍遥派-地下石室");
        if ($("span:contains('躺尸')").length) inject.send("perform sword.wu");
      }
    },
    "mpzm6": {
      name: "丐帮",
      callback: (key, opt) => {
        game.go("丐帮-林间小屋");
        if ($("span:contains('躺尸')").length) inject.send("perform sword.wu");
      }
    }
  };
  let menu_Daily = {
    "daily1": {
      name: "武道",
      callback: (key, opt) => {
        game.daily.start("武道");
      }
    },
    "daily2": {
      name: "衙门",
      callback: (key, opt) => {
        game.daily.start("衙门");
      }
    },
    "daily3": {
      name: "师门",
      callback: (key, opt) => {
        game.daily.start("师门");
      }
    },
    "daily4": {
      name: "副本",
      callback: (key, opt) => {
        game.daily.start("副本");
      }
    },
    "daily5": {
      name: "签到",
      callback: (key, opt) => {
        game.daily.start("签到");
      }
    },
    "sep1": "---------",
    "daily6": {
      name: "运镖",
      callback: (key, opt) => {
        game.daily.start("运镖");
      }
    },
    "sep2": "---------",
    "daily7": {
      name: "扫荡副本",
      callback: (key, opt) => {
        game.dungeonDisplay("swipe");
      }
    },
    "daily8": {
      name: "秒进副本",
      callback: (key, opt) => {
        game.dungeonDisplay("fast");
      }
    }
  };
  let Menu_XY = {
    "领取低保": {
      name: "领取低保",
      callback: (key, opt) => {}
    },
    "sep1": "---------",
    "襄阳城-东门外": {
      name: "东门",
      callback: (key, opt) => {}
    },
    "襄阳城-西门外": {
      name: "西门",
      callback: (key, opt) => {}
    },
    "襄阳城-南门外": {
      name: "南门",
      callback: (key, opt) => {}
    },
    "襄阳城-北门外": {
      name: "北门",
      callback: (key, opt) => {}
    },
    "sep2": "---------",
    "襄阳城-东北城墙": {
      name: "东北城墙",
      callback: (key, opt) => {}
    },
    "襄阳城-东南城墙": {
      name: "东南城墙",
      callback: (key, opt) => {}
    },
    "襄阳城-西南城墙": {
      name: "西南城墙",
      callback: (key, opt) => {}
    },
    "襄阳城-西北城墙": {
      name: "西北城墙",
      callback: (key, opt) => {}
    }
  };
  let Menu_Pack = {
    "pack1": {
      name: "保存为战斗",
      callback: (key, opt) => {
        game.equipSuitSave("战斗");
      }
    },
    "pack2": {
      name: "保存为练习",
      callback: (key, opt) => {
        game.equipSuitSave("练习");
      }
    },
    "pack3": {
      name: "自定义保存",
      callback: (key, opt) => {
        game.equipSuitSave();
      }
    },
    "pack4": {
      name: "删除",
      callback: (key, opt) => {
        game.equipSuitDelete();
      }
    }
  };
  let Menu_Skill = {
    "skill1": {
      name: "保存为战斗",
      callback: (key, opt) => {
        game.skillSuitSave("战斗");
      }
    },
    "skill2": {
      name: "保存为练习",
      callback: (key, opt) => {
        game.skillSuitSave("练习");
      }
    },
    "skill3": {
      name: "自定义保存",
      callback: (key, opt) => {
        game.skillSuitSave();
      }
    },
    "skill4": {
      name: "删除",
      callback: (key, opt) => {
        game.skillSuitDelete();
      }
    }
  };
  let menu_xiulian = {
    "xiulian1": {
      name: "自动修炼",
      callback: (key, opt) => {
        game.idle.practice();
      }
    },
    "xiulian3": {
      name: "自动比试",
      callback: (key, opt) => {
        game.skillSuitSave("练习");
      }
    },
    "xiulian4": {
      name: "挂机修炼",
      callback: (key, opt) => {
        game.idle.practice_build();
      }
    },
    "xiulian5": {
      name: "清除挂机",
      callback: (key, opt) => {
        game.idle.practice_clear();
      }
    }
  };
  addbutton_left("装备", () => {
    let c = "<div id='displayequip' class='item-commands'>装备";
    $("#displayequip").remove();
    let list = game.getEqList();

    for (let i = 0; i < list.length; i++) {
      c += "<span class='equip_click'>" + list[i] + "</span>";
    }

    log(c + "</div>");
    $(".equip_click").on("click", function () {
      game.equipSuit($(this).text());
    });
  });
  addbutton_left("技能", () => {
    let c = "<div id='dispalySkill' class='item-commands'>技能";
    $("#dispalySkill").remove();
    let list = game.getSkillList();

    for (let i = 0; i < list.length; i++) {
      c += "<span class='skill_click'>" + list[i] + "</span>";
    }

    log(c + "</div>");
    $(".skill_click").on("click", function () {
      game.setSkill($(this).text());
    });
  });
  addbutton_left("掌门", () => {
    let c = "<div id='displayCS' class='item-commands'>";
    $("#displayCS").remove();

    for (let key in menu_ZM) {
      c += "<span  id='" + key + "'>" + menu_ZM[key].name + "</span>";
    }

    log(c + "</div>");

    for (let key in menu_ZM) $("#" + key).on("click", menu_ZM[key].callback);
  });
  addbutton_left("副本", () => {
    game.dungeonDisplay("single");
  });
  $(".auto_perform").on("click", () => {
    $(".auto_perform").text(game.fight.toggleAuto() ? "关闭" : "自动");
  });
  addbutton("日常", () => {
    game.daily.start();
  }, "Q");
  addbutton("停止", () => {
    game.stop();
  }, "W");
  addbutton("叫杀", () => {
    game.kill_all();
  }, "E");
  addbutton("拾取", () => {
    game.get_all();
  }, "R");
  addbutton("整理", () => {
    game.backman.packUp();
  }, "R");
  addbutton("挂机", () => {
    game.idle.start();
  }, "Y");
  $(".room_items").on("click", ".room-item", selectItem);
  $.contextMenu({
    selector: isPC ? ".container" : ".plugins_contextMenu",
    trigger: "right",
    autoHide: 0,
    zIndex: 100,
    items: {
      "快捷传送": {
        name: "常用地点",
        "items": menu_KJ
      },
      "门派传送": {
        name: "门派传送",
        "items": menu_MP
      },
      "门派掌门": {
        name: "门派掌门",
        "items": menu_ZM
      },
      "日常": {
        name: "日常",
        "items": menu_Daily
      },
      "修炼": {
        name: "修炼",
        "items": menu_xiulian
      },
      "襄阳": {
        name: "襄阳",
        "items": Menu_XY
      },
      "装备设置": {
        name: "装备设置",
        visible: () => {
          return $(".dialog-pack").is(':visible');
        },
        "items": Menu_Pack
      },
      "技能设置": {
        name: "技能设置",
        visible: () => {
          return $(".dialog-skills").is(':visible');
        },
        "items": Menu_Skill
      },
      "辅助": {
        name: "辅助",
        "items": {
          "sep1": "---------",
          "安排随从": {
            name: "安排随从",
            callback: (key, opt) => {
              game.backman.arrangeServants();
            }
          },
          "新手指南": {
            name: "新手指南",
            callback: (key, opt) => {
              game.backman.newbieGuide();
            }
          },
          "sep2": "---------",
          "代码显示": {
            name: "代码显示",
            visible: () => {
              return !_Injector__WEBPACK_IMPORTED_MODULE_1__["default"].getInstance().echo;
            },
            callback: () => {
              _Injector__WEBPACK_IMPORTED_MODULE_1__["default"].getInstance().echo = true;
            }
          },
          "代码关闭": {
            name: "代码关闭",
            visible: () => {
              return _Injector__WEBPACK_IMPORTED_MODULE_1__["default"].getInstance().echo;
            },
            callback: () => {
              _Injector__WEBPACK_IMPORTED_MODULE_1__["default"].getInstance().echo = false;
            }
          }
        }
      },
      "设置": {
        name: "设置",
        callback: function (key, opt) {
          $("span[command='setting']").click();
          $(".footer-item[for='custom']").click();
        }
      }
    }
  });
}

function addbutton_left(text, callback, shortkey) {
  let id = Object(_Util__WEBPACK_IMPORTED_MODULE_3__["createRandomId"])();
  let span = document.createElement("span");
  span.className = "zdy-item";
  span.id = id;
  span.innerText = text;
  $(".plugin_left").append(span);
  $("#" + id).on("click", callback);

  if (shortkey && key) {
    GM_addStyle(`#${id}:after{content:'(${shortkey})';"`);
    key.addKey(shortkey.charCodeAt(), callback);
  }
}

function addbutton(text, callback, shortkey) {
  let id = Object(_Util__WEBPACK_IMPORTED_MODULE_3__["createRandomId"])();
  let span = document.createElement("span");
  span.className = "zdy-item";
  span.id = id;
  span.innerText = text;
  $(".plugin_bottom").append(span);
  $("#" + id).on("click", callback);

  if (shortkey && key) {
    GM_addStyle(`#${id}:after{content:'(${shortkey})';"`);
    key.addKey(shortkey.charCodeAt(), callback);
  }
}

/***/ }),

/***/ "./src/module/Util.js":
/*!****************************!*\
  !*** ./src/module/Util.js ***!
  \****************************/
/*! exports provided: Ch2Num, getThisWeek, createRandomId, nameSplit, inArray */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ch2Num", function() { return Ch2Num; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getThisWeek", function() { return getThisWeek; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createRandomId", function() { return createRandomId; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "nameSplit", function() { return nameSplit; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "inArray", function() { return inArray; });
/* 工具模块 */


const Ch2Num = function (chnStr) {
  var chnNumChar = {
    零: 0,
    一: 1,
    二: 2,
    三: 3,
    四: 4,
    五: 5,
    六: 6,
    七: 7,
    八: 8,
    九: 9
  };
  var chnNameValue = {
    十: {
      value: 10,
      secUnit: false
    },
    百: {
      value: 100,
      secUnit: false
    },
    千: {
      value: 1000,
      secUnit: false
    },
    万: {
      value: 10000,
      secUnit: true
    },
    亿: {
      value: 100000000,
      secUnit: true
    }
  };
  var rtn = 0;
  var section = 0;
  var number = 0;
  var secUnit = false;
  var str = chnStr.split('');

  for (var i = 0; i < str.length; i++) {
    var num = chnNumChar[str[i]];

    if (typeof num !== 'undefined') {
      number = num;

      if (i === str.length - 1) {
        section += number;
      }
    } else {
      var unit = chnNameValue[str[i]].value;
      secUnit = chnNameValue[str[i]].secUnit;

      if (i == 0) {
        section += 10;
      }

      if (secUnit) {
        section = (section + number) * unit;
        rtn += section;
        section = 0;
      } else {
        section += number * unit;
      }

      number = 0;
    }
  }

  return rtn + section;
};
const getThisWeek = function () {
  let date = new Date();
  date.setHours(0, 0, 0, 0);
  date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7);
  var week1 = new Date(date.getFullYear(), 0, 4);
  return 1 + Math.round((date.getTime() - week1.getTime() - 3 + (week1.getDay() + 6) % 7) / 7);
};
const createRandomId = function () {
  return Math.random().toString(32).substr(2) + new Date().getTime();
};
const nameSplit = name => {
  let n = $.trim($('<body>' + name + '</body>').text());
  let i = n.lastIndexOf(' ');
  let j = n.lastIndexOf('<');
  let t = "";
  let s = "";

  if (i >= 0) {
    t = n.substr(0, i);

    if (j >= 0) {
      s = n.substr(j + 1, 2);
    }

    n = n.substr(i + 1).replace(/<.*>/g, '');
  }

  return {
    name: n,
    title: t,
    state: s
  };
};
const inArray = (val, arr) => {
  if (typeof val != "string") return false;

  for (let i = 0; i < arr.length; i++) {
    let item = arr[i];
    if (item.length < 2) continue;

    if (item[0] == "<") {
      if (item == val) return true;
    } else {
      if (val.indexOf(item) >= 0) return true;
    }
  }

  return false;
};

/***/ }),

/***/ "./src/module/backman.js":
/*!*******************************!*\
  !*** ./src/module/backman.js ***!
  \*******************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return Backman; });
/* harmony import */ var _commander__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./commander */ "./src/module/commander.js");


 // 杂工,处理零散的任务

/**
 * 安排随从
 * 清理包裹
 */

class Backman extends _commander__WEBPACK_IMPORTED_MODULE_0__["Commander"] {
  constructor() {
    super();
    this.name = "杂项功能";
  }
  /** 安排随从去采药 */


  arrangeServants() {
    let servants = [];
    this.start();
    this.setWork("安排随从");
    this.send("stopstate;team dismiss");
    this.goWait("住房-院子");
    this.waitItems(items => items.forEach(item => {
      if (item.id && item.p != 1) {
        this.send(`team with ${item.id}`);
        servants.push(item);
      }
    }));
    this.enterRoom("go northeast", "住房-小花园");
    this.waitItems(items => items.forEach(item => {
      if (item.id && item.p != 1) this.send(`dc ${item.id} diao;dc ${item.id} cai`);
    }));
    this.call(() => {
      servants.forEach(servant => this.send(`dc ${servant.id} diao;dc ${servant.id} cai`));
    });
    this.send("team dismiss");
    this.setWork(null);
    this.run();
  }
  /** 清理包裹 */


  packUp() {
    this.start();
    this.stopstate();
    super.deposite();
    super.sellall();
    super.decompose();
    this.run();
  }
  /** 新手引导 */


  newbieGuide() {
    this.start();
    let guideID = null;

    for (let [id, npc] of this.game.data.npcs) {
      if (npc.name == "指引者") {
        guideID = id;
        break;
      }
    }

    if (guideID == null) {
      this.print("新手引导需要在新手-训练室开始");
      return;
    }

    this.log("自动新手引导");
    this.send("setting auto_get 1;setting auto_work 1;setting show_command 1;setting item_firstme 1;setting keep_msg 1");
    this.send("setting off_move 1;setting auto_sortitem 1;setting no_message 1;setting show_hpnum 1");
    this.send(`select ${guideID};guid ${guideID}`);
    this.waitText("<hig>指引者对你说道:接下来,点击动作按钮,你将会看到一些操作,那是你所在房间或自己的可用命令。嗯,站着听课也累了,坐下来试试。</hig>");
    this.send("actions;zuo");
    this.waitText("指引者微笑着说到:有时候房间里有些隐藏物品可以操作,比如这里有个椅子,你可以坐在椅子上面。(在房间描述里点击【椅子】如果物品可用会显示描述及可用操作)");
    this.send("look yizi;zuo2 yizi");
    this.waitText("指引者说道:接下来教你怎么移动到别的房间:点击房间的出口方向就可以走出这个房间,来东面的训练室找我。");
    this.send("go east");
    this.waitText("指引者给了你一本<wht>拳脚快速入门</wht>。");
    this.find("<wht>拳脚快速入门</wht>", item => {
      this.send(`study ${item.id}`);
    });
    this.waitText("这本书上的内容对你来说太浅了。");
    this.send(`next ${guideID}`);
    this.waitText("杀掉一个木头人,带点战利品回来。");
    this.enterRoom("go south;go north;go south", "新手-训练室");
    this.waitKill("木头人");
    this.waitCombatEnd();
    this.enterRoom("go north", "新手-训练室");
    this.send(`next ${guideID}`);
    this.waitText("指引者给了你一本<wht>内功快速入门</wht>。");
    this.find("<wht>内功快速入门</wht>", item => {
      this.send(`study ${item.id}`);
    });
    this.waitText("这本书上的内容对你来说太浅了。");
    this.recover();
    this.send(`next ${guideID}`);
    this.waitType("cmds");
    this.send(`ask6 ${guideID}`);
    this.waitRoom("扬州城-有间客栈");
    this.goWait("扬州城-打铁铺");
    let tie = "";
    this.waitItem("铁匠铺老板 铁匠", item => {
      tie = item.id;
      this.send(`list ${item.id}`);
    });
    this.waitSellings(items => {
      items.forEach(item => {
        if (item.name == "<wht>铁镐</wht>") {
          this.send(`buy 1 ${item.id} from ${tie}`);
        }
      });
    });
    this.waitType("dialog", data => {
      this.send(`eq ${data.id}`);
    });
    this.delay(1);
    this.goWait("扬州城-矿山");
    this.send("wa");
    this.log("完成 - 新手引导", 3);
    this.run();
  }

}

/***/ }),

/***/ "./src/module/commander.js":
/*!*********************************!*\
  !*** ./src/module/commander.js ***!
  \*********************************/
/*! exports provided: Commander */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Commander", function() { return Commander; });
/* harmony import */ var _Game__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Game */ "./src/module/Game.js");
/* harmony import */ var _Plugin__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Plugin */ "./src/module/Plugin.js");
/* harmony import */ var _Injector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Injector */ "./src/module/Injector.js");
/* harmony import */ var _Util__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Util */ "./src/module/Util.js");
/* harmony import */ var _Const__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Const */ "./src/module/Const.js");
/* harmony import */ var _setting__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./setting */ "./src/module/setting.js");









const hasContent = function (data, contents) {
  var found = false;
  contents.forEach(content => {
    if (data.content && data.content.indexOf(content) >= 0) {
      found = true;
    }
  });
  return found;
};

class Commander {
  constructor() {
    this.game = _Game__WEBPACK_IMPORTED_MODULE_0__["default"].getInstance();
    this.inject = _Injector__WEBPACK_IMPORTED_MODULE_2__["default"].getInstance();

    this.print = (m, c) => Object(_Plugin__WEBPACK_IMPORTED_MODULE_1__["log"])(m, c, this.name);

    this.setState = _Plugin__WEBPACK_IMPORTED_MODULE_1__["setState"]; //内部数据

    this.commands = [];
    this.commandFlow = [];
    this.command = null;
    this.onStart = null;
    this.onComplete = null;
  }

  start() {
    this.reset();
    this.onStart && this.onStart();
  }
  /** 停止监听信息和计时器 */


  stop() {
    this.game.setWork(null);
    this.inject.setListener(null, "没有监听 - 来自停止");
    this.removeTimeoutTimer();
    this.removeIntevalTimer();
  }
  /** 重置命令列表和当前命令 */


  reset() {
    this.commands = [];
    this.commandFlow = [];
    this.command = null;
  } // 进入执行状态


  run() {
    if (!this.command) {
      this.next();
    }
  } // 取出并执行下一个指令


  next() {
    if (this.commands.length) {
      this.commandFlow = this.commands.concat(this.commandFlow);
      this.commands = [];
    }

    this.command = this.commandFlow.shift();
    if (this.command) this.command();
  }

  setWork(state) {
    this.call(() => {
      this.game.setWork(state);
    });
  }

  // 调用函数
  call(func) {
    this.commands.push(() => {
      func();
      this.next();
    });
  }

  send(text) {
    this.call(() => this.inject.send(text));
  }

  waylay(trigger) {
    this.call(() => this.inject.waylay(trigger));
  }

  stopstate() {
    this.send("stopstate");
  }

  go(place) {
    this.commands.push(() => {
      this.game.go(place);
      this.next();
    });
  }

  goCheck(place) {
    this.commands.push(() => {
      if (!this.game.at(place)) this.game.go(place);
      this.next();
    });
  }

  goWait(place) {
    this.go(place);
    this.waitRoom(place);
  } // 完成


  complete() {
    this.call(() => {
      this.onComplete && this.onComplete();
    });
  } // 日志


  log(text, color) {
    this.call(() => this.print(text, color));
  }

  waitUntil(trigger, callback, timeout, info) {
    this.commands.push(() => this._waitUntil(trigger, callback, timeout, info));
  }

  _waitUntil(trigger, callback, timeout, info, notNext) {
    let elpasedSeconds = 0;
    let seconds = timeout ? timeout.seconds : 0;
    this.removeIntevalTimer();
    this.intervalTimer = setInterval(() => {
      if (!trigger()) {
        elpasedSeconds += 0.1;
        this.setState(`等待[${info}] - ${elpasedSeconds.toFixed(1)}${seconds > 0 ? "/" + seconds : ""}秒`, 1);
        if (seconds <= 0) return; // 没有时间限制

        if (elpasedSeconds < seconds) return; // 没有超时
      } // 触发成功或者超时


      this.removeIntevalTimer(); // 等待超过20秒,设置为Free状态

      if (seconds > 0 && elpasedSeconds >= seconds) {
        // 超时
        this.setState(`等待[${info}] - 超时,继续执行`, 1);
        timeout.callback && timeout.callback();
      } else {
        this.setState(`等待[${info}] - 成功`, 1);
        callback && callback();
      }

      if (!notNext) this.next();
    }, 100);
  }

  waitFinish() {
    this.send("look 1");
    this.waitText("你要看什么?");
  }
  /** 在 wait 内部调用的 delay */


  _delay(seconds, callback) {
    this._waitUntil(() => false, null, {
      seconds,
      callback
    }, "延时", true);
  }

  delay(seconds) {
    this.waitUntil(() => {
      seconds -= 0.1;
      return seconds <= 0;
    }, null, {
      seconds
    }, "延时");
  }
  /**
   * 等待接收到服务器的数据
   * @param {function} trigger function(data) return false 继续等待; return true 调用callback
   * @param {function} callback function(data)  
   * @param {{seconds:number, callback:function}} timeout 超时后,调用callback,并执行下一个队列指令
   * @param {*} info 等待时的状态信息
   */


  wait(trigger, callback, timeout, info) {
    this.commands.push(() => {
      this._wait(trigger, callback, timeout, info);
    });
  } // 命令:等待服务器的数据,执行trigger(data):boolean,返回true, 结束等待。


  _wait(trigger, callback, timeout, info) {
    let listener = data => {
      if (trigger(data)) {
        this.inject.setListener(null, "没有监听 - 来自触发[" + info + "]成功");
        console.log("触发" + info + "成功");

        if (timeout) {
          this.removeTimeoutTimer();
        }

        callback && callback(data);
        this.next();
      }
    };

    if (timeout) {
      this.removeTimeoutTimer();
      this.timer = setTimeout(() => {
        this.inject.setListener(null, "没有监听 - 来自等待[" + info + "]超时");
        this.removeTimeoutTimer();
        timeout.callback && timeout.callback();
        this.next();
      }, timeout.seconds * 1000);
    }

    this.inject.setListener(listener, "正在等待[" + info + "]" + (timeout ? "/" + timeout.seconds + "秒" : ""));
  }

  waitType(type, callback) {
    this.wait(data => {
      return data.type == type;
    }, callback, null, "data.type==" + type);
  }

  waitText(text, callback) {
    this.wait(data => {
      return data.type == "text" && data.content && data.content.indexOf(text) >= 0;
    }, callback, null, text);
  }

  waitTexts(texts, callback) {
    this.wait(data => {
      if (data.type != "text") return false;
      if (!data.content) return false;

      for (const text of texts) {
        if (data.content.match(text)) return true;
      }

      return false;
    }, callback, null, texts[0]);
  }

  waitMatch(text, callback) {
    this.wait(data => {
      if (data.type != "text" || data.content == null) return false;
      let found = data.content.match(text);
      if (!found) return false;
      callback && callback(found);
      return true;
    }, null, null, "匹配" + text);
  }

  waitRoom(roomName, callback) {
    this.wait(data => {
      // error handling
      if (data.type == "text" && data.content == "你在绝壁前站定,深吸一口气,猛然跃起,可还差一大截呢,看来是轻功不够好。") {
        this.print("轻功太低,跳不上绝壁", 4);
        this.inject.send("go eastdown");
        return true;
      }

      return data.type == "room" && data.name.indexOf(roomName) >= 0;
    }, callback, null, "进入房间" + roomName);
  }
  /**
   * 等待进入房间
   * @param {*} command 发送命令来进入房间
   * @param {*} roomName 房间名
   * @param {Function} callback function(data)
   */


  enterRoom(command, roomName, callback) {
    this.send(command);
    this.waitRoom(roomName, callback);
  }
  /**
   * 进入并清光房间
   * @param {*} enter 
   * @param {*} room 
   * @param {*} corpseCount 
   */


  clearRoom(enter, room, corpseCount) {
    this.send(enter);
    this.waitRoom(room);
    this.wait(data => {
      if (data.type == "text" && data.content == "你要攻击谁?") return true; // 加入尸体数量检查

      if (data.type == "itemadd" && data.name != null && data.name.indexOf("的尸体") >= 0) {
        if (corpseCount) {
          corpseCount--;
        }

        return false;
      }

      if (data.type == "combat" && data.end == 1 && !corpseCount) return true;
      if (data.type != "items") return false;
      if (data.items == null) return false;
      let needFight = false;

      for (let item of data.items) {
        if (item.id != null && item.p != 1) {
          if (item.name.indexOf("的尸体") >= 0) continue;
          needFight = true;
          this.inject.send("kill " + item.id);
          this.print("叫杀" + item.name);
        }
      }

      return !needFight;
    }, null, null, "杀光光");
    this.waitFree();
  }
  /**
   * @param {string} itemName 
   * @param {Function} success 
   * @param {Function} timeout {callback: Function, seconds: Number}
   */


  waitItem(itemName, success, timeout, info) {
    this.wait(data => {
      if (data.type != "items") return false;
      if (data.items == null) return false;

      for (var item of data.items) {
        if (item.name != null && item.name.indexOf(itemName) >= 0) {
          success && success(item);
          return true;
        }
      }

      return false;
    }, null, timeout, info ? info : itemName);
  }
  /**
   * 等待直到收到items消息
   * @param {Function} callback function(items), items is an array
   */


  waitItems(callback) {
    this.wait(data => {
      if (data.type != "items") return false;
      if (data.items == null) return false;
      return true;
    }, data => {
      callback && callback(data.items);
    }, null, "房间物品列表");
  }

  waitEach(itemName, callback) {
    this.wait( // data: "{"type":"items","items":[{id:"f4gc2dcf0f7",name:"守门人"
    data => {
      if (data.type != "items") return false;
      if (data.items == null) return false;
      var found = false;

      for (var item of data.items) {
        if (item.name != null && item.name.indexOf(itemName) >= 0) {
          found = true;

          if (callback != null) {
            callback(item);
          }
        }
      }

      return found;
    }, null, null, "包含" + itemName + "的items消息");
  }

  waitSellings(callback) {
    this.wait(data => {
      if (data.type != "dialog" || data.dialog != "list" || data.selllist == null) return false;
      callback(data.selllist);
      return true;
    }, null, null, "出售列表消息");
  }

  waitCombatStart() {
    this.wait(data => data.type == "combat" && data.start == 1, null, null, "战斗开始");
  }

  waitCombatEnd(timeout) {
    this.wait(data => data.type == "combat" && data.end == 1, null, timeout, "退出战斗");
  }

  waitGlobalCooldown() {
    this.commands.push(() => {
      let seconds = 0;
      this.intervalTimer = setInterval(() => {
        if (this.game.fight.gcd) {
          seconds += 0.1;
          this.setState(`正在等待公共冷却结束] ` + seconds.toFixed(1) + "秒", 1);
          return;
        }

        this.removeIntevalTimer();
        this.next();
      }, 100);
      this.setState(`正在等待公共冷却结束`, 1);
    });
  }
  /**
   * 等待技能,知道技能cooldown结束
   */


  waitCooldown() {
    this.commands.push(() => {
      let seconds = 0;
      this.intervalTimer = setInterval(() => {
        if (this.game.fight.isCooldown()) {
          seconds += 0.1;
          this.setState(`正在等待技能冷却结束] ` + seconds.toFixed(1) + "秒", 1);
          return;
        }

        this.removeIntevalTimer();
        this.next();
      }, 100);
      this.setState(`正在等待技能冷却结束`, 1);
    });
  }

  removeIntevalTimer() {
    if (this.intervalTimer) {
      clearInterval(this.intervalTimer);
      delete this.intervalTimer;
    }
  }

  removeTimeoutTimer() {
    if (this.timer) {
      clearTimeout(this.timer);
      delete this.timer;
    }
  }

  waitFree() {
    this.waitUntil(() => this.game.fight.isFree(), null, {
      seconds: 30
    }, "自由状态");
  }

  waitUnweak() {
    this.waitUntil(() => this.game.fight.isWeak() ? false : true, null, {
      seconds: 60
    }, "非虚弱状态");
  }

  waitPack(callback, info) {
    this.send("pack");
    this.wait(data => data.type == "dialog" && data.dialog == "pack" && data.items != null, data => callback(data.items, data.eqs), {
      seconds: 60
    }, info ? info : "背包列表");
  }

  // 在背包中找物品
  find(itemName, callback, excludeEquips = false) {
    this.waitPack((items, eqs) => {
      var list = excludeEquips ? items : items.concat(eqs);

      for (var item of list) {
        // 第一轮优先考虑强化过的
        if (this.isItemMatch(item, `[☆★].*${itemName}`)) {
          callback(item);
          return true;
        }
      }

      for (var item of list) {
        if (this.isItemMatch(item, itemName)) {
          callback(item);
          return true;
        }
      }

      callback(null);
      return true;
    }, itemName);
  }

  waitKill(itemName) {
    this.waitEach(itemName, item => {
      this.inject.send("kill " + item.id);
    });
  }

  recover(fast = false) {
    if (fast) this.goCheck("扬州城-武庙");
    ;
    this.recoverMP();
    this.recoverHP();
  }

  recoverMP() {
    this.commands.push(() => {
      if (this.game.data.owner.mp > this.game.data.owner.max_mp / 2) {
        this.next();
        return;
      }

      this.inject.send("dazuo");

      let trigger = data => data.type == "sc" && data.id == this.game.data.id && data.mp > this.game.data.owner.max_mp / 2 || data.type == "text" && data.content.indexOf("你觉得你的经脉充盈,已经没有办法再增加内力了。") >= 0;

      let callback = data => this.inject.send("stopstate");

      let timeout = {
        seconds: 120,
        callback: () => this.inject.send("stopstate")
      };

      this._wait(trigger, callback, timeout, "打坐完成(120秒超时)");
    });
  }

  recoverHP() {
    this.commands.push(() => {
      if (this.game.data.owner.hp >= this.game.data.owner.max_hp) {
        this.next();
        return;
      }

      this.inject.send("liaoshang");

      let trigger = data => data.type == "text" && hasContent(data, ["你疗伤完毕,深深吸了口气,脸色看起来好了很多。", "你目前气血充沛,没有受到任何伤害。", "你内力枯竭无法治疗伤势。", "你内力不够,无法治疗自身伤势。"]);

      let timeout = {
        seconds: 120,
        callback: () => this.inject.send("stopstate")
      };

      this._wait(trigger, null, timeout, "疗伤完成(120秒超时)");
    });
  }

  equipSuit(name, idx) {
    this.call(() => this.game.equipSuit(name, idx));
  }

  setSkill(name) {
    this.call(() => this.game.setSkill(name));
  }

  isItemMatch(item, pattern) {
    return item && item.name && item.name.match(pattern);
  }

  isTextMatch(data, pattern) {
    return data && data.type == "text" && data.content && data.content.match(pattern);
  }

  buySwipe(count) {
    this.call(() => {
      //检查扫荡符
      let item = game.data.findPacksByName("<hic>扫荡符</hic>");

      if (item) {
        if (item.count < count) this.inject.send("shop 0 " + (count - item.count));
      } else {
        this.inject.send("shop 0 " + count);
      }
    });
  }

  containStar(itemName) {
    return itemName.indexOf("☆") >= 0 || itemName.indexOf("★") >= 0;
  }

  decomposable(itemName) {
    if (game.decomposings.indexOf(itemName) >= 0) return true;
    if (this.combat.autoDecompose.includes(itemName)) return true;
    let patterns = [/<hi[gc]>曙光.*/, /<hi[gc]>真武.*/, /<hi[gc]>混天.*/, /<hi[gc]>君子.*/, /<hi[gc]>鲲鹏.*/, /<hi[gc]>罗汉.*/];

    for (const pattern of patterns) {
      if (itemName.match(pattern)) return true;
    }

    return false;
  } // 分解


  decompose() {
    let drop_list = _setting__WEBPACK_IMPORTED_MODULE_5__["default"].drop_list == "" ? [] : _setting__WEBPACK_IMPORTED_MODULE_5__["default"].drop_list.split(",");
    let fenjie_list = _setting__WEBPACK_IMPORTED_MODULE_5__["default"].fenjie_list == "" ? [] : _setting__WEBPACK_IMPORTED_MODULE_5__["default"].fenjie_list.split(",");
    this.send("pack");
    this.wait(data => {
      if (data.type != "dialog") return false;
      if (data.dialog != "pack") return false;
      if (!data.items) return false;

      for (const item of data.items) {
        if (item.name == null) continue; //丢弃

        if (drop_list.length && Object(_Util__WEBPACK_IMPORTED_MODULE_3__["inArray"])(item.name, drop_list)) {
          this.inject.send("drop " + item.count + " " + item.id);
          continue;
        } //分解,2级强化以上不分解


        if (fenjie_list.length && item.can_eq && Object(_Util__WEBPACK_IMPORTED_MODULE_3__["inArray"])(item.name, fenjie_list) && !this.containStar(item.name)) {
          this.inject.send("fenjie " + item.id);
          continue;
        }
      }

      return true;
    }, null, {
      seconds: 20
    }, "丢弃和分解");
    this.waitFinish();
  }
  /** 到杂货铺卖东西 */


  sellall() {
    this.call(() => {
      game.go("扬州城-杂货铺");
      this.inject.send("sell all");
    });
    this.waitFinish();
  }
  /** 合并背包到仓库 */


  deposite() {
    let stores = [];
    let depos_items = [];
    let store_list = _setting__WEBPACK_IMPORTED_MODULE_5__["default"].store_list == "" ? [] : _setting__WEBPACK_IMPORTED_MODULE_5__["default"].store_list.split(",");
    this.go("扬州城-钱庄");
    this.send("store");
    this.wait(data => {
      if (data.type != "dialog") return false;
      if (data.dialog != "list") return false;
      if (!data.stores) return false; //去重

      for (let i = 0; i < data.stores.length; i++) {
        let s = null;

        for (let j = 0; j < stores.length; j++) {
          if (stores[j].name == data.stores[i].name) {
            s = stores[j];
            break;
          }
        }

        if (s != null) {
          s.count += data.stores[i].count;
        } else {
          stores.push(data.stores[i]);
        }
      }

      return true;
    }, null, null, "仓库列表");
    this.call(() => {
      for (let item of game.data.packs) {
        if (Object(_Util__WEBPACK_IMPORTED_MODULE_3__["inArray"])(item.name, _Const__WEBPACK_IMPORTED_MODULE_4__["default"].store_list) || Object(_Util__WEBPACK_IMPORTED_MODULE_3__["inArray"])(item.name, store_list)) if (item.can_eq) {
          let store = null;

          for (let j = 0; j < stores.length; j++) {
            if (stores[j].name == item.name) {
              store = stores[j];
              break;
            }
          }

          if (store != null) {
            if (store.count < _setting__WEBPACK_IMPORTED_MODULE_5__["default"].packup_max) {
              store.count += item.count;
              this.inject.send("store " + item.count + " " + item.id);
            }
          } else {
            stores.push(item);
            this.inject.send("store " + item.count + " " + item.id);
          }
        } else {
          this.inject.send("store " + item.count + " " + item.id);
        }
      }
    });
    this.waitFinish();
  }
  /** 清理包裹 */


  packUp(packNeed = 0) {
    if (packNeed) {
      this.send("pack");
      this.wait(data => {
        if (data.type == "dialog" && data.dialog == "pack" && data.items) {
          if (data.items.length > data.max_item_count - packNeed) {
            this.deposite();
            this.sellall();
            this.decompose();
          }

          return true;
        }

        return false;
      }, null, null, "检查背包");
    } else {
      this.deposite();
      this.sellall();
      this.decompose();
    }
  }

}

/***/ }),

/***/ "./src/module/daily.js":
/*!*****************************!*\
  !*** ./src/module/daily.js ***!
  \*****************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return Daily; });
/* harmony import */ var _commander__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./commander */ "./src/module/commander.js");
/* harmony import */ var _Util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Util */ "./src/module/Util.js");
/* harmony import */ var _setting__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./setting */ "./src/module/setting.js");
/* harmony import */ var _Const__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Const */ "./src/module/Const.js");
/* harmony import */ var _dungeon__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./dungeon */ "./src/module/dungeon.js");






 // 日常:武道,衙门,师门,副本,签到,请安,吃药

class Daily {
  constructor() {
    this.tasks = [];
    this.idx = 0;
    this.current = null;
    this.onStart = null;
    this.allSwipe = false;
  } // 执行每日任务


  start(tasks) {
    this.allSwipe = false;
    this.onStart && this.onStart();

    if (tasks) {
      this.tasks = tasks.split(",");
    } else {
      this.tasks = ["武道", "衙门", "师门", "副本", "签到"];
    }

    this.idx = 0;
    this.setTask();
  }

  swipe(tasks) {
    this.allSwipe = true;
    this.onStart && this.onStart();

    if (tasks) {
      this.tasks = tasks.split(",");
    } else {
      this.tasks = ["武道", "衙门", "副本", "师门", "签到"];
    }

    this.idx = 0;
    this.setTask();
  }

  stop() {
    if (this.current) {
      this.current.stop();
      this.current.reset();
      this.current = null;
    }
  }

  setTask() {
    this.stop();

    if (this.idx >= this.tasks.length) {
      this.onComplete && this.onComplete();
      return;
    }

    switch (this.tasks[this.idx++]) {
      case "武道":
        this.current = new Tower();
        break;

      case "衙门":
        this.current = new Yamen();
        break;

      case "师门":
        this.current = new ShiMen();
        break;

      case "副本":
        this.current = new _dungeon__WEBPACK_IMPORTED_MODULE_4__["default"]();
        break;

      case "签到":
        this.current = new signIn();
        break;

      case "运镖":
        this.current = new YunBiao();
        break;

      default:
        this.setTask();
        return;
    }

    this.current.onComplete = () => {
      this.setTask();
    };

    if (this.allSwipe && this.current["swipe"]) this.current.swipe();else this.current.start();
  }

} // 武道塔
// 策略,直接重置武道塔开始打,前期直接打,中期回血打,后期等待CD打

class Tower extends _commander__WEBPACK_IMPORTED_MODULE_0__["Commander"] {
  constructor() {
    super();
    this.name = "自动武道";
    this.ChallengeName = "武道塔守护者";
    let r = String(_setting__WEBPACK_IMPORTED_MODULE_2__["default"].wudao).match(/^(\d+),(\d+),(\d+)$/);

    if (r) {
      this.levelRecover = parseInt(r[1]);
      this.levelWaitCD = parseInt(r[2]);
      this.levelStop = parseInt(r[3]);
      if (this.levelStop > 99) this.levelStop = 99;
    } else {
      this.print("武道设置参数错误,使用默认参数0,50,99");
      {
        this.levelRecover = 0;
        this.levelWaitCD = 50;
        this.levelStop = 99;
      }
    }

    this.eqSuit = _setting__WEBPACK_IMPORTED_MODULE_2__["default"].local.eq.hasOwnProperty("武道") ? "武道" : "战斗";
    this.skillSuit = _setting__WEBPACK_IMPORTED_MODULE_2__["default"].local.skill.hasOwnProperty("武道") ? "武道" : "战斗";
  }

  start() {
    super.start();
    this.stopstate();
    this.fetchTask();
    this.run();
  }

  fetchTask() {
    this.waylay(data => data.type == "dialog" && data.dialog == "tasks");
    this.send("tasks");
    this.wait(data => data.type == "dialog" && data.dialog == "tasks", data => {
      data.items.forEach(item => {
        if (item.id != "signin") return;
        let found = item.desc.match(/武道塔(.*)重置,进度(\d+)\/(\d+)/);

        if (found) {
          let needReset = found[1] == "可以";
          this.lv = needReset ? 1 : parseInt(found[2]);

          if (this.lv < 99) {
            this.setSkill(this.skillSuit);
            this.equipSuit(this.eqSuit);
            if (game.data.map == 'wudao') this.send("go up;go out");else this.goWait("武道塔-入口");

            if (needReset) {
              this.waitItem("守门人", item => this.send("ask1 " + item.id + ";ask1 " + item.id));
              this.waitText("你今天已经重置过了");
            }

            this.climb(true);
          } else this.complete();
        } else {
          this.fetchTask();
          return;
        }
      });
    }, null, "任务数据");
  } // 向上爬


  climb(enter) {
    if (enter) this.send("go enter");else this.send("go up");
    this.waitRoom("武道塔", data => {
      //检查当前武道塔层数            
      this.setWork(data.name);
      this.print(data.name, 2);
      let r = data.name.match(/^武道塔-第(.+)层$/);
      this.lv = r ? Object(_Util__WEBPACK_IMPORTED_MODULE_1__["Ch2Num"])(r[1]) : 0;
      if (this.lv > this.levelStop) this.complete();
    });
    this.waitItem("武道塔守护者", item => {
      this.waitGlobalCooldown();
      this.equipSuit(this.eqSuit, 0);
      if (this.lv > this.levelRecover) this.recover();
      if (this.lv > this.levelWaitCD) this.waitCooldown();
      this.Challenge(item.id);
    });
  }

  Challenge(id) {
    this.waitGlobalCooldown();
    this.send("kill " + id);
    this.wait(data => {
      if (data.type == "die" || data.type == "text" && data.content.indexOf("你的挑战失败了") >= 0) {
        this.waitFree();
        this.complete();
        return true;
      }

      if (data.type == "combat" && data.end == 1) {
        // 昏迷状态中结束战斗,说明失败了
        if (this.game.data.owner.buffs.has["faint"]) {
          this.complete();
          return true;
        }

        this.waitFree();
        this.climb();
        return true;
      }

      return false;
    }, null, null, "击杀武道塔守护者结果");
  }
  /** 扫荡,然后再往上打,最后重置,然后再扫荡,结束 */


  swipe() {
    super.start();
    this.stopstate();
    this.goWait("武道塔-入口");
    this.waitItem("守门人", item => {
      this.menId = item.id;
      this.send("ask2 " + item.id);
    });
    this.wait(data => {
      if (data.type != "text") return false;

      if (data.content == "你目前的进度已经是你记录的最高层了,用不着快速挑战了。" || data.content.match(/^你目前记录的最高层数小于.*层,无法快速挑战。/)) {
        this.complete();
        return true;
      }

      let found = data.content.match(/^你当前的进度是.*层,你最高到达.*层,快速挑战需要(.*)张扫荡符。/);
      if (!found) return false;
      this.buySwipe(found[1]);
      this.send("ask3 " + this.menId);
      this.waitTexts([/^挑战完成。/, /^你目前的进度和最高记录差距不到.*层,不用快速挑战。/]);
      this.complete();
      return true;
    });
    this.run();
  }

} // 衙门


class Yamen extends _commander__WEBPACK_IMPORTED_MODULE_0__["Commander"] {
  constructor() {
    super();
    this.name = "自动追捕";
    this.convict = null; // 逃犯

    this.place = null; // 出没地点

    this.path = null; // 寻怪路径

    this.isJourney = false; //全图搜索

    this.MAX_RETRY = 2;
    this.retry = 0;
    this.idx = 0; //读取配置

    let r = String(_setting__WEBPACK_IMPORTED_MODULE_2__["default"].yamen).match(/^(\d+),(\d+),(\d+)$/);

    if (r) {
      this.levelRecover = parseInt(r[1]);
      this.levelWaitCD = parseInt(r[2]);
      this.levelRestart = parseInt(r[3]);
      this.print("追捕上限:" + this.levelRestart);
    } else {
      this.levelRecover = 20;
      this.levelWaitCD = 22;
      this.levelRestart = 22;
      this.print("参数错误,使用默认参数20,22,22");
    }

    this.eqSuit = _setting__WEBPACK_IMPORTED_MODULE_2__["default"].local.eq.hasOwnProperty("衙门") ? "衙门" : "战斗";
    this.skillSuit = _setting__WEBPACK_IMPORTED_MODULE_2__["default"].local.skill.hasOwnProperty("衙门") ? "衙门" : "战斗";
  }

  start() {
    //设置为扫荡
    if (_setting__WEBPACK_IMPORTED_MODULE_2__["default"].zb == 1) {
      this.swipe();
      return;
    }

    super.start(); //战斗失败复活

    this.game.fight.autoRelive(true, () => {
      this.retry++;
      super.stop();
      this.reset();
      this.wait(data => {
        return data.type == "die" && data.relive;
      }, null, null, "等待复活");

      if (this.retry > this.MAX_RETRY) {
        this.log(`复活成功,请手动扫荡或者放弃任务`, 1);
        this.recover();
        this.complete();
        this.run();
      } else {
        this.log(`复活成功,重试:${this.retry}/${this.MAX_RETRY}`, 1);
        this.recover();
        this.waitCooldown();
        this.waitUnweak();
        this.search();
        this.run();
      }
    });
    this.log("开始追捕");
    this.stopstate();
    this.retry = 0;
    this.recover(true);
    this.setSkill(this.skillSuit);
    this.equipSuit(this.eqSuit);
    this.fetchTask();
    this.run();
  }

  stop() {
    this.game.fight.autoRelive(false);
    super.stop();
  }

  complete() {
    this.game.fight.autoRelive(false);
    super.complete();
  }

  acceptTask() {
    if (this.level > this.levelWaitCD) this.waitCooldown();
    this.goWait("扬州城-衙门正厅");
    this.waitItem("扬州知府 程药发", item => {
      this.send("ask1 " + item.id);
    });
    this.wait(data => {
      if (data.type != "text") return false;

      if (data.content == "程药发对你说道:你不是在追捕吗? 如果你不想干,就放弃吧。") {
        this.fetchTask();
        return true;
      }

      if (data.content == "程药发对你说道:最近没有在逃的逃犯了,你先休息下吧。" || data.content == "程药发对你说道:这位小兄弟,你还是多历练一番再来吧。") {
        this.print("完成 - 追捕", 3);
        this.complete();
        return true;
      }

      if (data.content.match(/^程药发对你说道:嗯,你的帮派正在进攻.*,你等一会再来吧。/)) {
        this.print("帮派战期间 - 等待", 1);
        this.delay(5);
        this.getTask();
        return true;
      }

      var found = data.content.match(/^程药发对你说道:(.+)作恶多端,还请.+为民除害,听说他最近在(.+)出现过。/);
      if (!found) return false;
      this.convict = found[1];
      this.place = found[2];
      this.setWork("追捕" + this.convict);
      this.search();
      return true;
    }, null, null, "找程药发接受任务");
  }

  fetchTask() {
    this.waylay(data => data.type == "dialog" && data.dialog == "tasks");
    this.send("tasks");
    this.wait(data => data.type == "dialog" && data.dialog == "tasks", data => {
      data.items.forEach(item => {
        if (item.id != "yamen") return;
        let found = item.desc.match(/^扬州知府委托你追杀逃犯:(.*)目前完成(\d+)\/20个,共连续完成(\d+)个。$/);

        if (found) {
          this.idx = parseInt(found[2]);
          this.level = parseInt(found[3]);

          if (this.idx >= 20) {
            this.complete();
            return;
          }

          if (this.level > this.levelRestart) {
            this.abandon();
            return;
          }
        } else {
          this.fetchTask();
          return;
        }

        found = found[1].match(/^(.+),据说最近在(.+)出现过,你还有.+去寻找他,$/);

        if (!found) {
          this.acceptTask();
        } else {
          this.convict = found[1];
          this.place = found[2];
          this.setWork(`[${this.idx}轮]追捕${this.convict}`);
          this.search();
        }
      });
    }, null, "任务数据");
  } // 放弃任务


  abandon() {
    this.goWait("扬州城-衙门正厅");
    this.waitItem("扬州知府 程药发", item => {
      this.send("ask2 " + item.id);
      this.send("ask1 " + item.id);
      this.fetchTask();
    });
  }

  getJourney() {
    let found = this.place.match("(.*)-.*");

    if (found) {
      let family = found[1];
      if (family == "峨嵋派") family = "峨眉派";
      let journey = _Const__WEBPACK_IMPORTED_MODULE_3__["default"].families[family] ? _Const__WEBPACK_IMPORTED_MODULE_3__["default"].families[family].journey : null;

      if (journey) {
        return journey.split(";");
      }
    }

    return null;
  }

  search() {
    this.call(() => this.isJourney = false);
    this.log("追捕:" + this.convict + "   地点:" + this.place, 2);
    this.path = _Const__WEBPACK_IMPORTED_MODULE_3__["default"].path[this.place];
    let path2 = _Const__WEBPACK_IMPORTED_MODULE_3__["default"].path2[this.place];
    if (this.path && path2) this.path += ";" + path2;
    if (this.path) this.path = this.path.split(";");
    this.send(this.path.shift());
    this.wait(data => {
      if (this.isTextMatch(data, /^<hiy>慢慢的你又恢复了知觉.../)) {
        // 有概率少林被狮子吼
        this.search();
        return true;
      }

      if (this.isTextMatch(data, /^你在绝壁前站定,深吸一口气,猛然跃起,可还差一大截呢,看来是轻功不够好。/)) {
        // 华山绝顶,失败,重置任务
        this.abandon();
        return true;
      }

      if (data.type != "items" || data.items == null) return false;

      for (const item of data.items) {
        if (!item.name) continue;

        if (item.name.indexOf(this.convict) >= 0) {
          // 设置当前房间,死亡后会直接回到该房间
          this.place = this.game.data.room_name;
          this.print(`猎物在[${this.place}]`, 1);
          this.kill(item);
          return true;
        }
      }

      ;

      if (!this.path || this.path.length == 0) {
        if (!this.isJourney) {
          this.isJourney = true;
          this.path = this.getJourney();

          if (this.path) {
            this.print("猎物不在[" + this.place + "], 进行全图搜索", 1);
            let cmd = this.path.shift();
            this.inject.send(cmd);
            return false;
          }
        }

        this.print("全图搜索失败,再次搜索", 4);
        this.search();
      } else {
        let cmd = this.path.shift();

        if (cmd == "break bi") {
          this.inject.send(cmd);
          cmd = this.path.shift();
        }

        if (cmd == "jumpup") {// 需要轻功800,
        }

        this.inject.send(cmd);
        return false;
      }

      return true;
    }, null, null, "猎物" + this.convict);
  } // 击杀猎物


  kill(item) {
    this.print("击杀猎物 " + item.name);
    this.equipSuit(this.eqSuit, 0);
    this.send("kill " + item.id);
    this.wait(data => {
      if (data.type == "text" && data.content == "你要攻击谁?") {
        this.search();
        return true;
      }

      if (data.type == "text" && data.content.indexOf("你的追捕任务失败了。") >= 0) {
        this.print(`${data.content},任务超时。`);
        this.waitFree();
        this.recover();
        this.complete();
        return true;
      }

      if (data.type == "itemadd" && data.name && data.name.indexOf(this.convict + "的尸体") >= 0) {
        this.wait(data => {
          if (data.type == "text" && data.content.match(/^<hig>你的追捕任务完成了,目前完成.*个,已连续完成.*个。/)) {
            return true;
          }

          return false;
        });
        this.retry = 0;
        this.waitFree();

        if (this.level > this.levelRecover) {
          this.goWait("扬州城-武庙");
          this.recover();
        }

        this.fetchTask();
        return true;
      }

      return false;
    }, null, null, "你要攻击谁,死亡," + this.convict + "的尸体");
  }
  /** 快速扫荡 */


  swipe() {
    super.start();
    this.stopstate();
    this.goWait("扬州城-衙门正厅");
    this.buySwipe(20);
    this.waitItem("扬州知府 程药发", item => {
      this.npc = item.id;
      this.send("ask3 " + item.id);
    });
    this.wait(data => {
      if (data.type != "text") return false;

      if (data.content.match(/^你的追捕连续次数大于你的最大连续次数\(.*\)无法快速完成。/)) {
        this.inject.send("ask1 " + this.npc);
        this.inject.send("ask2 " + this.npc);
        this.inject.send("ask3 " + this.npc);
        delete this.npc;
        return false;
      }

      if (data.content == "程药发对你说道:这位小兄弟,你还是多历练一番再来吧。" || data.content == "你的追捕任务已经完成了。" || data.content.match(/^<hig>你的追捕任务完成了,目前完成20\/20个,已连续完成.*个。<\/hig>/)) {
        this.print(data.content);
        this.complete();
        return true;
      }

      return false;
    }, null, null, "等待扫荡完成");
    this.run();
  }

}
/**
 * 师门
 */


class ShiMen extends _commander__WEBPACK_IMPORTED_MODULE_0__["Commander"] {
  constructor() {
    super();
    this.name = "自动师门";
    this.servants = [];
    this.issuer = null;
    this.round = 0;
    this.type = _setting__WEBPACK_IMPORTED_MODULE_2__["default"].sm; // temp variables

    this.seller = null;
    this.buying = null;
  }

  start() {
    super.start();
    this.issuer = _Const__WEBPACK_IMPORTED_MODULE_3__["default"].families[this.game.data.family].issuer;
    if (this.type == 2) this.setWork("师门-补牌");else if (this.type == 1) this.setWork("师门-放弃");else this.setWork("师门");
    this.fetchTask();
    this.run();
  }

  fetchTask() {
    this.waylay(data => data.type == "dialog" && data.dialog == "tasks");
    this.send("tasks");
    this.wait(data => {
      if (data.type != "dialog") return false;
      if (data.dialog != "tasks") return false;

      for (const item of data.items) {
        if (item.id != null && item.id == "sm") {
          var found = item.desc.match("目前完成([^%]+)/20个,共连续完成([^%]+)个。");
          this.count = parseInt(found[1]);
          this.round = parseInt(found[2]);

          if (this.count >= 20) {
            this.print("师门任务已完成", 3);
            this.complete();
          } else {
            this.cache();
          }
        }
      }

      return true;
    }, null, null, "师门任务数据");
  } // 缓存仓库和随从


  cache() {
    this.servants = [];
    this.stopstate();
    this.packUp();
    this.goWait("扬州城-大门");
    this.send("go enter");
    this.wait(data => {
      if (data.type == "text" && data.content.indexOf("这里是私人住宅区,你不能进去") >= 0) {
        this.fetchIssuer();
        return true;
      }

      if (data.type != "room") return false;

      if (data.name == "住房-院子") {
        this.inject.send("go northeast");
        return false;
      }

      this.waitItems(items => {
        this.cacheServant(items);
      });
      return true;
    }, null, null, "进入卧室,小花园或者不让进去");
  }

  cacheServant(items) {
    const item = items.shift();

    if (!item) {
      this.fetchIssuer();
    } else if (item.p) {
      this.cacheServant(items);
    } else {
      this.send("pack " + item.id);
      this.wait(data => {
        if (data.type != "dialog" || data.dialog != "pack2" || data.items == null) return false;
        return true;
      }, data => {
        if (item.name.indexOf("钓鱼") > -1) data.work = "diao";
        if (item.name.indexOf("采药") > -1) data.work = "cai";
        this.servants.push(data);
        this.cacheServant(items);
      }, null, "随从背包" + item.name);
    }
  }

  fetchIssuer() {
    this.go(this.issuer.place);
    this.waitItem(this.issuer.npc, item => {
      this.issuer.id = item.id;
      this.acceptTask();
    }, {
      callback: () => {
        this.print("师门NPC被杀", 4);
        this.complete();
      },
      seconds: 10
    }, this.issuer.npc);
  }

  acceptTask() {
    this.send("task sm " + this.issuer.id);
    this.send("task sm " + this.issuer.id);
    this.wait(data => {
      if (data.type != "text") return false;

      if (data.content.indexOf("辛苦了, 你先去休息") >= 0) {
        this.print("完成 - 20次师门任务", 3);
        this.complete();
        return true;
      }

      let found = data.content.match("对你说道:我要的是([^%]+),你要是找不到就换别的吧。");
      if (!found) return false;
      let itemName = found[1];
      this.print("需要" + itemName);
      this.seek(itemName);
      return true;
    }, null, null, "接受师门任务");
  }

  itemInServants(itemName) {
    for (const servant of this.servants) {
      for (const item of servant.items) {
        if (item.name == itemName) {
          return {
            servant,
            item
          };
        }
      }
    }
  }

  seek(itemName) {
    this.call(() => {
      // 先找背包
      let item = this.game.data.findPacksByName(itemName);

      if (item && item.count) {
        this.submit(item);
        return;
      } //购买清单 


      let shop = this.canBuy(itemName);

      if (shop) {
        this.buy(itemName, shop);
        return;
      } // 其次仓库


      item = this.game.data.findPacksByName(itemName);
      ;

      if (item && itemInStore.count > 0) {
        this.takeFromStore(itemInStore);
        return;
      } //再次随从


      let itemInServants = this.itemInServants(itemName);

      if (itemInServants && itemInServants.item.count > 0) {
        this.takeFromServant(itemInServants);
        return;
      } //


      if (this.type == 1) {
        this.abandon();
      } else if (this.type == 2) {
        //补牌
        this.useToken();
      } else {
        this.log("缺少材料" + itemName);
        this.complete();
      }
    });
  }

  useToken() {
    this.call(() => {
      let itemName;
      if (this.round < 30) itemName = "<hig>师门令牌</hig>";else if (this.round < 50) itemName = "<hic>师门令牌</hic>";else if (this.round < 70) itemName = "<hiy>师门令牌</hiy>";else if (this.round < 90) itemName = "<HIZ>师门令牌</HIZ>";else itemName = "<hioo>师门令牌</hio>"; // 先找背包

      let item = this.game.data.findPacksByName(itemName);

      if (item && item.count) {
        this.log("自动提交" + item.name);
        this.submit(item);
      } else {
        this.log("背包未发现师门令牌,结束师门");
        this.complete();
      }
    });
  }

  canBuy(itemName) {
    for (const shop of _Const__WEBPACK_IMPORTED_MODULE_3__["default"].shop) {
      for (let j = 0; j < shop.items.length; j++) {
        if (shop.items[j] == itemName) {
          return shop;
        }
      }
    }
  }

  takeFromStore(item) {
    this.go("扬州城-钱庄");
    this.send("qu 1 " + item.id);
    this.wait(data => {
      if (data.type == "dialog" && data.dialog == "list" && data.store < 0) {
        this.log("仓库取出" + item.name);
        this.submit(data);
        return true;
      }

      return false;
    }, null, null, "等待从仓库取出物品成功");
  }

  takeFromServant(itemInServant) {
    let servant = itemInServant.servant;
    let item = itemInServant.item;
    this.go("住房-小花园");
    this.send("dc " + servant.id + " stopstate");
    this.send("dc " + servant.id + " give " + this.game.data.id + " 1 " + item.id);
    if (servant.work) this.send("dc " + servant.id + " " + servant.work);
    this.wait(data => {
      if (data.type != "dialog" || data.dialog != "pack") return false;
      if (data.name != item.name) return false;
      item.count--;
      this.log("随从" + servant.name + "给你一个" + item.name);
      this.submit(data);
      return true;
    }, null, null, "随从给" + item.name + "成果");
  }

  buy(itemName, shop) {
    this.go(shop.place);
    this.waitItem(shop.npc, npc => {
      this.seller = npc;
      this.send("list " + this.seller.id);
    });
    this.waitSellings(list => {
      for (const item of list) {
        if (item.name == itemName) this.send("buy 1 " + item.id + " from " + this.seller.id);
      }
    });
    this.waitBuying(itemName);
  }

  waitBuying(itemName) {
    this.wait(data => {
      if (data.type == "text" && data.content == "你要从哪买东西?") {// Error!
      }

      if (data.type != "dialog" || data.dialog != "pack") return false;
      this.submit(data);
      return true;
    }, null, null, "购买" + itemName + "成功");
  }

  abandon(itemName) {
    this.send("task sm " + this.issuer.id + " giveup");
    this.round = 0;
    this.acceptTask();
  }

  submit(item) {
    this.call(() => {
      if (!this.game.at(this.issuer.place)) this.game.go(this.issuer.place);
      this.send("task sm " + this.issuer.id + " give " + item.id);
    });
    this.waitMatch("你的师门任务完成了,目前完成([^%]+)/20个,连续完成([^%]+)个", found => {
      this.count = parseInt(found[1]);
      this.round = parseInt(found[2]);
      this.print(found[0]);
      this.acceptTask();
    });
  }

}
/**
 * 签到
 */


class signIn extends _commander__WEBPACK_IMPORTED_MODULE_0__["Commander"] {
  constructor() {
    super();
    this.name = "自动签到";
    this.canGreet = false;
  }

  start() {
    super.start();
    this.setWork("签到");
    this.stopstate();
    this.fetchTask();
    this.run();
  }

  fetchTask() {
    this.waylay(data => data.type == "dialog" && data.dialog == "tasks");
    this.send("tasks");
    this.wait(data => {
      if (data.type != "dialog") return false;
      if (data.dialog != "tasks") return false;

      for (const item of data.items) {
        if (item.id != null && item.state == 2) {
          //领取奖励
          this.waylay(data => data.type == "dialog" && data.dialog == "tasks");
          this.send("taskover " + item.id);
          this.wait(data => {
            return data.type == "dialog" && data.dialog == "tasks";
          }, null, null, "等待领取任务奖励");
        } //请安检查


        if (item.id != null && item.id == "signin") {
          this.canGreet = item.desc.indexOf("已经首席请安") == -1;
        }
      }

      if (this.canGreet && this.game.data.family != "无门无派") this.greet();else this.checkEnergy();
      return true;
    }, null, null, "师门任务数据");
  }

  greet() {
    let senior = _Const__WEBPACK_IMPORTED_MODULE_3__["default"].families[this.game.data.family].senior;
    this.stopstate();

    if (senior) {
      this.go(senior.place);
      this.waitItem(senior.npc, item => {
        this.send("ask2 " + item.id);
        this.checkEnergy();
      }, {
        callback: () => {
          this.print("首席被杀,请安失败", 4);
          this.checkEnergy();
        },
        seconds: 10
      }, senior.npc);
    } else {
      this.checkEnergy();
    }
  }

  checkEnergy() {
    this.call(() => {
      //检查绿色养精丹,是否需要购买
      let item = game.data.findPacksByName("<hig>养精丹</hig>");
      let cnt = 10;
      if (item) cnt = item.count > 10 ? 0 : 10 - item.count;

      if (cnt) {
        this.packUp(1);
        this.buyEnergy(cnt);
      }

      this.waitFinish();
      this.eatEnergy();
    });
  }

  buyEnergy(count) {
    this.go("扬州城-药铺");
    let pingID = null;
    this.waitItem("药铺老板 平一指", item => {
      pingID = item.id;
      this.send("list " + item.id);
    });
    this.wait(data => {
      if (data.type == "text" && data.content == "你没有那么多的钱。") {
        return true;
      }

      if (data.type == "dialog" && data.dialog == "pack" && data.name == "<hig>养精丹</hig>") {
        return true;
      }

      if (data.type == "dialog" && data.dialog == "list" && data.selllist) {
        for (var item of data.selllist) {
          if (item.name == "<hig>养精丹</hig>") {
            this.inject.send(`buy ${count} ${item.id} from ${pingID}`);
            break;
          }
        }
      }

      return false;
    }, null, null, "销售列表");
  }

  eatEnergy() {
    this.call(() => {
      this.energy = [];

      for (const item of this.game.data.packs) {
        if (item.name.indexOf("养精丹") > -1) this.energy.push({
          id: item.id,
          count: item.count
        });
      }

      if (this.energy.length) {
        let item = this.energy.shift();
        this.inject.send("use " + item.id);
        ;
        this.wait(data => {
          if (data.type == "text" && data.content.match("你增加了[^%]+精力")) {
            if (item.count == 1) {
              item = this.energy.shift();
              if (item) this.inject.send("use " + item.id);else {
                this.eatOther();
                return true;
              }
            } else {
              item.count--;
              this.inject.send("use " + item.id);
            }
          }

          if (data.type == "text" && data.content == "<yel>你已经吃太多养精丹了,要注意身体。</yel>") {
            item = this.energy.shift();
            if (item) this.inject.send("use " + item.id);else {
              this.eatOther();
              return true;
            }
          }

          return false;
        }, null, null, "养精丹");
      }
    });
  }

  eatOther() {
    let other = ["培元丹", "潜灵丹", "潜灵果", "朱果"];
    this.call(() => {
      for (const item of this.game.data.packs) {
        for (let i = 0; i < other.length; i++) if (item.name.indexOf(other[i]) > -1) {
          for (let j = 0; j < item.count; j++) this.inject.send("use " + item.id);
        }

        this.energy.push({
          id: item.id,
          count: item.count
        });
      }
    });
    this.waitFinish();
    this.complete();
  }

} // 运镖


class YunBiao extends _commander__WEBPACK_IMPORTED_MODULE_0__["Commander"] {
  constructor() {
    super();
    this.name = "自动运镖";
    this.MAX_RETRY = 3;
    this.cmd = null;
    this.dadao_idx = 0;
    this.eqSuit = _setting__WEBPACK_IMPORTED_MODULE_2__["default"].local.eq.hasOwnProperty("运镖") ? "运镖" : "战斗";
    this.skillSuit = _setting__WEBPACK_IMPORTED_MODULE_2__["default"].local.skill.hasOwnProperty("运镖") ? "运镖" : "战斗";
  }

  start() {
    super.start(); //战斗失败复活

    this.game.fight.autoRelive(true, () => {
      this.retry++;
      super.stop();
      this.reset();
      this.wait(data => {
        return data.type == "die" && data.relive;
      }, null, null, "等待复活");

      if (this.retry > this.MAX_RETRY) {
        this.log(`复活成功,运镖3次重试失败`, 1);
        this.recover();
        this.complete();
        this.run();
      } else {
        this.log(`复活成功,重试:${this.retry}/${this.MAX_RETRY}`, 1);
        this.recover();
        this.waitCooldown();
        this.waitUnweak();
        this.acceptTask();
        this.run();
      }
    });
    this.log("开始运镖");
    this.stopstate();
    this.retry = 0;
    this.setSkill(this.skillSuit);
    this.equipSuit(this.eqSuit);
    this.acceptTask();
    this.run();
  }

  stop() {
    this.game.fight.autoRelive(false);
    super.stop();
  }

  complete() {
    this.game.fight.autoRelive(false);
    super.complete();
  }

  acceptTask() {
    this.goWait("扬州城-镖局正厅");
    this.waitItem("林震南", item => {
      this.send("biao " + item.id);
    });
    this.wait(data => {
      if (data.type == "text" && data.content == "林震南说道:最近暂时没有委托,你先休息下吧。") {
        this.complete();
        return true;
      }

      if (data.type == "cmds") {
        for (let item of data.items) {
          if (item.name == "继续") {
            this.send(item.cmd);
            this.biaolu();
            return true;
          }

          if (item.name == "开始运镖") {
            this.cmd = item.cmd;
            this.send(this.cmd);
            this.wait(data => {
              if (data.type == "text") {
                if (data.content.match("林震南说道:你来的正好,这里有一批镖银需要交给(.*),你现在就出发吧。")) {
                  this.dadao_idx = 0;
                  return true;
                }

                if (data.content == "林震南说道:你先等等,客户好像不见了。") {
                  this.inject.send(this.cmd);
                }
              }

              return false;
            }, null, null, "等待接收运镖任务");
            this.biaolu();
            return true;
          }
        }
      }

      return false;
    }, null, null, "找林震南接受任务");
  }

  biaolu() {
    this.wait(data => {
      if (data.type == "room") {
        if (data.name == "运镖-青石大道") {
          this.waitCombatEnd();
          this.call(() => {
            this.retry = 0;
            this.dadao_idx++;
          });
          this.log(`运镖路上已击杀${this.dadao_idx}名蒙面大盗。`);
          this.waitFree();
          this.recover();
          this.waitCooldown();
          this.send("go east");
          this.biaolu();
        } else if (data.name == "运镖-城门") {
          this.recover();
          this.waitCooldown();
          this.send("go east");
          this.biaolu();
        } else {
          this.waitMatch("只要把镖银交给(.*)+就完成", found => {
            this.game.data.npcs.forEach((npc, id) => {
              if (npc.name.indexOf(found[1]) > -1) this.send(`task yunbiao ${id} give`);
            });
          });
          this.acceptTask();
        }

        return true;
      }
    }, null, null, "运镖");
  }

}

/***/ }),

/***/ "./src/module/dungeon.js":
/*!*******************************!*\
  !*** ./src/module/dungeon.js ***!
  \*******************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return Dungeon; });
/* harmony import */ var _commander__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./commander */ "./src/module/commander.js");
/* harmony import */ var _Const__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Const */ "./src/module/Const.js");
/* harmony import */ var _setting__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./setting */ "./src/module/setting.js");





class Dungeon extends _commander__WEBPACK_IMPORTED_MODULE_0__["Commander"] {
  constructor() {
    super();
    this.name = "自动副本";
    this.remain = 20;

    this.auto = () => this.nop();

    this.percentage = 100; // 副本完成度

    this.packNeed = 5; //需要背包空间

    this.eqSuit = _setting__WEBPACK_IMPORTED_MODULE_2__["default"].local.eq.hasOwnProperty("副本") ? "副本" : "战斗";
    this.skillSuit = _setting__WEBPACK_IMPORTED_MODULE_2__["default"].local.skill.hasOwnProperty("副本") ? "副本" : "战斗";
  }

  setDungeon(dungeonName) {
    if (!dungeonName) dungeonName = _Const__WEBPACK_IMPORTED_MODULE_1__["default"].getDungeonList()[_setting__WEBPACK_IMPORTED_MODULE_2__["default"].fb];
    if (!dungeonName) return;
    let hard = dungeonName.indexOf("困难");

    if (hard > 0) {
      this.hard = true;
      dungeonName = dungeonName.substring(0, hard);
    } else this.hard = false;

    this.dungeon = _Const__WEBPACK_IMPORTED_MODULE_1__["default"].dungeon.find(d => {
      return d.name == dungeonName;
    });

    this.auto = () => this[this.dungeon.auto]();

    this.eqSuit = _setting__WEBPACK_IMPORTED_MODULE_2__["default"].local.eq.hasOwnProperty("副本") ? "副本" : "战斗";
    this.skillSuit = _setting__WEBPACK_IMPORTED_MODULE_2__["default"].local.skill.hasOwnProperty("副本") ? "副本" : "战斗";
  }

  nop() {
    this.print("不支持该副本");
  } // 单独执行N次副本


  single(dungeonName, times = 0) {
    super.start();

    if (times == 0) {
      this.fetchTask();
      this.call(() => {
        times = this.remain;
        if (times > 0) this._single(dungeonName, times);
      });
    } else this._single(dungeonName, times);

    this.run();
  }

  fast(dungeonName, times = 0) {
    super.start();

    if (times == 0) {
      this.fetchTask();
      this.call(() => {
        times = this.remain;
        if (times > 0) this._fast(dungeonName, times);
      });
    } else this._fast(dungeonName, times);

    this.run();
  }

  swipe(dungeonName, times = 0) {
    super.start();

    if (times == 0) {
      this.fetchTask();
      this.call(() => {
        times = this.remain;
        if (times > 0) this._swipe(dungeonName, times);
      });
    } else this._swipe(dungeonName, times);

    this.run();
  }

  _single(dungeonName, times = 0) {
    this.remain = times;
    this.send("stopstate");
    this.setSkill(this.skillSuit);
    this.equipSuit(this.eqSuit);
    this.game.fight.autoRelive(true, () => {
      super.stop();
      this.reset();
      this.wait(data => {
        return data.type == "die" && data.relive;
      }, null, null, "等待复活");
      this.log(`复活成功,自动副本失败`, 1);
      this.recover();
      this.complete();
      this.run();
    });
    this.setDungeon(dungeonName);
    this.packUp(this.packNeed);
    this.loop();
    this.run();
  }

  complete() {
    this.game.fight.autoRelive(false);
    super.complete();
  }

  _fast(dungeonName, times = 0) {
    super.start();
    this.setDungeon(dungeonName);
    this.setWork("秒进" + this.dungeon.name + (this.hard ? "困难" : ""));
    this.call(() => {
      this.inject.send("stopstate");

      for (let i = 0; i < times; i++) this.inject.send(`cr ${this.dungeon.id} ${this.dungeon.hard ? "1" : "0"} 0;cr over`);
    });
    this.waitFinish();
    this.setWork(null);
    this.complete();
  }

  _swipe(dungeonName, times = 0) {
    this.setDungeon();
    this.setWork("扫荡" + this.dungeon.name + (this.hard ? "困难" : ""));
    this.buySwipe(times);
    this.call(() => {
      this.inject.send("stopstate");
      this.inject.send(`cr ${this.dungeon.id} ${this.dungeon.hard ? "1" : "0"} ${times}`);
    });
    if (times > 1) this.waitMatch(".*扫荡完成。");else this.waitFinish();
    this.setWork(null);
    this.complete();
  } // 执行20次日常副本


  start() {
    super.start();
    this.fetchTask();
    this.call(() => {
      if (this.remain > 0) {
        switch (parseInt(_setting__WEBPACK_IMPORTED_MODULE_2__["default"].rc)) {
          case 1:
            this._single("", this.remain);

            break;

          case 2:
            this._swipe("", this.remain);

            break;

          case 3:
            this._fast("", this.remain);

            break;

          default:
            this.complete();
            break;
        }
      } else this.complete();
    });
    this.run();
  }

  fetchTask() {
    this.waylay(data => data.type == "dialog" && data.dialog == "tasks");
    this.send("tasks");
    this.wait(data => {
      if (data.type != "dialog") return false;
      if (data.dialog != "tasks") return false;

      for (const item of data.items) {
        if (item.id != null && item.id == "signin") {
          var found = item.desc.match("副本:<[^%]+>([^%]+)/20</[^%]+>");
          this.remain = 20 - parseInt(found[1]);
          this.print("完成 - 日常副本 - 共计" + this.remain + "次");
        }
      }

      return true;
    }, null, null, "任务列表数据");
  }

  loop() {
    this.call(() => {
      if (this.remain <= 0) {
        this.setWork(null);
        this.complete();
      } else {
        this.print("自动副本-" + this.dungeon.name + (this.hard ? "困难" : "") + this.remain + "次");
        this.setWork(this.dungeon.name + (this.hard ? "困难" : "") + this.remain + "次");
        this.percentage = 100;
        this.recover(true);
        this.equipSuit(this.eqSuit, 0);
        this.auto();
        this.call(() => this.remain--);
        this.loop();
      }
    });
  }

  kill(npcName) {
    this.call(() => {
      this.game.data.npcs.forEach((npc, id) => {
        if (npc.name.indexOf(npcName) > -1 || npc.title.indexOf(npcName) > -1) this.inject.send("kill " + id);
      });
    });
  }

  cha(npcName) {
    this.call(() => {
      this.game.data.npcs.forEach((npc, id) => {
        if (npc.name.indexOf(npcName) > -1 || npc.title.indexOf(npcName) > -1) this.inject.send("cha " + id);
      });
    });
  }

  shulin() {
    this.enterRoom("cr yz/lw/shangu", "树林-山谷");
    this.clearRoom("go west", "树林-密林", 2);
    this.clearRoom("go west", "树林-密林", 2);
    this.clearRoom("go west", "树林-密林深处");
    this.send("search");
    this.exit();
  } // 财主家


  caizhu() {
    this.percentage = 80;
    let girl = "";
    this.clearRoom("cr yz/cuifu/caizhu 1 0", "财主家-大门", 2);
    this.clearRoom("go north", "财主家-大院", 3);
    this.clearRoom("go north", "财主家-后院");
    this.send("open men");
    this.wait(data => {
      if (data.type == "text" && data.content == "你不会撬锁。") return true;
      if (data.type == "text" && data.content == "你用一把钥匙打开了秘门,可是钥匙却断了。") return true;
      return false;
    }, data => {
      if (data.content == "你用一把钥匙打开了秘门,可是钥匙却断了。") {
        // 救丫鬟
        this.send("go east");
        this.waitItem("丫鬟", item => {
          girl = item.id;
          this.send("ok " + item.id);
        });
        this.waitText("<hig>丫鬟决定跟随你一起行动。</hig>");
        this.call(() => {
          this.send(`go west;go south;go south;ok ${girl};go north;go north`);
        });
      }

      this.send("go west");
      this.waitRoom("财主家-西厢");
      this.waitItem("崔莺莺", item => {
        this.send("ask " + item.id + " about 东厢");
        this.send("kill " + item.id);
      });
      this.waitCombatEnd();

      if (data.content == "你用一把钥匙打开了秘门,可是钥匙却断了。") {
        // 拿箱子
        this.send("go east;go east;search gui");
        this.waitText("你从得到了一个 <hic>小箱子</hic>。");
      }

      this.exit();
    });
  } // 流氓巷


  lmw() {
    this.clearRoom("cr yz/lmw/xiangzi1", "流氓巷-小巷子", 2);
    this.clearRoom("go east", "流氓巷-小巷子", 2);
    this.clearRoom("go north", "流氓巷-破茅屋", 3);
    this.clearRoom("go south;go east", "流氓巷-巷子深处", 2);
    this.clearRoom("go east", "流氓巷-头目房间");
    this.exit();
  } // 丽春院


  lcy() {
    this.clearRoom("cr yz/lcy/dating", "丽春院-大厅", 1);
    this.clearRoom("go up", "丽春院-二楼", 1);
    this.clearRoom("go west", "丽春院-东厢", 1);
    this.clearRoom("tui tai;go enter", "丽春院-密室", 1);
    this.exit();
  } // 兵营


  bingying() {
    this.clearRoom("cr yz/by/damen", "兵营-兵营大门", 2);
    this.clearRoom("go south", "兵营-兵营", 6);
    this.send("open men");
    this.waitText("你大喝一声,使出全力推开铁门。");
    this.enterRoom("go south", "兵营-兵器库");
    this.send("search");
    this.exit();
  } // 庄府


  zhuang() {
    this.enterRoom("cr bj/zhuang/xiaolu", "庄府-小路");
    this.clearRoom("go north", "庄府-小路");
    this.clearRoom("go north;climb wall", "庄府-大院", 2);
    this.clearRoom("go north", "庄府-大厅", 2);
    this.clearRoom("go west", "庄府-大厅");
    this.enterRoom("go east", "庄府-大厅");
    this.clearRoom("go east", "庄府-大厅");
    this.clearRoom("go west;go north", "庄府-长廊");
    this.clearRoom("go north", "庄府-长廊", 2);
    this.exit();
  } // 鳌拜府


  aobai() {
    this.clearRoom("cr bj/ao/damen", "鳌拜府-大门", 2);
    this.clearRoom("go west", "鳌拜府-大院");
    this.clearRoom("go north", "鳌拜府-厨房");
    this.clearRoom("go south;go west", "鳌拜府-后院", 3);
    this.clearRoom("go west", "鳌拜府-卧房");
    this.send("go east");
    this.waitRoom("鳌拜府-后院");
    this.send("unlock men");
    this.wait(data => {
      if (data.type == "text" && data.content == "你不会撬锁。") return true;
      if (data.type == "text" && data.content == "你用一把钥匙打开了牢房门,可是钥匙却断了。") return true;
      return false;
    }, data => {
      if (data.content == "你用一把钥匙打开了牢房门,可是钥匙却断了。") {
        // 问庄允城
        this.send("go south");
        this.waitItem("庄允城", item => {
          this.send("ask " + item.id + " about 吴之荣");
        });
        this.waitText("庄允城给了你");
        this.send("go north");
      }

      this.send("go north");
      this.waitRoom("鳌拜府-书房");
      this.send("open shu");
      this.wait(data => {
        if (data.type != "text") return false;

        if (data.content == "你打开《明史辑略》,发现扉页的左下角被鳌拜写了一个大大的杀字!") {
          this.send("tleft hua");
          return true;
        }

        if (data.content == "你打开《明史辑略》,发现扉页的右下角被鳌拜写了一个大大的杀字!") {
          this.send("tright hua");
          return true;
        }

        return false;
      });
      this.waitType("exits");
      this.send("go north");
      this.waitItem("四十二章经", item => {
        this.send("get " + item.id);
      });
      this.exit();
    });
  } // 天地会


  tiandihui() {
    this.clearRoom("cr bj/tdh/hct", "天地会-回春堂药店", 2);
    this.clearRoom("go west", "天地会-内室");
    this.send("knock");
    this.wait(data => {
      if (data.type == "exits") {
        return true;
      }

      if (data.type == "text" && data.content == "你在木板上咚地敲了一下。") {
        this.inject.send("knock");
      }

      return false;
    }, null, null, "敲地板");
    this.clearRoom("go down", "天地会-暗道");

    for (let i = 0; i < 4; i++) {
      this.enterRoom("go west", "天地会-暗道");
    }

    this.clearRoom("go west", "天地会-暗道");
    this.clearRoom("go north", "天地会-青木堂");
    this.recover();
    this.enterRoom("go east", "天地会-侧厅");
    this.waitItems(items => {
      items.forEach(item => {
        if (item.id && !item.p) {
          this.send(`get ${item.id}`);
        }
      });
    });
    this.decompose();
    this.enterRoom("go west;go north;go east", "天地会-东客房");
    this.waitCombatEnd();
    this.cha("独臂神尼");
    this.kill("独臂神尼");
    this.waitCombatEnd();
    this.exit();
  } // 神龙教


  shenlong() {
    this.send("cr bj/shenlong/haitan");
    this.waitRoom("神龙教");
    this.clearRoom("go north", "神龙教-灌木林", 2);
    this.send("kan bush");
    this.waitType("exits");
    this.clearRoom("go north", "神龙教-灌木林", 2);
    this.clearRoom("go north", "神龙教-空地", 2);
    this.clearRoom("go north", "神龙教-小屋");
    this.clearRoom("go south;go east", "神龙教-大道");
    this.clearRoom("go east", "神龙教-练武场", 2);
    this.clearRoom("go north;go north", "神龙教-大门", 2);
    this.recover();
    this.clearRoom("go north", "神龙教-大厅");
    this.exit();
  }
  /** 关外 */


  guanwai() {
    this.clearRoom("cr bj/guanwai/damen;go northeast", "关外-二门坎子");
    this.clearRoom("go east", "关外-满天星");
    this.clearRoom("go southeast", "关外-草谷垛");
    this.clearRoom("go east", "关外-白河");
    this.clearRoom("go east", "关外-密林");
    this.clearRoom("go eastup", "关外-密林");
    this.clearRoom("go southup", "关外-密林");
    this.recover();
    this.clearRoom("go eastup", "关外-黑风口");
    this.enterRoom("go westdown;go northdown;go west;go west;go northwest;go west;go southwest", "关外-大门坎子");
    this.waitItem("船夫", item => {
      this.send("go west");
      this.send(`give ${item.id} 10000 money`);
    });
    this.waitRoom("关外-松花江面");
    this.waitRoom("关外-船厂");
    this.waitItem("船夫", item => {
      this.send(`kill ${item.id}`);
    });
    this.waitCombatEnd();
    this.enterRoom("go south;go west;go west;go west;go west;go west", "关外-荒路");
    this.clearRoom("go north", "关外-山神庙");
    this.exit();
  } // 温府


  wen() {
    let perform = this.game.fight.performs.find(p => p.ctrl);
    let auto = this.game.fight.auto;

    if (perform == undefined) {
      this.log("没有控制打什么温府");
      return;
    }

    this.percentage = 98;
    this.send("cr cd/wen/damen");
    this.waitRoom("温府-大门");
    this.send("climb tree");
    this.waitRoom("温府-大院");
    this.waitCooldown(); // 关闭自动施法

    this.call(() => this.game.fight.auto = false);
    this.send("go north");
    this.waitRoom("温府-大厅");
    this.waitCombatStart();
    this.send("perform " + perform.id);
    this.send("go northeast");
    this.waitCombatEnd();
    this.call(() => {
      this.game.fight.auto = auto;
    });
    this.send("go northeast;go north;go north;go northwest;go north");
    this.waitRoom("温府-亭子");
    this.send("tiao zhuang");
    this.waitCombatEnd();
    this.waitFree();
    this.recover();
    this.clearRoom("tiao zhuang", "温府-小院");
    this.waitFree();
    this.clearRoom("go north", "温府-小楼", 1);
    this.exit();
  } // 五毒教


  wudu() {
    this.clearRoom("cr cd/wudu/damen", "五毒教-大门", 4);
    this.clearRoom("go east", "五毒教-练武场");
    this.clearRoom("go south", "五毒教-南院");
    this.clearRoom("go west", "五毒教-厢房");
    this.clearRoom("go east;go south", "五毒教-练毒室");
    this.recover();
    this.clearRoom("go north;go north;go east", "五毒教-药室", 3);
    this.recover();
    this.clearRoom("go east", "五毒教-花园");
    this.recover();
    this.clearRoom("go east", "五毒教-花厅");
    this.exit();
  } // 青城山


  qingcheng() {
    this.clearRoom("cr wuyue/qingcheng/shanlu;go westup", "青城山-天师洞", 2);
    this.clearRoom("go north;go northup;go eastup", "青城山-上清宫", 2);
    this.clearRoom("go northup", "青城山-松风观");
    this.clearRoom("go north;go north;go north", "青城山-练武场");
    this.clearRoom("go north", "青城山-上清殿");
    this.clearRoom("go south;go east", "青城山-花园");
    this.recover();
    this.waitCooldown();
    this.delay(1);
    this.clearRoom("go north", "青城山-卧室");
    this.waitFree();
    this.exit();
  } // 衡山


  henshan() {
    this.percentage = 40;
    this.waitCooldown();
    this.clearRoom("cr wuyue/henshan/hengyang;go west;go north", "衡山-刘府大门", 2);
    this.send("go north;go north");
    this.waitRoom("衡山-刘府大厅");
    this.waitKill("费彬");
    this.wait(data => {
      if (data.type != "itemadd") return false;
      if (data.name == null) return false;
      if (data.name.indexOf("史登达") >= 0) return true;
      if (data.name.indexOf("丁勉") >= 0) return true;
      return false;
    }, data => {
      this.inject.send("kill " + data.id);
    }, null, "史登达和丁勉");
    this.wait(data => {
      if (data.type != "itemadd") return false;
      if (data.name == null) return false;
      if (data.name.indexOf("史登达") >= 0) return true;
      if (data.name.indexOf("丁勉") >= 0) return true;
      return false;
    }, data => {
      this.inject.send("kill " + data.id);
    }, null, "史登达和丁勉");
    this.waitCombatEnd({
      seconds: 60
    });
    this.delay(5);
    this.kill("史登达");
    this.kill("丁勉");
    this.delay(1);
    this.kill("刘正风");
    this.waitCombatEnd({
      seconds: 60
    });
    this.recover();
    this.delay(2);
    this.clearRoom("go south;go south;go south;go west;go west", "衡山-山涧");
    this.recover();
    this.delay(2);
    this.clearRoom("go east;go east;go east;go east;go southeast;go south;go east;go south", "衡山-祝融殿");
    this.exit();
  } //泰山


  taishan() {
    this.clearRoom("cr wuyue/taishan/daizong;go northup;go northup", "泰山-二天门");
    this.clearRoom("go northup;go northup", "泰山-龙门");
    this.clearRoom("go northup;go northup;go northup;go northup", "泰山-南天门");
    this.exit();
  } // 嵩山


  songshan() {
    this.clearRoom("cr wuyue/songshan/taishi", "嵩山-太室阙");
    this.clearRoom("go north;go north", "嵩山-中岳大殿");
    this.clearRoom("go northup;go northeast;go northup;go northup", "嵩山-峻极山门");
    this.recover();
    this.waitCooldown();
    this.clearRoom("go northup;go north", "嵩山-峻极禅院");
    this.recover();
    this.waitCooldown();
    this.clearRoom("go north", "嵩山-中门");
    this.recover();
    this.waitCooldown();
    this.clearRoom("go north", "嵩山-会盟堂");
    this.exit();
  } // 云梦沼泽


  yunmeng() {
    this.clearRoom("cr cd/yunmeng/senlin;go east", "云梦沼泽-云梦之泽");
    this.clearRoom("go north", "云梦沼泽-云梦之泽");
    this.recover();
    this.clearRoom("go east", "云梦沼泽-云梦之泽");
    this.recover();
    this.waitCooldown();
    this.clearRoom("go north;jump wei", "云梦沼泽-茅屋");
    this.recover();
    this.enterRoom("go west;go south", "云梦沼泽-云梦之泽");
    this.enterRoom("go west", "云梦沼泽-云梦之泽");
    this.clearRoom("go north", "云梦沼泽-云梦之泽");
    this.recover();
    this.clearRoom("kan lu;go north", "云梦沼泽-洪荒古泽");
    this.recover();
    this.clearRoom("go north", "云梦沼泽-洪荒古泽");
    this.recover();
    this.clearRoom("go north", "云梦沼泽-洪荒古泽");
    this.recover();
    this.clearRoom("go north", "云梦沼泽-洪荒古泽");
    this.exit();
  } // 桃花岛


  taohuadao() {
    this.clearRoom("cr cd/yunmeng/senlin;go east", "云梦沼泽-云梦之泽");
    this.clearRoom("go north", "云梦沼泽-云梦之泽");
    this.recover();
    this.clearRoom("go east", "云梦沼泽-云梦之泽");
    this.recover();
    this.waitCooldown();
    this.clearRoom("go north;jump wei", "云梦沼泽-茅屋");
    this.recover();
    this.enterRoom("go west;go south", "云梦沼泽-云梦之泽");
    this.enterRoom("go west", "云梦沼泽-云梦之泽");
    this.clearRoom("go north", "云梦沼泽-云梦之泽");
    this.recover();
    this.clearRoom("kan lu;go north", "云梦沼泽-洪荒古泽");
    this.recover();
    this.clearRoom("go north", "云梦沼泽-洪荒古泽");
    this.recover();
    this.clearRoom("go north", "云梦沼泽-洪荒古泽");
    this.recover();
    this.clearRoom("go north", "云梦沼泽-洪荒古泽");
    this.exit();
  } // 白驼山


  baituo() {
    this.clearRoom("cr baituo/damen;go north;go north;go north", "白驼山-花园", 2);
    this.recover();
    this.waitCooldown();
    this.clearRoom("go north", "白驼山-大厅");
    this.clearRoom("go south;go south;go south;go west;go south", "白驼山-药房");
    this.clearRoom("go north;go west;go west", "白驼山-草丛");
    this.clearRoom("go north", "白驼山-草丛");
    this.recover();
    this.waitCooldown();
    this.clearRoom("go north;go north", "白驼山-岩洞");
    this.exit();
  } // 星宿海


  xingxiu() {
    this.enterRoom("cr xingxiu/xxh6", "星宿海-星宿海");
    this.clearRoom("go northwest", "星宿海-星宿海");
    this.clearRoom("go north", "星宿海-星宿海");
    this.enterRoom("go south", "星宿海-星宿海");
    this.enterRoom("go southeast", "星宿海-星宿海");
    this.clearRoom("go northeast", "星宿海-星宿海");
    this.clearRoom("go north", "星宿海-星宿海");
    this.recover();
    this.clearRoom("go northwest", "星宿海-星宿海");
    this.recover();
    this.waitCooldown();
    this.clearRoom("go north", "星宿海-日月洞");
    this.exit();
  } // 冰火岛


  binghuodao() {
    this.enterRoom("cr mj/bhd/haibian", "冰火岛-海边岩石");
    this.clearRoom("go north", "冰火岛-丛林");
    this.clearRoom("go north", "冰火岛-丛林", 2);
    this.recover();
    this.waitCooldown();
    this.clearRoom("go north;go west;zuan dong", "冰火岛-石洞");
    this.recover();
    this.enterRoom("go out", "冰火岛-石山");
    this.clearRoom("go east;go south;go south;go south;go west", "冰火岛-火山路");
    this.clearRoom("go west", "冰火岛-火山路");
    this.recover();
    this.clearRoom("go west", "冰火岛-火山脚下");
    this.exit();
  } // 移花宫


  yihua() {
    this.percentage = 85;
    this.enterRoom(`cr huashan/yihua/shandao${this.hard ? " 1 0" : ""}`, "移花宫-山道");
    this.send("go south");
    this.wait(data => {
      if (data.type == "text" && data.content.indexOf("你疗伤完毕,深深吸了口气,脸色看起来好了很多。") >= 0) {
        this.inject.send("go south");
        return false;
      }

      if (data.type == "items" && data.items) {
        let npc = data.items.find(npc => npc.name == "花月奴");

        if (npc) {
          this.recover();
          this.send("kill " + npc.id);
          this.waitCombatEnd();
          return true;
        }

        let needRecover = this.game.data.owner.hp < this.game.data.owner.max_hp / 2;

        if (needRecover) {
          this.inject.send("liaoshang");
        } else {
          this.inject.send("go south");
        }
      }

      return false;
    }, null, null, "走出花径击杀花月奴");
    this.clearRoom("go south;go south", "移花宫-桂花廊");
    this.clearRoom("go south", "移花宫-玫瑰廊");
    this.recover();
    this.waitCooldown();
    this.clearRoom("go southeast", "移花宫-涟星宫");
    this.recover();
    this.send("look hua");
    let hua_right = 0;
    this.wait(data => {
      if (data.type != "item") return false;
      let found = data.desc.match(/这是一丛美丽的.*花丛,你数了下大概有(.*)朵花。/);
      if (!found) return false;
      hua_right = parseInt(found[1]);
      return true;
    }, null, null, "看花");
    this.waitCooldown();
    this.clearRoom("go southwest;go northwest", "移花宫-邀月宫");
    this.recover();
    this.send("look hua");
    let hua_left = 0;
    this.wait(data => {
      if (data.type != "item") return false;
      let found = data.desc.match(/这是一丛美丽的.*花丛,你数了下大概有(.*)朵花。/);
      if (!found) return false;
      hua_left = parseInt(found[1]);
      return true;
    }, null, null, "看花");
    this.enterRoom("go southeast", "移花宫-宫主卧室");
    this.call(() => {
      for (let index = 0; index < hua_left; index++) {
        this.send("pushleft bed");
      }

      for (let index = 0; index < hua_right; index++) {
        this.send("pushright bed");
      }
    });
    this.enterRoom("go down", "移花宫-密道");
    this.send("fire");
    this.wait(data => {
      if (data.type == "text") {
        if (data.content == "你点燃了火折,发现密道中似乎有一条路可以走过去。") {
          this.clearRoom("go west", "移花宫-密道");
          this.send("open xia");
          return true;
        }

        if (data.content == "你身上没有火折子怎么点火?") {
          return true;
        }
      }
    }, null, null, "点火");
    this.exit();
  } // 燕子坞


  yanziwu() {
    this.enterRoom("cr murong/anbian", "燕子坞-岸边");
    this.waitItem("神秘商人", item => this.inject.send(`ask3 ${item.id}`));
    this.waitTexts([/^.*对你说道:.*/], data => {
      this.print(data.content);
    });
    this.clearRoom("go east;go east", "燕子坞-庄门");
    this.clearRoom("go east;go south;go east;go south;go south", "燕子坞-云锦楼");
    this.recover();
    this.waitCooldown();
    this.clearRoom("go north;go north;go west;go north;go east;go east;go east;go east", "燕子坞-书房");
    this.recover();
    this.waitCooldown();
    this.send("go west;go north;bai pai;bai pai;bai pai;go north;search;go south");
    this.waitCombatEnd();
    this.exit();
  }

  gumu() {
    this.percentage = 0;
    this.enterRoom(`cr gumu/gumukou ${this.hard ? "1 0" : ""};go enter`, "古墓派-前厅");
    this.waitCooldown();
    this.clearRoom("go east", "古墓派-后堂");
    this.exit();
  } // 华山论剑


  huashanlunjian() {
    this.enterRoom("cr huashan/lunjian/leitaixia;go up", "华山论剑-论剑台");
    this.waitText("<hic>恭喜你战胜了五绝!</hic>");
    this.send("jump bi");
    this.waitItem("五绝宝箱", item => this.inject.send(`get all from ${item.id}`));
    this.exit();
  } // 退出副本


  exit() {
    this.send("cr");
    this.wait(data => {
      if (data.type != "text") return false;
      let found = data.content.match(/完成度[:a-zA-Z<>]+(\d+)%/);
      if (found && parseInt(found[1]) >= this.percentage) return true;
      return false;
    }, null, null, `当前副本需要完成度${this.percentage}%`);
    this.send("cr over");
    this.packUp(this.packNeed);
  }

}

/***/ }),

/***/ "./src/module/idle.js":
/*!****************************!*\
  !*** ./src/module/idle.js ***!
  \****************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return Idle; });
/* harmony import */ var _commander__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./commander */ "./src/module/commander.js");
/* harmony import */ var _Util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Util */ "./src/module/Util.js");
/* harmony import */ var _setting__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./setting */ "./src/module/setting.js");
/* harmony import */ var _Const__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Const */ "./src/module/Const.js");
/* harmony import */ var _dungeon__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./dungeon */ "./src/module/dungeon.js");






 // 日常:挖矿,修炼,喜宴,BOSS,门派,帮派

class Idle extends _commander__WEBPACK_IMPORTED_MODULE_0__["Commander"] {
  constructor() {
    super();
    this.name = "武神挂机";
    this.current = null;

    this.listener = data => {
      this.monitor(data);
    };

    this.enabled = false;
    this.inPractice = false;
    this.practicePlace = "住房-练功房";
    this.checkKuang = false;
    this.practicelist = [];
    this.master = "";

    let stateListener = data => {
      if (data.type == "state") {
        if (this.game.data.map_id == "home" | this.game.data.room_id == "kuang" && this.game.data.inState.match(/读书|练习|打坐|学习|领悟|挖矿|闭关/)) this.enable();
        this.inject.removeListener(stateListener);
      }
    };

    this.inject.addListener(stateListener);
  } // 执行每日任务


  start() {
    super.start();
    this.name = "武神挂机";
    this.inPractice = false;
    this.idle();
    this.run();
  }

  stop() {
    super.stop();

    if (this.current) {
      this.current.stop();
      this.current = null;
    }
  }

  monitor(data) {
    //喜宴
    if (_setting__WEBPACK_IMPORTED_MODULE_2__["default"].auto_xiyan && data.type == "msg" && data.ch == "sys" && /^(.+)和(.+)于今日大婚,在醉仙楼大摆宴席,婚礼将在一分钟后开始。$/.test(data.content)) {
      this.xiyan();
    } //自动BOSS

    /*
    if (setting.auto_boss && data.ch == "rumor") {
        let r = data.content.match(/^听说(.+)出现在(.+)一带。$/);
        if (r) {
            //清除火龙王等标红
            let boss_name = $.trim($("<body>" + r[1] + "</body>").text());
            let tmp = setting.boss.split(":");
            let noboss = tmp[0] == "" ? [] : tmp[0].split(",");
            let fastboss = tmp[1] == undefined || tmp[1] == "" ? [] : tmp[1].split(",");
            if (inArray(boss_name, noboss)) this.logger(boss_name + "在BOSS黑名单中,不击杀");
            else this.boss(boss_name, r[2], inArray(boss_name, fastboss));
        }
    }
    //自动帮派
    if (setting.auto_bpz && data.ch == "pty") {
        let r = data.content.match(/^.+成员听令,即刻起开始进攻(.+)。$/);
        if (r) {
            this.bpz(r[1]);
        }
    }*/

  }

  enable() {
    if (this.enabled == true) return;
    this.enabled = true;
    this.print(`开启功能:${_setting__WEBPACK_IMPORTED_MODULE_2__["default"].auto_xiyan ? "<HIR>喜宴</HIR> " : " "}${_setting__WEBPACK_IMPORTED_MODULE_2__["default"].auto_boss ? "<HIM>BOSS</HIM> " : " "}`);
    this.inject.addListener(this.listener);
  }

  disable() {
    if (this.enabled == false) return;
    this.enabled = false;
    this.inject.removeListener(this.listener);
  }

  idle() {
    if (this.inPractice) {
      this.practice_Step1();
    }

    if (this.game.data.level == "<hio>武帝</hio>") this.biguan();else this.wakuang();
  }

  biguan() {
    this.disable();
    this.stopstate();
    this.goCheck("住房-练功房");
    this.send("xiulian");
    this.waitText("<hic>你盘膝坐下开始闭关修炼。</hic>");
    this.call(() => {
      this.enable();
    });
    this.complete();
  }

  wakuang() {
    this.disable();
    this.stopstate();
    this.call(() => {
      //查找铁镐
      if (game.data.eqs[0] && game.data.eqs[0].name.indexOf("铁镐") > 0) return;
      let item = game.data.packs.find(t => t.name.indexOf("★铁镐") > 0 || t.name.indexOf("☆铁镐") > 0);
      if (!item) item = game.data.packs.find(t => t.name.indexOf("铁镐") > 0);
      if (!item) this.buyPick();else {
        this.waitGlobalCooldown();
        this.send("eq " + item.id);
      }
    });
    this.goCheck("扬州城-矿山");
    this.send("wa");
    this.waitMatch(/你挥着铁镐开始认真挖矿。|你正在挖矿中,没时间这么做。/);
    this.call(() => {
      if (this.inPractice) {
        this.wait(data => {
          if (data.type == "text") {
            let r = data.content.match(/^<hig>你获得了(\d+)点经验,(\d+)点潜能。<\/hig>$/);

            if (r) {
              if (parseInt(r[2]) < _setting__WEBPACK_IMPORTED_MODULE_2__["default"].xl2wk) {
                this.log("低于挖矿阀值,返回修炼");
                this.practice_Step2();
                return true;
              }
            }
          }
        }, null, null, "检查挖矿加成");
      } else {
        this.call(() => {
          this.enable();
        });
        this.complete();
      }
    });
  }

  buyPick() {
    let tie = "";
    this.goWait("扬州城-打铁铺");
    this.waitItem("铁匠铺老板 铁匠", item => {
      tie = item.id;
      this.send(`list ${tie}`);
    });
    this.wait(data => {
      if (data.type == "text" && data.content == "你没有那么多的钱。") {
        return true;
      }

      if (data.type == "dialog" && data.dialog == "pack" && data.name == "<wht>铁镐</wht>") {
        this.waitGlobalCooldown();
        this.send("eq " + data.id);
        return true;
      }

      if (data.type == "dialog" && data.dialog == "list" && data.selllist) {
        for (const item of data.selllist) {
          if (item.name == "<wht>铁镐</wht>") {
            this.inject.send(`buy 1 ${item.id} from ${tie}`);
            break;
          }
        }
      }

      return false;
    }, null, null, "购买铁镐");
  }

  practice() {
    super.start();
    this.name = "自动修炼";
    this.practice_Step1();
    this.run();
  }

  practice_Step1() {
    this.disable();
    this.call(() => {
      this.practicePlace = "住房-练功房";
      this.practiceMax = 0;
      this.practicelist = [];
      let isStuty = false;
      let tmp2 = [];

      if (_setting__WEBPACK_IMPORTED_MODULE_2__["default"].practice.lentgh == 0) {
        this.log("未设置修炼列表");
        this.call(() => {
          this.start();
        });
        return;
      }

      let tmp1 = _setting__WEBPACK_IMPORTED_MODULE_2__["default"].practice.split(":");

      for (let a of tmp1) {
        let r1 = a.match(/^([Bb]?)(\d{0,4}$)/);
        let r2 = a.match(/^([Xx]+)(\d{0,4}$)/);

        if (r1) {
          this.practicePlace = r1[1] == "" ? "住房-练功房" : "帮会-练功房";
          this.practiceMax = Number(r1[2]);
        } else if (r2) {
          isStuty = true;
          this.practiceMax = Number(r2[2]);
        } else if (/[\u4E00-\u9FA5\uF900-\uFA2D]/.test(a)) {
          tmp2 = a.split(",");
        }
      }

      if (isStuty) {
        this.waylay(data => data.type == "dialog" && data.dialog == "score");
        this.send("score");
        this.wait(data => data.type == "dialog" && data.dialog == "score", data => {
          this.master = data.master;
          this.practicePlace = _Const__WEBPACK_IMPORTED_MODULE_3__["default"].master[this.master];

          if (undefined == this.practicePlace) {
            this.log(this.master + "师傅无数据");
            this.call(() => {
              this.start();
            });
            return true;
          } else {
            this.stopstate();
            this.goWait(this.practicePlace);
            this.waitItem(this.master, item => {
              this.waylay(data => data.type == "dialog" && data.dialog == "master");
              this.send("cha " + item.id);
            });
            return true;
          }
        }, null, "获取师傅");
        this.wait(data => data.type == "dialog" && data.dialog == "master" && data.items, data => {
          if (this.practiceMax == 0) this.practiceMax = data.limit;
          tmp2.forEach(n => {
            let c = data.items.filter(k => k.name.indexOf(n) > -1);
            c.forEach(item => {
              this.practicelist.push({
                cmd: `xue ${item.id} from ${data.master}`,
                name: item.name
              });
            });
            if (n == "打坐") this.practicelist.push({
              cmd: "dazuo",
              name: "<wht>打坐</wht>"
            });
          });

          if (this.practicelist.length) {
            let msg = "学习队列:";
            this.practicelist.forEach(item => msg += item.name + " ");
            this.log(msg);
            this.call(() => {
              this.practice_clear();
            });
            this.practice_Step2();
          } else {
            this.log("没有技能需要练习");
            this.call(() => {
              this.start();
            });
          }
        }, null, "师傅技能");
      } else {
        this.waylay(data => data.type == "dialog" && data.dialog == "skills");
        this.send("cha");
        this.wait(data => data.type == "dialog" && data.dialog == "skills" && data.items, data => {
          let max = this.practiceMax ? this.practiceMax : data.limit;
          tmp2.forEach(n => {
            let c = data.items.filter(k => k.name.indexOf(n) > -1 && k.level < max);
            c.forEach(item => {
              this.practicelist.push({
                cmd: `lianxi ${item.id}${this.practiceMax ? " " + this.practiceMax : ""}`,
                name: item.name
              });
            });
            if (n == "打坐") this.practicelist.push({
              id: "dazuo",
              name: "<wht>打坐</wht>"
            });
          });

          if (this.practicelist.length) {
            let msg = "练习队列:";
            this.practicelist.forEach(item => msg += item.name + " ");
            this.log(msg);
            this.call(() => {
              this.practice_clear();
            });
            this.practice_Step2();
          } else {
            this.log("没有技能需要练习");
            this.call(() => {
              this.start();
            });
          }
        }, null, "技能数据");
      }
    });
  }

  practice_Step2() {
    this.call(() => {
      this.inPractice = true;
      if (this.practicePlace == "住房-练功房" && _setting__WEBPACK_IMPORTED_MODULE_2__["default"].xl2wk && this.game.data.level != "<hio>武帝</hio>") this.checkKuang = true;else this.checkKuang = false;
    });
    this.stopstate();
    this.waitGlobalCooldown();
    this.setSkill("练习");
    this.equipSuit("练习");
    this.goCheck(this.practicePlace);
    this.enable();
    this.practice_Step3();
  }

  practice_Step3() {
    this.call(() => {
      let skill = this.practicelist.shift();

      if (skill == undefined) {
        this.call(() => {
          this.start();
        });
        return;
      }

      this.send(skill.cmd);
      this.log(`开始修炼${skill.name}`);
      this.wait(data => {
        if (data.type == "text") {
          if (data.content.match(/^也许是缺乏实战经验,你觉得你的.+已经到了瓶颈了。$/) || data.content.match(/^你的.+等级不够100,无法练习。$/) || data.content.match(/^你的.+练习完毕。$/) || data.content.match(/^也许是缺乏实战经验,你对.+的讲解总是无法领会。$/) || data.content.match(/^也许是基本功火候未到,你对.+的讲解总是无法领会。$/) || data.content.match(/^你的.+已经练习完成了。$/) || data.content.match(/^.+不会这个技能。$/) || data.content == "你的基本功火候未到,必须先打好基础才能继续提高。" || data.content == "<hic>你觉得你的经脉充盈,已经没有办法再增加内力了。</hic>" || data.content == "你不会这个技能。" || data.content == "你必须找把刀才能学五虎断门刀。" || data.content == "这项技能你的程度已经不输你师父了。" || data.content == "没有这个技能。") {
            this.stopstate();
            this.practice_Step3();
            return true;
          } else if (data.content == "你的潜能不够,无法继续练习下去了。" || data.content == "你的潜能不够,无法继续学习下去了。") {
            this.call(() => {
              this.start();
            });
            return true;
          }
        } else if (this.checkKuang && data.type == "msg" && data.ch == "sys") {
          let r = data.content.match(/^(.+)捡到一本挖矿指南,学会了里面记载的挖矿技巧,所有人的挖矿效率都提高了。$/);

          if (r) {
            //挖矿指南,前往挖矿
            this.practicelist.unshift(skill);
            this.wakuang();
            return true;
          }
        }

        return false;
      }, null, null, `练习${skill.name},队列还有<hir>${this.practicelist.length}</hir>`);
    });
  }

  practice_build() {
    if (this.practicelist.length) {
      let cmd = "";
      this.practicelist.forEach(item => cmd += item.cmd + ",");

      if (this.game.data.level == "<hio>武帝</hio>") {
        if (this.practicePlace != "住房-练功房") ;
        cmd += "jh fam 0 start,go west,go west,go north,go enter,go west,";
        cmd += "xiulian";
      } else cmd += "wakuang";

      if (cmd.length > 200) {
        this.print("离线挂机代码过长,请在豪宅修炼或者减少修炼技能");
        return;
      }

      this.inject.send("setting auto_work " + cmd);
      $("#auto_work").val(cmd);
      this.print("已设置挂机代码,可离线,下次请清除代码");
      this.stop();
    } else {
      this.print("请先运行自动修炼,再生成挂机代码");
    }
  }

  practice_clear() {
    this.inject.send("setting auto_work 0");
    $("#auto_work").val("");
  }

  xiyan() {
    this.disable();
    this.send("stopstate;jh fam 0 start;go north;go north;go east;go up");
    this.wait(data => {
      if (data.type == "items" && data.items) {
        let item = data.items.find(item => {
          return item.name == "<hio>婚宴礼桌</hio>" || item == "<hiy>婚宴礼桌</hiy>";
        });

        if (item) {
          this.inject.send("get all from " + item.id);
          this.log("喜宴完成");
          this.idle();
          return true;
        }
      } else if (data.type == "text") {
        let tmp = /^店小二拦住你说道:怎么又是你,每次都跑这么快,等下再进去。$/.test(data.content);

        if (tmp || /^店小二拦住你说道:这位(.+),不好意思,婚宴宾客已经太多了。$/.test(data.content)) {
          this.log( true ? "今天已经领过了吧!" : undefined);
          this.idle();
          return true;
        }
      } else if (data.type == "cmds") {
        for (let i = 0; i < data.items.length; i++) {
          if (data.items[i].name == "99金贺礼" || data.items[i].name == "9金贺礼" || data.items[i].name == "1金贺礼") {
            this.inject.send(data.items[i].cmd + ";go up");
            break;
          }
        }
      }

      return false;
    }, null, {
      seconds: 20,
      callback: () => {
        this.idle();
      }
    }, "喜宴");
    this.run();
  }

}

/***/ }),

/***/ "./src/module/setting.js":
/*!*******************************!*\
  !*** ./src/module/setting.js ***!
  \*******************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _Injector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Injector */ "./src/module/Injector.js");
/* harmony import */ var _Plugin__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Plugin */ "./src/module/Plugin.js");
/* harmony import */ var _Const__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Const */ "./src/module/Const.js");




 //读写setting

var switchClick = function (e) {
  let t = $(this),
      s = t.parent().attr("for");

  if (t.is(".on")) {
    t.removeClass("on");
    t.find(".switch-text").html("关");
  } else {
    t.addClass("on");
    t.find(".switch-text").html("开");
  }
};

var saveClick = function () {
  for (let w = $(".setting>.setting-item2"), t = 0; t < w.length; t++) {
    let s = $(w[t]),
        i = s.attr("for"),
        t1,
        t2;

    if (i) {
      t1 = s.find(".settingbox2");
      t2 = s.find(".switch2");

      if (t1.length) {
        setting.save(i, t1.val().length ? t1.val() : 0);
      } else if (t2.length) {
        setting.save(i, t2.hasClass("on") ? 1 : 0);
      }
    }
  }

  Object(_Plugin__WEBPACK_IMPORTED_MODULE_1__["log"])("<hic>设置已保存。</hic>");
  $(".dialog-close").click();
};

var setHeight = function (element) {
  $(element).css({
    'height': 'auto',
    'overflow-y': 'hidden'
  }).height(element.scrollHeight == 0 ? "16px" : element.scrollHeight);
};

var storage = {
  set(key, value) {
    localStorage.setItem(key, JSON.stringify(value));
  },

  get(key) {
    return JSON.parse(localStorage.getItem(key));
  },

  remove(key) {
    localStorage.removeItem(key);
  }

};

class Setting {
  constructor() {
    this.localid = null;
    this.yamen = "";
    this.packup_max = 4;
    this.auto_xiyan = 0;
    this.auto_boss = 0;
    this.auto_bpz = 0;
    this.auto_mpz = 0;
    this.practice = "";
    this.auto_perform = "";
    this.wudao = "";
    this.boss = "";
    this.xl2wk = 80;
    this.store_list = "";
    this.drop_list = "";
    this.fenjie_list = "";
    this.item_hp = 0;
    this.kill_player = 0;
    this.kill_maxHp = 39999999;
    this.sm = 0;
    this.rc = 0;
    this.zb = 0;
    this.fb = 0;
    this.local = {
      eq: {
        "战斗": [],
        "练习": []
      },
      skill: {
        "战斗": `{"none":"none"}`,
        "练习": `{"none":"none"}`
      }
    };
    this.onSetTrigger = null;
  }

  load(id, e) {
    if (e) for (let t in e) this[t] == undefined || (this[t] = e[t], this.set_prop(t, e[t]));
    this.html();

    for (let w = $(".setting>.setting-item2"), t = 0; t < w.length; t++) {
      var s = $(w[t]),
          i = s.attr("for");

      if (i) {
        var n = this[i];

        switch (i) {
          case "practice":
          case "auto_perform":
          case "wudao":
          case "yamen":
          case "xl2wk":
          case "boss":
          case "store_list":
          case "drop_list":
          case "fenjie_list":
          case "kill_maxHp":
          case "sm":
          case "rc":
          case "zb":
          case "fb":
          case "skills":
            $("#" + i).show().val(n);
            break;

          default:
            1 == n && (s.find(".switch2").addClass("on"), s.find(".switch-text").html("开"));
        }
      }
    }

    console.log(id);
    this.localid = id;
    let local = storage.get(this.localid) || {};

    for (let key in this.local) {
      local[key] && Object.assign(this.local[key], local[key]);
    }
  }

  set_prop(e, t) {
    this.onSetTrigger && this.onSetTrigger(e, t);

    switch (e) {
      default:
        break;
    }
  }

  save(e, t) {
    if (this[e] != t) {
      if (/^[0-9]+.?[0-9]*$/.test(t)) this[e] = parseInt(t);else this[e] = t;
      _Injector__WEBPACK_IMPORTED_MODULE_0__["default"].getInstance().send("setting " + e + " " + t);
    }

    this.set_prop(e, t);
  }

  saveEq(name, data) {
    this.local.eq[name] = data;
    storage.set(this.localid, this.local);
  }

  deleteEq(name) {
    delete this.local.eq[name];
    storage.set(this.localid, this.local);
  }

  saveSkill(name, data) {
    this.local.skill[name] = data;
    storage.set(this.localid, this.local);
  }

  deleteSkill(name) {
    delete this.local.skill[name];
    storage.set(this.localid, this.local);
  }

  html_switch(prop, title) {
    return `
        <div class="setting-item setting-item2 " for="${prop}" style='display: inline-block;'>
        <span class="title"> ${title}</span>
        <span class="switch2">
        <span class="switch-button"></span>
        <span class="switch-text">关</span>
        </span>
        </div>
        `;
  }

  html_select(prop, title, options) {
    let options_html = "";

    for (let i = 0; i < options.length; i++) options_html += "<option value ='" + i + "'>" + options[i] + "</option>";

    return `
        <div class="setting-item setting-item2 " for="${prop}" style='display: inline-block;'>
        <span class="title"> ${title}</span>
        <select class="settingbox2 hide" id="${prop}" style="width: unset;background-color: white;color: black;">${options_html}</select>
        </div>
        `;
  }

  html_input(prop, title, attr, br) {
    return `
        <div class="setting-item setting-item2" for="${prop}" ${br ? "style='display: inline-block;'" : ""} >
        <span class="title"> ${title}</span>
        <input class="settingbox2 hide" spellcheck="false" id="${prop}"  ${attr}></input>
        </div>
        `;
  }

  html_textarea(prop, title, attr) {
    return `
        <div class="setting-item setting-item2" for="${prop}">
        <span class="title"> ${title}</span><br>
        <textarea class="settingbox2 hide" spellcheck="false" id="${prop}"  ${attr}></textarea>
        </div>
        `;
  }

  html() {
    if ($(".WG_setting").length) return;
    let setting_html = "<h3 class='WG_setting'>插件设置</h3>" + this.html_switch("item_hp", "显血") + this.html_switch("auto_xiyan", "喜宴") + this.html_switch("auto_boss", "BOSS") + this.html_switch("auto_mpz", "门派") + "<br>" + this.html_select("fb", "副本", _Const__WEBPACK_IMPORTED_MODULE_2__["default"].getDungeonList()) + this.html_select("rc", "副本日常", ["关", "自动", "扫荡", "秒进"]) + this.html_select("sm", "师门", ["正常", "自动放弃", "自动补牌"]) + this.html_select("zb", "追捕", ["正常", "快速扫荡"]) + "<br>" + this.html_input("kill_maxHp", "叫杀限制", `style='width:80px;' placeholder="叫杀血量限制" oninput="value=value.replace(/[^\\d]/g,'');"`, true) + this.html_input("yamen", "追捕设置", `style='width:90px;' placeholder="快速,修整,重置" oninput="value=value.replace(/[^\\d\\,]/g,'');"`, true) + this.html_input("wudao", "武道设置", `style='width:90px;' placeholder="快速,修整,停止" oninput="value=value.replace(/[^\\d\\,]/g,'');"`, true) + this.html_input("xl2wk", "挖矿阀值", `style='width:80px;' placeholder="自动修炼判断阀值" oninput="value=value.replace(/[^\\d]/g,'');"`, true) + this.html_input("boss", "BOSS名单", `style='width:300px;' placeholder="黑名单:抢先名单(BOSS名字,BOSS名字……)"`, true) + this.html_textarea("practice", "修炼列表", `style='width:90%;height:2.5rem;' placeholder="选项:中文技能1,中文技能2(选项为B数字或者,B表示帮派修炼,X表示学习,数字表示上限" `) + this.html_textarea("auto_perform", "自动攻击", `style='width:90%;height:2.5rem;' placeholder="控制技能(k技能名),黑名单(b技能名),不修整等待(n技能名),buff控制(技能名buffid)设置完切换武器生效"`) + this.html_textarea("store_list", "整理-存储", `style='width:90%;height:2.5rem;' placeholder="物品1,物品2……"`) + this.html_textarea("drop_list", "整理-丢弃", `style='width:90%;height:2.5rem;' placeholder="物品1,物品2……(注意,这边的丢弃没有提示)"`) + this.html_textarea("fenjie_list", "整理-分解", `style='width:90%;height:2.5rem;' placeholder="物品1,物品2……(注意,这边的分解没有提示,2级强化的物品不会分解)"`) + "<button class='setting-save'>保存插件设置</button><h3>原设置</h3>";
    $(".dialog-custom").prepend(setting_html);
    $(".dialog-custom").on("click", ".switch2", switchClick);
    $(".dialog-custom").on("click", ".setting-save", saveClick);
    $('textarea').each(function () {
      setHeight(this);
    }).on('input', function () {
      setHeight(this);
    }).on('focus', function () {
      setHeight(this);
    });
  }

}

var setting = new Setting();
/* harmony default export */ __webpack_exports__["default"] = (setting);

/***/ }),

/***/ "./src/module/wsmud.css":
/*!******************************!*\
  !*** ./src/module/wsmud.css ***!
  \******************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

exports = module.exports = __webpack_require__(/*! ../../node_modules/css-loader/dist/runtime/api.js */ "./node_modules/css-loader/dist/runtime/api.js")(false);
// Module
exports.push([module.i, ".plugin{display:grid;grid-template-columns:60px auto;width:-webkit-calc(100% - 40px);width:-moz-calc(100% - 40px);border:1px solid #404000;width:calc(100% - 40px);max-height:10em}.plugin_log{-webkit-box-flex:1;-webkit-flex:1;-moz-box-flex:1;-ms-flex:1;flex:1;overflow-y:auto;max-height:10em}.plugin_log>pre{margin:0;white-space:pre-line}.plugin_bottom,.plugin_state{width:-webkit-calc(100% - 40px);width:-moz-calc(100% - 40px);width:calc(100% - 40px)}.plugin_state{border:1px solid #404000;padding:1px;-o-text-overflow:ellipsis;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.item-hp{display:block;float:right;width:100px}.progress{width:5em}.state-bar{width:-webkit-calc(100% - 17em);width:-moz-calc(100% - 17em);width:calc(100% - 17em)}.zdy-item{display:inline-block;border:1px solid grey;color:grey;background-color:#000;text-align:center;cursor:pointer;-webkit-border-radius:.25em;-moz-border-radius:.25em;border-radius:.25em;min-width:2.5em;margin-right:.4em;margin-left:.4em;margin-bottom:.2em;position:relative;padding-left:.4em;padding-right:.4em;line-height:2em}.setting>.setting-save{border:1px solid grey;background-color:transparent;color:unset;width:7rem;height:1.7rem;margin-left:.625em}.setting-item2{color:#fff}.switch2{display:inline-block;position:relative;width:3.125em;line-height:1.25em;background:#dedede;cursor:pointer;-ms-user-select:none;-moz-user-select:none;-webkit-user-select:none;user-select:none;vertical-align:middle;text-align:center}.switch2,.switch2>.switch-button{height:1.25em;-webkit-border-radius:.875em;-moz-border-radius:.875em;border-radius:.875em}.switch2>.switch-button{position:absolute;width:1.25em;background:#fff;-webkit-box-shadow:0 0 5px rgba(0,0,0,.2);-moz-box-shadow:0 0 5px rgba(0,0,0,.2);box-shadow:0 0 5px rgba(0,0,0,.2);-o-transition:.3s;-moz-transition:.3s;transition:.3s;-webkit-transition:.3s;left:0}.switch2>.switch-text{color:#898989;margin-left:.625em}.on{background-color:green}.on>.switch-button{right:0;left:auto}.on>.switch-text{margin-right:.625em;margin-left:0;color:#fff}.settingbox2{margin-left:.625em;border:1px solid grey;background-color:transparent;color:unset;resize:none;width:80%;margin-bottom:0;padding:0}.dialog-custom{min-height:35em}.combat-commands.red:before{color:red}.backman_state{margin-left:5em;color:#f0f}", ""]);



/***/ })

/******/ });
});
//# sourceMappingURL=func.user.js.map