From 8517dbdabfc51270b6c2a7282637171787479ccc Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Wed, 16 Nov 2022 23:01:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=80=AA=E7=89=A9=E6=89=8B=E5=86=8C=E5=88=9D?= =?UTF-8?q?=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .prettierignore | 1 + components.d.ts | 2 + idea.md | 4 +- mota.config.ts | 2 +- package.json | 1 + pnpm-lock.yaml | 371 ++++ public/libs/icons.js | 34 +- public/libs/loader.js | 494 ++++-- public/libs/maps.js | 2880 +++++++++++++++++++++++-------- public/libs/utils.js | 1004 ++++++----- public/main.js | 2 +- public/project/enemys.js | 100 +- public/project/floors/MT2.js | 132 +- public/project/floors/tower4.js | 146 +- public/project/floors/tower6.js | 1114 +++++++++--- public/project/plugins.js | 134 +- public/server.cjs | 16 +- src/App.vue | 7 + src/components/bookOne.vue | 0 src/components/boxAnimate.vue | 55 + src/components/enemyOne.vue | 195 +++ src/components/scroll.vue | 114 +- src/initPlugin.ts | 5 +- src/main.ts | 1 + src/plugin/animateController.ts | 32 + src/plugin/use.ts | 7 +- src/plugin/utils.ts | 27 + src/types/core.d.ts | 8 + src/types/enemy.d.ts | 2 +- src/types/icon.d.ts | 8 +- src/types/plugin.d.ts | 31 +- src/types/util.d.ts | 27 +- src/ui/book.vue | 79 +- vite.config.ts | 2 + 34 files changed, 5179 insertions(+), 1858 deletions(-) delete mode 100644 src/components/bookOne.vue create mode 100644 src/components/enemyOne.vue create mode 100644 src/plugin/animateController.ts create mode 100644 src/plugin/utils.ts diff --git a/.prettierignore b/.prettierignore index fc61e63..7cd1be8 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1 +1,2 @@ vite.config.ts +public/project/*.js \ No newline at end of file diff --git a/components.d.ts b/components.d.ts index a43197b..b7d04c5 100644 --- a/components.d.ts +++ b/components.d.ts @@ -7,8 +7,10 @@ export {} declare module '@vue/runtime-core' { export interface GlobalComponents { + ADivider: typeof import('ant-design-vue/es')['Divider'] BookOne: typeof import('./src/components/bookOne.vue')['default'] BoxAnimate: typeof import('./src/components/boxAnimate.vue')['default'] + EnemyOne: typeof import('./src/components/enemyOne.vue')['default'] Scroll: typeof import('./src/components/scroll.vue')['default'] } } diff --git a/idea.md b/idea.md index c144200..9dd5af9 100644 --- a/idea.md +++ b/idea.md @@ -39,8 +39,8 @@ ## 成就 -- 学坏了:学习电摇嘲讽 +- 学坏了:学习敌人的电摇嘲讽技能 - 我就是傻子:不学习反抢夺通过第二章 - 真能刷:勇气之路的刷血怪刷到 15w 以上的血 -- 满腹经纶:把所有怪物技能都学一遍 +- 满腹经纶:把所有能学的怪物技能都学一遍 - 冰与火之舞:通过第二章特殊战的困难难度 diff --git a/mota.config.ts b/mota.config.ts index 71ce30b..759b572 100644 --- a/mota.config.ts +++ b/mota.config.ts @@ -8,5 +8,5 @@ function defineConfig(config: MotaConfig): MotaConfig { export default defineConfig({ // 这里修改塔的name,请保持与全塔属性的完全相同,否则发布之后可能无法进行游玩 - name: 'template' + name: 'HumanBreak' }); diff --git a/package.json b/package.json index 5e6c3a8..0a1ff9e 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "@types/node": "^18.11.7", "@vitejs/plugin-legacy": "^2.3.0", "@vitejs/plugin-vue": "^3.2.0", + "@vitejs/plugin-vue-jsx": "^2.1.1", "compressing": "^1.6.2", "fontmin": "^0.9.9", "form-data": "^4.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0eea5c9..2a4e3d0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,6 +9,7 @@ specifiers: '@types/node': ^18.11.7 '@vitejs/plugin-legacy': ^2.3.0 '@vitejs/plugin-vue': ^3.2.0 + '@vitejs/plugin-vue-jsx': ^2.1.1 ant-design-vue: ^3.2.13 axios: ^1.1.3 compressing: ^1.6.2 @@ -44,6 +45,7 @@ devDependencies: '@types/node': 18.11.9 '@vitejs/plugin-legacy': 2.3.1_terser@5.15.1+vite@3.2.3 '@vitejs/plugin-vue': 3.2.0_vite@3.2.3+vue@3.2.45 + '@vitejs/plugin-vue-jsx': 2.1.1_vite@3.2.3+vue@3.2.45 compressing: 1.6.2 fontmin: 0.9.9 form-data: 4.0.0 @@ -58,6 +60,14 @@ devDependencies: packages: + /@ampproject/remapping/2.2.0: + resolution: {integrity: sha512-qRmjj8nj9qmLTQXXmaR1cck3UXSRMPrbsLJAasZpF+t3riI71BXed5ebIOYwQntykeZuhjsdweEc9BxH5Jc26w==} + engines: {node: '>=6.0.0'} + dependencies: + '@jridgewell/gen-mapping': 0.1.1 + '@jridgewell/trace-mapping': 0.3.17 + dev: true + /@ant-design/colors/6.0.0: resolution: {integrity: sha512-qAZRvPzfdWHtfameEGP2Qvuf838NhergR35o+EuVyB5XvSA98xod5r4utvi4TJ3ywmevm290g9nsCG5MryrdWQ==} dependencies: @@ -89,6 +99,170 @@ packages: '@babel/highlight': 7.18.6 dev: true + /@babel/compat-data/7.20.1: + resolution: {integrity: sha512-EWZ4mE2diW3QALKvDMiXnbZpRvlj+nayZ112nK93SnhqOtpdsbVD4W+2tEoT3YNBAG9RBR0ISY758ZkOgsn6pQ==} + engines: {node: '>=6.9.0'} + dev: true + + /@babel/core/7.20.2: + resolution: {integrity: sha512-w7DbG8DtMrJcFOi4VrLm+8QM4az8Mo+PuLBKLp2zrYRCow8W/f9xiXm5sN53C8HksCyDQwCKha9JiDoIyPjT2g==} + engines: {node: '>=6.9.0'} + dependencies: + '@ampproject/remapping': 2.2.0 + '@babel/code-frame': 7.18.6 + '@babel/generator': 7.20.4 + '@babel/helper-compilation-targets': 7.20.0_@babel+core@7.20.2 + '@babel/helper-module-transforms': 7.20.2 + '@babel/helpers': 7.20.1 + '@babel/parser': 7.20.3 + '@babel/template': 7.18.10 + '@babel/traverse': 7.20.1 + '@babel/types': 7.20.2 + convert-source-map: 1.9.0 + debug: 4.3.4 + gensync: 1.0.0-beta.2 + json5: 2.2.1 + semver: 6.3.0 + transitivePeerDependencies: + - supports-color + dev: true + + /@babel/generator/7.20.4: + resolution: {integrity: sha512-luCf7yk/cm7yab6CAW1aiFnmEfBJplb/JojV56MYEK7ziWfGmFlTfmL9Ehwfy4gFhbjBfWO1wj7/TuSbVNEEtA==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/types': 7.20.2 + '@jridgewell/gen-mapping': 0.3.2 + jsesc: 2.5.2 + dev: true + + /@babel/helper-annotate-as-pure/7.18.6: + resolution: {integrity: sha512-duORpUiYrEpzKIop6iNbjnwKLAKnJ47csTyRACyEmWj0QdUrm5aqNJGHSSEQSUAvNW0ojX0dOmK9dZduvkfeXA==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/types': 7.20.2 + dev: true + + /@babel/helper-compilation-targets/7.20.0_@babel+core@7.20.2: + resolution: {integrity: sha512-0jp//vDGp9e8hZzBc6N/KwA5ZK3Wsm/pfm4CrY7vzegkVxc65SgSn6wYOnwHe9Js9HRQ1YTCKLGPzDtaS3RoLQ==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0 + dependencies: + '@babel/compat-data': 7.20.1 + '@babel/core': 7.20.2 + '@babel/helper-validator-option': 7.18.6 + browserslist: 4.21.4 + semver: 6.3.0 + dev: true + + /@babel/helper-create-class-features-plugin/7.20.2_@babel+core@7.20.2: + resolution: {integrity: sha512-k22GoYRAHPYr9I+Gvy2ZQlAe5mGy8BqWst2wRt8cwIufWTxrsVshhIBvYNqC80N0GSFWTsqRVexOtfzlgOEDvA==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0 + dependencies: + '@babel/core': 7.20.2 + '@babel/helper-annotate-as-pure': 7.18.6 + '@babel/helper-environment-visitor': 7.18.9 + '@babel/helper-function-name': 7.19.0 + '@babel/helper-member-expression-to-functions': 7.18.9 + '@babel/helper-optimise-call-expression': 7.18.6 + '@babel/helper-replace-supers': 7.19.1 + '@babel/helper-split-export-declaration': 7.18.6 + transitivePeerDependencies: + - supports-color + dev: true + + /@babel/helper-environment-visitor/7.18.9: + resolution: {integrity: sha512-3r/aACDJ3fhQ/EVgFy0hpj8oHyHpQc+LPtJoY9SzTThAsStm4Ptegq92vqKoE3vD706ZVFWITnMnxucw+S9Ipg==} + engines: {node: '>=6.9.0'} + dev: true + + /@babel/helper-function-name/7.19.0: + resolution: {integrity: sha512-WAwHBINyrpqywkUH0nTnNgI5ina5TFn85HKS0pbPDfxFfhyR/aNQEn4hGi1P1JyT//I0t4OgXUlofzWILRvS5w==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/template': 7.18.10 + '@babel/types': 7.20.2 + dev: true + + /@babel/helper-hoist-variables/7.18.6: + resolution: {integrity: sha512-UlJQPkFqFULIcyW5sbzgbkxn2FKRgwWiRexcuaR8RNJRy8+LLveqPjwZV/bwrLZCN0eUHD/x8D0heK1ozuoo6Q==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/types': 7.20.2 + dev: true + + /@babel/helper-member-expression-to-functions/7.18.9: + resolution: {integrity: sha512-RxifAh2ZoVU67PyKIO4AMi1wTenGfMR/O/ae0CCRqwgBAt5v7xjdtRw7UoSbsreKrQn5t7r89eruK/9JjYHuDg==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/types': 7.20.2 + dev: true + + /@babel/helper-module-imports/7.18.6: + resolution: {integrity: sha512-0NFvs3VkuSYbFi1x2Vd6tKrywq+z/cLeYC/RJNFrIX/30Bf5aiGYbtvGXolEktzJH8o5E5KJ3tT+nkxuuZFVlA==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/types': 7.20.2 + dev: true + + /@babel/helper-module-transforms/7.20.2: + resolution: {integrity: sha512-zvBKyJXRbmK07XhMuujYoJ48B5yvvmM6+wcpv6Ivj4Yg6qO7NOZOSnvZN9CRl1zz1Z4cKf8YejmCMh8clOoOeA==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/helper-environment-visitor': 7.18.9 + '@babel/helper-module-imports': 7.18.6 + '@babel/helper-simple-access': 7.20.2 + '@babel/helper-split-export-declaration': 7.18.6 + '@babel/helper-validator-identifier': 7.19.1 + '@babel/template': 7.18.10 + '@babel/traverse': 7.20.1 + '@babel/types': 7.20.2 + transitivePeerDependencies: + - supports-color + dev: true + + /@babel/helper-optimise-call-expression/7.18.6: + resolution: {integrity: sha512-HP59oD9/fEHQkdcbgFCnbmgH5vIQTJbxh2yf+CdM89/glUNnuzr87Q8GIjGEnOktTROemO0Pe0iPAYbqZuOUiA==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/types': 7.20.2 + dev: true + + /@babel/helper-plugin-utils/7.20.2: + resolution: {integrity: sha512-8RvlJG2mj4huQ4pZ+rU9lqKi9ZKiRmuvGuM2HlWmkmgOhbs6zEAw6IEiJ5cQqGbDzGZOhwuOQNtZMi/ENLjZoQ==} + engines: {node: '>=6.9.0'} + dev: true + + /@babel/helper-replace-supers/7.19.1: + resolution: {integrity: sha512-T7ahH7wV0Hfs46SFh5Jz3s0B6+o8g3c+7TMxu7xKfmHikg7EAZ3I2Qk9LFhjxXq8sL7UkP5JflezNwoZa8WvWw==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/helper-environment-visitor': 7.18.9 + '@babel/helper-member-expression-to-functions': 7.18.9 + '@babel/helper-optimise-call-expression': 7.18.6 + '@babel/traverse': 7.20.1 + '@babel/types': 7.20.2 + transitivePeerDependencies: + - supports-color + dev: true + + /@babel/helper-simple-access/7.20.2: + resolution: {integrity: sha512-+0woI/WPq59IrqDYbVGfshjT5Dmk/nnbdpcF8SnMhhXObpTq2KNBdLFRFrkVdbDOyUmHBCxzm5FHV1rACIkIbA==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/types': 7.20.2 + dev: true + + /@babel/helper-split-export-declaration/7.18.6: + resolution: {integrity: sha512-bde1etTx6ZyTmobl9LLMMQsaizFVZrquTEHOqKeQESMKo4PlObf+8+JA25ZsIpZhT/WEd39+vOdLXAFG/nELpA==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/types': 7.20.2 + dev: true + /@babel/helper-string-parser/7.19.4: resolution: {integrity: sha512-nHtDoQcuqFmwYNYPz3Rah5ph2p8PFeFCsZk9A/48dPc/rGocJ5J3hAAZ7pb76VWX3fZKu+uEr/FhH5jLx7umrw==} engines: {node: '>=6.9.0'} @@ -97,6 +271,22 @@ packages: resolution: {integrity: sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==} engines: {node: '>=6.9.0'} + /@babel/helper-validator-option/7.18.6: + resolution: {integrity: sha512-XO7gESt5ouv/LRJdrVjkShckw6STTaB7l9BrpBaAHDeF5YZT+01PCwmR0SJHnkW6i8OwW/EVWRShfi4j2x+KQw==} + engines: {node: '>=6.9.0'} + dev: true + + /@babel/helpers/7.20.1: + resolution: {integrity: sha512-J77mUVaDTUJFZ5BpP6mMn6OIl3rEWymk2ZxDBQJUG3P+PbmyMcF3bYWvz0ma69Af1oobDqT/iAsvzhB58xhQUg==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/template': 7.18.10 + '@babel/traverse': 7.20.1 + '@babel/types': 7.20.2 + transitivePeerDependencies: + - supports-color + dev: true + /@babel/highlight/7.18.6: resolution: {integrity: sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==} engines: {node: '>=6.9.0'} @@ -113,6 +303,40 @@ packages: dependencies: '@babel/types': 7.20.2 + /@babel/plugin-syntax-jsx/7.18.6_@babel+core@7.20.2: + resolution: {integrity: sha512-6mmljtAedFGTWu2p/8WIORGwy+61PLgOMPOdazc7YoJ9ZCWUyFy3A6CpPkRKLKD1ToAesxX8KGEViAiLo9N+7Q==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + dependencies: + '@babel/core': 7.20.2 + '@babel/helper-plugin-utils': 7.20.2 + dev: true + + /@babel/plugin-syntax-typescript/7.20.0_@babel+core@7.20.2: + resolution: {integrity: sha512-rd9TkG+u1CExzS4SM1BlMEhMXwFLKVjOAFFCDx9PbX5ycJWDoWMcwdJH9RhkPu1dOgn5TrxLot/Gx6lWFuAUNQ==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + dependencies: + '@babel/core': 7.20.2 + '@babel/helper-plugin-utils': 7.20.2 + dev: true + + /@babel/plugin-transform-typescript/7.20.2_@babel+core@7.20.2: + resolution: {integrity: sha512-jvS+ngBfrnTUBfOQq8NfGnSbF9BrqlR6hjJ2yVxMkmO5nL/cdifNbI30EfjRlN4g5wYWNnMPyj5Sa6R1pbLeag==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + dependencies: + '@babel/core': 7.20.2 + '@babel/helper-create-class-features-plugin': 7.20.2_@babel+core@7.20.2 + '@babel/helper-plugin-utils': 7.20.2 + '@babel/plugin-syntax-typescript': 7.20.0_@babel+core@7.20.2 + transitivePeerDependencies: + - supports-color + dev: true + /@babel/runtime/7.20.1: resolution: {integrity: sha512-mrzLkl6U9YLF8qpqI7TB82PESyEGjm/0Ly91jG575eVxMMlb8fYfOXFZIJ8XfLrJZQbm7dlKry2bJmXBUEkdFg==} engines: {node: '>=6.9.0'} @@ -125,6 +349,33 @@ packages: engines: {node: '>=6.9.0'} dev: true + /@babel/template/7.18.10: + resolution: {integrity: sha512-TI+rCtooWHr3QJ27kJxfjutghu44DLnasDMwpDqCXVTal9RLp3RSYNh4NdBrRP2cQAoG9A8juOQl6P6oZG4JxA==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/code-frame': 7.18.6 + '@babel/parser': 7.20.3 + '@babel/types': 7.20.2 + dev: true + + /@babel/traverse/7.20.1: + resolution: {integrity: sha512-d3tN8fkVJwFLkHkBN479SOsw4DMZnz8cdbL/gvuDuzy3TS6Nfw80HuQqhw1pITbIruHyh7d1fMA47kWzmcUEGA==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/code-frame': 7.18.6 + '@babel/generator': 7.20.4 + '@babel/helper-environment-visitor': 7.18.9 + '@babel/helper-function-name': 7.19.0 + '@babel/helper-hoist-variables': 7.18.6 + '@babel/helper-split-export-declaration': 7.18.6 + '@babel/parser': 7.20.3 + '@babel/types': 7.20.2 + debug: 4.3.4 + globals: 11.12.0 + transitivePeerDependencies: + - supports-color + dev: true + /@babel/types/7.20.2: resolution: {integrity: sha512-FnnvsNWgZCr232sqtXggapvlkk/tuwR/qhGzcmxI0GXLCjmPYQPzio2FbdlWuY6y1sHFfQKk+rRbUZ9VStQMog==} engines: {node: '>=6.9.0'} @@ -167,6 +418,14 @@ packages: resolution: {integrity: sha512-k2Ty1JcVojjJFwrg/ThKi2ujJ7XNLYaFGNB/bWT9wGR+oSMJHMa5w+CUq6p/pVrKeNNgA7pCqEcjSnHVoqJQFw==} dev: true + /@jridgewell/gen-mapping/0.1.1: + resolution: {integrity: sha512-sQXCasFk+U8lWYEe66WxRDOE9PjVz4vSM51fTu3Hw+ClTpUSQb718772vH3pyS5pShp6lvQM7SxgIDXXXmOX7w==} + engines: {node: '>=6.0.0'} + dependencies: + '@jridgewell/set-array': 1.1.2 + '@jridgewell/sourcemap-codec': 1.4.14 + dev: true + /@jridgewell/gen-mapping/0.3.2: resolution: {integrity: sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A==} engines: {node: '>=6.0.0'} @@ -343,6 +602,22 @@ packages: vite: 3.2.3_sjdpriiyqai3ghwmd5e3ldppum dev: true + /@vitejs/plugin-vue-jsx/2.1.1_vite@3.2.3+vue@3.2.45: + resolution: {integrity: sha512-JgDhxstQlwnHBvZ1BSnU5mbmyQ14/t5JhREc6YH5kWyu2QdAAOsLF6xgHoIWarj8tddaiwFrNzLbWJPudpXKYA==} + engines: {node: ^14.18.0 || >=16.0.0} + peerDependencies: + vite: ^3.0.0 + vue: ^3.0.0 + dependencies: + '@babel/core': 7.20.2 + '@babel/plugin-transform-typescript': 7.20.2_@babel+core@7.20.2 + '@vue/babel-plugin-jsx': 1.1.1_@babel+core@7.20.2 + vite: 3.2.3_sjdpriiyqai3ghwmd5e3ldppum + vue: 3.2.45 + transitivePeerDependencies: + - supports-color + dev: true + /@vitejs/plugin-vue/3.2.0_vite@3.2.3+vue@3.2.45: resolution: {integrity: sha512-E0tnaL4fr+qkdCNxJ+Xd0yM31UwMkQje76fsDVBBUCoGOUPexu2VDUYHL8P4CwV+zMvWw6nlRw19OnRKmYAJpw==} engines: {node: ^14.18.0 || >=16.0.0} @@ -394,6 +669,27 @@ packages: '@volar/vue-language-core': 1.0.9 dev: true + /@vue/babel-helper-vue-transform-on/1.0.2: + resolution: {integrity: sha512-hz4R8tS5jMn8lDq6iD+yWL6XNB699pGIVLk7WSJnn1dbpjaazsjZQkieJoRX6gW5zpYSCFqQ7jUquPNY65tQYA==} + dev: true + + /@vue/babel-plugin-jsx/1.1.1_@babel+core@7.20.2: + resolution: {integrity: sha512-j2uVfZjnB5+zkcbc/zsOc0fSNGCMMjaEXP52wdwdIfn0qjFfEYpYZBFKFg+HHnQeJCVrjOeO0YxgaL7DMrym9w==} + dependencies: + '@babel/helper-module-imports': 7.18.6 + '@babel/plugin-syntax-jsx': 7.18.6_@babel+core@7.20.2 + '@babel/template': 7.18.10 + '@babel/traverse': 7.20.1 + '@babel/types': 7.20.2 + '@vue/babel-helper-vue-transform-on': 1.0.2 + camelcase: 6.3.0 + html-tags: 3.2.0 + svg-tags: 1.0.0 + transitivePeerDependencies: + - '@babel/core' + - supports-color + dev: true + /@vue/compiler-core/3.2.45: resolution: {integrity: sha512-rcMj7H+PYe5wBV3iYeUgbCglC+pbpN8hBLTJvRiK2eKQiWqu+fG9F+8sW99JdL4LQi7Re178UOxn09puSXvn4A==} dependencies: @@ -656,6 +952,17 @@ packages: fill-range: 7.0.1 dev: true + /browserslist/4.21.4: + resolution: {integrity: sha512-CBHJJdDmgjl3daYjN5Cp5kbTf1mUhZoS+beLklHIvkOWscs83YAhLlF3Wsh/lciQYAcbBJgTOD44VtG31ZM4Hw==} + engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} + hasBin: true + dependencies: + caniuse-lite: 1.0.30001431 + electron-to-chromium: 1.4.284 + node-releases: 2.0.6 + update-browserslist-db: 1.0.10_browserslist@4.21.4 + dev: true + /buffer-alloc-unsafe/1.1.0: resolution: {integrity: sha512-TEM2iMIEQdJ2yjPJoSIsldnleVaAk1oW3DBVUykyOLsEsFmEc9kn+SFFPz+gl54KQNxlDnAwCXosOS9Okx2xAg==} dev: true @@ -749,6 +1056,10 @@ packages: engines: {node: '>=10'} dev: true + /caniuse-lite/1.0.30001431: + resolution: {integrity: sha512-zBUoFU0ZcxpvSt9IU66dXVT/3ctO1cy4y9cscs1szkPlcWb6pasYM144GqrUygUbT+k7cmUCW61cvskjcv0enQ==} + dev: true + /chalk/2.4.2: resolution: {integrity: sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==} engines: {node: '>=4'} @@ -1008,6 +1319,10 @@ packages: stream-shift: 1.0.1 dev: true + /electron-to-chromium/1.4.284: + resolution: {integrity: sha512-M8WEXFuKXMYMVr45fo8mq0wUrrJHheiKZf6BArTKk9ZBYCKJEOU5H8cdWgDT+qCVZf7Na4lVUaZsA+h6uA9+PA==} + dev: true + /emoji-regex/8.0.0: resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} dev: true @@ -1260,6 +1575,11 @@ packages: esbuild-windows-arm64: 0.15.13 dev: true + /escalade/3.1.1: + resolution: {integrity: sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==} + engines: {node: '>=6'} + dev: true + /escape-string-regexp/1.0.5: resolution: {integrity: sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==} engines: {node: '>=0.8.0'} @@ -1446,6 +1766,11 @@ packages: wide-align: 1.1.5 dev: true + /gensync/1.0.0-beta.2: + resolution: {integrity: sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==} + engines: {node: '>=6.9.0'} + dev: true + /get-intrinsic/1.1.3: resolution: {integrity: sha512-QJVz1Tj7MS099PevUG5jvnt9tSkXN8K14dxQlikJuPt4uD9hHAHjLyLBiLR5zELelBdD9QNRAXZzsJx0WaDL9A==} dependencies: @@ -1515,6 +1840,11 @@ packages: once: 1.4.0 dev: true + /globals/11.12.0: + resolution: {integrity: sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==} + engines: {node: '>=4'} + dev: true + /graceful-fs/4.2.10: resolution: {integrity: sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==} dev: true @@ -1563,6 +1893,11 @@ packages: lru-cache: 6.0.0 dev: true + /html-tags/3.2.0: + resolution: {integrity: sha512-vy7ClnArOZwCnqZgvv+ddgHgJiAFXe3Ge9ML5/mBctVJoUoYPCdxVucOywjDARn6CVoh3dRSFdPHy2sX80L0Wg==} + engines: {node: '>=8'} + dev: true + /http-cache-semantics/4.1.0: resolution: {integrity: sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ==} dev: true @@ -1792,6 +2127,12 @@ packages: /js-tokens/4.0.0: resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} + /jsesc/2.5.2: + resolution: {integrity: sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==} + engines: {node: '>=4'} + hasBin: true + dev: true + /json-parse-even-better-errors/2.3.1: resolution: {integrity: sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==} dev: true @@ -1800,6 +2141,12 @@ packages: resolution: {integrity: sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==} dev: true + /json5/2.2.1: + resolution: {integrity: sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==} + engines: {node: '>=6'} + hasBin: true + dev: true + /jsonfile/6.1.0: resolution: {integrity: sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==} dependencies: @@ -2170,6 +2517,10 @@ packages: - supports-color dev: true + /node-releases/2.0.6: + resolution: {integrity: sha512-PiVXnNuFm5+iYkLBNeq5211hvO38y63T0i2KKh2KnUs3RpzJ+JtODFjkD8yjLwnDkTYF1eKXheUwdssR+NRZdg==} + dev: true + /nopt/6.0.0: resolution: {integrity: sha512-ZwLpbTgdhuZUnZzjd7nb1ZV+4DoiC6/sfiVKok72ym/4Tlf+DFdlHYmT2JPmcNNWV6Pi3SDf1kT+A4r9RTuT9g==} engines: {node: ^12.13.0 || ^14.15.0 || >=16.0.0} @@ -2563,6 +2914,11 @@ packages: dev: true optional: true + /semver/6.3.0: + resolution: {integrity: sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==} + hasBin: true + dev: true + /semver/7.3.8: resolution: {integrity: sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==} engines: {node: '>=10'} @@ -2721,6 +3077,10 @@ packages: engines: {node: '>= 0.4'} dev: true + /svg-tags/1.0.0: + resolution: {integrity: sha512-ovssysQTa+luh7A5Weu3Rta6FJlFBBbInjOh722LIt6klpU2/HtdUbszju/G4devcvk8PGt7FCLv5wftu3THUA==} + dev: true + /systemjs/6.13.0: resolution: {integrity: sha512-P3cgh2bpaPvAO2NE3uRp/n6hmk4xPX4DQf+UzTlCAycssKdqhp6hjw+ENWe+aUS7TogKRFtptMosTSFeC6R55g==} dev: true @@ -2951,6 +3311,17 @@ packages: webpack-virtual-modules: 0.4.6 dev: true + /update-browserslist-db/1.0.10_browserslist@4.21.4: + resolution: {integrity: sha512-OztqDenkfFkbSG+tRxBeAnCVPckDBcvibKd35yDONx6OU8N7sqgwc7rCbkJ/WcYtVRZ4ba68d6byhC21GFh7sQ==} + hasBin: true + peerDependencies: + browserslist: '>= 4.21.0' + dependencies: + browserslist: 4.21.4 + escalade: 3.1.1 + picocolors: 1.0.0 + dev: true + /util-deprecate/1.0.2: resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} dev: true diff --git a/public/libs/icons.js b/public/libs/icons.js index 7efd6ef..a764e30 100644 --- a/public/libs/icons.js +++ b/public/libs/icons.js @@ -1,7 +1,6 @@ +'use strict'; -"use strict"; - -function icons () { +function icons() { this._init(); } @@ -11,23 +10,22 @@ icons.prototype._init = function () { // tileset的起点 this.tilesetStartOffset = 10000; -} +}; icons.prototype.getIcons = function () { var icons = core.clone(this.icons); icons.hero.leftup = icons.hero.leftdown = icons.hero.left; icons.hero.rightup = icons.hero.rightdown = icons.hero.right; return icons; -} +}; ////// 根据道具ID获得其cls ////// icons.prototype.getClsFromId = function (id) { for (var cls in core.material.icons) { - if (cls != 'hero' && id in core.material.icons[cls]) - return cls; + if (cls != 'hero' && id in core.material.icons[cls]) return cls; } return null; -} +}; icons.prototype.getAllIconIds = function () { if (this.allIconIds) return this.allIconIds; @@ -36,9 +34,9 @@ icons.prototype.getAllIconIds = function () { this.allIconIds = this.allIconIds.concat(Object.keys(this.icons[type])); } return this.allIconIds; -} +}; -icons.prototype._getAnimateFrames = function (cls) { +icons.prototype.getAnimateFrames = function (cls) { if (cls == 'enemys' || cls == 'npcs') { return 2; } @@ -46,18 +44,16 @@ icons.prototype._getAnimateFrames = function (cls) { return 4; } return 1; -} +}; ////// 根据图块数字或ID获得所在的tileset和坐标信息 ////// icons.prototype.getTilesetOffset = function (id) { - if (typeof id == 'string') { id = core.getIdOfThis(id); // Tileset的ID必须是 X+数字 的形式 if (!/^X\d+$/.test(id)) return null; id = parseInt(id.substring(1)); - } - else if (typeof id != 'number') { + } else if (typeof id != 'number') { return null; } @@ -66,12 +62,14 @@ icons.prototype.getTilesetOffset = function (id) { for (var i in core.tilesets) { var imgName = core.tilesets[i]; var img = core.material.images.tilesets[imgName]; - var width = Math.floor(parseInt(img.getAttribute('_width')) / 32), height = Math.floor(parseInt(img.getAttribute('_height')) / 32); + var width = Math.floor(parseInt(img.getAttribute('_width')) / 32), + height = Math.floor(parseInt(img.getAttribute('_height')) / 32); if (id >= startOffset && id < startOffset + width * height) { - var x = (id - startOffset) % width, y = parseInt((id - startOffset) / width); - return { "image": imgName, "x": x, "y": y }; + var x = (id - startOffset) % width, + y = parseInt((id - startOffset) / width); + return { image: imgName, x: x, y: y }; } startOffset += this.tilesetStartOffset; } return null; -} +}; diff --git a/public/libs/loader.js b/public/libs/loader.js index 2b3b538..a2bad38 100644 --- a/public/libs/loader.js +++ b/public/libs/loader.js @@ -1,27 +1,24 @@ - /* loader.js:负责对资源的加载 */ -"use strict"; +'use strict'; -function loader () { +function loader() { this._init(); } -loader.prototype._init = function () { - -} +loader.prototype._init = function () {}; ////// 设置加载进度条进度 ////// loader.prototype._setStartProgressVal = function (val) { core.dom.startTopProgress.style.width = val + '%'; -} +}; ////// 设置加载进度条提示文字 ////// loader.prototype._setStartLoadTipText = function (text) { core.dom.startTopLoadTips.innerText = text; -} +}; loader.prototype._load = function (callback) { if (main.useCompress) { @@ -29,7 +26,7 @@ loader.prototype._load = function (callback) { } else { this._load_sync(callback); } -} +}; loader.prototype._load_sync = function (callback) { this._loadAnimates_sync(); @@ -38,10 +35,10 @@ loader.prototype._load_sync = function (callback) { core.loader._loadExtraImages_sync(function () { core.loader._loadAutotiles_sync(function () { core.loader._loadTilesets_sync(callback); - }) - }) + }); + }); }); -} +}; loader.prototype._load_async = function (callback) { core.loader._setStartLoadTipText('正在加载资源文件...'); @@ -52,23 +49,32 @@ loader.prototype._load_async = function (callback) { return function (loaded, total) { all[name].loaded = loaded; all[name].total = total; - var allLoaded = 0, allTotal = 0; + var allLoaded = 0, + allTotal = 0; for (var one in all) { allLoaded += all[one].loaded; allTotal += all[one].total; } if (allTotal > 0) { if (allLoaded == allTotal) { - core.loader._setStartLoadTipText("正在处理资源文件... 请稍候..."); + core.loader._setStartLoadTipText( + '正在处理资源文件... 请稍候...' + ); } else { - core.loader._setStartLoadTipText('正在加载资源文件... ' + - core.formatSize(allLoaded) + " / " + core.formatSize(allTotal) + - " (" + (allLoaded / allTotal * 100).toFixed(2) + "%)"); + core.loader._setStartLoadTipText( + '正在加载资源文件... ' + + core.formatSize(allLoaded) + + ' / ' + + core.formatSize(allTotal) + + ' (' + + ((allLoaded / allTotal) * 100).toFixed(2) + + '%)' + ); } - core.loader._setStartProgressVal(allLoaded / allTotal * 100); + core.loader._setStartProgressVal((allLoaded / allTotal) * 100); } }; - } + }; var _makeOnFinished = function (name) { return function () { setTimeout(function () { @@ -78,33 +84,59 @@ loader.prototype._load_async = function (callback) { } callback(); }); - } - } + }; + }; - this._loadAnimates_async(_makeOnProgress('animates'), _makeOnFinished('animates')); + this._loadAnimates_async( + _makeOnProgress('animates'), + _makeOnFinished('animates') + ); this._loadMusic_async(_makeOnProgress('sounds'), _makeOnFinished('sounds')); - this._loadMaterials_async(_makeOnProgress('materials'), _makeOnFinished('materials')); - this._loadExtraImages_async(_makeOnProgress('images'), _makeOnFinished('images')); - this._loadAutotiles_async(_makeOnProgress('autotiles'), _makeOnFinished('autotiles')); - this._loadTilesets_async(_makeOnProgress('tilesets'), _makeOnFinished('tilesets')); -} + this._loadMaterials_async( + _makeOnProgress('materials'), + _makeOnFinished('materials') + ); + this._loadExtraImages_async( + _makeOnProgress('images'), + _makeOnFinished('images') + ); + this._loadAutotiles_async( + _makeOnProgress('autotiles'), + _makeOnFinished('autotiles') + ); + this._loadTilesets_async( + _makeOnProgress('tilesets'), + _makeOnFinished('tilesets') + ); +}; // ----- 加载资源文件 ------ // loader.prototype._loadMaterials_sync = function (callback) { - this._setStartLoadTipText("正在加载资源文件..."); - this.loadImages("materials", core.materials, core.material.images, function () { - core.loader._loadMaterials_afterLoad(); - callback(); - }); -} + this._setStartLoadTipText('正在加载资源文件...'); + this.loadImages( + 'materials', + core.materials, + core.material.images, + function () { + core.loader._loadMaterials_afterLoad(); + callback(); + } + ); +}; loader.prototype._loadMaterials_async = function (onprogress, onfinished) { - this.loadImagesFromZip('project/materials/materials.h5data', core.materials, core.material.images, onprogress, function () { - core.loader._loadMaterials_afterLoad(); - onfinished(); - }); -} + this.loadImagesFromZip( + 'project/materials/materials.h5data', + core.materials, + core.material.images, + onprogress, + function () { + core.loader._loadMaterials_afterLoad(); + onfinished(); + } + ); +}; loader.prototype._loadMaterials_afterLoad = function () { var images = core.splitImage(core.material.images['icons']); @@ -115,15 +147,20 @@ loader.prototype._loadMaterials_afterLoad = function () { core.statusBar.image[key].src = core.statusBar.icons[key].src; } } -} +}; // ------ 加载使用的图片 ------ // loader.prototype._loadExtraImages_sync = function (callback) { core.material.images.images = {}; - this._setStartLoadTipText("正在加载图片文件..."); - core.loadImages("images", core.images, core.material.images.images, callback); -} + this._setStartLoadTipText('正在加载图片文件...'); + core.loadImages( + 'images', + core.images, + core.material.images.images, + callback + ); +}; loader.prototype._loadExtraImages_async = function (onprogress, onfinished) { core.material.images.images = {}; @@ -137,16 +174,22 @@ loader.prototype._loadExtraImages_async = function (onprogress, onfinished) { return !name.toLowerCase().endsWith('.gif'); }); - this.loadImagesFromZip('project/images/images.h5data', images, core.material.images.images, onprogress, onfinished); + this.loadImagesFromZip( + 'project/images/images.h5data', + images, + core.material.images.images, + onprogress, + onfinished + ); // gif没有被压缩在zip中,延迟加载... gifs.forEach(function (gif) { - this.loadImage("images", gif, function (id, image) { + this.loadImage('images', gif, function (id, image) { if (image != null) { core.material.images.images[gif] = image; } }); }, this); -} +}; // ------ 加载自动元件 ------ // @@ -155,23 +198,29 @@ loader.prototype._loadAutotiles_sync = function (callback) { var keys = Object.keys(core.material.icons.autotile); var autotiles = {}; - this._setStartLoadTipText("正在加载自动元件..."); - this.loadImages("autotiles", keys, autotiles, function () { + this._setStartLoadTipText('正在加载自动元件...'); + this.loadImages('autotiles', keys, autotiles, function () { core.loader._loadAutotiles_afterLoad(keys, autotiles); callback(); }); -} +}; loader.prototype._loadAutotiles_async = function (onprogress, onfinished) { core.material.images.autotile = {}; var keys = Object.keys(core.material.icons.autotile); var autotiles = {}; - this.loadImagesFromZip('project/autotiles/autotiles.h5data', keys, autotiles, onprogress, function () { - core.loader._loadAutotiles_afterLoad(keys, autotiles); - onfinished(); - }); -} + this.loadImagesFromZip( + 'project/autotiles/autotiles.h5data', + keys, + autotiles, + onprogress, + function () { + core.loader._loadAutotiles_afterLoad(keys, autotiles); + onfinished(); + } + ); +}; loader.prototype._loadAutotiles_afterLoad = function (keys, autotiles) { // autotile需要保证顺序 @@ -182,40 +231,50 @@ loader.prototype._loadAutotiles_afterLoad = function (keys, autotiles) { setTimeout(function () { core.maps._makeAutotileEdges(); }); - -} +}; // ------ 加载额外素材 ------ // loader.prototype._loadTilesets_sync = function (callback) { core.material.images.tilesets = {}; - this._setStartLoadTipText("正在加载额外素材..."); - this.loadImages("tilesets", core.tilesets, core.material.images.tilesets, function () { - core.loader._loadTilesets_afterLoad(); - callback(); - }); -} + this._setStartLoadTipText('正在加载额外素材...'); + this.loadImages( + 'tilesets', + core.tilesets, + core.material.images.tilesets, + function () { + core.loader._loadTilesets_afterLoad(); + callback(); + } + ); +}; loader.prototype._loadTilesets_async = function (onprogress, onfinished) { core.material.images.tilesets = {}; - this.loadImagesFromZip('project/tilesets/tilesets.h5data', core.tilesets, core.material.images.tilesets, onprogress, function () { - core.loader._loadTilesets_afterLoad(); - onfinished(); - }); -} + this.loadImagesFromZip( + 'project/tilesets/tilesets.h5data', + core.tilesets, + core.material.images.tilesets, + onprogress, + function () { + core.loader._loadTilesets_afterLoad(); + onfinished(); + } + ); +}; loader.prototype._loadTilesets_afterLoad = function () { // 检查宽高是32倍数,如果出错在控制台报错 for (var imgName in core.material.images.tilesets) { var img = core.material.images.tilesets[imgName]; if (img.width % 32 != 0 || img.height % 32 != 0) { - console.warn("警告!" + imgName + "的宽或高不是32的倍数!"); + console.warn('警告!' + imgName + '的宽或高不是32的倍数!'); } if (img.width * img.height > 32 * 32 * 3000) { - console.warn("警告!" + imgName + "上的图块素材个数大于3000!"); + console.warn('警告!' + imgName + '上的图块素材个数大于3000!'); } } -} +}; // ------ 实际加载一系列图片 ------ // @@ -227,10 +286,9 @@ loader.prototype.loadImages = function (dir, names, toSave, callback) { var items = 0; for (var i = 0; i < names.length; i++) { this.loadImage(dir, names[i], function (id, image) { - core.loader._setStartLoadTipText('正在加载图片 ' + id + "..."); + core.loader._setStartLoadTipText('正在加载图片 ' + id + '...'); if (toSave[id] !== undefined) { - if (image != null) - toSave[id] = image; + if (image != null) toSave[id] = image; return; } toSave[id] = image; @@ -239,109 +297,145 @@ loader.prototype.loadImages = function (dir, names, toSave, callback) { if (items == names.length) { if (callback) callback(); } - }) + }); } -} +}; loader.prototype.loadImage = function (dir, imgName, callback) { try { var name = imgName; - if (name.indexOf(".") < 0) - name = name + ".png"; + if (name.indexOf('.') < 0) name = name + '.png'; var image = new Image(); image.onload = function () { image.setAttribute('_width', image.width); image.setAttribute('_height', image.height); callback(imgName, image); - } + }; image.onerror = function () { callback(imgName, null); - } - image.src = 'project/' + dir + '/' + name + "?v=" + main.version; - if (name.endsWith('.gif')) - callback(imgName, null); - } - catch (e) { + }; + image.src = 'project/' + dir + '/' + name + '?v=' + main.version; + if (name.endsWith('.gif')) callback(imgName, null); + } catch (e) { console.error(e); } -} +}; // ------ 从zip中加载一系列图片 ------ // -loader.prototype.loadImagesFromZip = function (url, names, toSave, onprogress, onfinished) { +loader.prototype.loadImagesFromZip = function ( + url, + names, + toSave, + onprogress, + onfinished +) { if (!names || names.length == 0) { if (onfinished) onfinished(); return; } - core.unzip(url + "?v=" + main.version, function (data) { - var cnt = 1; - names.forEach(function (name) { - var imgName = name; - if (imgName.indexOf('.') < 0) imgName += '.png'; - if (imgName in data) { - var img = new Image(); - var url = URL.createObjectURL(data[imgName]); - cnt++; - img.onload = function () { - cnt--; - URL.revokeObjectURL(url); - img.setAttribute('_width', img.width); - img.setAttribute('_height', img.height); - if (cnt == 0 && onfinished) onfinished(); + core.unzip( + url + '?v=' + main.version, + function (data) { + var cnt = 1; + names.forEach(function (name) { + var imgName = name; + if (imgName.indexOf('.') < 0) imgName += '.png'; + if (imgName in data) { + var img = new Image(); + var url = URL.createObjectURL(data[imgName]); + cnt++; + img.onload = function () { + cnt--; + URL.revokeObjectURL(url); + img.setAttribute('_width', img.width); + img.setAttribute('_height', img.height); + if (cnt == 0 && onfinished) onfinished(); + }; + img.src = url; + toSave[name] = img; } - img.src = url; - toSave[name] = img; - } - }); - cnt--; - if (cnt == 0 && onfinished) onfinished(); - }, null, false, onprogress); -} + }); + cnt--; + if (cnt == 0 && onfinished) onfinished(); + }, + null, + false, + onprogress + ); +}; // ------ 加载动画文件 ------ // loader.prototype._loadAnimates_sync = function () { - this._setStartLoadTipText("正在加载动画文件..."); + this._setStartLoadTipText('正在加载动画文件...'); if (main.supportBunch) { if (core.animates.length > 0) { - core.http('GET', '__all_animates__?v=' + main.version + '&id=' + core.animates.join(','), null, function (content) { - var u = content.split('@@@~~~###~~~@@@'); - for (var i = 0; i < core.animates.length; ++i) { - if (u[i] != '') { - core.material.animates[core.animates[i]] = core.loader._loadAnimate(u[i]); - } else { - console.error('无法找到动画文件' + core.animates[i] + '!'); + core.http( + 'GET', + '/all/__all_animates__?v=' + + main.version + + '&id=' + + core.animates.join(','), + null, + function (content) { + var u = content.split('@@@~~~###~~~@@@'); + for (var i = 0; i < core.animates.length; ++i) { + if (u[i] != '') { + core.material.animates[core.animates[i]] = + core.loader._loadAnimate(u[i]); + } else { + console.error( + '无法找到动画文件' + core.animates[i] + '!' + ); + } } - } - }, "text/plain; charset=x-user-defined"); + }, + 'text/plain; charset=x-user-defined' + ); } return; } core.animates.forEach(function (t) { - core.http('GET', 'project/animates/' + t + ".animate?v=" + main.version, null, function (content) { - core.material.animates[t] = core.loader._loadAnimate(content); - }, function (e) { - console.error(e); - core.material.animates[t] = null; - }, "text/plain; charset=x-user-defined") + core.http( + 'GET', + 'project/animates/' + t + '.animate?v=' + main.version, + null, + function (content) { + core.material.animates[t] = core.loader._loadAnimate(content); + }, + function (e) { + console.error(e); + core.material.animates[t] = null; + }, + 'text/plain; charset=x-user-defined' + ); }); -} +}; loader.prototype._loadAnimates_async = function (onprogress, onfinished) { - core.unzip('project/animates/animates.h5data?v=' + main.version, function (animates) { - for (var name in animates) { - if (name.endsWith(".animate")) { - var t = name.substring(0, name.length - 8); - if (core.animates.indexOf(t) >= 0) - core.material.animates[t] = core.loader._loadAnimate(animates[name]); + core.unzip( + 'project/animates/animates.h5data?v=' + main.version, + function (animates) { + for (var name in animates) { + if (name.endsWith('.animate')) { + var t = name.substring(0, name.length - 8); + if (core.animates.indexOf(t) >= 0) + core.material.animates[t] = core.loader._loadAnimate( + animates[name] + ); + } } - } - onfinished(); - }, null, true, onprogress); -} + onfinished(); + }, + null, + true, + onprogress + ); +}; loader.prototype._loadAnimate = function (content) { try { @@ -354,8 +448,7 @@ loader.prototype._loadAnimate = function (content) { content.bitmaps.forEach(function (t2) { if (!t2) { data.images.push(null); - } - else { + } else { try { var image = new Image(); image.src = t2; @@ -365,36 +458,35 @@ loader.prototype._loadAnimate = function (content) { data.images.push(null); } } - }) + }); data.frame = content.frame_max; data.frames = []; content.frames.forEach(function (t2) { var info = []; t2.forEach(function (t3) { info.push({ - 'index': t3[0], - 'x': t3[1], - 'y': t3[2], - 'zoom': t3[3], - 'opacity': t3[4], - 'mirror': t3[5] || 0, - 'angle': t3[6] || 0, - }) - }) + index: t3[0], + x: t3[1], + y: t3[2], + zoom: t3[3], + opacity: t3[4], + mirror: t3[5] || 0, + angle: t3[6] || 0 + }); + }); data.frames.push(info); }); return data; - } - catch (e) { + } catch (e) { console.error(e); return null; } -} +}; // ------ 加载音乐和音效 ------ // loader.prototype._loadMusic_sync = function () { - this._setStartLoadTipText("正在加载音效文件..."); + this._setStartLoadTipText('正在加载音效文件...'); core.bgms.forEach(function (t) { core.loader.loadOneMusic(t); }); @@ -403,45 +495,60 @@ loader.prototype._loadMusic_sync = function () { }); // 直接开始播放 core.playBgm(main.startBgm); -} +}; loader.prototype._loadMusic_async = function (onprogress, onfinished) { core.bgms.forEach(function (t) { core.loader.loadOneMusic(t); }); - core.unzip('project/sounds/sounds.h5data?v=' + main.version, function (data) { - // 延迟解析 - setTimeout(function () { - for (var name in data) { - if (core.sounds.indexOf(name) >= 0) { - core.loader._loadOneSound_decodeData(name, data[name]); + core.unzip( + 'project/sounds/sounds.h5data?v=' + main.version, + function (data) { + // 延迟解析 + setTimeout(function () { + for (var name in data) { + if (core.sounds.indexOf(name) >= 0) { + core.loader._loadOneSound_decodeData(name, data[name]); + } } - } - }); - onfinished(); - }, null, false, onprogress); + }); + onfinished(); + }, + null, + false, + onprogress + ); // 直接开始播放 core.playBgm(main.startBgm); -} +}; loader.prototype.loadOneMusic = function (name) { var music = new Audio(); music.preload = 'none'; - if (main.bgmRemote) music.src = main.bgmRemoteRoot + core.firstData.name + '/' + name; + if (main.bgmRemote) + music.src = main.bgmRemoteRoot + core.firstData.name + '/' + name; else music.src = 'project/bgms/' + name; music.loop = 'loop'; core.material.bgms[name] = music; -} +}; loader.prototype.loadOneSound = function (name) { - core.http('GET', 'project/sounds/' + name + "?v=" + main.version, null, function (data) { - core.loader._loadOneSound_decodeData(name, data); - }, function (e) { - console.error(e); - core.material.sounds[name] = null; - }, null, 'arraybuffer'); -} + core.http( + 'GET', + 'project/sounds/' + name + '?v=' + main.version, + null, + function (data) { + core.loader._loadOneSound_decodeData(name, data); + }, + function (e) { + console.error(e); + core.material.sounds[name] = null; + }, + null, + 'arraybuffer' + ); +}; loader.prototype._loadOneSound_decodeData = function (name, data) { if (data instanceof Blob) { @@ -449,23 +556,26 @@ loader.prototype._loadOneSound_decodeData = function (name, data) { blobReader.init(function () { blobReader.readUint8Array(0, blobReader.size, function (uint8) { core.loader._loadOneSound_decodeData(name, uint8.buffer); - }) + }); }); return; } try { - core.musicStatus.audioContext.decodeAudioData(data, function (buffer) { - core.material.sounds[name] = buffer; - }, function (e) { - console.error(e); - core.material.sounds[name] = null; - }) - } - catch (e) { + core.musicStatus.audioContext.decodeAudioData( + data, + function (buffer) { + core.material.sounds[name] = buffer; + }, + function (e) { + console.error(e); + core.material.sounds[name] = null; + } + ); + } catch (e) { console.error(e); core.material.sounds[name] = null; } -} +}; loader.prototype.loadBgm = function (name) { name = core.getMappedName(name); @@ -476,34 +586,38 @@ loader.prototype.loadBgm = function (name) { var index = core.musicStatus.cachedBgms.indexOf(name); if (index >= 0) { core.musicStatus.cachedBgms.splice(index, 1); - } - else { + } else { // 预加载BGM this._preloadBgm(core.material.bgms[name]); // core.material.bgms[name].load(); // 清理尾巴 - if (core.musicStatus.cachedBgms.length == core.musicStatus.cachedBgmCount) { + if ( + core.musicStatus.cachedBgms.length == + core.musicStatus.cachedBgmCount + ) { this.freeBgm(core.musicStatus.cachedBgms.pop()); } } // 移动到缓存最前方 core.musicStatus.cachedBgms.unshift(name); -} +}; loader.prototype._preloadBgm = function (bgm) { bgm.volume = 0; bgm.play(); -} +}; loader.prototype.freeBgm = function (name) { name = core.getMappedName(name); if (!core.material.bgms[name]) return; // 从cachedBgms中删除 - core.musicStatus.cachedBgms = core.musicStatus.cachedBgms.filter(function (t) { + core.musicStatus.cachedBgms = core.musicStatus.cachedBgms.filter(function ( + t + ) { return t != name; }); // 清掉缓存 - core.material.bgms[name].removeAttribute("src"); + core.material.bgms[name].removeAttribute('src'); core.material.bgms[name].load(); core.material.bgms[name] = null; if (name == core.musicStatus.playingBgm) { @@ -513,4 +627,4 @@ loader.prototype.freeBgm = function (name) { setTimeout(function () { core.loader.loadOneMusic(name); }, 3000); -} \ No newline at end of file +}; diff --git a/public/libs/maps.js b/public/libs/maps.js index 1c69af3..caf0b86 100644 --- a/public/libs/maps.js +++ b/public/libs/maps.js @@ -1,14 +1,13 @@ +'use strict'; -"use strict"; - -function maps () { +function maps() { this._init(); } maps.prototype._init = function () { this.blocksInfo = maps_90f36752_8815_4be8_b32b_d7fad1d0542e; //delete(maps_90f36752_8815_4be8_b32b_d7fad1d0542e); -} +}; maps.prototype._initFloors = function (floorId) { if (!floorId) { @@ -18,21 +17,23 @@ maps.prototype._initFloors = function (floorId) { return; } // 战前事件兼容性 - if (!core.floors[floorId].beforeBattle) core.floors[floorId].beforeBattle = {} + if (!core.floors[floorId].beforeBattle) + core.floors[floorId].beforeBattle = {}; // cannotMoveIn兼容性 - if (!core.floors[floorId].cannotMoveIn) core.floors[floorId].cannotMoveIn = {} -} + if (!core.floors[floorId].cannotMoveIn) + core.floors[floorId].cannotMoveIn = {}; +}; maps.prototype._resetFloorImages = function () { for (var floorId in core.status.maps) { (core.status.maps[floorId].images || []).forEach(function (one) { - var flag = "__floorImg__" + floorId + "_" + one.x + "_" + one.y; + var flag = '__floorImg__' + floorId + '_' + one.x + '_' + one.y; if (core.getFlag(flag) == null) { if (one.disabled) core.setFlag(flag, true); } - }) + }); } -} +}; maps.prototype._setHDCanvasSize = function (ctx, width, height, isTempCanvas) { ctx.setTransform(1, 0, 0, 1, 0, 0); @@ -43,7 +44,7 @@ maps.prototype._setHDCanvasSize = function (ctx, width, height, isTempCanvas) { if (height != null) ctx.canvas.height = height * ratio; ctx.scale(ratio, ratio); ctx.canvas.setAttribute('isHD', 1); -} +}; // ------ 加载地图与地图的存档读档(压缩与解压缩) ------ // @@ -52,7 +53,7 @@ maps.prototype.loadFloor = function (floorId, map) { var floor = core.floors[floorId]; if (!map) map = core.cloneArray(floor.map); if (map instanceof Array) { - map = { "map": map }; + map = { map: map }; } if (!map.map) map.map = core.cloneArray(floor.map); var content = {}; @@ -70,15 +71,27 @@ maps.prototype.loadFloor = function (floorId, map) { this.extractBlocks(content); } return content; -} +}; maps.prototype._loadFloor_doNotCopy = function () { return [ - "firstArrive", "eachArrive", "blocks", "parallelDo", "map", "bgmap", "fgmap", - "events", "changeFloor", "beforeBattle", "afterBattle", "afterGetItem", "afterOpenDoor", - "cannotMove", "cannotMoveIn" + 'firstArrive', + 'eachArrive', + 'blocks', + 'parallelDo', + 'map', + 'bgmap', + 'fgmap', + 'events', + 'changeFloor', + 'beforeBattle', + 'afterBattle', + 'afterGetItem', + 'afterOpenDoor', + 'cannotMove', + 'cannotMoveIn' ]; -} +}; /// 根据需求解析出blocks maps.prototype.extractBlocks = function (map) { @@ -91,8 +104,12 @@ maps.prototype.extractBlocks = function (map) { return; } var floorId = map.floorId; - map.blocks = this._mapIntoBlocks(this.decompressMap(map.map, floorId), core.floors[floorId], floorId); -} + map.blocks = this._mapIntoBlocks( + this.decompressMap(map.map, floorId), + core.floors[floorId], + floorId + ); +}; maps.prototype._mapIntoBlocks = function (map, floor, floorId) { var blocks = []; @@ -100,23 +117,28 @@ maps.prototype._mapIntoBlocks = function (map, floor, floorId) { var mh = core.floors[floorId].height; for (var i = 0; i < mh; i++) { for (var j = 0; j < mw; j++) { - var number = (map[i] || [])[j] || 0, block; + var number = (map[i] || [])[j] || 0, + block; if (main.mode == 'editor') { if (!number) continue; - block = { x: j, y: i, id: number, event: this.getBlockByNumber(number).event }; + block = { + x: j, + y: i, + id: number, + event: this.getBlockByNumber(number).event + }; } else { block = this.initBlock(j, i, number, true, floor); } - if (block.id != 0 || block.event.trigger) - blocks.push(block); + if (block.id != 0 || block.event.trigger) blocks.push(block); } } return blocks; -} +}; maps.prototype.extractBlocksForUI = function (map, flags) { if (!map || map.blocks) return; - if (map.deleted) return map.blocks = []; + if (map.deleted) return (map.blocks = []); var floorId = map.floorId; var decompressed = this.decompressMap(map.map, floorId); map.blocks = []; @@ -131,33 +153,42 @@ maps.prototype.extractBlocksForUI = function (map, flags) { if (isDisabled) continue; if (isDisabled == null) { // 检查是否初始禁用 - var event = (floor.events || {})[j + "," + i]; + var event = (floor.events || {})[j + ',' + i]; if (event != null && event.enable === false) continue; } var opacity = this._getBlockOpacityFromFlag(floorId, j, i, flags); if (opacity == null) { // 检查初始不透明度 - var event = (floor.events || {})[j + "," + i]; - if (event != null && event.opacity != null) opacity = event.opacity; + var event = (floor.events || {})[j + ',' + i]; + if (event != null && event.opacity != null) + opacity = event.opacity; } var filter = this._getBlockFilterFromFlag(floorId, j, i, flags); if (filter == null) { // 检查初始filter - var event = (floor.events || {})[j + "," + i]; - if (event != null && event.filter != null) filter = core.clone(event.filter); + var event = (floor.events || {})[j + ',' + i]; + if (event != null && event.filter != null) + filter = core.clone(event.filter); } - map.blocks.push(Object.assign({}, this.getBlockByNumber(number), { x: j, y: i, opacity: opacity, filter: filter })); + map.blocks.push( + Object.assign({}, this.getBlockByNumber(number), { + x: j, + y: i, + opacity: opacity, + filter: filter + }) + ); } } -} +}; ////// 从ID获得数字 ////// maps.prototype.getNumberById = function (id) { id = this.getIdOfThis(id); core.status.id2number = core.status.id2number || {}; if (core.status.id2number[id] != null) return core.status.id2number[id]; - return core.status.id2number[id] = this._getNumberById(id); -} + return (core.status.id2number[id] = this._getNumberById(id)); +}; maps.prototype._getNumberById = function (id) { for (var number in this.blocksInfo) { @@ -172,24 +203,38 @@ maps.prototype._getNumberById = function (id) { if (id == 'none') return 0; if (id == 'airwall') return 17; return 0; -} +}; maps.prototype.getBlockByNumber = function (number) { core.status.number2Block = core.status.number2Block || {}; - if (core.status.number2Block[number] != null) return core.status.number2Block[number]; - return core.status.number2Block[number] = this.initBlock(null, null, number, true); -} + if (core.status.number2Block[number] != null) + return core.status.number2Block[number]; + return (core.status.number2Block[number] = this.initBlock( + null, + null, + number, + true + )); +}; maps.prototype.getBlockById = function (id) { return this.getBlockByNumber(this.getNumberById(id)); -} +}; maps.prototype.getIdOfThis = function (id) { if (id != 'this') return id; if (core.status.event.id != 'action') return id; - if (!core.status.event.data || core.status.event.data.x == null || core.status.event.data.y == null) return id; - return core.getBlockId(core.status.event.data.x, core.status.event.data.y) || id; -} + if ( + !core.status.event.data || + core.status.event.data.x == null || + core.status.event.data.y == null + ) + return id; + return ( + core.getBlockId(core.status.event.data.x, core.status.event.data.y) || + id + ); +}; ////// 数字和ID的对应关系 ////// maps.prototype.initBlock = function (x, y, id, addInfo, eventFloor) { @@ -201,15 +246,22 @@ maps.prototype.initBlock = function (x, y, id, addInfo, eventFloor) { opacity = this._getBlockOpacityFromFlag(eventFloor.floorId, x, y); filter = this._getBlockFilterFromFlag(eventFloor.floorId, x, y); } - var block = { 'x': x, 'y': y, 'id': id }; + var block = { x: x, y: y, id: id }; if (disable != null) block.disable = disable; if (opacity != null) block.opacity = opacity; if (filter != null) block.filter = filter; - if (id == 17) block.event = { "cls": "terrains", "id": "airwall", "cannotIn": ["up", "down", "left", "right"] }; - else if (id in this.blocksInfo) block.event = JSON.parse(JSON.stringify(this.blocksInfo[id])); - else if (core.icons.getTilesetOffset(id)) block.event = { "cls": "tileset", "id": "X" + id }; - else block.event = { 'cls': 'terrains', 'id': 'none', 'noPass': false }; + if (id == 17) + block.event = { + cls: 'terrains', + id: 'airwall', + cannotIn: ['up', 'down', 'left', 'right'] + }; + else if (id in this.blocksInfo) + block.event = JSON.parse(JSON.stringify(this.blocksInfo[id])); + else if (core.icons.getTilesetOffset(id)) + block.event = { cls: 'tileset', id: 'X' + id }; + else block.event = { cls: 'terrains', id: 'none', noPass: false }; if (block.event.noPass == null) { if (block.event.canPass == null) { @@ -221,7 +273,7 @@ maps.prototype.initBlock = function (x, y, id, addInfo, eventFloor) { delete block.event.canPass; // 增加怪物的faceIds - if (block.event.cls.indexOf("enemy") == 0) { + if (block.event.cls.indexOf('enemy') == 0) { var enemy = core.material.enemys[block.event.id]; if (enemy && enemy.faceIds) { block.event.faceIds = enemy.faceIds; @@ -230,39 +282,42 @@ maps.prototype.initBlock = function (x, y, id, addInfo, eventFloor) { if (addInfo) this._addInfo(block); if (eventFloor) { - this._addEvent(block, x, y, (eventFloor.events || {})[x + "," + y]); - var changeFloor = (eventFloor.changeFloor || {})[x + "," + y]; - if (changeFloor) this._addEvent(block, x, y, { "trigger": "changeFloor", "data": changeFloor }); + this._addEvent(block, x, y, (eventFloor.events || {})[x + ',' + y]); + var changeFloor = (eventFloor.changeFloor || {})[x + ',' + y]; + if (changeFloor) + this._addEvent(block, x, y, { + trigger: 'changeFloor', + data: changeFloor + }); } if (main.mode == 'editor') delete block.disable; return block; -} +}; ////// 添加一些信息到block上 ////// maps.prototype._addInfo = function (block) { - if (block.event.cls.indexOf("enemy") == 0 && !block.event.trigger) { + if (block.event.cls.indexOf('enemy') == 0 && !block.event.trigger) { block.event.trigger = 'battle'; } if (block.event.cls == 'items' && !block.event.trigger) { block.event.trigger = 'getItem'; } if (block.event.animate == null) { - block.event.animate = core.icons._getAnimateFrames(block.event.cls); + block.event.animate = core.icons.getAnimateFrames(block.event.cls); } block.event.height = 32; if (block.event.cls == 'enemy48' || block.event.cls == 'npc48') block.event.height = 48; -} +}; ////// 向该楼层添加剧本的自定义事件 ////// maps.prototype._addEvent = function (block, x, y, event) { if (!event) return; // event是字符串或数组? - if (typeof event == "string") { - event = { "data": [event] }; - } - else if (event instanceof Array) { - event = { "data": event }; + if (typeof event == 'string') { + event = { data: [event] }; + } else if (event instanceof Array) { + event = { data: event }; } event.data = event.data || []; @@ -283,7 +338,13 @@ maps.prototype._addEvent = function (block, x, y, event) { } // 覆盖所有属性 for (var key in event) { - if (key != "enable" && key != "animate" && key != "opacity" && key != "filter" && event[key] != null) { + if ( + key != 'enable' && + key != 'animate' && + key != 'opacity' && + key != 'filter' && + event[key] != null + ) { block.event[key] = core.clone(event[key]); } } @@ -291,7 +352,7 @@ maps.prototype._addEvent = function (block, x, y, event) { if (!block.event.trigger) { block.event.trigger = 'action'; } -} +}; ////// 初始化所有地图 ////// maps.prototype._initMaps = function () { @@ -302,7 +363,7 @@ maps.prototype._initMaps = function () { maps[floorId] = this.loadFloor(floorId); } return maps; -} +}; ////// 压缩地图 maps.prototype.compressMap = function (mapArr, floorId) { @@ -315,8 +376,7 @@ maps.prototype.compressMap = function (mapArr, floorId) { if (core.utils.same(mapArr[x], floorMap[x])) { // 没有改变的行直接删掉记成0 mapArr[x] = 0; - } - else { + } else { for (var y = 0; y < mw; y++) { if (mapArr[x][y] === floorMap[x][y]) { // 没有改变的数据记成-1 @@ -326,7 +386,7 @@ maps.prototype.compressMap = function (mapArr, floorId) { } } return mapArr; -} +}; maps.prototype._processInvalidMap = function (mapArr, width, height) { if (mapArr.length == height && mapArr[0].length == width) return mapArr; @@ -341,7 +401,7 @@ maps.prototype._processInvalidMap = function (mapArr, width, height) { } } return map; -} +}; maps.prototype._getBlockOpacityFromFlag = function (floorId, x, y, flags) { if (flags == null) flags = (core.status.hero || {}).flags; @@ -352,7 +412,7 @@ maps.prototype._getBlockOpacityFromFlag = function (floorId, x, y, flags) { if ((flags.__removed__ || []).indexOf(floorId) >= 0) return null; var index = x + y * core.floors[floorId].width; return (__opacity__[floorId] || {})[index]; -} +}; maps.prototype._getBlockFilterFromFlag = function (floorId, x, y, flags) { if (flags == null) flags = (core.status.hero || {}).flags; @@ -363,7 +423,7 @@ maps.prototype._getBlockFilterFromFlag = function (floorId, x, y, flags) { if ((flags.__removed__ || []).indexOf(floorId) >= 0) return null; var index = x + y * core.floors[floorId].width; return core.clone((__filter__[floorId] || {})[index]); -} +}; ////// 设置某个点的不透明度 ////// maps.prototype.setBlockOpacity = function (opacity, x, y, floorId) { @@ -391,7 +451,7 @@ maps.prototype.setBlockOpacity = function (opacity, x, y, floorId) { } } } -} +}; maps.prototype.setBlockFilter = function (filter, x, y, floorId) { if (window.flags == null) return; @@ -404,7 +464,13 @@ maps.prototype.setBlockFilter = function (filter, x, y, floorId) { if (!__filter__[floorId]) __filter__[floorId] = {}; if (filter == null) delete __filter__[floorId][index]; else { - if (!filter.blur && !filter.hue && !filter.shadow && !filter.grayscale && !filter.invert) + if ( + !filter.blur && + !filter.hue && + !filter.shadow && + !filter.grayscale && + !filter.invert + ) delete __filter__[floorId][index]; else __filter__[floorId][index] = core.clone(filter); } @@ -422,7 +488,7 @@ maps.prototype.setBlockFilter = function (filter, x, y, floorId) { } } } -} +}; ////// 某个点图块是否被强制启用或禁用 maps.prototype.isMapBlockDisabled = function (floorId, x, y, flags) { @@ -436,7 +502,7 @@ maps.prototype.isMapBlockDisabled = function (floorId, x, y, flags) { if (!__disabled__[floorId]) return null; if (__disabled__[floorId][0].indexOf(index) >= 0) return true; if (__disabled__[floorId][1].indexOf(index) >= 0) return false; -} +}; ////// 设置某个点的图块强制启用/禁用状态 maps.prototype.setMapBlockDisabled = function (floorId, x, y, disabled) { @@ -448,12 +514,16 @@ maps.prototype.setMapBlockDisabled = function (floorId, x, y, disabled) { var __disabled__ = window.flags.__disabled__ || {}; if (!__disabled__[floorId]) __disabled__[floorId] = [[], []]; var index = x + y * core.floors[floorId].width; - __disabled__[floorId][0] = __disabled__[floorId][0].filter(function (x) { return x != index }); - __disabled__[floorId][1] = __disabled__[floorId][1].filter(function (x) { return x != index }); + __disabled__[floorId][0] = __disabled__[floorId][0].filter(function (x) { + return x != index; + }); + __disabled__[floorId][1] = __disabled__[floorId][1].filter(function (x) { + return x != index; + }); if (disabled == null) return; if (disabled) __disabled__[floorId][0].push(index); else __disabled__[floorId][1].push(index); -} +}; ////// 解压缩地图 maps.prototype.decompressMap = function (mapArr, floorId) { @@ -469,8 +539,7 @@ maps.prototype.decompressMap = function (mapArr, floorId) { } if (mapArr[x] === 0) { mapArr[x] = core.cloneArray(floorMap[x]); - } - else { + } else { for (var y = 0; y < mw; y++) { if (y >= mapArr[x].length) mapArr[x].push(-1); if (mapArr[x][y] === -1) { @@ -480,7 +549,7 @@ maps.prototype.decompressMap = function (mapArr, floorId) { } } return mapArr; -} +}; ////// 将当前地图重新变成数字,以便于存档 ////// maps.prototype.saveMap = function (floorId) { @@ -500,10 +569,20 @@ maps.prototype.saveMap = function (floorId) { var map = maps[floorId]; var thisFloor = this._compressFloorData(map, core.floors[floorId]); - var mapArr = this.compressMap(map.blocks ? this._getMapArrayFromBlocks(map.blocks, map.width, map.height, true) : map.map, floorId); + var mapArr = this.compressMap( + map.blocks + ? this._getMapArrayFromBlocks( + map.blocks, + map.width, + map.height, + true + ) + : map.map, + floorId + ); if (mapArr != null) thisFloor.map = mapArr; return thisFloor; -} +}; maps.prototype._compressFloorData = function (map, floor) { var thisFloor = {}; @@ -517,7 +596,7 @@ maps.prototype._compressFloorData = function (map, floor) { } } return thisFloor; -} +}; ////// 将存档中的地图信息重新读取出来 ////// maps.prototype.loadMap = function (data, floorId, flags) { @@ -525,14 +604,19 @@ maps.prototype.loadMap = function (data, floorId, flags) { var map = {}; core.floorIds.forEach(function (id) { if (core.inArray((flags || {}).__removed__, id)) { - data[id] = { deleted: true, canFlyTo: false, canFlyFrom: false, cannotViewMap: true }; + data[id] = { + deleted: true, + canFlyTo: false, + canFlyFrom: false, + cannotViewMap: true + }; } map[id] = core.maps.loadFloor(id, data[id]); - }) + }); return map; } return this.loadFloor(floorId, data[floorId]); -} +}; ////// 更改地图画布的尺寸 maps.prototype.resizeMap = function (floorId) { @@ -542,7 +626,8 @@ maps.prototype.resizeMap = function (floorId) { core.bigmap.height = core.floors[floorId].height; core.bigmap.posX = core.bigmap.posY = 0; - core.bigmap.v2 = core.bigmap.width * core.bigmap.height > core.bigmap.threshold; + core.bigmap.v2 = + core.bigmap.width * core.bigmap.height > core.bigmap.threshold; var width = core.bigmap.v2 ? core._PX_ + 64 : core.bigmap.width * 32; var height = core.bigmap.v2 ? core._PY_ + 64 : core.bigmap.height * 32; @@ -553,28 +638,38 @@ maps.prototype.resizeMap = function (floorId) { core.canvas[cn].canvas.width = width; core.canvas[cn].canvas.height = height; } - core.canvas[cn].canvas.style.width = width * core.domStyle.scale + "px"; - core.canvas[cn].canvas.style.height = height * core.domStyle.scale + "px"; - core.canvas[cn].translate(core.bigmap.v2 ? 32 : 0, core.bigmap.v2 ? 32 : 0); + core.canvas[cn].canvas.style.width = width * core.domStyle.scale + 'px'; + core.canvas[cn].canvas.style.height = + height * core.domStyle.scale + 'px'; + core.canvas[cn].translate( + core.bigmap.v2 ? 32 : 0, + core.bigmap.v2 ? 32 : 0 + ); if (main.mode === 'editor' && editor.isMobile) { - core.canvas[cn].canvas.style.width = width / core._PX_ * 96 + "vw"; - core.canvas[cn].canvas.style.height = height / core._PY_ * 96 + "vw"; + core.canvas[cn].canvas.style.width = + (width / core._PX_) * 96 + 'vw'; + core.canvas[cn].canvas.style.height = + (height / core._PY_) * 96 + 'vw'; } }); -} +}; ////// 将当前地图重新变成二维数组形式 ////// maps.prototype.getMapArray = function (floorId, noCache) { floorId = floorId || core.status.floorId; var map = core.status.maps[floorId]; if (!map.blocks || !noCache) return map.map; - return map.map = this._getMapArrayFromBlocks(map.blocks, map.width, map.height); -} + return (map.map = this._getMapArrayFromBlocks( + map.blocks, + map.width, + map.height + )); +}; ////// 获得地图上某点的数字 maps.prototype.getMapNumber = function (x, y, floorId, noCache) { return this.getMapArray(floorId, noCache)[y][x]; -} +}; maps.prototype._updateMapArray = function (floorId, x, y) { floorId = floorId || core.status.floorId; @@ -584,18 +679,22 @@ maps.prototype._updateMapArray = function (floorId, x, y) { var block = this.getBlock(x, y, floorId, true); if (block == null || block.disable) map.map[y][x] = 0; else map.map[y][x] = block.id; -} +}; -maps.prototype._getMapArrayFromBlocks = function (blockArray, width, height, showDisable) { +maps.prototype._getMapArrayFromBlocks = function ( + blockArray, + width, + height, + showDisable +) { var blocks = []; for (var x = 0; x < height; x++) blocks.push(Array(width).fill(0)); blockArray.forEach(function (block) { - if (showDisable || !block.disable) - blocks[block.y][block.x] = block.id; + if (showDisable || !block.disable) blocks[block.y][block.x] = block.id; }); return blocks; -} +}; ////// 以x,y的形式返回每个点的事件 ////// maps.prototype.getMapBlocksObj = function (floorId, noCache) { @@ -606,10 +705,10 @@ maps.prototype.getMapBlocksObj = function (floorId, noCache) { var obj = {}; core.extractBlocks(floorId); core.status.maps[floorId].blocks.forEach(function (block) { - obj[block.x + "," + block.y] = block; + obj[block.x + ',' + block.y] = block; }); - return core.status.mapBlockObjs[floorId] = obj; -} + return (core.status.mapBlockObjs[floorId] = obj); +}; ////// 将背景前景层变成二维数组的形式 ////// maps.prototype._getBgFgMapArray = function (name, floorId, noCache) { @@ -618,21 +717,28 @@ maps.prototype._getBgFgMapArray = function (name, floorId, noCache) { var width = core.floors[floorId].width; var height = core.floors[floorId].height; - if (!noCache && core.status[name + "maps"][floorId]) - return core.status[name + "maps"][floorId]; + if (!noCache && core.status[name + 'maps'][floorId]) + return core.status[name + 'maps'][floorId]; - var arr = (main.mode == 'editor' && !(window.editor && editor.uievent && editor.uievent.isOpen)) - ? core.cloneArray(editor[name + 'map']) : null; + var arr = + main.mode == 'editor' && + !(window.editor && editor.uievent && editor.uievent.isOpen) + ? core.cloneArray(editor[name + 'map']) + : null; if (arr == null) - arr = core.cloneArray(core.floors[floorId][name + "map"] || []); + arr = core.cloneArray(core.floors[floorId][name + 'map'] || []); for (var y = 0; y < height; ++y) { if (arr[y] == null) arr[y] = Array(width).fill(0); } - (core.getFlag('__' + name + 'v__', {})[floorId] || []).forEach(function (one) { + (core.getFlag('__' + name + 'v__', {})[floorId] || []).forEach(function ( + one + ) { arr[one[1]][one[0]] = one[2] || 0; }); - (core.getFlag('__' + name + 'd__', {})[floorId] || []).forEach(function (one) { + (core.getFlag('__' + name + 'd__', {})[floorId] || []).forEach(function ( + one + ) { arr[one[1]][one[0]] = 0; }); if (main.mode == 'editor') { @@ -642,32 +748,31 @@ maps.prototype._getBgFgMapArray = function (name, floorId, noCache) { } } } - if (core.status[name + "maps"]) - core.status[name + "maps"][floorId] = arr; + if (core.status[name + 'maps']) core.status[name + 'maps'][floorId] = arr; return arr; -} +}; maps.prototype.getBgMapArray = function (floorId) { return this._getBgFgMapArray('bg', floorId); -} +}; maps.prototype.getFgMapArray = function (floorId) { return this._getBgFgMapArray('fg', floorId); -} +}; maps.prototype._getBgFgNumber = function (name, x, y, floorId) { if (x == null) x = core.getHeroLoc('x'); if (y == null) y = core.getHeroLoc('y'); return this._getBgFgMapArray(name, floorId)[y][x]; -} +}; maps.prototype.getBgNumber = function (x, y, floorId) { return this._getBgFgNumber('bg', x, y, floorId); -} +}; maps.prototype.getFgNumber = function (x, y, floorId) { return this._getBgFgNumber('fg', x, y, floorId); -} +}; // ------ 当前能否朝某方向移动,能否瞬间移动 ------ // @@ -677,26 +782,45 @@ maps.prototype.generateMovableArray = function (floorId) { if (!floorId) return null; var arrays = this._generateMovableArray_arrays(floorId); - var width = core.floors[floorId].width, height = core.floors[floorId].height; + var width = core.floors[floorId].width, + height = core.floors[floorId].height; var array = []; for (var x = 0; x < width; ++x) { array[x] = Array(height).fill([]); } var v2 = floorId == core.status.floorId && core.bigmap.v2; var startX = v2 ? Math.max(0, core.bigmap.posX - core.bigmap.extend) : 0; - var endX = v2 ? Math.min(width, core.bigmap.posX + core._WIDTH_ + core.bigmap.extend + 1) : width; + var endX = v2 + ? Math.min( + width, + core.bigmap.posX + core._WIDTH_ + core.bigmap.extend + 1 + ) + : width; var startY = v2 ? Math.max(0, core.bigmap.posY - core.bigmap.extend) : 0; - var endY = v2 ? Math.min(height, core.bigmap.posY + core._HEIGHT_ + core.bigmap.extend + 1) : height; + var endY = v2 + ? Math.min( + height, + core.bigmap.posY + core._HEIGHT_ + core.bigmap.extend + 1 + ) + : height; for (var x = startX; x < endX; x++) { for (var y = startY; y < endY; y++) { - array[x][y] = ["left", "down", "up", "right"].filter(function (direction) { - return core.maps._canMoveHero_checkPoint(x, y, direction, floorId, arrays); + array[x][y] = ['left', 'down', 'up', 'right'].filter(function ( + direction + ) { + return core.maps._canMoveHero_checkPoint( + x, + y, + direction, + floorId, + arrays + ); }); } } return array; -} +}; maps.prototype._generateMovableArray_arrays = function (floorId) { return { @@ -704,7 +828,7 @@ maps.prototype._generateMovableArray_arrays = function (floorId) { fgArray: this.getFgMapArray(floorId), eventArray: this.getMapArray(floorId) }; -} +}; ////// 勇士能否前往某方向 ////// maps.prototype.canMoveHero = function (x, y, direction, floorId) { @@ -712,40 +836,88 @@ maps.prototype.canMoveHero = function (x, y, direction, floorId) { if (y == null) y = core.getHeroLoc('y'); direction = direction || core.getHeroLoc('direction'); return this._canMoveHero_checkPoint(x, y, direction, floorId); -} +}; -maps.prototype._canMoveHero_checkPoint = function (x, y, direction, floorId, arrays) { +maps.prototype._canMoveHero_checkPoint = function ( + x, + y, + direction, + floorId, + arrays +) { floorId = floorId || core.status.floorId; if (!floorId) return false; arrays = arrays || this._generateMovableArray_arrays(floorId); // 1. 检查该点 cannotMove - if (core.inArray((core.floors[floorId].cannotMove || {})[x + "," + y], direction)) + if ( + core.inArray( + (core.floors[floorId].cannotMove || {})[x + ',' + y], + direction + ) + ) return false; - var nx = x + core.utils.scan[direction].x, ny = y + core.utils.scan[direction].y; - if (nx < 0 || ny < 0 || nx >= core.floors[floorId].width || ny >= core.floors[floorId].height) + var nx = x + core.utils.scan[direction].x, + ny = y + core.utils.scan[direction].y; + if ( + nx < 0 || + ny < 0 || + nx >= core.floors[floorId].width || + ny >= core.floors[floorId].height + ) return false; // 2. 检查下个点的 cannotMoveIn - if (core.inArray((core.floors[floorId].cannotMoveIn || {})[nx + "," + ny], core.turnDirection(":back", direction))) + if ( + core.inArray( + (core.floors[floorId].cannotMoveIn || {})[nx + ',' + ny], + core.turnDirection(':back', direction) + ) + ) return false; // 3. 检查该点素材的 cannotOut 和下一个点的 cannotIn - if (this._canMoveHero_checkCannotInOut(Object.keys(arrays).map(function (name) { return arrays[name][y][x]; }), "cannotOut", direction)) + if ( + this._canMoveHero_checkCannotInOut( + Object.keys(arrays).map(function (name) { + return arrays[name][y][x]; + }), + 'cannotOut', + direction + ) + ) return false; - if (this._canMoveHero_checkCannotInOut(Object.keys(arrays).map(function (name) { return arrays[name][ny][nx]; }), "cannotIn", direction)) + if ( + this._canMoveHero_checkCannotInOut( + Object.keys(arrays).map(function (name) { + return arrays[name][ny][nx]; + }), + 'cannotIn', + direction + ) + ) return false; // 4. 检查是否能进将死的领域 - if (floorId == core.status.floorId && !core.flags.canGoDeadZone && !core.status.lockControl && - Math.max(core.status.hero.hp, 1) <= ((core.status.checkBlock.damage || {})[nx + "," + ny] || 0) && arrays.eventArray[ny][nx] == 0) + if ( + floorId == core.status.floorId && + !core.flags.canGoDeadZone && + !core.status.lockControl && + Math.max(core.status.hero.hp, 1) <= + ((core.status.checkBlock.damage || {})[nx + ',' + ny] || 0) && + arrays.eventArray[ny][nx] == 0 + ) return false; return true; -} +}; -maps.prototype._canMoveHero_checkCannotInOut = function (number, name, direction) { +maps.prototype._canMoveHero_checkCannotInOut = function ( + number, + name, + direction +) { if (number instanceof Array) { for (var x in number) { if (this._canMoveHero_checkCannotInOut(number[x], name, direction)) @@ -753,19 +925,24 @@ maps.prototype._canMoveHero_checkCannotInOut = function (number, name, direction } return false; } - if (name == 'cannotIn') direction = core.turnDirection(":back", direction); - return core.inArray((this.getBlockByNumber(number).event || {})[name], direction); -} + if (name == 'cannotIn') direction = core.turnDirection(':back', direction); + return core.inArray( + (this.getBlockByNumber(number).event || {})[name], + direction + ); +}; ////// 能否瞬间移动 ////// maps.prototype.canMoveDirectly = function (destX, destY) { return this.canMoveDirectlyArray([[destX, destY]])[0]; -} +}; maps.prototype.canMoveDirectlyArray = function (locs, canMoveArray) { - var ans = [], number = locs.length; + var ans = [], + number = locs.length; - var fromX = core.getHeroLoc('x'), fromY = core.getHeroLoc('y'); + var fromX = core.getHeroLoc('x'), + fromY = core.getHeroLoc('y'); if (!this._canMoveDirectly_checkGlobal()) { for (var i = 0; i < number; ++i) ans.push(-1); return ans; @@ -774,12 +951,15 @@ maps.prototype.canMoveDirectlyArray = function (locs, canMoveArray) { if (locs[i][0] == fromX && locs[i][1] == fromY) { ans.push(0); number--; - } - else if (locs[i][0] < 0 || locs[i][0] >= core.bigmap.width || locs[i][1] < 0 || locs[i][1] >= core.bigmap.height) { + } else if ( + locs[i][0] < 0 || + locs[i][0] >= core.bigmap.width || + locs[i][1] < 0 || + locs[i][1] >= core.bigmap.height + ) { ans.push(-1); number--; - } - else ans.push(null); + } else ans.push(null); } if (number == 0) return ans; @@ -791,8 +971,15 @@ maps.prototype.canMoveDirectlyArray = function (locs, canMoveArray) { return ans; } - return this._canMoveDirectly_bfs(fromX, fromY, locs, number, ans, canMoveArray); -} + return this._canMoveDirectly_bfs( + fromX, + fromY, + locs, + number, + ans, + canMoveArray + ); +}; maps.prototype._canMoveDirectly_checkGlobal = function () { // 检查全塔是否禁止瞬间移动 @@ -803,42 +990,55 @@ maps.prototype._canMoveDirectly_checkGlobal = function () { if (core.hasFlag('cannotMoveDirectly')) return false; return true; -} +}; maps.prototype._canMoveDirectly_checkStartPoint = function (sx, sy) { - if (core.status.checkBlock.damage[sx + "," + sy]) return false; + if (core.status.checkBlock.damage[sx + ',' + sy]) return false; var block = core.getBlock(sx, sy); if (block != null) { // 只有起点是传送点才是能无视 return block.event.trigger == 'changeFloor'; } return true; -} +}; -maps.prototype._canMoveDirectly_bfs = function (sx, sy, locs, number, ans, canMoveArray) { +maps.prototype._canMoveDirectly_bfs = function ( + sx, + sy, + locs, + number, + ans, + canMoveArray +) { canMoveArray = canMoveArray || this.generateMovableArray(); var blocksObj = this.getMapBlocksObj(); // 滑冰 var bgMap = this.getBgMapArray(); - var visited = [], queue = []; - visited[sx + "," + sy] = 0; - queue.push(sx + "," + sy); + var visited = [], + queue = []; + visited[sx + ',' + sy] = 0; + queue.push(sx + ',' + sy); while (queue.length > 0) { - var now = queue.shift().split(","), x = parseInt(now[0]), y = parseInt(now[1]); + var now = queue.shift().split(','), + x = parseInt(now[0]), + y = parseInt(now[1]); for (var direction in core.utils.scan) { if (!core.inArray(canMoveArray[x][y], direction)) continue; - var nx = x + core.utils.scan[direction].x, ny = y + core.utils.scan[direction].y, nindex = nx + "," + ny; + var nx = x + core.utils.scan[direction].x, + ny = y + core.utils.scan[direction].y, + nindex = nx + ',' + ny; if (visited[nindex]) continue; if (core.onSki(bgMap[ny][nx])) continue; - if (!this._canMoveDirectly_checkNextPoint(blocksObj, nx, ny)) continue; + if (!this._canMoveDirectly_checkNextPoint(blocksObj, nx, ny)) + continue; visited[nindex] = visited[now] + 1; // if (nx == ex && ny == ey) return visited[nindex]; for (var i in ans) { if (locs[i][0] == nx && locs[i][1] == ny && ans[i] == null) { // 不可以绿点为终点 - var block = blocksObj[nx + "," + ny]; + var block = blocksObj[nx + ',' + ny]; if (block && !block.disable && block.event.trigger) { ans[i] = -1; } else { @@ -856,13 +1056,17 @@ maps.prototype._canMoveDirectly_bfs = function (sx, sy, locs, number, ans, canMo if (ans[i] == null) ans[i] = -1; } return ans; -} +}; maps.prototype._canMoveDirectly_checkNextPoint = function (blocksObj, x, y) { - var index = x + "," + y; + var index = x + ',' + y; var block = blocksObj[index]; // 该点是否不可通行或有脚本 - if (block && !block.disable && (block.event.noPass || block.event.script || block.event.event)) + if ( + block && + !block.disable && + (block.event.noPass || block.event.script || block.event.event) + ) return false; // 该点是否是绿点可触发 if (block && !block.disable && block.event.trigger) { @@ -879,87 +1083,116 @@ maps.prototype._canMoveDirectly_checkNextPoint = function (blocksObj, x, y) { if (core.status.checkBlock.ambush[index]) return false; return true; -} +}; ////// 自动寻路找寻最优路径 ////// maps.prototype.automaticRoute = function (destX, destY) { - var startX = core.getHeroLoc('x'), startY = core.getHeroLoc('y'); + var startX = core.getHeroLoc('x'), + startY = core.getHeroLoc('y'); if (destX == startX && destY == startY) return []; // BFS找寻最短路径 var route = this._automaticRoute_bfs(startX, startY, destX, destY); - if (route[destX + "," + destY] == null) return []; + if (route[destX + ',' + destY] == null) return []; // 路径数组转换 - var ans = [], nowX = destX, nowY = destY; + var ans = [], + nowX = destX, + nowY = destY; while (nowX != startX || nowY != startY) { - var dir = route[nowX + "," + nowY]; - ans.push({ 'direction': dir, 'x': nowX, 'y': nowY }); + var dir = route[nowX + ',' + nowY]; + ans.push({ direction: dir, x: nowX, y: nowY }); nowX -= core.utils.scan[dir].x; nowY -= core.utils.scan[dir].y; } ans.reverse(); return ans; -} +}; maps.prototype._automaticRoute_bfs = function (startX, startY, destX, destY) { - var route = {}, canMoveArray = this.generateMovableArray(); + var route = {}, + canMoveArray = this.generateMovableArray(); // 使用优先队列 - var queue = new PriorityQueue({ comparator: function (a, b) { return a.depth - b.depth; } }); - route[startX + "," + startY] = ''; + var queue = new PriorityQueue({ + comparator: function (a, b) { + return a.depth - b.depth; + } + }); + route[startX + ',' + startY] = ''; queue.queue({ depth: 0, x: startX, y: startY }); var blocks = core.getMapBlocksObj(); while (queue.length != 0) { - var curr = queue.dequeue(), deep = curr.depth, nowX = curr.x, nowY = curr.y; + var curr = queue.dequeue(), + deep = curr.depth, + nowX = curr.x, + nowY = curr.y; for (var direction in core.utils.scan) { if (!core.inArray(canMoveArray[nowX][nowY], direction)) continue; var nx = nowX + core.utils.scan[direction].x; var ny = nowY + core.utils.scan[direction].y; - if (nx < 0 || nx >= core.bigmap.width || ny < 0 || ny >= core.bigmap.height || route[nx + "," + ny] != null) continue; + if ( + nx < 0 || + nx >= core.bigmap.width || + ny < 0 || + ny >= core.bigmap.height || + route[nx + ',' + ny] != null + ) + continue; // 重点 if (nx == destX && ny == destY) { - route[nx + "," + ny] = direction; + route[nx + ',' + ny] = direction; break; } // 不可通行 if (core.noPass(nx, ny)) continue; - route[nx + "," + ny] = direction; - queue.queue({ depth: deep + this._automaticRoute_deepAdd(nx, ny, blocks), x: nx, y: ny }); + route[nx + ',' + ny] = direction; + queue.queue({ + depth: deep + this._automaticRoute_deepAdd(nx, ny, blocks), + x: nx, + y: ny + }); } - if (route[destX + "," + destY] != null) break; + if (route[destX + ',' + destY] != null) break; } return route; -} +}; maps.prototype._automaticRoute_deepAdd = function (x, y, blocks) { // 判定每个可通行点的损耗值,越高越应该绕路 var deepAdd = 1; - var block = blocks[x + "," + y]; + var block = blocks[x + ',' + y]; if (block && !block.disable) { var id = block.event.id; // 绕过亮灯 - if (id == "light") deepAdd += 100; + if (id == 'light') deepAdd += 100; // 绕过路障 - if (id.endsWith("Net") && !core.hasFlag(id.substring(0, id.length - 3))) deepAdd += 100; + if (id.endsWith('Net') && !core.hasFlag(id.substring(0, id.length - 3))) + deepAdd += 100; // 绕过血瓶和绿宝石 - if (core.hasFlag('__potionNoRouting__') && (id.endsWith("Potion") || id == 'greenGem')) deepAdd += 100; + if ( + core.hasFlag('__potionNoRouting__') && + (id.endsWith('Potion') || id == 'greenGem') + ) + deepAdd += 100; // 绕过传送点 // if (block.event.trigger == 'changeFloor') deepAdd+=10; } // 绕过存在伤害的地方 - deepAdd += (core.status.checkBlock.damage[x + "," + y] || 0) * 100; + deepAdd += (core.status.checkBlock.damage[x + ',' + y] || 0) * 100; // 绕过捕捉 - if (core.status.checkBlock.ambush[x + "," + y]) deepAdd += 1000; + if (core.status.checkBlock.ambush[x + ',' + y]) deepAdd += 1000; return deepAdd; -} +}; // -------- 绘制地图,各层图块,楼层贴图,Autotile -------- // maps.prototype._getBigImageInfo = function (bigImage, face, animate) { - face = face || "down"; - if (["up", "down", "left", "right"].indexOf(face) < 0) face = "down"; + face = face || 'down'; + if (['up', 'down', 'left', 'right'].indexOf(face) < 0) face = 'down'; var per_width = bigImage.width / 4; var per_height = bigImage.height / 4; - var sx = animate * per_width, sy; - if (per_height <= per_width / 2) { // 强制视为 1*4 的怪物 + var sx = animate * per_width, + sy; + if (per_height <= per_width / 2) { + // 强制视为 1*4 的怪物 per_height = bigImage.height; sy = 0; } else { @@ -967,50 +1200,83 @@ maps.prototype._getBigImageInfo = function (bigImage, face, animate) { } var dx, dy; switch (face) { - case "down": case "up": case "left": case "right": dx = 16 - per_width / 2; dy = 32 - per_height; break; + case 'down': + case 'up': + case 'left': + case 'right': + dx = 16 - per_width / 2; + dy = 32 - per_height; + break; // case "left": dx = 0; dy = 32 - per_height; break; // case "right": dx = 32 - per_width; dy = 32 - per_height; break; } - return { sx: sx, sy: sy, per_width: per_width, per_height: per_height, face: face, dx: dx, dy: dy }; -} + return { + sx: sx, + sy: sy, + per_width: per_width, + per_height: per_height, + face: face, + dx: dx, + dy: dy + }; +}; ////// 绘制一个图块 ////// maps.prototype.drawBlock = function (block, animate, ctx) { if (block.event.id == 'none') return; var redraw = animate != null; if (!redraw) animate = 0; - var x = block.x, y = block.y; + var x = block.x, + y = block.y; // --- 在界面外的动画不绘制 // 判定是否绘制 if (core.bigmap.v2) { - var posX = core.bigmap.posX, posY = core.bigmap.posY; - if (x < posX - 1 || y < posY - 1 || x > posX + core._WIDTH_ || y > posY + core._HEIGHT_ + 1) { // +1 for 48 height + var posX = core.bigmap.posX, + posY = core.bigmap.posY; + if ( + x < posX - 1 || + y < posY - 1 || + x > posX + core._WIDTH_ || + y > posY + core._HEIGHT_ + 1 + ) { + // +1 for 48 height return; } } else { - if (redraw && block.event.animate > 1 && - (32 * x < core.bigmap.offsetX - 64 || 32 * x > core.bigmap.offsetX + core._PX_ + 32 - || 32 * y < core.bigmap.offsetY - 64 || 32 * y > core.bigmap.offsetY + core._PY_ + 32 + 16)) { + if ( + redraw && + block.event.animate > 1 && + (32 * x < core.bigmap.offsetX - 64 || + 32 * x > core.bigmap.offsetX + core._PX_ + 32 || + 32 * y < core.bigmap.offsetY - 64 || + 32 * y > core.bigmap.offsetY + core._PY_ + 32 + 16) + ) { return; } } var blockInfo = this.getBlockInfo(block); if (blockInfo == null) return; - if (blockInfo.cls != 'tileset') blockInfo.posX = animate % blockInfo.animate; + if (blockInfo.cls != 'tileset') + blockInfo.posX = animate % blockInfo.animate; blockInfo.opacity = block.opacity; blockInfo.filter = block.filter; - if (!block.name) - this._drawBlockInfo(blockInfo, block.x, block.y, ctx); - else - this._drawBlockInfo_bgfg(blockInfo, block.name, block.x, block.y, ctx); -} + if (!block.name) this._drawBlockInfo(blockInfo, block.x, block.y, ctx); + else this._drawBlockInfo_bgfg(blockInfo, block.name, block.x, block.y, ctx); +}; maps.prototype._drawBlockInfo_bigImage = function (blockInfo, x, y, ctx) { - var bigImageInfo = this._getBigImageInfo(blockInfo.bigImage, blockInfo.face, blockInfo.posX); - var per_width = bigImageInfo.per_width, per_height = bigImageInfo.per_height, sx = bigImageInfo.sx, sy = bigImageInfo.sy; + var bigImageInfo = this._getBigImageInfo( + blockInfo.bigImage, + blockInfo.face, + blockInfo.posX + ); + var per_width = bigImageInfo.per_width, + per_height = bigImageInfo.per_height, + sx = bigImageInfo.sx, + sy = bigImageInfo.sy; var bigImage = blockInfo.bigImage; if (main.mode == 'editor') { @@ -1018,7 +1284,18 @@ maps.prototype._drawBlockInfo_bigImage = function (blockInfo, x, y, ctx) { var py = 32 * y - 32 * core.bigmap.posY; if (ctx == null) ctx = 'event'; core.clearMap(ctx, px, py, 32, 32); - core.drawImage(ctx, bigImage, sx, sy, per_width, per_height, px, py, 32, 32); + core.drawImage( + ctx, + bigImage, + sx, + sy, + per_width, + per_height, + px, + py, + 32, + 32 + ); return; } @@ -1026,21 +1303,47 @@ maps.prototype._drawBlockInfo_bigImage = function (blockInfo, x, y, ctx) { var py = 32 * y - core.bigmap.offsetY; // 上半部分 - 会遮挡勇士;z值高于event2,为51 - var header = "_bigImage_header_" + x + "_" + y; + var header = '_bigImage_header_' + x + '_' + y; // 下半部分 - 会被勇士遮挡;z值高于event,为31 - var body = "_bigImage_body_" + x + "_" + y; - var dx = bigImageInfo.dx, dy = bigImageInfo.dy; + var body = '_bigImage_body_' + x + '_' + y; + var dx = bigImageInfo.dx, + dy = bigImageInfo.dy; switch (bigImageInfo.face) { - case "down": case "up": case "left": case "right": + case 'down': + case 'up': + case 'left': + case 'right': core.createCanvas(header, px + dx, py + dy, per_width, -dy, 51); this._drawBlockInfo_drawWithFilter(blockInfo, header, function () { - core.drawImage(header, bigImage, sx, sy, per_width, -dy, 0, 0, per_width, -dy); + core.drawImage( + header, + bigImage, + sx, + sy, + per_width, + -dy, + 0, + 0, + per_width, + -dy + ); }); core.createCanvas(body, px + dx, py, per_width, 32, 31); this._drawBlockInfo_drawWithFilter(blockInfo, body, function () { - core.drawImage(body, bigImage, sx, sy - dy, per_width, 32, 0, 0, per_width, 32); - }) + core.drawImage( + body, + bigImage, + sx, + sy - dy, + per_width, + 32, + 0, + 0, + per_width, + 32 + ); + }); break; /*case "left": core.createCanvas(header, px + dx, py + dy, per_width, -dy, 51); @@ -1071,39 +1374,69 @@ maps.prototype._drawBlockInfo_bigImage = function (blockInfo, x, y, ctx) { core.dymCanvas[body].canvas.setAttribute('_ox', 32 * x + dx); core.dymCanvas[body].canvas.setAttribute('_oy', 32 * y); } -} +}; maps.prototype._drawBlockInfo_drawWithFilter = function (blockInfo, ctx, func) { var alpha = null; - if (blockInfo.opacity != null) alpha = core.setAlpha(ctx, blockInfo.opacity); + if (blockInfo.opacity != null) + alpha = core.setAlpha(ctx, blockInfo.opacity); core.setFilter(ctx, blockInfo.filter); func(); core.setFilter(ctx, null); if (alpha != null) core.setAlpha(ctx, alpha); -} +}; maps.prototype._drawBlockInfo = function (blockInfo, x, y, ctx) { - if (blockInfo.bigImage) return this._drawBlockInfo_bigImage(blockInfo, x, y, ctx); + if (blockInfo.bigImage) + return this._drawBlockInfo_bigImage(blockInfo, x, y, ctx); - var image = blockInfo.image, posX = blockInfo.posX, posY = blockInfo.posY, height = blockInfo.height; + var image = blockInfo.image, + posX = blockInfo.posX, + posY = blockInfo.posY, + height = blockInfo.height; var px = 32 * x - 32 * core.bigmap.posX; var py = 32 * y - 32 * core.bigmap.posY; if (ctx == null) ctx = 'event'; this._drawBlockInfo_drawWithFilter(blockInfo, ctx, function () { core.clearMap(ctx, px, py, 32, 32); - core.drawImage(ctx, image, posX * 32, posY * height + height - 32, 32, 32, px, py, 32, 32); + core.drawImage( + ctx, + image, + posX * 32, + posY * height + height - 32, + 32, + 32, + px, + py, + 32, + 32 + ); }); if (height > 32) { this._drawBlockInfo_drawWithFilter(blockInfo, 'event2', function () { core.clearMap('event2', px, py + 32 - height, 32, height - 32); - core.drawImage('event2', image, posX * 32, posY * height, 32, height - 32, px, py + 32 - height, 32, height - 32); + core.drawImage( + 'event2', + image, + posX * 32, + posY * height, + 32, + height - 32, + px, + py + 32 - height, + 32, + height - 32 + ); }); } -} +}; maps.prototype._drawBlockInfo_bgfg = function (blockInfo, name, x, y, ctx) { - var image = blockInfo.image, posX = blockInfo.posX, posY = blockInfo.posY, height = blockInfo.height; + var image = blockInfo.image, + posX = blockInfo.posX, + posY = blockInfo.posY, + height = blockInfo.height; var px = 32 * x - 32 * core.bigmap.posX; var py = 32 * y - 32 * core.bigmap.posY; if (ctx == null) ctx = name; @@ -1117,35 +1450,66 @@ maps.prototype._drawBlockInfo_bgfg = function (blockInfo, name, x, y, ctx) { core.drawImage(ctx, core.material.groundCanvas.canvas, px, py); } var alpha = null; - if (blockInfo.opacity != null) alpha = core.setAlpha(ctx, blockInfo.opacity); - else if (name == 'fg' && this._drawBlockInfo_shouldBlurFg(x, y)) alpha = core.setAlpha(ctx, 0.6); + if (blockInfo.opacity != null) + alpha = core.setAlpha(ctx, blockInfo.opacity); + else if (name == 'fg' && this._drawBlockInfo_shouldBlurFg(x, y)) + alpha = core.setAlpha(ctx, 0.6); core.setFilter(ctx, blockInfo.filter); - core.drawImage(ctx, image, posX * 32, posY * height, 32, height, px, py + 32 - height, 32, height); + core.drawImage( + ctx, + image, + posX * 32, + posY * height, + 32, + height, + px, + py + 32 - height, + 32, + height + ); core.setFilter(ctx, null); if (alpha != null) core.setAlpha(ctx, alpha); -} +}; ////// 是否应当存在事件时虚化前景层 ////// maps.prototype._drawBlockInfo_shouldBlurFg = function (x, y) { if (main.mode == 'play' && !core.flags.blurFg) return false; var block = this.getBlock(x, y); if (block == null || block.id == 0) return false; - if (block.event.cls == 'autotile' || block.event.cls == 'tileset') return block.event.script || block.event.event; + if (block.event.cls == 'autotile' || block.event.cls == 'tileset') + return block.event.script || block.event.event; return true; -} +}; ////// 生成groundPattern ////// maps.prototype.generateGroundPattern = function (floorId) { // 生成floorId层的groundPattern(盒子内的怪物动画) - var groundId = ((core.status.maps || core.floors)[floorId || core.status.floorId] || {}).defaultGround || "ground"; + var groundId = + ( + (core.status.maps || core.floors)[floorId || core.status.floorId] || + {} + ).defaultGround || 'ground'; var groundInfo = core.getBlockInfo(groundId); if (groundInfo == null) return; core.material.groundCanvas.clearRect(0, 0, 32, 32); - core.material.groundCanvas.drawImage(groundInfo.image, 32 * groundInfo.posX, groundInfo.height * groundInfo.posY, 32, 32, 0, 0, 32, 32); - core.material.groundPattern = core.material.groundCanvas.createPattern(core.material.groundCanvas.canvas, 'repeat'); + core.material.groundCanvas.drawImage( + groundInfo.image, + 32 * groundInfo.posX, + groundInfo.height * groundInfo.posY, + 32, + 32, + 0, + 0, + 32, + 32 + ); + core.material.groundPattern = core.material.groundCanvas.createPattern( + core.material.groundCanvas.canvas, + 'repeat' + ); // 如果需要用纯色可以直接将下面代码改成改成 // core.material.groundPattern = '#000000'; -} +}; ////// 绘制某张地图 ////// maps.prototype.drawMap = function (floorId) { @@ -1159,11 +1523,18 @@ maps.prototype.drawMap = function (floorId) { this._drawMap_drawAll(); if (core.status.curtainColor) { - core.fillRect('curtain', 0, 0, core._PX_, core._PY_, core.arrayToRGBA(core.status.curtainColor)); + core.fillRect( + 'curtain', + 0, + 0, + core._PX_, + core._PY_, + core.arrayToRGBA(core.status.curtainColor) + ); } core.drawHero(); core.updateStatusBar(); -} +}; ////// 重绘某张地图 ////// maps.prototype.redrawMap = function () { @@ -1172,27 +1543,41 @@ maps.prototype.redrawMap = function () { }); this._drawMap_drawAll(null, { redraw: true }); core.drawDamage(); -} +}; maps.prototype._drawMap_drawAll = function (floorId, config) { floorId = floorId || core.status.floorId; this.drawBg(floorId, config); this.drawEvents(floorId); this.drawFg(floorId, config); -} +}; -maps.prototype._drawMap_drawBlockInfo = function (ctx, block, blockInfo, arr, config) { +maps.prototype._drawMap_drawBlockInfo = function ( + ctx, + block, + blockInfo, + arr, + config +) { if (blockInfo == null) return; var onMap = config.onMap; if (onMap && core.bigmap.v2) { // 判定是否绘制 - var posX = core.bigmap.posX, posY = core.bigmap.posY; - if (block.x < posX - 1 || block.y < posY - 1 || block.x > posX + core._WIDTH_ || block.y > posY + core._HEIGHT_ + 1) { // +1 for 48 height + var posX = core.bigmap.posX, + posY = core.bigmap.posY; + if ( + block.x < posX - 1 || + block.y < posY - 1 || + block.x > posX + core._WIDTH_ || + block.y > posY + core._HEIGHT_ + 1 + ) { + // +1 for 48 height return; } } - if (blockInfo.cls == 'autotile') { // Autotile单独处理 + if (blockInfo.cls == 'autotile') { + // Autotile单独处理 var alpha = null; if (block.opacity != null) alpha = core.setAlpha(ctx, block.opacity); core.setFilter(ctx, block.filter); @@ -1206,23 +1591,53 @@ maps.prototype._drawMap_drawBlockInfo = function (ctx, block, blockInfo, arr, co var height = blockInfo.height; if (blockInfo.bigImage) { config.postDraw.push(function () { - var bigImageInfo = core.maps._getBigImageInfo(blockInfo.bigImage, blockInfo.face, 0); - var per_width = bigImageInfo.per_width, per_height = bigImageInfo.per_height; - core.maps._drawBlockInfo_drawWithFilter(block, ctx, function () { - core.drawImage(ctx, blockInfo.bigImage, bigImageInfo.sx, bigImageInfo.sy, per_width, per_height, - 32 * block.x + bigImageInfo.dx, 32 * block.y + bigImageInfo.dy, per_width, per_height); - }); + var bigImageInfo = core.maps._getBigImageInfo( + blockInfo.bigImage, + blockInfo.face, + 0 + ); + var per_width = bigImageInfo.per_width, + per_height = bigImageInfo.per_height; + core.maps._drawBlockInfo_drawWithFilter( + block, + ctx, + function () { + core.drawImage( + ctx, + blockInfo.bigImage, + bigImageInfo.sx, + bigImageInfo.sy, + per_width, + per_height, + 32 * block.x + bigImageInfo.dx, + 32 * block.y + bigImageInfo.dy, + per_width, + per_height + ); + } + ); }); return; } this._drawBlockInfo_drawWithFilter(block, ctx, function () { - core.drawImage(ctx, blockInfo.image, 32 * blockInfo.posX, height * blockInfo.posY, 32, height, 32 * block.x, 32 * block.y + 32 - height, 32, height); + core.drawImage( + ctx, + blockInfo.image, + 32 * blockInfo.posX, + height * blockInfo.posY, + 32, + height, + 32 * block.x, + 32 * block.y + 32 - height, + 32, + height + ); }); return; } this.drawBlock(block, null, ctx); this.addGlobalAnimate(block); -} +}; ////// 绘制背景层 ////// // config:绘制的参数,可包含如下项: @@ -1250,35 +1665,73 @@ maps.prototype.drawBg = function (floorId, config) { } this._drawBg_draw(floorId, toDrawCtx, cacheCtx, config); if (config.onMap) cacheCtx.translate(0, 0); -} +}; maps.prototype._drawBg_draw = function (floorId, toDrawCtx, cacheCtx, config) { config.ctx = cacheCtx; core.maps._drawBg_drawBackground(floorId, config); // ------ 调整这两行的顺序来控制是先绘制贴图还是先绘制背景图块;后绘制的覆盖先绘制的。 - core.maps._drawFloorImages(floorId, config.ctx, 'bg', null, null, config.onMap); + core.maps._drawFloorImages( + floorId, + config.ctx, + 'bg', + null, + null, + config.onMap + ); core.maps._drawBgFgMap(floorId, 'bg', config); - if (config.onMap) core.drawImage(toDrawCtx, cacheCtx.canvas, core.bigmap.v2 ? -32 : 0, core.bigmap.v2 ? -32 : 0); + if (config.onMap) + core.drawImage( + toDrawCtx, + cacheCtx.canvas, + core.bigmap.v2 ? -32 : 0, + core.bigmap.v2 ? -32 : 0 + ); config.ctx = toDrawCtx; -} +}; maps.prototype._drawBg_drawBackground = function (floorId, config) { - var groundId = (core.status.maps || core.floors)[floorId].defaultGround || "ground"; + var groundId = + (core.status.maps || core.floors)[floorId].defaultGround || 'ground'; var groundInfo = core.getBlockInfo(groundId); var onMap = config.onMap; if (groundInfo != null) { var start = onMap && core.bigmap.v2 ? -1 : 0; - var endX = onMap && core.bigmap.v2 ? core._WIDTH_ + 1 : core.floors[floorId].width; - var endY = onMap && core.bigmap.v2 ? core._HEIGHT_ + 1 : core.floors[floorId].height; + var endX = + onMap && core.bigmap.v2 + ? core._WIDTH_ + 1 + : core.floors[floorId].width; + var endY = + onMap && core.bigmap.v2 + ? core._HEIGHT_ + 1 + : core.floors[floorId].height; var patternCanvas = document.createElement('canvas'); patternCanvas.width = patternCanvas.height = 32; var patternCtx = patternCanvas.getContext('2d'); - core.drawImage(patternCtx, groundInfo.image, 32 * groundInfo.posX, groundInfo.height * groundInfo.posY, 32, 32, 0, 0, 32, 32) + core.drawImage( + patternCtx, + groundInfo.image, + 32 * groundInfo.posX, + groundInfo.height * groundInfo.posY, + 32, + 32, + 0, + 0, + 32, + 32 + ); - core.fillRect(config.ctx, 32 * start, 32 * start, 32 * (endX - start), 32 * (endY - start), patternCtx.createPattern(patternCanvas, 'repeat')); + core.fillRect( + config.ctx, + 32 * start, + 32 * start, + 32 * (endX - start), + 32 * (endY - start), + patternCtx.createPattern(patternCanvas, 'repeat') + ); } -} +}; ////// 绘制事件层 ////// maps.prototype.drawEvents = function (floorId, blocks, config) { @@ -1307,32 +1760,58 @@ maps.prototype.drawEvents = function (floorId, blocks, config) { if (!blocks) { core.extractBlocks(floorId); blocks = core.status.maps[floorId].blocks; - arr = this.getMapArray(floorId, !config.redraw) + arr = this.getMapArray(floorId, !config.redraw); } else { - arr = this._getMapArrayFromBlocks(blocks, core.floors[floorId].width, core.floors[floorId].height); + arr = this._getMapArrayFromBlocks( + blocks, + core.floors[floorId].width, + core.floors[floorId].height + ); } config.postDraw = []; - blocks.filter(function (block) { - if (config.onMap && core.bigmap.v2) { - // 判定是否绘制 - var posX = core.bigmap.posX, posY = core.bigmap.posY; - if (block.x < posX - 1 || block.y < posY - 1 || block.x > posX + core._WIDTH_ || block.y > posY + core._HEIGHT_ + 1) { // +1 for 48 height - return false; + blocks + .filter(function (block) { + if (config.onMap && core.bigmap.v2) { + // 判定是否绘制 + var posX = core.bigmap.posX, + posY = core.bigmap.posY; + if ( + block.x < posX - 1 || + block.y < posY - 1 || + block.x > posX + core._WIDTH_ || + block.y > posY + core._HEIGHT_ + 1 + ) { + // +1 for 48 height + return false; + } } - } - return block.event && !block.disable; - }).forEach(function (block) { - core.maps._drawMap_drawBlockInfo(cacheCtx, block, core.maps.getBlockInfo(block), arr, config); + return block.event && !block.disable; + }) + .forEach(function (block) { + core.maps._drawMap_drawBlockInfo( + cacheCtx, + block, + core.maps.getBlockInfo(block), + arr, + config + ); + }); + config.postDraw.forEach(function (v) { + v(); }); - config.postDraw.forEach(function (v) { v(); }); delete config.postDraw; if (config.onMap) { - core.drawImage(toDrawCtx, cacheCtx.canvas, core.bigmap.v2 ? -32 : 0, core.bigmap.v2 ? -32 : 0); + core.drawImage( + toDrawCtx, + cacheCtx.canvas, + core.bigmap.v2 ? -32 : 0, + core.bigmap.v2 ? -32 : 0 + ); cacheCtx.translate(0, 0); } -} +}; ////// 绘制前景层 ////// // config:绘制的参数,可包含如下项: @@ -1359,16 +1838,29 @@ maps.prototype.drawFg = function (floorId, config) { } this._drawFg_draw(floorId, toDrawCtx, cacheCtx, config); if (config.onMap) cacheCtx.translate(0, 0); -} +}; maps.prototype._drawFg_draw = function (floorId, toDrawCtx, cacheCtx, config) { config.ctx = cacheCtx; // ------ 调整这两行的顺序来控制是先绘制贴图还是先绘制前景图块;后绘制的覆盖先绘制的。 - core.maps._drawFloorImages(floorId, config.ctx, 'fg', null, null, config.onMap); + core.maps._drawFloorImages( + floorId, + config.ctx, + 'fg', + null, + null, + config.onMap + ); core.maps._drawBgFgMap(floorId, 'fg', config); - if (config.onMap) core.drawImage(toDrawCtx, cacheCtx.canvas, core.bigmap.v2 ? -32 : 0, core.bigmap.v2 ? -32 : 0); + if (config.onMap) + core.drawImage( + toDrawCtx, + cacheCtx.canvas, + core.bigmap.v2 ? -32 : 0, + core.bigmap.v2 ? -32 : 0 + ); config.ctx = toDrawCtx; -} +}; ////// 实际的背景/前景图块的绘制 ////// maps.prototype._drawBgFgMap = function (floorId, name, config) { @@ -1377,13 +1869,20 @@ maps.prototype._drawBgFgMap = function (floorId, name, config) { var width = core.floors[floorId].width; var height = core.floors[floorId].height; - if (!core.status[name + "maps"]) - core.status[name + "maps"] = {}; + if (!core.status[name + 'maps']) core.status[name + 'maps'] = {}; - var startX = config.onMap && core.bigmap.v2 ? Math.max(0, core.bigmap.posX - 1) : 0; - var endX = config.onMap && core.bigmap.v2 ? Math.min(width, core.bigmap.posX + core._WIDTH_ + 1) : width; - var startY = config.onMap && core.bigmap.v2 ? Math.max(0, core.bigmap.posY - 1) : 0; - var endY = config.onMap && core.bigmap.v2 ? Math.min(height, core.bigmap.posY + core._HEIGHT_ + 2) : height; + var startX = + config.onMap && core.bigmap.v2 ? Math.max(0, core.bigmap.posX - 1) : 0; + var endX = + config.onMap && core.bigmap.v2 + ? Math.min(width, core.bigmap.posX + core._WIDTH_ + 1) + : width; + var startY = + config.onMap && core.bigmap.v2 ? Math.max(0, core.bigmap.posY - 1) : 0; + var endY = + config.onMap && core.bigmap.v2 + ? Math.min(height, core.bigmap.posY + core._HEIGHT_ + 2) + : height; var arr = this._getBgFgMapArray(name, floorId, !config.redraw); config.postDraw = []; @@ -1394,15 +1893,30 @@ maps.prototype._drawBgFgMap = function (floorId, name, config) { block.name = name; var blockInfo = this.getBlockInfo(block); if (!blockInfo) continue; - this._drawMap_drawBlockInfo(config.ctx, block, blockInfo, arr, config); + this._drawMap_drawBlockInfo( + config.ctx, + block, + blockInfo, + arr, + config + ); } } - config.postDraw.forEach(function (v) { v(); }); + config.postDraw.forEach(function (v) { + v(); + }); delete config.postDraw; -} +}; ////// 绘制楼层贴图 ////// -maps.prototype._drawFloorImages = function (floorId, ctx, name, images, currStatus, onMap) { +maps.prototype._drawFloorImages = function ( + floorId, + ctx, + name, + images, + currStatus, + onMap +) { floorId = floorId || core.status.floorId; if (!images) images = this._getFloorImages(floorId); var redraw = currStatus != null; @@ -1410,7 +1924,7 @@ maps.prototype._drawFloorImages = function (floorId, ctx, name, images, currStat var image = core.material.images.images[core.getMappedName(one.name)]; var frame = one.frame || 1; if (!image) return; - var flag = "__floorImg__" + floorId + "_" + one.x + "_" + one.y; + var flag = '__floorImg__' + floorId + '_' + one.x + '_' + one.y; if (core.hasFlag(flag)) return; if (redraw && frame == 1) return; // 不重绘 @@ -1421,36 +1935,55 @@ maps.prototype._drawFloorImages = function (floorId, ctx, name, images, currStat } this._drawFloorImage(ctx, name, one, image, currStatus, onMap); }, this); -} +}; maps.prototype._getFloorImages = function (floorId) { - return ((core.status.maps || core.floors)[floorId || core.status.floorId] || {}).images || []; -} + return ( + ( + (core.status.maps || core.floors)[floorId || core.status.floorId] || + {} + ).images || [] + ); +}; maps.prototype._drawFloorImages_gif = function (image, dx, dy) { - core.dom.gif.innerHTML = ""; + core.dom.gif.innerHTML = ''; var gif = new Image(); gif.src = image.src; gif.style.position = 'absolute'; - gif.style.left = (dx * core.domStyle.scale) + "px"; - gif.style.top = (dy * core.domStyle.scale) + "px"; - gif.style.width = image.width * core.domStyle.scale + "px"; - gif.style.height = image.height * core.domStyle.scale + "px"; + gif.style.left = dx * core.domStyle.scale + 'px'; + gif.style.top = dy * core.domStyle.scale + 'px'; + gif.style.width = image.width * core.domStyle.scale + 'px'; + gif.style.height = image.height * core.domStyle.scale + 'px'; core.dom.gif.appendChild(gif); return; -} +}; -maps.prototype._drawFloorImage = function (ctx, name, one, image, currStatus, onMap) { +maps.prototype._drawFloorImage = function ( + ctx, + name, + one, + image, + currStatus, + onMap +) { var height = image.height; var imageName = one.name + (one.reverse || ''); - var width = parseInt((one.w == null ? image.width : one.w) / (one.frame || 1)); + var width = parseInt( + (one.w == null ? image.width : one.w) / (one.frame || 1) + ); var height = one.h == null ? image.height : one.h; - var sx = (one.sx || 0) + (currStatus || 0) % (one.frame || 1) * width; + var sx = (one.sx || 0) + ((currStatus || 0) % (one.frame || 1)) * width; var sy = one.sy || 0; - var x = one.x || 0, y = one.y || 0; + var x = one.x || 0, + y = one.y || 0; if (onMap && core.bigmap.v2) { - if (x > 32 * core.bigmap.posX + core._PX_ + 32 || x + width < 32 * core.bigmap.posX - 32 - || y > 32 * core.bigmap.posX + core._PY_ + 32 || y + height < 32 * core.bigmap.posY - 32) { + if ( + x > 32 * core.bigmap.posX + core._PX_ + 32 || + x + width < 32 * core.bigmap.posX - 32 || + y > 32 * core.bigmap.posX + core._PY_ + 32 || + y + height < 32 * core.bigmap.posY - 32 + ) { return; } x -= 32 * core.bigmap.posX; @@ -1460,122 +1993,322 @@ maps.prototype._drawFloorImage = function (ctx, name, one, image, currStatus, on if (one.canvas != 'auto' && one.canvas != name) return; if (one.canvas != 'auto') { if (currStatus != null) core.clearMap(ctx, x, y, width, height); - core.drawImage(ctx, imageName, sx, sy, width, height, x, y, width, height); + core.drawImage( + ctx, + imageName, + sx, + sy, + width, + height, + x, + y, + width, + height + ); } else { if (name == 'bg') { - if (currStatus != null) core.clearMap(ctx, x, y + height - 32, width, 32); - core.drawImage(ctx, imageName, sx, sy + height - 32, width, 32, x, y + height - 32, width, 32); + if (currStatus != null) + core.clearMap(ctx, x, y + height - 32, width, 32); + core.drawImage( + ctx, + imageName, + sx, + sy + height - 32, + width, + 32, + x, + y + height - 32, + width, + 32 + ); } else if (name == 'fg') { - if (currStatus != null) core.clearMap(ctx, x, y, width, height - 32); - core.drawImage(ctx, imageName, sx, sy, width, height - 32, x, y, width, height - 32); + if (currStatus != null) + core.clearMap(ctx, x, y, width, height - 32); + core.drawImage( + ctx, + imageName, + sx, + sy, + width, + height - 32, + x, + y, + width, + height - 32 + ); } } -} +}; ////// 绘制Autotile ////// - -maps.prototype._drawAutotile = function (ctx, mapArr, block, size, left, top, status, onMap) { - var xx = block.x, yy = block.y; +maps.prototype._drawAutotile = function ( + ctx, + mapArr, + block, + size, + left, + top, + status, + onMap +) { + var xx = block.x, + yy = block.y; var autotile = core.material.images['autotile'][block.event.id]; status = status || 0; status %= parseInt(autotile.width / 96); var done = {}; var isGrass = function (x, y) { - if (core.maps._drawAutotile_getAutotileAroundId(mapArr[yy][xx], x, y, mapArr)) { + if ( + core.maps._drawAutotile_getAutotileAroundId( + mapArr[yy][xx], + x, + y, + mapArr + ) + ) { return 1; } else { return 0; } - } + }; var iG = []; [-1, 0, 1].forEach(function (_x) { iG[_x] = []; [-1, 0, 1].forEach(function (_y) { iG[_x][_y] = isGrass(xx + _x, yy + _y); - }) + }); }); if (iG[-1][-1] + iG[0][-1] + iG[0][0] + iG[-1][0] == 3 && !iG[-1][-1]) { - this._drawAutotile_render(ctx, xx * size + left, yy * size + top, size, autotile, status, 16, null, onMap); + this._drawAutotile_render( + ctx, + xx * size + left, + yy * size + top, + size, + autotile, + status, + 16, + null, + onMap + ); done[0] = true; } if (iG[0][-1] + iG[1][-1] + iG[1][0] + iG[0][0] == 3 && !iG[1][-1]) { - this._drawAutotile_render(ctx, xx * size + left + size / 2, yy * size + top, size, autotile, status, 17, null, onMap); + this._drawAutotile_render( + ctx, + xx * size + left + size / 2, + yy * size + top, + size, + autotile, + status, + 17, + null, + onMap + ); done[1] = true; } if (iG[0][0] + iG[1][0] + iG[1][1] + iG[0][1] == 3 && !iG[1][1]) { - this._drawAutotile_render(ctx, xx * size + left + size / 2, yy * size + top + size / 2, size, autotile, status, 18, null, onMap); + this._drawAutotile_render( + ctx, + xx * size + left + size / 2, + yy * size + top + size / 2, + size, + autotile, + status, + 18, + null, + onMap + ); done[3] = true; } if (iG[0 - 1][0] + iG[0][0] + iG[0][1] + iG[-1][1] == 3 && !iG[-1][1]) { - this._drawAutotile_render(ctx, xx * size + left, yy * size + top + size / 2, size, autotile, status, 19, null, onMap); + this._drawAutotile_render( + ctx, + xx * size + left, + yy * size + top + size / 2, + size, + autotile, + status, + 19, + null, + onMap + ); done[2] = true; } var _id = iG[0][-1] + 2 * iG[-1][0] + 4 * iG[0][1] + 8 * iG[1][0]; - this._drawAutotile_render(ctx, xx * size, yy * size, size, autotile, status, _id, done, onMap); -} + this._drawAutotile_render( + ctx, + xx * size, + yy * size, + size, + autotile, + status, + _id, + done, + onMap + ); +}; - -maps.prototype._drawAutotile_render = function (canvas, x, y, size, autotile, status, index, done, onMap) { +maps.prototype._drawAutotile_render = function ( + canvas, + x, + y, + size, + autotile, + status, + index, + done, + onMap +) { if (onMap) { x -= 32 * core.bigmap.posX; y -= 32 * core.bigmap.posY; } - var indexData = [[[96 * status, 0, 32, 32, x, y, size, size],], - [[96 * status, 3 * 32, 16, 32, x, y, size / 2, size], [96 * status + 2 * 32 + 16, 3 * 32, 16, 32, x + size / 2, y, size / 2, size],], - [[96 * status + 2 * 32, 32, 32, 16, x, y, size, size / 2], [96 * status + 2 * 32, 3 * 32 + 16, 32, 16, x, y + size / 2, size, size / 2],], - [[96 * status + 2 * 32, 3 * 32, 32, 32, x, y, size, size],], - [[96 * status, 32, 16, 32, x, y, size / 2, size], [96 * status + 2 * 32 + 16, 32, 16, 32, x + size / 2, y, size / 2, size],], - [[96 * status, 2 * 32, 16, 32, x, y, size / 2, size], [96 * status + 2 * 32 + 16, 2 * 32, 16, 32, x + size / 2, y, size / 2, size],], - [[96 * status + 2 * 32, 32, 32, 32, x, y, size, size],], - [[96 * status + 2 * 32, 2 * 32, 32, 32, x, y, size, size],], - [[96 * status, 32, 32, 16, x, y, size, size / 2], [96 * status, 3 * 32 + 16, 32, 16, x, y + size / 2, size, size / 2],], - [[96 * status, 3 * 32, 32, 32, x, y, size, size],], - [[96 * status + 32, 32, 32, 16, x, y, size, size / 2], [96 * status + 32, 3 * 32 + 16, 32, 16, x, y + size / 2, size, size / 2],], - [[96 * status + 32, 3 * 32, 32, 32, x, y, size, size],], - [[96 * status, 32, 32, 32, x, y, size, size],], - [[96 * status, 2 * 32, 32, 32, x, y, size, size],], - [[96 * status + 32, 32, 32, 32, x, y, size, size],], - [[96 * status + 32, 2 * 32, 32, 32, x, y, size, size],], - [[96 * status + 2 * 32, 0, 16, 16, x, y, size / 2, size / 2],], - [[96 * status + 2 * 32 + 16, 0, 16, 16, x, y, size / 2, size / 2],], - [[96 * status + 2 * 32 + 16, 16, 16, 16, x, y, size / 2, size / 2],], - [[96 * status + 2 * 32, 16, 16, 16, x, y, size / 2, size / 2],], + var indexData = [ + [[96 * status, 0, 32, 32, x, y, size, size]], + [ + [96 * status, 3 * 32, 16, 32, x, y, size / 2, size], + [ + 96 * status + 2 * 32 + 16, + 3 * 32, + 16, + 32, + x + size / 2, + y, + size / 2, + size + ] + ], + [ + [96 * status + 2 * 32, 32, 32, 16, x, y, size, size / 2], + [ + 96 * status + 2 * 32, + 3 * 32 + 16, + 32, + 16, + x, + y + size / 2, + size, + size / 2 + ] + ], + [[96 * status + 2 * 32, 3 * 32, 32, 32, x, y, size, size]], + [ + [96 * status, 32, 16, 32, x, y, size / 2, size], + [ + 96 * status + 2 * 32 + 16, + 32, + 16, + 32, + x + size / 2, + y, + size / 2, + size + ] + ], + [ + [96 * status, 2 * 32, 16, 32, x, y, size / 2, size], + [ + 96 * status + 2 * 32 + 16, + 2 * 32, + 16, + 32, + x + size / 2, + y, + size / 2, + size + ] + ], + [[96 * status + 2 * 32, 32, 32, 32, x, y, size, size]], + [[96 * status + 2 * 32, 2 * 32, 32, 32, x, y, size, size]], + [ + [96 * status, 32, 32, 16, x, y, size, size / 2], + [96 * status, 3 * 32 + 16, 32, 16, x, y + size / 2, size, size / 2] + ], + [[96 * status, 3 * 32, 32, 32, x, y, size, size]], + [ + [96 * status + 32, 32, 32, 16, x, y, size, size / 2], + [ + 96 * status + 32, + 3 * 32 + 16, + 32, + 16, + x, + y + size / 2, + size, + size / 2 + ] + ], + [[96 * status + 32, 3 * 32, 32, 32, x, y, size, size]], + [[96 * status, 32, 32, 32, x, y, size, size]], + [[96 * status, 2 * 32, 32, 32, x, y, size, size]], + [[96 * status + 32, 32, 32, 32, x, y, size, size]], + [[96 * status + 32, 2 * 32, 32, 32, x, y, size, size]], + [[96 * status + 2 * 32, 0, 16, 16, x, y, size / 2, size / 2]], + [[96 * status + 2 * 32 + 16, 0, 16, 16, x, y, size / 2, size / 2]], + [[96 * status + 2 * 32 + 16, 16, 16, 16, x, y, size / 2, size / 2]], + [[96 * status + 2 * 32, 16, 16, 16, x, y, size / 2, size / 2]] ]; var data = indexData[index]; - if (index >= 16) { // 拐角直接绘制 - core.drawImage(canvas, autotile, data[0][0], data[0][1], data[0][2], data[0][3], data[0][4], data[0][5], size / 2, size / 2); - } else { // 非拐角要根据是否已经绘制进行切分后绘制 + if (index >= 16) { + // 拐角直接绘制 + core.drawImage( + canvas, + autotile, + data[0][0], + data[0][1], + data[0][2], + data[0][3], + data[0][4], + data[0][5], + size / 2, + size / 2 + ); + } else { + // 非拐角要根据是否已经绘制进行切分后绘制 this._drawAutotile_renderCut(canvas, autotile, x, y, size, data, done); } -} +}; -maps.prototype._drawAutotile_renderCut = function (canvas, autotile, x, y, size, data, done) { +maps.prototype._drawAutotile_renderCut = function ( + canvas, + autotile, + x, + y, + size, + data, + done +) { var drawData = []; done = done || {}; if (data.length == 2) { var idx = 0; var cut = 0; for (var i in data) { - if (data[i][2] % 32) { // 是否纵切 + if (data[i][2] % 32) { + // 是否纵切 cut = 0; - } - else if (data[i][3] % 32) { // 是否横切 + } else if (data[i][3] % 32) { + // 是否横切 cut = 1; } - if (data[i][0] % 32 || data[i][1] % 32) { // right down + if (data[i][0] % 32 || data[i][1] % 32) { + // right down idx = 1; - } else { // left top + } else { + // left top idx = 0; } if (cut) { idx *= 2; if (!done[idx]) drawData[idx] = [data[i][0], data[i][1]]; - if (!done[idx + 1]) drawData[idx + 1] = [parseInt(data[i][0]) + 16, data[i][1]]; + if (!done[idx + 1]) + drawData[idx + 1] = [parseInt(data[i][0]) + 16, data[i][1]]; } else { if (!done[idx]) drawData[idx] = [data[i][0], data[i][1]]; - if (!done[idx + 2]) drawData[idx + 2] = [data[i][0], parseInt(data[i][1]) + 16]; + if (!done[idx + 2]) + drawData[idx + 2] = [data[i][0], parseInt(data[i][1]) + 16]; } } } else { @@ -1585,24 +2318,64 @@ maps.prototype._drawAutotile_renderCut = function (canvas, autotile, x, y, size, if (!done[3]) drawData[3] = [data[0][0] + 16, data[0][1] + 16]; } for (var i = 0; i < 4; i++) { - var dt = drawData[i]; if (!dt) continue; - core.drawImage(canvas, autotile, dt[0], dt[1], 16, 16, x + (i % 2) * size / 2, y + parseInt(i / 2) * size / 2, size / 2, size / 2); - }; -} + var dt = drawData[i]; + if (!dt) continue; + core.drawImage( + canvas, + autotile, + dt[0], + dt[1], + 16, + 16, + x + ((i % 2) * size) / 2, + y + (parseInt(i / 2) * size) / 2, + size / 2, + size / 2 + ); + } +}; - -maps.prototype._drawAutotile_drawBlockByIndex = function (ctx, dx, dy, autotileImg, index, size, status) { +maps.prototype._drawAutotile_drawBlockByIndex = function ( + ctx, + dx, + dy, + autotileImg, + index, + size, + status +) { //index为autotile的图块索引1-48 - var sx = 16 * ((index - 1) % 6), sy = 16 * (~~((index - 1) / 6)); + var sx = 16 * ((index - 1) % 6), + sy = 16 * ~~((index - 1) / 6); status = status || 0; status %= parseInt(autotileImg.width / 96); - core.drawImage(ctx, autotileImg, sx + 96 * status, sy, 16, 16, dx, dy, size / 2, size / 2); -} + core.drawImage( + ctx, + autotileImg, + sx + 96 * status, + sy, + 16, + 16, + dx, + dy, + size / 2, + size / 2 + ); +}; -maps.prototype._drawAutotile_getAutotileAroundId = function (currId, x, y, mapArr) { +maps.prototype._drawAutotile_getAutotileAroundId = function ( + currId, + x, + y, + mapArr +) { if (x < 0 || y < 0 || x >= mapArr[0].length || y >= mapArr.length) return 1; - else return (core.material.autotileEdges[currId] || []).indexOf(mapArr[y][x]) >= 0; -} + else + return ( + (core.material.autotileEdges[currId] || []).indexOf(mapArr[y][x]) >= + 0 + ); +}; maps.prototype._drawAutotile_checkAround = function (x, y, mapArr) { // 得到周围四个32*32块(周围每块都包含当前块的1/4,不清楚的话画下图你就明白)的数组索引 @@ -1610,80 +2383,154 @@ maps.prototype._drawAutotile_checkAround = function (x, y, mapArr) { var pointBlock = []; for (var i = 0; i < 4; i++) { var bsum = 0; - var offsetx = i % 2, offsety = ~~(i / 2); + var offsetx = i % 2, + offsety = ~~(i / 2); for (var j = 0; j < 4; j++) { - var mx = j % 2, my = ~~(j / 2); - var b = this._drawAutotile_getAutotileAroundId(currId, x + offsetx + mx - 1, y + offsety + my - 1, mapArr); - bsum += b * (Math.pow(2, 3 - j)); + var mx = j % 2, + my = ~~(j / 2); + var b = this._drawAutotile_getAutotileAroundId( + currId, + x + offsetx + mx - 1, + y + offsety + my - 1, + mapArr + ); + bsum += b * Math.pow(2, 3 - j); } pointBlock.push(bsum); } return pointBlock; -} +}; -maps.prototype._drawAutotile_getAutotileIndexs = function (x, y, mapArr, indexArrs) { +maps.prototype._drawAutotile_getAutotileIndexs = function ( + x, + y, + mapArr, + indexArrs +) { var indexArr = []; var pointBlocks = this._drawAutotile_checkAround(x, y, mapArr); for (var i = 0; i < 4; i++) { - var arr = indexArrs[pointBlocks[i]] + var arr = indexArrs[pointBlocks[i]]; indexArr.push(arr[3 - i]); } return indexArr; -} +}; maps.prototype._drawAutotileAnimate = function (block, animate) { - var x = block.x, y = block.y; + var x = block.x, + y = block.y; // ------ 界面外的动画不绘制 if (core.bigmap.v2) { - var posX = core.bigmap.posX, posY = core.bigmap.posY; - if (x < posX - 1 || y < posY - 1 || x > posX + core._WIDTH_ || y > posY + core._HEIGHT_) { + var posX = core.bigmap.posX, + posY = core.bigmap.posY; + if ( + x < posX - 1 || + y < posY - 1 || + x > posX + core._WIDTH_ || + y > posY + core._HEIGHT_ + ) { return; } } else { - if (32 * x < core.bigmap.offsetX - 64 || 32 * x > core.bigmap.offsetX + core._PX_ + 32 - || 32 * y < core.bigmap.offsetY - 64 || 32 * y > core.bigmap.offsetY + core._PY_ + 32 + 16) { + if ( + 32 * x < core.bigmap.offsetX - 64 || + 32 * x > core.bigmap.offsetX + core._PX_ + 32 || + 32 * y < core.bigmap.offsetY - 64 || + 32 * y > core.bigmap.offsetY + core._PY_ + 32 + 16 + ) { return; } } var cv = block.name ? core.canvas[block.name] : core.canvas.event; - cv.clearRect(32 * x - 32 * core.bigmap.posX, 32 * y - 32 * core.bigmap.posY, 32, 32); + cv.clearRect( + 32 * x - 32 * core.bigmap.posX, + 32 * y - 32 * core.bigmap.posY, + 32, + 32 + ); var alpha = null; if (block.opacity != null) alpha = core.setAlpha(cv, block.opacity); core.setFilter(cv, block.filter); if (block.name) { if (block.name == 'bg') - core.drawImage('bg', core.material.groundCanvas.canvas, 32 * x - 32 * core.bigmap.posX, 32 * y - 32 * core.bigmap.posY); - this._drawAutotile(cv, this._getBgFgMapArray(block.name), block, 32, 0, 0, animate, true); - } - else { - this._drawAutotile(cv, this.getMapArray(), block, 32, 0, 0, animate, true); + core.drawImage( + 'bg', + core.material.groundCanvas.canvas, + 32 * x - 32 * core.bigmap.posX, + 32 * y - 32 * core.bigmap.posY + ); + this._drawAutotile( + cv, + this._getBgFgMapArray(block.name), + block, + 32, + 0, + 0, + animate, + true + ); + } else { + this._drawAutotile( + cv, + this.getMapArray(), + block, + 32, + 0, + 0, + animate, + true + ); } core.setFilter(cv, null); if (alpha != null) core.setAlpha(cv, alpha); -} +}; -////// 为autotile判定边界 ////// +////// 为autotile判定边界 ////// maps.prototype._makeAutotileEdges = function () { var autotileIds = Object.keys(core.material.images.autotile); core.material.autotileEdges = {}; - var canvas = document.createElement("canvas"), ctx = canvas.getContext('2d'); + var canvas = document.createElement('canvas'), + ctx = canvas.getContext('2d'); canvas.width = canvas.height = 32; ctx.mozImageSmoothingEnabled = false; ctx.webkitImageSmoothingEnabled = false; ctx.msImageSmoothingEnabled = false; ctx.imageSmoothingEnabled = false; - var first = {}, second = {}; + var first = {}, + second = {}; autotileIds.forEach(function (t) { var n = core.maps.getNumberById(t); core.clearMap(ctx, 0, 0, 32, 32); - core.drawImage(ctx, core.material.images.autotile[t], 0, 0, 32, 32, 0, 0, 32, 32); - first[n] = canvas.toDataURL("image/png"); + core.drawImage( + ctx, + core.material.images.autotile[t], + 0, + 0, + 32, + 32, + 0, + 0, + 32, + 32 + ); + first[n] = canvas.toDataURL('image/png'); core.clearMap(ctx, 0, 0, 32, 32); - core.drawImage(ctx, core.material.images.autotile[t], 32, 0, 32, 32, 0, 0, 32, 32); - second[n] = canvas.toDataURL("image/png"); + core.drawImage( + ctx, + core.material.images.autotile[t], + 32, + 0, + 32, + 32, + 0, + 0, + 32, + 32 + ); + second[n] = canvas.toDataURL('image/png'); }); for (var n in first) { @@ -1697,7 +2544,7 @@ maps.prototype._makeAutotileEdges = function () { } } } -} +}; ////// 绘制缩略图 ////// // 此函数将绘制一个缩略图,floorId为目标floorId,blocks为地图的图块(可为null使用floorId对应默认的) @@ -1710,16 +2557,21 @@ maps.prototype.drawThumbnail = function (floorId, blocks, options) { floorId = floorId || core.status.floorId; if (!floorId) return; options = options || {}; - if (typeof options == 'string' || options.canvas) options = { ctx: options }; + if (typeof options == 'string' || options.canvas) + options = { ctx: options }; var ctx = options.ctx; // Step1:绘制到tempCanvas上 this._drawThumbnail_drawTempCanvas(floorId, blocks, options); options.ctx = ctx; // Step2:从tempCanvas绘制到对应的画布上 this._drawThumbnail_drawToTarget(floorId, options); -} +}; -maps.prototype._drawThumbnail_drawTempCanvas = function (floorId, blocks, options) { +maps.prototype._drawThumbnail_drawTempCanvas = function ( + floorId, + blocks, + options +) { var width = core.floors[floorId].width; var height = core.floors[floorId].height; // 绘制到tempCanvas上面 @@ -1732,7 +2584,14 @@ maps.prototype._drawThumbnail_drawTempCanvas = function (floorId, blocks, option if (options.noHD) { tempCanvas.canvas.width = width * 32 * scale; tempCanvas.canvas.height = height * 32 * scale; - } else core.resizeCanvas(tempCanvas, width * 32 * scale, height * 32 * scale, false, true); + } else + core.resizeCanvas( + tempCanvas, + width * 32 * scale, + height * 32 * scale, + false, + true + ); tempCanvas.scale(scale, scale); } else if (width * height > core.bigmap.threshold) { options.v2 = true; @@ -1740,27 +2599,37 @@ maps.prototype._drawThumbnail_drawTempCanvas = function (floorId, blocks, option tempCanvas.canvas.width = core._PX_; tempCanvas.canvas.height = core._PY_; } else core.resizeCanvas(tempCanvas, core._PX_, core._PY_); - var centerX = options.centerX, centerY = options.centerY; + var centerX = options.centerX, + centerY = options.centerY; if (centerX == null) centerX = Math.floor(width / 2); if (centerY == null) centerY = Math.floor(height / 2); - var offsetX = core.clamp(centerX - core._HALF_WIDTH_, 0, width - core._WIDTH_), - offsetY = core.clamp(centerY - core._HALF_HEIGHT_, 0, height - core._HEIGHT_); + var offsetX = core.clamp( + centerX - core._HALF_WIDTH_, + 0, + width - core._WIDTH_ + ), + offsetY = core.clamp( + centerY - core._HALF_HEIGHT_, + 0, + height - core._HEIGHT_ + ); tempCanvas.translate(-32 * offsetX, -32 * offsetY, false, true); } else { options.v2 = false; if (options.noHD) { tempCanvas.canvas.width = width * 32; tempCanvas.canvas.height = height * 32; - } else core.resizeCanvas(tempCanvas, width * 32, height * 32, false, true); + } else + core.resizeCanvas(tempCanvas, width * 32, height * 32, false, true); } options.ctx = tempCanvas; // 地图过大的缩略图不绘制显伤 - if (width * height > core.bigmap.threshold) - options.damage = false; + if (width * height > core.bigmap.threshold) options.damage = false; // --- 暂存 flags - var hasHero = core.status.hero != null, flags = null; + var hasHero = core.status.hero != null, + flags = null; if (options.flags) { if (!hasHero) core.status.hero = {}; flags = core.status.hero.flags; @@ -1773,22 +2642,38 @@ maps.prototype._drawThumbnail_drawTempCanvas = function (floorId, blocks, option if (!hasHero) delete core.status.hero; else if (flags != null) core.status.hero.flags = flags; tempCanvas.setTransform(1, 0, 0, 1, 0, 0); -} +}; -maps.prototype._drawThumbnail_realDrawTempCanvas = function (floorId, blocks, options) { +maps.prototype._drawThumbnail_realDrawTempCanvas = function ( + floorId, + blocks, + options +) { // 缩略图:背景 this.drawBg(floorId, options); // 缩略图:事件 this.drawEvents(floorId, blocks, options); // 缩略图:勇士 if (options.heroLoc) { - options.heroIcon = options.heroIcon || core.status.hero.image || 'hero.png'; + options.heroIcon = + options.heroIcon || core.status.hero.image || 'hero.png'; options.heroIcon = core.getMappedName(options.heroIcon); var icon = core.material.icons.hero[options.heroLoc.direction]; var height = core.material.images.images[options.heroIcon].height / 4; - var width = (core.material.images.images[options.heroIcon].width || 128) / 4; - core.drawImage(options.ctx, core.material.images.images[options.heroIcon], icon.stop * width, icon.loc * height, width, height, - 32 * options.heroLoc.x + 32 - width, 32 * options.heroLoc.y + 32 - height, width, height); + var width = + (core.material.images.images[options.heroIcon].width || 128) / 4; + core.drawImage( + options.ctx, + core.material.images.images[options.heroIcon], + icon.stop * width, + icon.loc * height, + width, + height, + 32 * options.heroLoc.x + 32 - width, + 32 * options.heroLoc.y + 32 - height, + width, + height + ); } // 缩略图:前景 this.drawFg(floorId, options); @@ -1797,59 +2682,131 @@ maps.prototype._drawThumbnail_realDrawTempCanvas = function (floorId, blocks, op core.updateCheckBlock(floorId); core.control.updateDamage(floorId, options.ctx); } -} +}; maps.prototype._drawThumbnail_drawToTarget = function (floorId, options) { var ctx = core.getContextByName(options.ctx); if (ctx == null) return; - var x = options.x || 0, y = options.y || 0, size = options.size || 1; + var x = options.x || 0, + y = options.y || 0, + size = options.size || 1; // size的含义改为(0,1]范围的系数以适配长方形,默认为1,楼传为3/4,SL界面为0.3 - var w = Math.ceil(size * core._PX_), h = Math.ceil(size * core._PY_); + var w = Math.ceil(size * core._PX_), + h = Math.ceil(size * core._PY_); // 特判是否为编辑器,编辑器中长宽均采用core.js的遗留正方形像素边长,以保证下面的绘制正常 if (main.mode == 'editor') w = h = size * core.__PIXELS__; - var width = core.floors[floorId].width, height = core.floors[floorId].height; - var centerX = options.centerX, centerY = options.centerY; + var width = core.floors[floorId].width, + height = core.floors[floorId].height; + var centerX = options.centerX, + centerY = options.centerY; if (centerX == null) centerX = Math.floor(width / 2); if (centerY == null) centerY = Math.floor(height / 2); var tempCanvas = core.bigmap.tempCanvas; if (options.all) { - var tempWidth = tempCanvas.canvas.width, tempHeight = tempCanvas.canvas.height; + var tempWidth = tempCanvas.canvas.width, + tempHeight = tempCanvas.canvas.height; // 绘制全景图 if (tempWidth <= tempHeight) { - var realHeight = h, realWidth = realHeight * tempWidth / tempHeight; + var realHeight = h, + realWidth = (realHeight * tempWidth) / tempHeight; var side = (w - realWidth) / 2; core.fillRect(ctx, x, y, side, realHeight, '#000000'); core.fillRect(ctx, x + w - side, y, side, realHeight); - core.drawImage(ctx, tempCanvas.canvas, 0, 0, tempWidth, tempHeight, x + side, y, realWidth, realHeight); - } - else { - var realWidth = w, realHeight = realWidth * tempHeight / tempWidth; + core.drawImage( + ctx, + tempCanvas.canvas, + 0, + 0, + tempWidth, + tempHeight, + x + side, + y, + realWidth, + realHeight + ); + } else { + var realWidth = w, + realHeight = (realWidth * tempHeight) / tempWidth; var side = (h - realHeight) / 2; core.fillRect(ctx, x, y, realWidth, side, '#000000'); core.fillRect(ctx, x, y + h - side, realWidth, side); - core.drawImage(ctx, tempCanvas.canvas, 0, 0, tempWidth, tempHeight, x, y + side, realWidth, realHeight); + core.drawImage( + ctx, + tempCanvas.canvas, + 0, + 0, + tempWidth, + tempHeight, + x, + y + side, + realWidth, + realHeight + ); } - } - else { + } else { // 只绘制可见窗口 - var pw = core._PX_, ph = core._PY_, hw = core._HALF_WIDTH_, hh = core._HALF_HEIGHT_, W = core._WIDTH_, H = core._HEIGHT_; - var ratio = core.domStyle.isVertical ? core.domStyle.ratio : core.domStyle.scale; - if (main.mode == 'editor') { pw = ph = core.__PIXELS__; hw = hh = core.__HALF_SIZE__; W = H = core.__SIZE__; } + var pw = core._PX_, + ph = core._PY_, + hw = core._HALF_WIDTH_, + hh = core._HALF_HEIGHT_, + W = core._WIDTH_, + H = core._HEIGHT_; + var ratio = core.domStyle.isVertical + ? core.domStyle.ratio + : core.domStyle.scale; + if (main.mode == 'editor') { + pw = ph = core.__PIXELS__; + hw = hh = core.__HALF_SIZE__; + W = H = core.__SIZE__; + } if (options.v2) { - core.drawImage(ctx, tempCanvas.canvas, 0, 0, pw * ratio, ph * ratio, x, y, w, h); + core.drawImage( + ctx, + tempCanvas.canvas, + 0, + 0, + pw * ratio, + ph * ratio, + x, + y, + w, + h + ); } else { var offsetX = core.clamp(centerX - hw, 0, width - W), offsetY = core.clamp(centerY - hh, 0, height - H), c = options.noHD ? 1 : core.domStyle.scale; if (options.noHD) { - core.drawImage(ctx, tempCanvas.canvas, offsetX * 32, offsetY * 32, pw, ph, x, y, w, h); + core.drawImage( + ctx, + tempCanvas.canvas, + offsetX * 32, + offsetY * 32, + pw, + ph, + x, + y, + w, + h + ); return; } - core.drawImage(ctx, tempCanvas.canvas, offsetX * 32 * ratio, offsetY * 32 * ratio, pw * ratio, ph * ratio, x, y, w, h); + core.drawImage( + ctx, + tempCanvas.canvas, + offsetX * 32 * ratio, + offsetY * 32 * ratio, + pw * ratio, + ph * ratio, + x, + y, + w, + h + ); } } -} +}; // -------- 获得某个点的图块信息 -------- // @@ -1858,43 +2815,60 @@ maps.prototype.noPass = function (x, y, floorId) { var block = core.getBlock(x, y, floorId); if (block == null) return false; return block.event.noPass; -} +}; ////// 某个点是否存在NPC ////// maps.prototype.npcExists = function (x, y, floorId) { var block = this.getBlock(x, y, floorId); if (block == null) return false; return block.event.cls.indexOf('npc') == 0; -} +}; ////// 某个点是否存在(指定的)地形 ////// maps.prototype.terrainExists = function (x, y, id, floorId) { var block = this.getBlock(x, y, floorId); if (block == null) return false; return block.event.cls == 'terrains' && (id ? block.event.id == id : true); -} +}; ////// 某个点是否存在楼梯 ////// maps.prototype.stairExists = function (x, y, floorId) { var blockId = this.getBlockId(x, y, floorId); if (blockId == null) return false; var ids = ['upFloor', 'downFloor']; - ids = ids.concat(['leftPortal', 'rightPortal', 'upPortal', 'downPortal', 'portal', 'starPortal']); + ids = ids.concat([ + 'leftPortal', + 'rightPortal', + 'upPortal', + 'downPortal', + 'portal', + 'starPortal' + ]); return ids.indexOf(blockId) >= 0; -} +}; ////// 当前位置是否在楼梯边 ////// maps.prototype.nearStair = function () { - var x = core.getHeroLoc('x'), y = core.getHeroLoc('y'); - return this.stairExists(x, y) || this.stairExists(x - 1, y) || this.stairExists(x, y - 1) || this.stairExists(x + 1, y) || this.stairExists(x, y + 1); -} + var x = core.getHeroLoc('x'), + y = core.getHeroLoc('y'); + return ( + this.stairExists(x, y) || + this.stairExists(x - 1, y) || + this.stairExists(x, y - 1) || + this.stairExists(x + 1, y) || + this.stairExists(x, y + 1) + ); +}; ////// 某个点是否存在(指定的)怪物 ////// maps.prototype.enemyExists = function (x, y, id, floorId) { var block = this.getBlock(x, y, floorId); if (block == null) return false; - return block.event.cls.indexOf('enemy') == 0 && (id ? block.event.id == id : true); -} + return ( + block.event.cls.indexOf('enemy') == 0 && + (id ? block.event.id == id : true) + ); +}; ////// 获得某个点的block ////// maps.prototype.getBlock = function (x, y, floorId, showDisable) { @@ -1902,28 +2876,28 @@ maps.prototype.getBlock = function (x, y, floorId, showDisable) { if (!floorId) return null; core.extractBlocks(floorId); var blockObjs = this.getMapBlocksObj(floorId); - var block = blockObjs[x + "," + y]; + var block = blockObjs[x + ',' + y]; if (block && (showDisable || !block.disable)) return block; return null; -} +}; ////// 获得某个点的blockId ////// maps.prototype.getBlockId = function (x, y, floorId, showDisable) { var block = core.getBlock(x, y, floorId, showDisable); return block == null ? null : block.event.id; -} +}; ////// 获得某个点的数字 ////// maps.prototype.getBlockNumber = function (x, y, floorId, showDisable) { var block = core.getBlock(x, y, floorId, showDisable); return block == null ? null : block.id; -} +}; ////// 获得某个点的blockCls ////// maps.prototype.getBlockCls = function (x, y, floorId, showDisable) { var block = core.getBlock(x, y, floorId, showDisable); return block == null ? null : block.event.cls; -} +}; ////// 获得某个点的不透明度 ////// maps.prototype.getBlockOpacity = function (x, y, floorId, showDisable) { @@ -1931,47 +2905,57 @@ maps.prototype.getBlockOpacity = function (x, y, floorId, showDisable) { if (block == null) return null; if (block.opacity == null) return 1.0; return block.opacity == null ? 1.0 : block.opacity; -} +}; ////// 获得某个点的filter ////// maps.prototype.getBlockFilter = function (x, y, floorId, showDisable) { var block = core.getBlock(x, y, floorId, showDisable); if (block == null) return null; - if (block.filter == null) return { blur: 0, hue: 0, grayscale: 0, invert: false, shadow: 0 }; + if (block.filter == null) + return { blur: 0, hue: 0, grayscale: 0, invert: false, shadow: 0 }; return core.clone(block.filter); -} +}; ////// 获得某个图块或素材的信息,包括 ID,cls,图片,坐标,faceIds 等等 ////// maps.prototype.getBlockInfo = function (block) { if (!block) return null; - if (typeof block == 'string') { // 参数是ID + if (typeof block == 'string') { + // 参数是ID block = this.getNumberById(block); } - if (typeof block == 'number') { // 参数是数字 + if (typeof block == 'number') { + // 参数是数字 if (block == 0) return null; block = this.getBlockByNumber(block); } - var number = block.id, id = block.event.id, cls = block.event.cls, name = block.event.name, - image = null, posX = 0, posY = 0, animate = block.event.animate, doorInfo = block.event.doorInfo, - height = block.event.height || 32, faceIds = {}, face = 'down', bigImage = null; + var number = block.id, + id = block.event.id, + cls = block.event.cls, + name = block.event.name, + image = null, + posX = 0, + posY = 0, + animate = block.event.animate, + doorInfo = block.event.doorInfo, + height = block.event.height || 32, + faceIds = {}, + face = 'down', + bigImage = null; if (id == 'none') return null; else if (id == 'airwall') { if (!core.material.images.airwall) return null; image = core.material.images.airwall; - name = "空气墙"; - } - else if (cls == 'tileset') { + name = '空气墙'; + } else if (cls == 'tileset') { var offset = core.icons.getTilesetOffset(id); if (offset == null) return null; posX = offset.x; posY = offset.y; image = core.material.images.tilesets[offset.image]; - } - else if (cls == 'autotile') { + } else if (cls == 'autotile') { image = core.material.images.autotile[id]; - } - else { + } else { image = core.material.images[cls]; posY = core.material.icons[cls][id]; faceIds = block.event.faceIds || {}; @@ -1981,10 +2965,12 @@ maps.prototype.getBlockInfo = function (block) { break; } } - if (block.event.bigImage) bigImage = core.material.images.images[block.event.bigImage]; + if (block.event.bigImage) + bigImage = core.material.images.images[block.event.bigImage]; if (core.material.enemys[id]) { name = core.material.enemys[id].name; - bigImage = core.material.images.images[core.material.enemys[id].bigImage]; + bigImage = + core.material.images.images[core.material.enemys[id].bigImage]; } else if (core.material.items[id]) { name = core.material.items[id].name; } @@ -1993,10 +2979,21 @@ maps.prototype.getBlockInfo = function (block) { } return { - number: number, id: id, cls: cls, name: name, image: image, posX: posX, doorInfo: doorInfo, - posY: posY, height: height, faceIds: faceIds, animate: animate, face: face, bigImage: bigImage + number: number, + id: id, + cls: cls, + name: name, + image: image, + posX: posX, + doorInfo: doorInfo, + posY: posY, + height: height, + faceIds: faceIds, + animate: animate, + face: face, + bigImage: bigImage }; -} +}; ////// 搜索某个图块出现的所有位置 ////// maps.prototype.searchBlock = function (id, floorId, showDisable) { @@ -2012,20 +3009,35 @@ maps.prototype.searchBlock = function (id, floorId, showDisable) { core.extractBlocks(floorId); for (var i = 0; i < core.status.maps[floorId].blocks.length; ++i) { var block = core.status.maps[floorId].blocks[i]; - if ((showDisable || !block.disable) && (core.matchWildcard(id, block.event.id) || core.matchRegex(id, block.event.id))) { - result.push({ floorId: floorId, x: block.x, y: block.y, block: block }); + if ( + (showDisable || !block.disable) && + (core.matchWildcard(id, block.event.id) || + core.matchRegex(id, block.event.id)) + ) { + result.push({ + floorId: floorId, + x: block.x, + y: block.y, + block: block + }); } } return result; -} +}; ////// 给定筛选函数,搜索某个图块出现的所有位置 ////// -maps.prototype.searchBlockWithFilter = function (blockFilter, floorId, showDisable) { +maps.prototype.searchBlockWithFilter = function ( + blockFilter, + floorId, + showDisable +) { floorId = floorId || core.status.floorId; var result = []; if (floorId instanceof Array) { floorId.forEach(function (floorId) { - result = result.concat(core.searchBlockWithFilter(blockFilter, floorId, showDisable)); + result = result.concat( + core.searchBlockWithFilter(blockFilter, floorId, showDisable) + ); }); return result; } @@ -2033,25 +3045,32 @@ maps.prototype.searchBlockWithFilter = function (blockFilter, floorId, showDisab for (var i = 0; i < core.status.maps[floorId].blocks.length; ++i) { var block = core.status.maps[floorId].blocks[i]; if ((showDisable || !block.disable) && blockFilter(block)) { - result.push({ floorId: floorId, x: block.x, y: block.y, block: block }); + result.push({ + floorId: floorId, + x: block.x, + y: block.y, + block: block + }); } } return result; -} +}; ////// 获得某个图块,其行走图朝向朝下的图块ID ////// maps.prototype.getFaceDownId = function (block) { if (block == null) return null; - if (typeof block == 'string') { // 参数是ID + if (typeof block == 'string') { + // 参数是ID block = this.getNumberById(block); } - if (typeof block == 'number') { // 参数是数字 + if (typeof block == 'number') { + // 参数是数字 if (block == 0) return null; block = this.getBlockByNumber(block); } if (!block.event) return null; return (block.event.faceIds || {}).down || block.event.id; -} +}; // -------- 启用/禁用图块,楼层贴图 -------- // @@ -2077,7 +3096,7 @@ maps.prototype.showBlock = function (x, y, floorId) { } } } -} +}; ////// 只隐藏但不删除某块 ////// maps.prototype.hideBlock = function (x, y, floorId) { @@ -2093,27 +3112,30 @@ maps.prototype.hideBlock = function (x, y, floorId) { // 删除动画,清除地图 this._removeBlockFromMap(floorId, block); -} +}; ////// 根据图块的索引来隐藏图块 ////// maps.prototype.hideBlockByIndex = function (index, floorId) { floorId = floorId || core.status.floorId; if (!floorId) return; core.extractBlocks(floorId); - var blocks = core.status.maps[floorId].blocks, block = blocks[index]; + var blocks = core.status.maps[floorId].blocks, + block = blocks[index]; block.disable = true; core.setMapBlockDisabled(floorId, block.x, block.y, true); this._updateMapArray(floorId, block.x, block.y); -} +}; ////// 一次性隐藏多个block ////// maps.prototype.hideBlockByIndexes = function (indexes, floorId) { - indexes.sort(function (a, b) { - return b - a; - }).forEach(function (index) { - core.hideBlockByIndex(index, floorId); - }); -} + indexes + .sort(function (a, b) { + return b - a; + }) + .forEach(function (index) { + core.hideBlockByIndex(index, floorId); + }); +}; maps.prototype._removeBlockFromMap = function (floorId, block) { if (floorId != core.status.floorId) return; @@ -2121,19 +3143,21 @@ maps.prototype._removeBlockFromMap = function (floorId, block) { if (block.event.cls == 'autotile' || filter.blur > 0 || filter.shadow > 0) { core.redrawMap(); } else { - var x = block.x, y = block.y; + var x = block.x, + y = block.y; var px = 32 * x - core.bigmap.posX * 32; var py = 32 * y - core.bigmap.posY * 32; core.removeGlobalAnimate(x, y); core.clearMap('event', px, py, 32, 32); var height = block.event.height || 32; - if (height > 32) core.clearMap('event2', px, py + 32 - height, 32, height - 32); + if (height > 32) + core.clearMap('event2', px, py + 32 - height, 32, height - 32); // 删除大怪物 - core.deleteCanvas("_bigImage_header_" + x + "_" + y); - core.deleteCanvas("_bigImage_body_" + x + "_" + y); + core.deleteCanvas('_bigImage_header_' + x + '_' + y); + core.deleteCanvas('_bigImage_body_' + x + '_' + y); core.updateStatusBar(); } -} +}; ////// 删除某个图块 ////// maps.prototype.removeBlock = function (x, y, floorId) { @@ -2150,46 +3174,48 @@ maps.prototype.removeBlock = function (x, y, floorId) { } } return false; -} +}; ////// 根据block的索引(尽可能)删除该块 ////// maps.prototype.removeBlockByIndex = function (index, floorId) { floorId = floorId || core.status.floorId; if (!floorId) return; core.extractBlocks(floorId); - var blocks = core.status.maps[floorId].blocks, block = blocks[index]; + var blocks = core.status.maps[floorId].blocks, + block = blocks[index]; blocks.splice(index, 1); if (core.status.mapBlockObjs[floorId]) - delete core.status.mapBlockObjs[floorId][block.x + "," + block.y]; + delete core.status.mapBlockObjs[floorId][block.x + ',' + block.y]; core.setMapBlockDisabled(floorId, block.x, block.y, true); this._updateMapArray(floorId, block.x, block.y); -} +}; ////// 一次性删除多个block ////// maps.prototype.removeBlockByIndexes = function (indexes, floorId) { - indexes.sort(function (a, b) { - return b - a; - }).forEach(function (index) { - core.removeBlockByIndex(index, floorId); - }); -} + indexes + .sort(function (a, b) { + return b - a; + }) + .forEach(function (index) { + core.removeBlockByIndex(index, floorId); + }); +}; ////// 显示前景/背景地图 ////// maps.prototype.showBgFgMap = function (name, loc, floorId, callback) { this._triggerBgFgMap('show', name, loc, floorId, callback); -} +}; ////// 隐藏前景/背景地图 ////// maps.prototype.hideBgFgMap = function (name, loc, floorId, callback) { this._triggerBgFgMap('hide', name, loc, floorId, callback); -} +}; ////// 设置前景/背景地图的显示状态 ////// maps.prototype._triggerBgFgMap = function (type, name, loc, floorId, callback) { if (type != 'show') type = 'hide'; if (!name || (!name.startsWith('bg') && !name.startsWith('fg'))) return; - if (typeof loc[0] == 'number' && typeof loc[1] == 'number') - loc = [loc]; + if (typeof loc[0] == 'number' && typeof loc[1] == 'number') loc = [loc]; floorId = floorId || core.status.floorId; if (!floorId) return; @@ -2200,56 +3226,64 @@ maps.prototype._triggerBgFgMap = function (type, name, loc, floorId, callback) { if (type == 'hide') { disabled[floorId].push([t[0], t[1]]); } else { - disabled[floorId] = disabled[floorId].filter(function (one) { return one[0] != t[0] || one[1] != t[1] }); + disabled[floorId] = disabled[floorId].filter(function (one) { + return one[0] != t[0] || one[1] != t[1]; + }); } - }) + }); core.setFlag('__' + name + 'd__', disabled); - core.status[name + "maps"][floorId] = null; + core.status[name + 'maps'][floorId] = null; if (floorId == core.status.floorId) { core.redrawMap(); } if (callback) callback(); -} +}; ////// 显示一个楼层贴图 ////// maps.prototype.showFloorImage = function (loc, floorId, callback) { this._triggerFloorImage('show', loc, floorId, callback); -} +}; ////// 隐藏一个楼层贴图 ////// maps.prototype.hideFloorImage = function (loc, floorId, callback) { this._triggerFloorImage('hide', loc, floorId, callback); -} +}; ///// 设置贴图显示状态 ////// maps.prototype._triggerFloorImage = function (type, loc, floorId, callback) { if (type != 'show') type = 'hide'; - if (typeof loc[0] == 'number' && typeof loc[1] == 'number') - loc = [loc]; + if (typeof loc[0] == 'number' && typeof loc[1] == 'number') loc = [loc]; floorId = floorId || core.status.floorId; if (!floorId) return; if (loc.length == 0) return; loc.forEach(function (t) { - var x = t[0], y = t[1]; - var flag = "__floorImg__" + floorId + "_" + x + "_" + y; + var x = t[0], + y = t[1]; + var flag = '__floorImg__' + floorId + '_' + x + '_' + y; if (type == 'hide') core.setFlag(flag, true); else core.removeFlag(flag); - }) + }); if (floorId == core.status.floorId) { core.redrawMap(); } if (callback) callback(); -} +}; ////// 改变图块 ////// maps.prototype.setBlock = function (number, x, y, floorId) { floorId = floorId || core.status.floorId; if (!floorId || number == null || x == null || y == null) return; - if (x < 0 || x >= core.floors[floorId].width || y < 0 || y >= core.floors[floorId].height) return; + if ( + x < 0 || + x >= core.floors[floorId].width || + y < 0 || + y >= core.floors[floorId].height + ) + return; if (typeof number == 'string') { if (/^\d+$/.test(number)) number = parseInt(number); else number = core.getNumberById(number); @@ -2266,11 +3300,10 @@ maps.prototype.setBlock = function (number, x, y, floorId) { if (originBlock == null) { core.status.maps[floorId].blocks.push(block); if (core.status.mapBlockObjs[floorId]) - core.status.mapBlockObjs[floorId][block.x + "," + block.y] = block; + core.status.mapBlockObjs[floorId][block.x + ',' + block.y] = block; core.setMapBlockDisabled(floorId, block.x, block.y, false); delete block.disable; - } - else { + } else { originBlock.id = number; originBlock.event = block.event; block = originBlock; @@ -2278,11 +3311,18 @@ maps.prototype.setBlock = function (number, x, y, floorId) { this._updateMapArray(floorId, x, y); if (floorId == core.status.floorId) { // 有任何一个是autotile直接重绘地图 - if ((originEvent != null && originEvent.cls == 'autotile') || block.event.cls == 'autotile') { + if ( + (originEvent != null && originEvent.cls == 'autotile') || + block.event.cls == 'autotile' + ) { core.redrawMap(); } else { if (originEvent != null) { - this._removeBlockFromMap(floorId, { x: x, y: y, event: originEvent }); + this._removeBlockFromMap(floorId, { + x: x, + y: y, + event: originEvent + }); } if (!block.disable) { core.drawBlock(block); @@ -2291,9 +3331,16 @@ maps.prototype.setBlock = function (number, x, y, floorId) { } } } -} +}; -maps.prototype.animateSetBlock = function (number, x, y, floorId, time, callback) { +maps.prototype.animateSetBlock = function ( + number, + x, + y, + floorId, + time, + callback +) { floorId = floorId || core.status.floorId; time = time || 0; if (floorId != core.status.floorId || time == 0) { @@ -2311,22 +3358,52 @@ maps.prototype.animateSetBlock = function (number, x, y, floorId, time, callback // 如果原本是启用的 if (originBlock != null && !originBlock.disable) { - return this._animateSetBlock_originEnabled(block, number, x, y, floorId, time, callback); + return this._animateSetBlock_originEnabled( + block, + number, + x, + y, + floorId, + time, + callback + ); } // 如果原本不存在 if (originBlock == null) { - return this._animateSetBlock_originNotExists(block, number, x, y, floorId, time, callback); + return this._animateSetBlock_originNotExists( + block, + number, + x, + y, + floorId, + time, + callback + ); } // 如果原本存在且禁用;应当直接设置,没有动画 if (originBlock != null && originBlock.disable) { - return this._animateSetBlock_originDisabled(number, x, y, floorId, callback); + return this._animateSetBlock_originDisabled( + number, + x, + y, + floorId, + callback + ); } if (callback) callback(); -} +}; -maps.prototype._animateSetBlock_originEnabled = function (block, number, x, y, floorId, time, callback) { +maps.prototype._animateSetBlock_originEnabled = function ( + block, + number, + x, + y, + floorId, + time, + callback +) { // 情况1:设置到0 if (block.id == 0) { // 如果该点红点没有事件 - 直接删除 @@ -2346,37 +3423,55 @@ maps.prototype._animateSetBlock_originEnabled = function (block, number, x, y, f return this.animateBlock([x, y], 'hide', time / 2, function () { core.setBlock(number, x, y, floorId); core.animateBlock([x, y], 'show', time / 2, callback); - }) + }); } -} +}; -maps.prototype._animateSetBlock_originNotExists = function (block, number, x, y, floorId, time, callback) { +maps.prototype._animateSetBlock_originNotExists = function ( + block, + number, + x, + y, + floorId, + time, + callback +) { // 情况1:设置到0;没有动画效果 if (block.id == 0) { core.setBlock(number, x, y, floorId); if (callback) callback(); - } - else { + } else { // 情况2:设置到非0,有淡入动画 core.setBlock(number, x, y, floorId); core.hideBlock(x, y, floorId); core.animateBlock([x, y], 'show', time, callback); return; } -} +}; -maps.prototype._animateSetBlock_originDisabled = function (number, x, y, floorId, callback) { +maps.prototype._animateSetBlock_originDisabled = function ( + number, + x, + y, + floorId, + callback +) { core.setBlock(number, x, y, floorId); if (callback) callback(); -} +}; -maps.prototype.animateSetBlocks = function (number, locs, floorId, time, callback) { +maps.prototype.animateSetBlocks = function ( + number, + locs, + floorId, + time, + callback +) { if (!(locs instanceof Array)) { if (callback) callback(); return; } - if (typeof locs[0] == 'number' && typeof locs[1] == 'number') - locs = [locs]; + if (typeof locs[0] == 'number' && typeof locs[1] == 'number') locs = [locs]; var count = locs.length; var _afterSet = function () { @@ -2384,11 +3479,11 @@ maps.prototype.animateSetBlocks = function (number, locs, floorId, time, callbac if (count == 0) { if (callback) callback(); } - } + }; locs.forEach(function (loc) { core.animateSetBlock(number, loc[0], loc[1], floorId, time, _afterSet); }); -} +}; ////// 事件转向 ////// maps.prototype.turnBlock = function (direction, x, y, floorId) { @@ -2408,7 +3503,7 @@ maps.prototype.turnBlock = function (direction, x, y, floorId) { if (nextId != null && nextId != id) { this.setBlock(nextId, x, y, floorId); } -} +}; ////// 将地图中所有某个图块替换成另一个图块 ////// maps.prototype.replaceBlock = function (fromNumber, toNumber, floorId) { @@ -2431,13 +3526,19 @@ maps.prototype.replaceBlock = function (fromNumber, toNumber, floorId) { } }, this); if (floorId == core.status.floorId) core.redrawMap(); -} +}; ////// 改变前景背景的图块 ////// maps.prototype.setBgFgBlock = function (name, number, x, y, floorId) { floorId = floorId || core.status.floorId; if (!floorId || number == null || x == null || y == null) return; - if (x < 0 || x >= core.floors[floorId].width || y < 0 || y >= core.floors[floorId].height) return; + if ( + x < 0 || + x >= core.floors[floorId].width || + y < 0 || + y >= core.floors[floorId].height + ) + return; if (!name || (!name.startsWith('bg') && !name.startsWith('fg'))) return; if (typeof number == 'string') { @@ -2446,11 +3547,13 @@ maps.prototype.setBgFgBlock = function (name, number, x, y, floorId) { } var values = core.getFlag('__' + name + 'v__', {}); - values[floorId] = (values[floorId] || []).filter(function (one) { return one[0] != x || one[1] != y }); + values[floorId] = (values[floorId] || []).filter(function (one) { + return one[0] != x || one[1] != y; + }); values[floorId].push([x, y, number]); core.setFlag('__' + name + 'v__', values); - core.status[name + "maps"][floorId] = null; + core.status[name + 'maps'][floorId] = null; this._getBgFgMapArray(name, floorId, true); @@ -2459,7 +3562,7 @@ maps.prototype.setBgFgBlock = function (name, number, x, y, floorId) { if (name.startsWith('bg')) core.drawBg(floorId); else core.drawFg(floorId); } -} +}; ////// 重置地图 ////// maps.prototype.resetMap = function (floorId) { @@ -2471,46 +3574,65 @@ maps.prototype.resetMap = function (floorId) { core.status.maps[t] = core.maps.loadFloor(t); // 重置本层的全部独立事件 Object.keys(core.status.hero.flags).forEach(function (one) { - if (one.startsWith(floorId + '@')) delete core.status.hero.flags[one]; - }) + if (one.startsWith(floorId + '@')) + delete core.status.hero.flags[one]; + }); // 重置本层的图块删除信息 delete (flags.__disabled__ || {})[t]; delete (core.status.mapBlockObjs || {})[t]; if (t == core.status.floorId) needRefresh = true; }); if (needRefresh) this.redrawMap(); - core.drawTip("地图重置成功"); -} + core.drawTip('地图重置成功'); +}; // -------- 移动/跳跃图块,图块的淡入淡出 -------- // ////// 初始化独立的block canvas ////// maps.prototype._initDetachedBlock = function (blockInfo, x, y, displayDamage) { - var headCanvas = null, bodyCanvas = '__body_' + x + "_" + y, damageCanvas = null; + var headCanvas = null, + bodyCanvas = '__body_' + x + '_' + y, + damageCanvas = null; // head if (!blockInfo.bigImage && blockInfo.height > 32) { - headCanvas = "__head_" + x + "_" + y; + headCanvas = '__head_' + x + '_' + y; core.createCanvas(headCanvas, 0, 0, 32, blockInfo.height - 32, 55); } // body if (blockInfo.bigImage) { - var bigImageInfo = this._getBigImageInfo(blockInfo.bigImage, blockInfo.face, blockInfo.posX); - core.createCanvas(bodyCanvas, 0, 0, bigImageInfo.per_width, bigImageInfo.per_height, 35); + var bigImageInfo = this._getBigImageInfo( + blockInfo.bigImage, + blockInfo.face, + blockInfo.posX + ); + core.createCanvas( + bodyCanvas, + 0, + 0, + bigImageInfo.per_width, + bigImageInfo.per_height, + 35 + ); } else { core.createCanvas(bodyCanvas, 0, 0, 32, 32, 35); } // damage - var damage = null, damageColor = null; - if (blockInfo.cls.indexOf('enemy') == 0 && core.hasItem('book') && displayDamage) { + var damage = null, + damageColor = null; + if ( + blockInfo.cls.indexOf('enemy') == 0 && + core.hasItem('book') && + displayDamage + ) { var damageString = core.enemys.getDamageString(blockInfo.id, x, y); damage = damageString.damage; damageColor = damageString.color; } if (damage != null) { - damageCanvas = "__damage_" + x + "_" + y; + damageCanvas = '__damage_' + x + '_' + y; var ctx = core.createCanvas(damageCanvas, 0, 0, 32, 32, 65); ctx.textAlign = 'left'; - ctx.font = "bold 11px Arial"; + ctx.font = 'bold 11px Arial'; core.fillBoldText(ctx, damage, 1, 31, damageColor); if (core.flags.displayCritical) { var critical = core.enemys.nextCriticals(blockInfo.id); @@ -2521,20 +3643,45 @@ maps.prototype._initDetachedBlock = function (blockInfo, x, y, displayDamage) { } } return { - "headCanvas": headCanvas, - "bodyCanvas": bodyCanvas, - "damageCanvas": damageCanvas - } -} + headCanvas: headCanvas, + bodyCanvas: bodyCanvas, + damageCanvas: damageCanvas + }; +}; ////// 移动独立的block canvas ////// -maps.prototype._moveDetachedBlock = function (blockInfo, nowX, nowY, opacity, canvases) { - var height = blockInfo.height, posX = blockInfo.posX, posY = blockInfo.posY, image = blockInfo.image; - var headCanvas = canvases.headCanvas, bodyCanvas = canvases.bodyCanvas, damageCanvas = canvases.damageCanvas; +maps.prototype._moveDetachedBlock = function ( + blockInfo, + nowX, + nowY, + opacity, + canvases +) { + var height = blockInfo.height, + posX = blockInfo.posX, + posY = blockInfo.posY, + image = blockInfo.image; + var headCanvas = canvases.headCanvas, + bodyCanvas = canvases.bodyCanvas, + damageCanvas = canvases.damageCanvas; if (headCanvas) { core.dymCanvas[headCanvas].clearRect(0, 0, 32, height); - core.dymCanvas[headCanvas].drawImage(image, posX * 32, posY * height, 32, height - 32, 0, 0, 32, height - 32); - core.relocateCanvas(headCanvas, nowX - core.bigmap.offsetX, nowY + 32 - height - core.bigmap.offsetY); + core.dymCanvas[headCanvas].drawImage( + image, + posX * 32, + posY * height, + 32, + height - 32, + 0, + 0, + 32, + height - 32 + ); + core.relocateCanvas( + headCanvas, + nowX - core.bigmap.offsetX, + nowY + 32 - height - core.bigmap.offsetY + ); core.setOpacity(headCanvas, opacity); } if (bodyCanvas) { @@ -2550,31 +3697,73 @@ maps.prototype._moveDetachedBlock = function (blockInfo, nowX, nowY, opacity, ca } } } - var bigImageInfo = this._getBigImageInfo(blockInfo.bigImage, face, blockInfo.posX); - var per_width = bigImageInfo.per_width, per_height = bigImageInfo.per_height; - core.dymCanvas[bodyCanvas].clearRect(0, 0, bigImageInfo.per_width, bigImageInfo.per_height); - core.dymCanvas[bodyCanvas].drawImage(blockInfo.bigImage, bigImageInfo.sx, bigImageInfo.sy, per_width, per_height, 0, 0, per_width, per_height); - core.relocateCanvas(bodyCanvas, nowX - core.bigmap.offsetX + bigImageInfo.dx, nowY - core.bigmap.offsetY + bigImageInfo.dy); + var bigImageInfo = this._getBigImageInfo( + blockInfo.bigImage, + face, + blockInfo.posX + ); + var per_width = bigImageInfo.per_width, + per_height = bigImageInfo.per_height; + core.dymCanvas[bodyCanvas].clearRect( + 0, + 0, + bigImageInfo.per_width, + bigImageInfo.per_height + ); + core.dymCanvas[bodyCanvas].drawImage( + blockInfo.bigImage, + bigImageInfo.sx, + bigImageInfo.sy, + per_width, + per_height, + 0, + 0, + per_width, + per_height + ); + core.relocateCanvas( + bodyCanvas, + nowX - core.bigmap.offsetX + bigImageInfo.dx, + nowY - core.bigmap.offsetY + bigImageInfo.dy + ); core.setOpacity(bodyCanvas, opacity); } else { core.dymCanvas[bodyCanvas].clearRect(0, 0, 32, 32); - core.dymCanvas[bodyCanvas].drawImage(image, posX * 32, posY * height + height - 32, 32, 32, 0, 0, 32, 32); - core.relocateCanvas(bodyCanvas, nowX - core.bigmap.offsetX, nowY - core.bigmap.offsetY); + core.dymCanvas[bodyCanvas].drawImage( + image, + posX * 32, + posY * height + height - 32, + 32, + 32, + 0, + 0, + 32, + 32 + ); + core.relocateCanvas( + bodyCanvas, + nowX - core.bigmap.offsetX, + nowY - core.bigmap.offsetY + ); core.setOpacity(bodyCanvas, opacity); } } if (damageCanvas) { - core.relocateCanvas(damageCanvas, nowX - core.bigmap.offsetX, nowY - core.bigmap.offsetY); + core.relocateCanvas( + damageCanvas, + nowX - core.bigmap.offsetX, + nowY - core.bigmap.offsetY + ); core.setOpacity(damageCanvas, opacity); } -} +}; ////// 删除独立的block canvas ////// maps.prototype._deleteDetachedBlock = function (canvases) { core.deleteCanvas(canvases.headCanvas); core.deleteCanvas(canvases.bodyCanvas); core.deleteCanvas(canvases.damageCanvas); -} +}; maps.prototype._getAndRemoveBlock = function (x, y) { var block = core.getBlock(x, y); @@ -2583,7 +3772,7 @@ maps.prototype._getAndRemoveBlock = function (x, y) { if (blockInfo == null) return; core.removeBlock(x, y); return [block, blockInfo]; -} +}; ////// 显示移动某块的动画,达到{“type”:”move”}的效果 ////// maps.prototype.moveBlock = function (x, y, steps, time, keep, callback) { @@ -2594,27 +3783,66 @@ maps.prototype.moveBlock = function (x, y, steps, time, keep, callback) { if (callback) callback(); return; } - var block = blockArr[0], blockInfo = blockArr[1]; - var moveSteps = (steps || []).map(function (t) { - return [t.split(':')[0], parseInt(t.split(':')[1] || "1")]; - }).filter(function (t) { - return ['up', 'down', 'left', 'right', 'forward', 'backward', 'leftup', 'leftdown', 'rightup', 'rightdown', 'speed'].indexOf(t[0]) >= 0 - && !(t[0] == 'speed' && t[1] < 16) - }); - var canvases = this._initDetachedBlock(blockInfo, x, y, block.event.animate !== false); + var block = blockArr[0], + blockInfo = blockArr[1]; + var moveSteps = (steps || []) + .map(function (t) { + return [t.split(':')[0], parseInt(t.split(':')[1] || '1')]; + }) + .filter(function (t) { + return ( + [ + 'up', + 'down', + 'left', + 'right', + 'forward', + 'backward', + 'leftup', + 'leftdown', + 'rightup', + 'rightdown', + 'speed' + ].indexOf(t[0]) >= 0 && !(t[0] == 'speed' && t[1] < 16) + ); + }); + var canvases = this._initDetachedBlock( + blockInfo, + x, + y, + block.event.animate !== false + ); this._moveDetachedBlock(blockInfo, 32 * x, 32 * y, 1, canvases); var moveInfo = { - sx: x, sy: y, x: x, y: y, px: 32 * x, py: 32 * y, opacity: 1, keep: keep, lastDirection: null, offset: 1, - moveSteps: moveSteps, step: 0, per_time: time / 16 / core.status.replay.speed - } + sx: x, + sy: y, + x: x, + y: y, + px: 32 * x, + py: 32 * y, + opacity: 1, + keep: keep, + lastDirection: null, + offset: 1, + moveSteps: moveSteps, + step: 0, + per_time: time / 16 / core.status.replay.speed + }; this._moveBlock_doMove(blockInfo, canvases, moveInfo, callback); -} +}; -maps.prototype._moveBlock_doMove = function (blockInfo, canvases, moveInfo, callback) { - var animateTotal = blockInfo.animate, animateTime = 0; +maps.prototype._moveBlock_doMove = function ( + blockInfo, + canvases, + moveInfo, + callback +) { + var animateTotal = blockInfo.animate, + animateTime = 0; // 强制npc48行走时使用四帧动画 - if (!blockInfo.doorInfo && !blockInfo.bigImage && blockInfo.cls == 'npc48') animateTotal = 4; + if (!blockInfo.doorInfo && !blockInfo.bigImage && blockInfo.cls == 'npc48') + animateTotal = 4; var _run = function () { var cb = function () { core.maps._deleteDetachedBlock(canvases); @@ -2622,10 +3850,15 @@ maps.prototype._moveBlock_doMove = function (blockInfo, canvases, moveInfo, call if (moveInfo.keep) { core.setBlock(blockInfo.number, moveInfo.x, moveInfo.y); core.showBlock(moveInfo.x, moveInfo.y); - core.moveEnemyOnPoint(moveInfo.sx, moveInfo.sy, moveInfo.x, moveInfo.y); + core.moveEnemyOnPoint( + moveInfo.sx, + moveInfo.sy, + moveInfo.x, + moveInfo.y + ); } if (callback) callback(); - } + }; var animate = window.setInterval(function () { if (blockInfo.cls != 'tileset') { @@ -2640,27 +3873,30 @@ maps.prototype._moveBlock_doMove = function (blockInfo, canvases, moveInfo, call clearInterval(animate); delete core.animateFrame.asyncId[animate]; _run(); - } - else core.maps._moveBlock_moving(blockInfo, canvases, moveInfo); - } - else - core.maps._moveJumpBlock_finished(blockInfo, canvases, moveInfo, animate, cb); + } else + core.maps._moveBlock_moving(blockInfo, canvases, moveInfo); + } else core.maps._moveJumpBlock_finished(blockInfo, canvases, moveInfo, animate, cb); }, moveInfo.per_time); core.animateFrame.lastAsyncId = animate; core.animateFrame.asyncId[animate] = cb; - } + }; _run(); -} +}; maps.prototype._moveBlock_updateSpeed = function (moveInfo) { - if (moveInfo.step == 0 && moveInfo.moveSteps[0][0] == 'speed' && moveInfo.moveSteps[0][1] >= 16) { - moveInfo.per_time = moveInfo.moveSteps[0][1] / 16 / core.status.replay.speed; + if ( + moveInfo.step == 0 && + moveInfo.moveSteps[0][0] == 'speed' && + moveInfo.moveSteps[0][1] >= 16 + ) { + moveInfo.per_time = + moveInfo.moveSteps[0][1] / 16 / core.status.replay.speed; moveInfo.moveSteps.shift(); return true; } return false; -} +}; maps.prototype._moveBlock_updateDirection = function (blockInfo, moveInfo) { moveInfo.offset = 1; @@ -2686,16 +3922,17 @@ maps.prototype._moveBlock_updateDirection = function (blockInfo, moveInfo) { moveInfo.moveSteps.shift(); return false; } - if (curr[0] == 'backward') - moveInfo.offset = -1; + if (curr[0] == 'backward') moveInfo.offset = -1; curr[0] = moveInfo.lastDirection; } moveInfo.lastDirection = curr[0]; // 根据faceIds修改朝向 var faceDirection = curr[0]; - if (faceDirection == 'leftup' || faceDirection == 'leftdown') faceDirection = 'left'; - if (faceDirection == 'rightup' || faceDirection == 'rightdown') faceDirection = 'right'; + if (faceDirection == 'leftup' || faceDirection == 'leftdown') + faceDirection = 'left'; + if (faceDirection == 'rightup' || faceDirection == 'rightdown') + faceDirection = 'right'; var currid = blockInfo.faceIds[faceDirection]; blockInfo.face = faceDirection; if (currid) { @@ -2713,7 +3950,7 @@ maps.prototype._moveBlock_updateDirection = function (blockInfo, moveInfo) { moveInfo.x += core.utils.scan2[curr[0]].x * moveInfo.offset; moveInfo.y += core.utils.scan2[curr[0]].y * moveInfo.offset; return true; -} +}; maps.prototype._moveBlock_moving = function (blockInfo, canvases, moveInfo) { if (moveInfo.step == 0) { @@ -2723,7 +3960,13 @@ maps.prototype._moveBlock_moving = function (blockInfo, canvases, moveInfo) { moveInfo.step++; moveInfo.px += core.utils.scan2[curr[0]].x * 2 * moveInfo.offset; moveInfo.py += core.utils.scan2[curr[0]].y * 2 * moveInfo.offset; - this._moveDetachedBlock(blockInfo, moveInfo.px, moveInfo.py, moveInfo.opacity, canvases); + this._moveDetachedBlock( + blockInfo, + moveInfo.px, + moveInfo.py, + moveInfo.opacity, + canvases + ); if (moveInfo.step == 16) { moveInfo.step = 0; moveInfo.moveSteps[0][1]--; @@ -2731,7 +3974,7 @@ maps.prototype._moveBlock_moving = function (blockInfo, canvases, moveInfo) { moveInfo.moveSteps.shift(); } } -} +}; ////// 显示跳跃某块的动画,达到{"type":"jump"}的效果 ////// maps.prototype.jumpBlock = function (sx, sy, ex, ey, time, keep, callback) { @@ -2741,82 +3984,144 @@ maps.prototype.jumpBlock = function (sx, sy, ex, ey, time, keep, callback) { if (callback) callback(); return; } - var block = blockArr[0], blockInfo = blockArr[1]; - var canvases = this._initDetachedBlock(blockInfo, sx, sy, block.event.animate !== false); + var block = blockArr[0], + blockInfo = blockArr[1]; + var canvases = this._initDetachedBlock( + blockInfo, + sx, + sy, + block.event.animate !== false + ); this._moveDetachedBlock(blockInfo, 32 * sx, 32 * sy, 1, canvases); var jumpInfo = this.__generateJumpInfo(sx, sy, ex, ey, time); jumpInfo.keep = keep; this._jumpBlock_doJump(blockInfo, canvases, jumpInfo, callback); -} +}; maps.prototype.__generateJumpInfo = function (sx, sy, ex, ey, time) { - var dx = ex - sx, dy = ey - sy, distance = Math.round(Math.sqrt(dx * dx + dy * dy)); - var jump_peak = 6 + distance, jump_count = jump_peak * 2; - time /= Math.max(core.status.replay.speed, 1) + var dx = ex - sx, + dy = ey - sy, + distance = Math.round(Math.sqrt(dx * dx + dy * dy)); + var jump_peak = 6 + distance, + jump_count = jump_peak * 2; + time /= Math.max(core.status.replay.speed, 1); return { - sx: sx, sy: sy, x: sx, y: sy, ex: ex, ey: ey, px: 32 * sx, py: 32 * sy, opacity: 1, - jump_peak: jump_peak, jump_count: jump_count, - step: 0, per_time: time / jump_count + sx: sx, + sy: sy, + x: sx, + y: sy, + ex: ex, + ey: ey, + px: 32 * sx, + py: 32 * sy, + opacity: 1, + jump_peak: jump_peak, + jump_count: jump_count, + step: 0, + per_time: time / jump_count }; -} +}; -maps.prototype._jumpBlock_doJump = function (blockInfo, canvases, jumpInfo, callback) { +maps.prototype._jumpBlock_doJump = function ( + blockInfo, + canvases, + jumpInfo, + callback +) { var cb = function () { core.maps._deleteDetachedBlock(canvases); // 不消失 if (jumpInfo.keep) { core.setBlock(blockInfo.number, jumpInfo.ex, jumpInfo.ey); core.showBlock(jumpInfo.ex, jumpInfo.ey); - core.moveEnemyOnPoint(jumpInfo.sx, jumpInfo.sy, jumpInfo.ex, jumpInfo.ey); + core.moveEnemyOnPoint( + jumpInfo.sx, + jumpInfo.sy, + jumpInfo.ex, + jumpInfo.ey + ); } if (callback) callback(); - } + }; var animate = window.setInterval(function () { if (jumpInfo.jump_count > 0) - core.maps._jumpBlock_jumping(blockInfo, canvases, jumpInfo) + core.maps._jumpBlock_jumping(blockInfo, canvases, jumpInfo); else - core.maps._moveJumpBlock_finished(blockInfo, canvases, jumpInfo, animate, cb); + core.maps._moveJumpBlock_finished( + blockInfo, + canvases, + jumpInfo, + animate, + cb + ); }, jumpInfo.per_time); core.animateFrame.lastAsyncId = animate; core.animateFrame.asyncId[animate] = cb; -} +}; maps.prototype.__updateJumpInfo = function (jumpInfo) { jumpInfo.jump_count--; - jumpInfo.x = (jumpInfo.x * jumpInfo.jump_count + jumpInfo.ex) / (jumpInfo.jump_count + 1.0); - jumpInfo.y = (jumpInfo.y * jumpInfo.jump_count + jumpInfo.ey) / (jumpInfo.jump_count + 1.0); + jumpInfo.x = + (jumpInfo.x * jumpInfo.jump_count + jumpInfo.ex) / + (jumpInfo.jump_count + 1.0); + jumpInfo.y = + (jumpInfo.y * jumpInfo.jump_count + jumpInfo.ey) / + (jumpInfo.jump_count + 1.0); jumpInfo.px = 32 * jumpInfo.x; var delta = Math.abs(jumpInfo.jump_count - jumpInfo.jump_peak); - jumpInfo.py = 32 * jumpInfo.y - (jumpInfo.jump_peak * jumpInfo.jump_peak - delta * delta) / 2; -} + jumpInfo.py = + 32 * jumpInfo.y - + (jumpInfo.jump_peak * jumpInfo.jump_peak - delta * delta) / 2; +}; maps.prototype._jumpBlock_jumping = function (blockInfo, canvases, jumpInfo) { this.__updateJumpInfo(jumpInfo); - core.maps._moveDetachedBlock(blockInfo, jumpInfo.px, jumpInfo.py, jumpInfo.opacity, canvases); -} + core.maps._moveDetachedBlock( + blockInfo, + jumpInfo.px, + jumpInfo.py, + jumpInfo.opacity, + canvases + ); +}; -maps.prototype._moveJumpBlock_finished = function (blockInfo, canvases, info, animate, cb) { +maps.prototype._moveJumpBlock_finished = function ( + blockInfo, + canvases, + info, + animate, + cb +) { if (info.keep) info.opacity = 0; else info.opacity -= 0.06; if (info.opacity <= 0) { delete core.animateFrame.asyncId[animate]; clearInterval(animate); cb(); + } else { + this._moveDetachedBlock( + blockInfo, + info.px, + info.py, + info.opacity, + canvases + ); } - else { - this._moveDetachedBlock(blockInfo, info.px, info.py, info.opacity, canvases); - } -} +}; ////// 显示/隐藏某个块时的动画效果 ////// maps.prototype.animateBlock = function (loc, type, time, callback) { if (core.status.replay.speed == 24) time = 1; - if (typeof loc[0] == 'number' && typeof loc[1] == 'number') - loc = [loc]; - if (type != 'show' && type != 'hide' && type != 'remove' && typeof type != 'number') { + if (typeof loc[0] == 'number' && typeof loc[1] == 'number') loc = [loc]; + if ( + type != 'show' && + type != 'hide' && + type != 'remove' && + typeof type != 'number' + ) { if (callback) callback(); } // --- 检测所有是0的点 @@ -2826,16 +4131,22 @@ maps.prototype.animateBlock = function (loc, type, time, callback) { return; } this._animateBlock_drawList(list, 0); - time /= Math.max(core.status.replay.speed, 1) + time /= Math.max(core.status.replay.speed, 1); this._animateBlock_doAnimate(loc, list, type, time, callback); -} +}; -maps.prototype._animateBlock_doAnimate = function (loc, list, type, time, callback) { - var step = 0, steps = Math.max(parseInt(time / 10), 1); +maps.prototype._animateBlock_doAnimate = function ( + loc, + list, + type, + time, + callback +) { + var step = 0, + steps = Math.max(parseInt(time / 10), 1); var cb = function () { list.forEach(function (t) { - if (t.blockInfo) - core.maps._deleteDetachedBlock(t.canvases); + if (t.blockInfo) core.maps._deleteDetachedBlock(t.canvases); }); loc.forEach(function (t) { if (type == 'show') core.showBlock(t[0], t[1]); @@ -2847,7 +4158,7 @@ maps.prototype._animateBlock_doAnimate = function (loc, list, type, time, callba } }); if (callback) callback(); - } + }; var animate = setInterval(function () { step++; @@ -2861,7 +4172,7 @@ maps.prototype._animateBlock_doAnimate = function (loc, list, type, time, callba core.animateFrame.lastAsyncId = animate; core.animateFrame.asyncId[animate] = cb; -} +}; maps.prototype._animateBlock_getList = function (loc, type) { var list = []; @@ -2874,13 +4185,16 @@ maps.prototype._animateBlock_getList = function (loc, type) { var blockInfo = core.maps.getBlockInfo(block); if (blockInfo == null) { - list.push({ 'x': t[0], 'y': t[1] }); + list.push({ x: t[0], y: t[1] }); return; } if (typeof type == 'number' && block.disable) return; // 该点是否已经被启用/删除 - if ((type == 'show' && !block.disable) || ((type == 'hide' || type == 'remove') && block.disable)) { - list.push({ 'x': t[0], 'y': t[1] }); + if ( + (type == 'show' && !block.disable) || + ((type == 'hide' || type == 'remove') && block.disable) + ) { + list.push({ x: t[0], y: t[1] }); return; } @@ -2888,32 +4202,44 @@ maps.prototype._animateBlock_getList = function (loc, type) { if (type == 'show') { toOpacity = fromOpacity; fromOpacity = 0.0; - } - else if (type == 'hide' || type == 'remove') { + } else if (type == 'hide' || type == 'remove') { core.hideBlock(t[0], t[1]); // 暂时先隐藏 toOpacity = 0.0; - } - else { + } else { core.hideBlock(t[0], t[1]); // 暂时先隐藏 } - var canvases = core.maps._initDetachedBlock(blockInfo, t[0], t[1], block.event.displayDamage !== false); + var canvases = core.maps._initDetachedBlock( + blockInfo, + t[0], + t[1], + block.event.displayDamage !== false + ); list.push({ - 'x': t[0], 'y': t[1], 'blockInfo': blockInfo, 'canvases': canvases, - 'fromOpacity': fromOpacity, 'toOpacity': toOpacity, + x: t[0], + y: t[1], + blockInfo: blockInfo, + canvases: canvases, + fromOpacity: fromOpacity, + toOpacity: toOpacity }); - }); return list; -} +}; maps.prototype._animateBlock_drawList = function (list, progress) { list.forEach(function (t) { if (t.blockInfo) - core.maps._moveDetachedBlock(t.blockInfo, t.x * 32, t.y * 32, t.fromOpacity + progress * (t.toOpacity - t.fromOpacity), t.canvases); + core.maps._moveDetachedBlock( + t.blockInfo, + t.x * 32, + t.y * 32, + t.fromOpacity + progress * (t.toOpacity - t.fromOpacity), + t.canvases + ); }); -} +}; // ------ 全局动画控制,动画绘制 ------ // @@ -2922,15 +4248,19 @@ maps.prototype.addGlobalAnimate = function (block) { if (!block || !block.event) return; this.removeGlobalAnimate(block.x, block.y, block.name); if (block.event.cls == 'autotile') { - var id = block.event.id, img = core.material.images.autotile[id]; + var id = block.event.id, + img = core.material.images.autotile[id]; if (!img || img.width == 96) return; core.status.autotileAnimateObjs.push(block); - } - else { - if (!block.event.bigImage && (!block.event.animate || block.event.animate == 1)) return; + } else { + if ( + !block.event.bigImage && + (!block.event.animate || block.event.animate == 1) + ) + return; core.status.globalAnimateObjs.push(block); } -} +}; ////// 删除一个或所有全局动画 ////// maps.prototype.removeGlobalAnimate = function (x, y, name) { @@ -2943,21 +4273,31 @@ maps.prototype.removeGlobalAnimate = function (x, y, name) { return; } - core.status.globalAnimateObjs = core.status.globalAnimateObjs.filter(function (block) { - return block.x != x || block.y != y || block.name != name; - }); + core.status.globalAnimateObjs = core.status.globalAnimateObjs.filter( + function (block) { + return block.x != x || block.y != y || block.name != name; + } + ); // 检查Autotile - core.status.autotileAnimateObjs = core.status.autotileAnimateObjs.filter(function (block) { - return block.x != x || block.y != y || block.name != name; - }); -} + core.status.autotileAnimateObjs = core.status.autotileAnimateObjs.filter( + function (block) { + return block.x != x || block.y != y || block.name != name; + } + ); +}; ////// 绘制UI层的box动画 ////// maps.prototype.drawBoxAnimate = function () { if (core.status.boxAnimateObjs.length == 0) return; // check ui2 - if (main.mode == 'play' && core.status.boxAnimateObjs.filter(function (one) { return one.bigImage }).length > 0 && !core.dymCanvas.ui2) { + if ( + main.mode == 'play' && + core.status.boxAnimateObjs.filter(function (one) { + return one.bigImage; + }).length > 0 && + !core.dymCanvas.ui2 + ) { core.createCanvas('ui2', 0, 0, core._PX_, core._PY_, 142); } core.clearMap('ui2'); @@ -2965,38 +4305,88 @@ maps.prototype.drawBoxAnimate = function () { core.status.boxAnimateObjs.forEach(function (obj) { if (obj.bigImage) { var ctx = obj.ctx || 'ui2'; - var bigImageInfo = core.maps._getBigImageInfo(obj.bigImage, obj.face, core.status.globalAnimateStatus % 4); - var sx = bigImageInfo.sx, sy = bigImageInfo.sy, per_width = bigImageInfo.per_width, per_height = bigImageInfo.per_height; - var actual_width = Math.min(per_width, obj.max_width || per_width), actual_height = per_height * actual_width / per_width; - var x = obj.centerX - actual_width / 2, y = obj.centerY - actual_height / 2; + var bigImageInfo = core.maps._getBigImageInfo( + obj.bigImage, + obj.face, + core.status.globalAnimateStatus % 4 + ); + var sx = bigImageInfo.sx, + sy = bigImageInfo.sy, + per_width = bigImageInfo.per_width, + per_height = bigImageInfo.per_height; + var actual_width = Math.min(per_width, obj.max_width || per_width), + actual_height = (per_height * actual_width) / per_width; + var x = obj.centerX - actual_width / 2, + y = obj.centerY - actual_height / 2; core.clearMap(ctx, x, y, actual_width, actual_height); - core.fillRect(ctx, x, y, actual_width, actual_height, core.material.groundPattern); + core.fillRect( + ctx, + x, + y, + actual_width, + actual_height, + core.material.groundPattern + ); core.strokeRect(ctx, x, y, actual_width, actual_height, 'gold', 2); - core.drawImage(ctx, obj.bigImage, sx, sy, per_width, per_height, - obj.centerX - actual_width / 2, obj.centerY - actual_height / 2, actual_width, actual_height); + core.drawImage( + ctx, + obj.bigImage, + sx, + sy, + per_width, + per_height, + obj.centerX - actual_width / 2, + obj.centerY - actual_height / 2, + actual_width, + actual_height + ); } else { var ctx = obj.ctx || 'ui'; core.clearMap(ctx, obj.bgx, obj.bgy, obj.bgWidth, obj.bgHeight); - core.fillRect(ctx, obj.bgx, obj.bgy, obj.bgWidth, obj.bgHeight, core.material.groundPattern); - core.drawImage(ctx, obj.image, core.status.globalAnimateStatus % obj.animate * 32, obj.pos, - 32, obj.height, obj.x, obj.y, obj.dw || 32, obj.dh || obj.height); + core.fillRect( + ctx, + obj.bgx, + obj.bgy, + obj.bgWidth, + obj.bgHeight, + core.material.groundPattern + ); + core.drawImage( + ctx, + obj.image, + (core.status.globalAnimateStatus % obj.animate) * 32, + obj.pos, + 32, + obj.height, + obj.x, + obj.y, + obj.dw || 32, + obj.dh || obj.height + ); } }); if (main.mode != 'play') core.status.boxAnimateObjs = []; -} +}; ////// 绘制动画 ////// maps.prototype.drawAnimate = function (name, x, y, alignWindow, callback) { name = core.getMappedName(name); // 正在播放录像:不显示动画 - if (core.isReplaying() || !core.material.animates[name] || x == null || y == null) { + if ( + core.isReplaying() || + !core.material.animates[name] || + x == null || + y == null + ) { if (callback) callback(); return -1; } // 开始绘制 - var animate = core.material.animates[name], centerX = 32 * x + 16, centerY = 32 * y + 16; + var animate = core.material.animates[name], + centerX = 32 * x + 16, + centerY = 32 * y + 16; if (alignWindow) { centerX += core.bigmap.offsetX; centerY += core.bigmap.offsetY; @@ -3006,17 +4396,17 @@ maps.prototype.drawAnimate = function (name, x, y, alignWindow, callback) { var id = setTimeout(null); core.status.animateObjs.push({ - "name": name, - "id": id, - "animate": animate, - "centerX": centerX, - "centerY": centerY, - "index": 0, - "callback": callback + name: name, + id: id, + animate: animate, + centerX: centerX, + centerY: centerY, + index: 0, + callback: callback }); return id; -} +}; ////// 绘制一个跟随勇士的动画 ////// maps.prototype.drawHeroAnimate = function (name, callback) { @@ -3035,51 +4425,78 @@ maps.prototype.drawHeroAnimate = function (name, callback) { var id = setTimeout(null); core.status.animateObjs.push({ - "name": name, - "id": id, - "animate": animate, - "hero": true, - "index": 0, - "callback": callback + name: name, + id: id, + animate: animate, + hero: true, + index: 0, + callback: callback }); return id; -} +}; ////// 获得当前正在播放的所有(指定)动画的id列表 ////// maps.prototype.getPlayingAnimates = function (name) { - return (core.status.animateObjs || []).filter(function (one) { - return name == null || one.name == name; - }).map(function (one) { return one.id }); -} + return (core.status.animateObjs || []) + .filter(function (one) { + return name == null || one.name == name; + }) + .map(function (one) { + return one.id; + }); +}; ////// 绘制动画的某一帧 ////// -maps.prototype._drawAnimateFrame = function (name, animate, centerX, centerY, index) { +maps.prototype._drawAnimateFrame = function ( + name, + animate, + centerX, + centerY, + index +) { var ctx = core.getContextByName(name); if (!ctx) return; var frame = animate.frames[index % animate.frame]; - core.playSound((animate.se || {})[index % animate.frame + 1], (animate.pitch || {})[index % animate.frame + 1]); + core.playSound( + (animate.se || {})[(index % animate.frame) + 1], + (animate.pitch || {})[(index % animate.frame) + 1] + ); var ratio = animate.ratio; frame.forEach(function (t) { var image = animate.images[t.index]; if (!image) return; - var realWidth = image.width * ratio * t.zoom / 100; - var realHeight = image.height * ratio * t.zoom / 100; + var realWidth = (image.width * ratio * t.zoom) / 100; + var realHeight = (image.height * ratio * t.zoom) / 100; core.setAlpha(ctx, t.opacity / 255); - var cx = centerX + t.x, cy = centerY + t.y; + var cx = centerX + t.x, + cy = centerY + t.y; var ix = cx - realWidth / 2 - core.bigmap.offsetX, iy = cy - realHeight / 2 - core.bigmap.offsetY; var mirror = t.mirror ? 'x' : null; - var angle = t.angle ? -t.angle * Math.PI / 180 : null; - core.drawImage(ctx, image, ix, iy, realWidth, realHeight, null, null, null, null, angle, mirror); + var angle = t.angle ? (-t.angle * Math.PI) / 180 : null; + core.drawImage( + ctx, + image, + ix, + iy, + realWidth, + realHeight, + null, + null, + null, + null, + angle, + mirror + ); core.setAlpha(ctx, 1); - }) -} + }); +}; ////// 停止动画 ////// maps.prototype.stopAnimate = function (id, doCallback) { @@ -3095,7 +4512,8 @@ maps.prototype.stopAnimate = function (id, doCallback) { } } } - core.status.animateObjs = core.status.animateObjs.filter(function (x) { return id != null && x.id != id }); - if (core.status.animateObjs.length == 0) - core.clearMap('animate'); -} + core.status.animateObjs = core.status.animateObjs.filter(function (x) { + return id != null && x.id != id; + }); + if (core.status.animateObjs.length == 0) core.clearMap('animate'); +}; diff --git a/public/libs/utils.js b/public/libs/utils.js index cd5e576..32d444a 100644 --- a/public/libs/utils.js +++ b/public/libs/utils.js @@ -1,41 +1,41 @@ - /* utils.js 工具类 */ -"use strict"; +'use strict'; -function utils () { +function utils() { this._init(); this.scan = { - 'up': { 'x': 0, 'y': -1 }, - 'left': { 'x': -1, 'y': 0 }, - 'down': { 'x': 0, 'y': 1 }, - 'right': { 'x': 1, 'y': 0 } + up: { x: 0, y: -1 }, + left: { x: -1, y: 0 }, + down: { x: 0, y: 1 }, + right: { x: 1, y: 0 } }; this.scan2 = { - 'up': { 'x': 0, 'y': -1 }, - 'left': { 'x': -1, 'y': 0 }, - 'down': { 'x': 0, 'y': 1 }, - 'right': { 'x': 1, 'y': 0 }, - 'leftup': { 'x': -1, 'y': -1 }, - 'leftdown': { 'x': -1, 'y': 1 }, - 'rightup': { 'x': 1, 'y': -1 }, - 'rightdown': { 'x': 1, 'y': 1 } + up: { x: 0, y: -1 }, + left: { x: -1, y: 0 }, + down: { x: 0, y: 1 }, + right: { x: 1, y: 0 }, + leftup: { x: -1, y: -1 }, + leftdown: { x: -1, y: 1 }, + rightup: { x: 1, y: -1 }, + rightdown: { x: 1, y: 1 } }; } utils.prototype._init = function () { // -} +}; ////// 将文字中的${和}(表达式)进行替换 ////// utils.prototype.replaceText = function (text, prefix) { if (typeof text != 'string') return text; - var index = text.indexOf("${"); + var index = text.indexOf('${'); if (index < 0) return text; - var cnt = 0, curr = index; + var cnt = 0, + curr = index; while (++curr < text.length) { if (text.charAt(curr) == '{') cnt++; if (text.charAt(curr) == '}') cnt--; @@ -43,47 +43,93 @@ utils.prototype.replaceText = function (text, prefix) { } if (cnt != 0) return text; var value = core.calValue(text.substring(index + 2, curr), prefix); - if (value == null) value = ""; - return text.substring(0, index) + value + core.replaceText(text.substring(curr + 1), prefix); -} + if (value == null) value = ''; + return ( + text.substring(0, index) + + value + + core.replaceText(text.substring(curr + 1), prefix) + ); +}; utils.prototype.replaceValue = function (value) { - if (typeof value == "string" && (value.indexOf(":") >= 0 || value.indexOf("flag:") >= 0 || value.indexOf('global:') >= 0)) { + if ( + typeof value == 'string' && + (value.indexOf(':') >= 0 || + value.indexOf('flag:') >= 0 || + value.indexOf('global:') >= 0) + ) { if (value.indexOf('status:') >= 0) - value = value.replace(/status:([a-zA-Z0-9_]+)/g, "core.getStatus('$1')"); + value = value.replace( + /status:([a-zA-Z0-9_]+)/g, + "core.getStatus('$1')" + ); if (value.indexOf('buff:') >= 0) - value = value.replace(/buff:([a-zA-Z0-9_]+)/g, "core.getBuff('$1')"); + value = value.replace( + /buff:([a-zA-Z0-9_]+)/g, + "core.getBuff('$1')" + ); if (value.indexOf('item:') >= 0) - value = value.replace(/item:([a-zA-Z0-9_]+)/g, "core.itemCount('$1')"); + value = value.replace( + /item:([a-zA-Z0-9_]+)/g, + "core.itemCount('$1')" + ); if (value.indexOf('flag:') >= 0 || value.indexOf('flag:') >= 0) - value = value.replace(/flag[::]([a-zA-Z0-9_\u4E00-\u9FCC\u3040-\u30FF\u2160-\u216B\u0391-\u03C9]+)/g, "core.getFlag('$1', 0)"); + value = value.replace( + /flag[::]([a-zA-Z0-9_\u4E00-\u9FCC\u3040-\u30FF\u2160-\u216B\u0391-\u03C9]+)/g, + "core.getFlag('$1', 0)" + ); //if (value.indexOf('switch:' >= 0)) // value = value.replace(/switch:([a-zA-Z0-9_]+)/g, "core.getFlag('" + (prefix || ":f@x@y") + "@$1', 0)"); if (value.indexOf('global:') >= 0 || value.indexOf('global:') >= 0) - value = value.replace(/global[::]([a-zA-Z0-9_\u4E00-\u9FCC\u3040-\u30FF\u2160-\u216B\u0391-\u03C9]+)/g, "core.getGlobal('$1', 0)"); + value = value.replace( + /global[::]([a-zA-Z0-9_\u4E00-\u9FCC\u3040-\u30FF\u2160-\u216B\u0391-\u03C9]+)/g, + "core.getGlobal('$1', 0)" + ); if (value.indexOf('enemy:') >= 0) - value = value.replace(/enemy:([a-zA-Z0-9_]+)[\.:]([a-zA-Z0-9_]+)/g, "core.material.enemys['$1'].$2"); + value = value.replace( + /enemy:([a-zA-Z0-9_]+)[\.:]([a-zA-Z0-9_]+)/g, + "core.material.enemys['$1'].$2" + ); if (value.indexOf('blockId:') >= 0) - value = value.replace(/blockId:(\d+),(\d+)/g, "core.getBlockId($1, $2)"); + value = value.replace( + /blockId:(\d+),(\d+)/g, + 'core.getBlockId($1, $2)' + ); if (value.indexOf('blockNumber:') >= 0) - value = value.replace(/blockNumber:(\d+),(\d+)/g, "core.getBlockNumber($1, $2)"); + value = value.replace( + /blockNumber:(\d+),(\d+)/g, + 'core.getBlockNumber($1, $2)' + ); if (value.indexOf('blockCls:') >= 0) - value = value.replace(/blockCls:(\d+),(\d+)/g, "core.getBlockCls($1, $2)"); + value = value.replace( + /blockCls:(\d+),(\d+)/g, + 'core.getBlockCls($1, $2)' + ); if (value.indexOf('equip:') >= 0) - value = value.replace(/equip:(\d)/g, "core.getEquip($1)"); + value = value.replace(/equip:(\d)/g, 'core.getEquip($1)'); if (value.indexOf('temp:') >= 0) - value = value.replace(/temp:([a-zA-Z0-9_]+)/g, "core.getFlag('@temp@$1', 0)"); + value = value.replace( + /temp:([a-zA-Z0-9_]+)/g, + "core.getFlag('@temp@$1', 0)" + ); } return value; -} +}; ////// 计算表达式的值 ////// utils.prototype.calValue = function (value, prefix) { if (!core.isset(value)) return null; if (typeof value === 'string') { - if (value.indexOf(':') >= 0 || value.indexOf("flag:") >= 0 || value.indexOf('global:') >= 0) { + if ( + value.indexOf(':') >= 0 || + value.indexOf('flag:') >= 0 || + value.indexOf('global:') >= 0 + ) { if (value.indexOf('switch:') >= 0) - value = value.replace(/switch:([a-zA-Z0-9_]+)/g, "core.getFlag('" + (prefix || ":f@x@y") + "@$1', 0)"); + value = value.replace( + /switch:([a-zA-Z0-9_]+)/g, + "core.getFlag('" + (prefix || ':f@x@y') + "@$1', 0)" + ); value = this.replaceValue(value); } return eval(value); @@ -92,19 +138,20 @@ utils.prototype.calValue = function (value, prefix) { return value(); } return value; -} +}; ////// 向某个数组前插入另一个数组或元素 ////// utils.prototype.unshift = function (a, b) { if (!(a instanceof Array) || b == null) return; if (b instanceof Array) { - core.clone(b).reverse().forEach(function (e) { - a.unshift(e); - }); - } - else a.unshift(b); + core.clone(b) + .reverse() + .forEach(function (e) { + a.unshift(e); + }); + } else a.unshift(b); return a; -} +}; ////// 向某个数组后插入另一个数组或元素 ////// utils.prototype.push = function (a, b) { @@ -113,32 +160,26 @@ utils.prototype.push = function (a, b) { core.clone(b).forEach(function (e) { a.push(e); }); - } - else a.push(b); + } else a.push(b); return a; -} +}; utils.prototype.decompress = function (value) { try { var output = lzw_decode(value); if (output) return JSON.parse(output); - } - catch (e) { - } + } catch (e) {} try { var output = LZString.decompress(value); if (output) return JSON.parse(output); - } - catch (e) { - } + } catch (e) {} try { return JSON.parse(value); - } - catch (e) { + } catch (e) { console.error(e); } return null; -} +}; ////// 设置本地存储 ////// utils.prototype.setLocalStorage = function (key, value) { @@ -148,62 +189,75 @@ utils.prototype.setLocalStorage = function (key, value) { return; } - var str = JSON.stringify(value).replace(/[\u007F-\uFFFF]/g, function (chr) { - return "\\u" + ("0000" + chr.charCodeAt(0).toString(16)).substr(-4) - }); - localStorage.setItem(core.firstData.name + "_" + key, str); + var str = JSON.stringify(value).replace( + /[\u007F-\uFFFF]/g, + function (chr) { + return ( + '\\u' + ('0000' + chr.charCodeAt(0).toString(16)).substr(-4) + ); + } + ); + localStorage.setItem(core.firstData.name + '_' + key, str); if (key == 'autoSave') core.saves.ids[0] = true; - else if (/^save\d+$/.test(key)) core.saves.ids[parseInt(key.substring(4))] = true; + else if (/^save\d+$/.test(key)) + core.saves.ids[parseInt(key.substring(4))] = true; return true; - } - catch (e) { + } catch (e) { console.error(e); return false; } -} +}; ////// 获得本地存储 ////// utils.prototype.getLocalStorage = function (key, defaultValue) { try { - var value = JSON.parse(localStorage.getItem(core.firstData.name + "_" + key)); + var value = JSON.parse( + localStorage.getItem(core.firstData.name + '_' + key) + ); if (value == null) return defaultValue; return value; } catch (e) { return defaultValue; } -} +}; ////// 移除本地存储 ////// utils.prototype.removeLocalStorage = function (key) { - localStorage.removeItem(core.firstData.name + "_" + key); + localStorage.removeItem(core.firstData.name + '_' + key); if (key == 'autoSave') delete core.saves.ids[0]; - else if (/^save\d+$/.test(key)) delete core.saves.ids[parseInt(key.substring(4))]; -} + else if (/^save\d+$/.test(key)) + delete core.saves.ids[parseInt(key.substring(4))]; +}; -utils.prototype.setLocalForage = function (key, value, successCallback, errorCallback) { +utils.prototype.setLocalForage = function ( + key, + value, + successCallback, + errorCallback +) { if (value == null) { this.removeLocalForage(key); return; } - var name = core.firstData.name + "_" + key; + var name = core.firstData.name + '_' + key; var str = JSON.stringify(value).replace(/[\u007F-\uFFFF]/g, function (chr) { - return "\\u" + ("0000" + chr.charCodeAt(0).toString(16)).substr(-4) + return '\\u' + ('0000' + chr.charCodeAt(0).toString(16)).substr(-4); }); var callback = function (err) { if (err) { if (errorCallback) errorCallback(err); - } - else { + } else { if (key == 'autoSave') core.saves.ids[0] = true; - else if (/^save\d+$/.test(key)) core.saves.ids[parseInt(key.substring(4))] = true; + else if (/^save\d+$/.test(key)) + core.saves.ids[parseInt(key.substring(4))] = true; if (successCallback) successCallback(); } - } + }; this._setLocalForage_set(name, str, callback); -} +}; utils.prototype._setLocalForage_set = function (name, str, callback) { if (window.jsinterface && window.jsinterface.setLocalForage) { @@ -212,19 +266,24 @@ utils.prototype._setLocalForage_set = function (name, str, callback) { core.saves.cache[name] = str; window.jsinterface.setLocalForage(id, name, str); } else { - var compressed = str.length > 100000 ? LZString.compress(str) : lzw_encode(str); + var compressed = + str.length > 100000 ? LZString.compress(str) : lzw_encode(str); core.saves.cache[name] = compressed; localforage.setItem(name, compressed, callback); } -} +}; -utils.prototype.getLocalForage = function (key, defaultValue, successCallback, errorCallback) { - var name = core.firstData.name + "_" + key; +utils.prototype.getLocalForage = function ( + key, + defaultValue, + successCallback, + errorCallback +) { + var name = core.firstData.name + '_' + key; var callback = function (err, value) { if (err) { if (errorCallback) errorCallback(err); - } - else { + } else { core.saves.cache[name] = value; if (!successCallback) return; if (value != null) { @@ -239,7 +298,7 @@ utils.prototype.getLocalForage = function (key, defaultValue, successCallback, e return callback(null, core.saves.cache[name]); } this._getLocalForage_get(name, callback); -} +}; utils.prototype._getLocalForage_get = function (name, callback) { if (window.jsinterface && window.jsinterface.getLocalForage) { @@ -249,23 +308,27 @@ utils.prototype._getLocalForage_get = function (name, callback) { } else { localforage.getItem(name, callback); } -} +}; -utils.prototype.removeLocalForage = function (key, successCallback, errorCallback) { - var name = core.firstData.name + "_" + key; +utils.prototype.removeLocalForage = function ( + key, + successCallback, + errorCallback +) { + var name = core.firstData.name + '_' + key; var callback = function (err) { if (err) { if (errorCallback) errorCallback(err); - } - else { + } else { if (key == 'autoSave') delete core.saves.ids[0]; - else if (/^save\d+$/.test(key)) delete core.saves.ids[parseInt(key.substring(4))]; + else if (/^save\d+$/.test(key)) + delete core.saves.ids[parseInt(key.substring(4))]; if (successCallback) successCallback(); } - } + }; delete core.saves.cache[name]; this._removeLocalForage_remove(name, callback); -} +}; utils.prototype._removeLocalForage_remove = function (name, callback) { if (window.jsinterface && window.jsinterface.removeLocalForage) { @@ -275,7 +338,7 @@ utils.prototype._removeLocalForage_remove = function (name, callback) { } else { localforage.removeItem(name, callback); } -} +}; utils.prototype.clearLocalForage = function (callback) { core.saves.cache = {}; @@ -286,7 +349,7 @@ utils.prototype.clearLocalForage = function (callback) { } else { localforage.clear(callback); } -} +}; utils.prototype.iterateLocalForage = function (iter, callback) { if (window.jsinterface && window.jsinterface.iterateLocalForage) { @@ -297,7 +360,7 @@ utils.prototype.iterateLocalForage = function (iter, callback) { } else { localforage.iterate(iter, callback); } -} +}; utils.prototype.keysLocalForage = function (callback) { if (window.jsinterface && window.jsinterface.keysLocalForage) { @@ -307,7 +370,7 @@ utils.prototype.keysLocalForage = function (callback) { } else { localforage.keys(callback); } -} +}; utils.prototype.lengthLocalForage = function (callback) { if (window.jsinterface && window.jsinterface.lengthLocalForage) { @@ -317,37 +380,42 @@ utils.prototype.lengthLocalForage = function (callback) { } else { localforage.length(callback); } -} +}; utils.prototype.setGlobal = function (key, value) { if (core.isReplaying()) return; core.setLocalStorage(key, value); -} +}; utils.prototype.getGlobal = function (key, defaultValue) { var value; if (core.isReplaying()) { // 不考虑key不一致的情况 var action = core.status.replay.toReplay.shift(); - if (action.indexOf("input2:") == 0) { + if (action.indexOf('input2:') == 0) { value = JSON.parse(core.decodeBase64(action.substring(7))); core.setFlag('__global__' + key, value); - core.status.route.push("input2:" + core.encodeBase64(JSON.stringify(value))); - } - else { + core.status.route.push( + 'input2:' + core.encodeBase64(JSON.stringify(value)) + ); + } else { // 录像兼容性:尝试从flag和localStorage获得 // 注意这里不再二次记录 input2: 到录像 core.status.replay.toReplay.unshift(action); - value = core.getFlag('__global__' + key, core.getLocalStorage(key, defaultValue)); + value = core.getFlag( + '__global__' + key, + core.getLocalStorage(key, defaultValue) + ); } - } - else { + } else { value = core.getLocalStorage(key, defaultValue); core.setFlag('__global__' + key, value); - core.status.route.push("input2:" + core.encodeBase64(JSON.stringify(value))); + core.status.route.push( + 'input2:' + core.encodeBase64(JSON.stringify(value)) + ); } return value; -} +}; ////// 深拷贝一个对象 ////// utils.prototype.clone = function (data, filter, recursion) { @@ -363,7 +431,11 @@ utils.prototype.clone = function (data, filter, recursion) { var copy = []; for (var i in data) { if (!filter || filter(i, data[i])) - copy[i] = core.clone(data[i], recursion ? filter : null, recursion); + copy[i] = core.clone( + data[i], + recursion ? filter : null, + recursion + ); } return copy; } @@ -376,90 +448,122 @@ utils.prototype.clone = function (data, filter, recursion) { var copy = {}; for (var i in data) { if (data.hasOwnProperty(i) && (!filter || filter(i, data[i]))) - copy[i] = core.clone(data[i], recursion ? filter : null, recursion); + copy[i] = core.clone( + data[i], + recursion ? filter : null, + recursion + ); } return copy; } return data; -} +}; ////// 深拷贝1D/2D数组优化 ////// utils.prototype.cloneArray = function (data) { if (!(data instanceof Array)) return this.clone(data); if (data[0] instanceof Array) { - return data.map(function (one) { return one.slice(); }); + return data.map(function (one) { + return one.slice(); + }); } else { return data.slice(); } -} +}; ////// 裁剪图片 ////// utils.prototype.splitImage = function (image, width, height) { - if (typeof image == "string") { + if (typeof image == 'string') { image = core.getMappedName(image); image = core.material.images.images[image]; } if (!image) return []; width = width || 32; height = height || width; - var canvas = document.createElement("canvas"); - var ctx = canvas.getContext("2d"); + var canvas = document.createElement('canvas'); + var ctx = canvas.getContext('2d'); var ans = []; for (var j = 0; j < image.height; j += height) { for (var i = 0; i < image.width; i += width) { - var w = Math.min(width, image.width - i), h = Math.min(height, image.height - j); - canvas.width = w; canvas.height = h; + var w = Math.min(width, image.width - i), + h = Math.min(height, image.height - j); + canvas.width = w; + canvas.height = h; core.drawImage(ctx, image, i, j, w, h, 0, 0, w, h); var img = new Image(); - img.src = canvas.toDataURL("image/png"); + img.src = canvas.toDataURL('image/png'); ans.push(img); } } return ans; -} +}; ////// 格式化时间为字符串 ////// utils.prototype.formatDate = function (date) { if (!date) date = new Date(); - return "" + date.getFullYear() + "-" + core.setTwoDigits(date.getMonth() + 1) + "-" + core.setTwoDigits(date.getDate()) + " " - + core.setTwoDigits(date.getHours()) + ":" + core.setTwoDigits(date.getMinutes()) + ":" + core.setTwoDigits(date.getSeconds()); -} + return ( + '' + + date.getFullYear() + + '-' + + core.setTwoDigits(date.getMonth() + 1) + + '-' + + core.setTwoDigits(date.getDate()) + + ' ' + + core.setTwoDigits(date.getHours()) + + ':' + + core.setTwoDigits(date.getMinutes()) + + ':' + + core.setTwoDigits(date.getSeconds()) + ); +}; ////// 格式化时间为最简字符串 ////// utils.prototype.formatDate2 = function (date) { if (!date) date = new Date(); - return "" + date.getFullYear() + core.setTwoDigits(date.getMonth() + 1) + core.setTwoDigits(date.getDate()) - + core.setTwoDigits(date.getHours()) + core.setTwoDigits(date.getMinutes()) + core.setTwoDigits(date.getSeconds()); -} + return ( + '' + + date.getFullYear() + + core.setTwoDigits(date.getMonth() + 1) + + core.setTwoDigits(date.getDate()) + + core.setTwoDigits(date.getHours()) + + core.setTwoDigits(date.getMinutes()) + + core.setTwoDigits(date.getSeconds()) + ); +}; utils.prototype.formatTime = function (time) { - return core.setTwoDigits(parseInt(time / 3600000)) - + ":" + core.setTwoDigits(parseInt(time / 60000) % 60) - + ":" + core.setTwoDigits(parseInt(time / 1000) % 60); -} + return ( + core.setTwoDigits(parseInt(time / 3600000)) + + ':' + + core.setTwoDigits(parseInt(time / 60000) % 60) + + ':' + + core.setTwoDigits(parseInt(time / 1000) % 60) + ); +}; ////// 两位数显示 ////// utils.prototype.setTwoDigits = function (x) { - return (parseInt(x) < 10 && parseInt(x) >= 0) ? "0" + x : x; -} + return parseInt(x) < 10 && parseInt(x) >= 0 ? '0' + x : x; +}; utils.prototype.formatSize = function (size) { if (size < 1024) return size + 'B'; - else if (size < 1024 * 1024) return (size / 1024).toFixed(2) + "KB"; - else return (size / 1024 / 1024).toFixed(2) + "MB"; -} + else if (size < 1024 * 1024) return (size / 1024).toFixed(2) + 'KB'; + else return (size / 1024 / 1024).toFixed(2) + 'MB'; +}; utils.prototype.formatBigNumber = function (x, digits) { if (digits === true) digits = 5; // 兼容旧版onMap参数 if (!digits || digits < 5) digits = 6; // 连同负号、小数点和后缀字母在内的总位数,至少需为5,默认为6 x = Math.trunc(parseFloat(x)); // 尝试识别为小数,然后向0取整 if (x == null || !Number.isFinite(x)) return '???'; // 无法识别的数或正负无穷大,显示'???' - var units = [ // 单位及其后缀字母,可自定义,如改成千进制下的K、M、G、T、P - { "val": 1e4, "suffix": "w" }, - { "val": 1e8, "suffix": "e" }, - { "val": 1e12, "suffix": "z" }, - { "val": 1e16, "suffix": "j" }, - { "val": 1e20, "suffix": "g" }, + var units = [ + // 单位及其后缀字母,可自定义,如改成千进制下的K、M、G、T、P + { val: 1e4, suffix: 'w' }, + { val: 1e8, suffix: 'e' }, + { val: 1e12, suffix: 'z' }, + { val: 1e16, suffix: 'j' }, + { val: 1e20, suffix: 'g' } ]; if (Math.abs(x) > 1e20 * Math.pow(10, digits - 2)) return x.toExponential(0); // 绝对值过大以致于失去精度的数,直接使用科学记数法,系数只保留整数 @@ -473,56 +577,67 @@ utils.prototype.formatBigNumber = function (x, digits) { var each = units[i]; var u = (x / each.val).toFixed(digits).substring(0, digits); if (u.indexOf('.') < 0) continue; - u = u.substring(0, u[u.length - 2] == '.' ? u.length - 2 : u.length - 1); + u = u.substring( + 0, + u[u.length - 2] == '.' ? u.length - 2 : u.length - 1 + ); return sign + u + each.suffix; } return sign + x.toExponential(0); -} +}; ////// 变速移动 ////// utils.prototype.applyEasing = function (name) { var list = { - "easeIn": function (t) { + easeIn: function (t) { return Math.pow(t, 3); }, - "easeOut": function (t) { + easeOut: function (t) { return 1 - Math.pow(1 - t, 3); }, - "easeInOut": function (t) { + easeInOut: function (t) { // easeInOut试了一下感觉二次方效果明显点 if (t < 0.5) return Math.pow(t, 2) * 2; else return 1 - Math.pow(1 - t, 2) * 2; }, - "linear": function (t) { - return t + linear: function (t) { + return t; } - } + }; if (name == 'random') { var keys = Object.keys(list); name = keys[Math.floor(Math.random() * keys.length)]; } return list[name] || list.linear; -} +}; ////// 数组转RGB ////// utils.prototype.arrayToRGB = function (color) { if (!(color instanceof Array)) return color; - var nowR = this.clamp(parseInt(color[0]), 0, 255), nowG = this.clamp(parseInt(color[1]), 0, 255), + var nowR = this.clamp(parseInt(color[0]), 0, 255), + nowG = this.clamp(parseInt(color[1]), 0, 255), nowB = this.clamp(parseInt(color[2]), 0, 255); - return "#" + ((1 << 24) + (nowR << 16) + (nowG << 8) + nowB).toString(16).slice(1); -} + return ( + '#' + + ((1 << 24) + (nowR << 16) + (nowG << 8) + nowB).toString(16).slice(1) + ); +}; utils.prototype.arrayToRGBA = function (color) { if (!(color instanceof Array)) return color; if (color[3] == null) color[3] = 1; - var nowR = this.clamp(parseInt(color[0]), 0, 255), nowG = this.clamp(parseInt(color[1]), 0, 255), - nowB = this.clamp(parseInt(color[2]), 0, 255), nowA = this.clamp(parseFloat(color[3]), 0, 1); - return "rgba(" + nowR + "," + nowG + "," + nowB + "," + nowA + ")"; -} + var nowR = this.clamp(parseInt(color[0]), 0, 255), + nowG = this.clamp(parseInt(color[1]), 0, 255), + nowB = this.clamp(parseInt(color[2]), 0, 255), + nowA = this.clamp(parseFloat(color[3]), 0, 1); + return 'rgba(' + nowR + ',' + nowG + ',' + nowB + ',' + nowA + ')'; +}; ////// 加密路线 ////// utils.prototype.encodeRoute = function (route) { - var ans = "", lastMove = "", cnt = 0; + var ans = '', + lastMove = '', + cnt = 0; route.forEach(function (t) { if (t == 'up' || t == 'down' || t == 'left' || t == 'right') { @@ -533,8 +648,7 @@ utils.prototype.encodeRoute = function (route) { } lastMove = t; cnt++; - } - else { + } else { if (cnt > 0) { ans += lastMove.substring(0, 1).toUpperCase(); if (cnt > 1) ans += cnt; @@ -548,56 +662,39 @@ utils.prototype.encodeRoute = function (route) { if (cnt > 1) ans += cnt; } return LZString.compressToBase64(ans); -} +}; utils.prototype._encodeRoute_id2number = function (id) { var number = core.maps.getNumberById(id); return number == 0 ? id : number; -} +}; utils.prototype._encodeRoute_encodeOne = function (t) { if (t.indexOf('item:') == 0) - return "I" + this._encodeRoute_id2number(t.substring(5)) + ":"; - else if (t.indexOf('unEquip:') == 0) - return "u" + t.substring(8); + return 'I' + this._encodeRoute_id2number(t.substring(5)) + ':'; + else if (t.indexOf('unEquip:') == 0) return 'u' + t.substring(8); else if (t.indexOf('equip:') == 0) - return "e" + this._encodeRoute_id2number(t.substring(6)) + ":"; - else if (t.indexOf('saveEquip:') == 0) - return "s" + t.substring(10); - else if (t.indexOf('loadEquip:') == 0) - return "l" + t.substring(10); - else if (t.indexOf('fly:') == 0) - return "F" + t.substring(4) + ":"; - else if (t == 'choices:none') - return "c"; - else if (t.indexOf('choices:') == 0) - return "C" + t.substring(8); - else if (t.indexOf('shop:') == 0) - return "S" + t.substring(5) + ":"; - else if (t == 'turn') - return 'T'; + return 'e' + this._encodeRoute_id2number(t.substring(6)) + ':'; + else if (t.indexOf('saveEquip:') == 0) return 's' + t.substring(10); + else if (t.indexOf('loadEquip:') == 0) return 'l' + t.substring(10); + else if (t.indexOf('fly:') == 0) return 'F' + t.substring(4) + ':'; + else if (t == 'choices:none') return 'c'; + else if (t.indexOf('choices:') == 0) return 'C' + t.substring(8); + else if (t.indexOf('shop:') == 0) return 'S' + t.substring(5) + ':'; + else if (t == 'turn') return 'T'; else if (t.indexOf('turn:') == 0) - return "t" + t.substring(5).substring(0, 1).toUpperCase() + ":"; - else if (t == 'getNext') - return 'G'; - else if (t == 'input:none') - return 'p'; - else if (t.indexOf('input:') == 0) - return "P" + t.substring(6); - else if (t.indexOf('input2:') == 0) - return "Q" + t.substring(7) + ":"; - else if (t == 'no') - return 'N'; - else if (t.indexOf('move:') == 0) - return "M" + t.substring(5); - else if (t.indexOf('key:') == 0) - return 'K' + t.substring(4); - else if (t.indexOf('click:') == 0) - return 'k' + t.substring(6); - else if (t.indexOf('random:') == 0) - return 'X' + t.substring(7); + return 't' + t.substring(5).substring(0, 1).toUpperCase() + ':'; + else if (t == 'getNext') return 'G'; + else if (t == 'input:none') return 'p'; + else if (t.indexOf('input:') == 0) return 'P' + t.substring(6); + else if (t.indexOf('input2:') == 0) return 'Q' + t.substring(7) + ':'; + else if (t == 'no') return 'N'; + else if (t.indexOf('move:') == 0) return 'M' + t.substring(5); + else if (t.indexOf('key:') == 0) return 'K' + t.substring(4); + else if (t.indexOf('click:') == 0) return 'k' + t.substring(6); + else if (t.indexOf('random:') == 0) return 'X' + t.substring(7); return '(' + t + ')'; -} +}; ////// 解密路线 ////// utils.prototype.decodeRoute = function (route) { @@ -607,21 +704,22 @@ utils.prototype.decodeRoute = function (route) { try { var v = LZString.decompressFromBase64(route); if (v != null && /^[-_a-zA-Z0-9+\/=:()]*$/.test(v)) { - if (v != "" || route.length < 8) - route = v; + if (v != '' || route.length < 8) route = v; } - } catch (e) { - } + } catch (e) {} var decodeObj = { route: route, index: 0, ans: [] }; while (decodeObj.index < decodeObj.route.length) { - this._decodeRoute_decodeOne(decodeObj, decodeObj.route.charAt(decodeObj.index++)); + this._decodeRoute_decodeOne( + decodeObj, + decodeObj.route.charAt(decodeObj.index++) + ); } return decodeObj.ans; -} +}; utils.prototype._decodeRoute_getNumber = function (decodeObj, noparse) { - var num = ""; + var num = ''; var first = true; while (true) { var ch = decodeObj.route.charAt(decodeObj.index); @@ -631,18 +729,21 @@ utils.prototype._decodeRoute_getNumber = function (decodeObj, noparse) { first = false; decodeObj.index++; } - if (num.length == 0) num = "1"; + if (num.length == 0) num = '1'; return noparse ? num : parseInt(num); -} +}; utils.prototype._decodeRoute_getString = function (decodeObj) { - var str = ""; - while (decodeObj.index < decodeObj.route.length && decodeObj.route.charAt(decodeObj.index) != ':') { + var str = ''; + while ( + decodeObj.index < decodeObj.route.length && + decodeObj.route.charAt(decodeObj.index) != ':' + ) { str += decodeObj.route.charAt(decodeObj.index++); } decodeObj.index++; return str; -} +}; utils.prototype._decodeRoute_number2id = function (number) { if (/^\d+$/.test(number)) { @@ -650,7 +751,7 @@ utils.prototype._decodeRoute_number2id = function (number) { if (info) return info.id; } return number; -} +}; utils.prototype._decodeRoute_decodeOne = function (decodeObj, c) { // --- 特殊处理自定义项 @@ -662,90 +763,94 @@ utils.prototype._decodeRoute_decodeOne = function (decodeObj, c) { return; } } - var nxt = (c == 'I' || c == 'e' || c == 'F' || c == 'S' || c == 'Q' || c == 't') ? - this._decodeRoute_getString(decodeObj) : this._decodeRoute_getNumber(decodeObj); + var nxt = + c == 'I' || c == 'e' || c == 'F' || c == 'S' || c == 'Q' || c == 't' + ? this._decodeRoute_getString(decodeObj) + : this._decodeRoute_getNumber(decodeObj); - var mp = { "U": "up", "D": "down", "L": "left", "R": "right" }; + var mp = { U: 'up', D: 'down', L: 'left', R: 'right' }; switch (c) { - case "U": - case "D": - case "L": - case "R": + case 'U': + case 'D': + case 'L': + case 'R': for (var i = 0; i < nxt; i++) decodeObj.ans.push(mp[c]); break; - case "I": - decodeObj.ans.push("item:" + this._decodeRoute_number2id(nxt)); + case 'I': + decodeObj.ans.push('item:' + this._decodeRoute_number2id(nxt)); break; - case "u": - decodeObj.ans.push("unEquip:" + nxt); + case 'u': + decodeObj.ans.push('unEquip:' + nxt); break; - case "e": - decodeObj.ans.push("equip:" + this._decodeRoute_number2id(nxt)); + case 'e': + decodeObj.ans.push('equip:' + this._decodeRoute_number2id(nxt)); break; - case "s": - decodeObj.ans.push("saveEquip:" + nxt); + case 's': + decodeObj.ans.push('saveEquip:' + nxt); break; - case "l": - decodeObj.ans.push("loadEquip:" + nxt); + case 'l': + decodeObj.ans.push('loadEquip:' + nxt); break; - case "F": - decodeObj.ans.push("fly:" + nxt); + case 'F': + decodeObj.ans.push('fly:' + nxt); break; case 'c': decodeObj.ans.push('choices:none'); break; - case "C": - decodeObj.ans.push("choices:" + nxt); + case 'C': + decodeObj.ans.push('choices:' + nxt); break; - case "S": - decodeObj.ans.push("shop:" + nxt); + case 'S': + decodeObj.ans.push('shop:' + nxt); break; - case "T": - decodeObj.ans.push("turn"); + case 'T': + decodeObj.ans.push('turn'); break; - case "t": - decodeObj.ans.push("turn:" + mp[nxt]); + case 't': + decodeObj.ans.push('turn:' + mp[nxt]); break; - case "G": - decodeObj.ans.push("getNext"); + case 'G': + decodeObj.ans.push('getNext'); break; - case "p": - decodeObj.ans.push("input:none"); + case 'p': + decodeObj.ans.push('input:none'); break; - case "P": - decodeObj.ans.push("input:" + nxt); + case 'P': + decodeObj.ans.push('input:' + nxt); break; - case "Q": - decodeObj.ans.push("input2:" + nxt); + case 'Q': + decodeObj.ans.push('input2:' + nxt); break; - case "N": - decodeObj.ans.push("no"); + case 'N': + decodeObj.ans.push('no'); break; - case "M": + case 'M': ++decodeObj.index; - decodeObj.ans.push("move:" + nxt + ":" + this._decodeRoute_getNumber(decodeObj)); + decodeObj.ans.push( + 'move:' + nxt + ':' + this._decodeRoute_getNumber(decodeObj) + ); break; - case "K": - decodeObj.ans.push("key:" + nxt); + case 'K': + decodeObj.ans.push('key:' + nxt); break; - case "k": + case 'k': ++decodeObj.index; var px = this._decodeRoute_getNumber(decodeObj); ++decodeObj.index; var py = this._decodeRoute_getNumber(decodeObj); - decodeObj.ans.push("click:" + nxt + ":" + px + ":" + py); + decodeObj.ans.push('click:' + nxt + ':' + px + ':' + py); break; - case "X": - decodeObj.ans.push("random:" + nxt); + case 'X': + decodeObj.ans.push('random:' + nxt); break; } -} +}; ////// 判断某对象是否不为null也不为NaN ////// utils.prototype.isset = function (val) { return val != null && !(typeof val == 'number' && isNaN(val)); -} +}; ////// 获得子数组 ////// utils.prototype.subarray = function (a, b) { @@ -755,29 +860,33 @@ utils.prototype.subarray = function (a, b) { if (a[i] != b[i]) return null; } return a.slice(b.length); -} +}; utils.prototype.inArray = function (array, element) { - return (array instanceof Array) && array.indexOf(element) >= 0; -} + return array instanceof Array && array.indexOf(element) >= 0; +}; utils.prototype.clamp = function (x, a, b) { - var min = Math.min(a, b), max = Math.max(a, b); + var min = Math.min(a, b), + max = Math.max(a, b); return Math.min(Math.max(x || 0, min), max); -} +}; utils.prototype.getCookie = function (name) { var match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)')); return match ? match[2] : null; -} +}; ////// 设置statusBar的innerHTML,会自动斜体和放缩,也可以增加自定义css ////// utils.prototype.setStatusBarInnerHTML = function (name, value, css) { if (!core.statusBar[name]) return; if (typeof value == 'number') value = this.formatBigNumber(value); - var italic = /^[-a-zA-Z0-9`~!@#$%^&*()_=+\[{\]}\\|;:'",<.>\/?]*$/.test(value); + var italic = /^[-a-zA-Z0-9`~!@#$%^&*()_=+\[{\]}\\|;:'",<.>\/?]*$/.test( + value + ); var style = 'font-style: ' + (italic ? 'italic' : 'normal') + '; '; - style += 'text-shadow: #000 1px 0 0, #000 0 1px 0, #000 -1px 0 0, #000 0 -1px 0; '; + style += + 'text-shadow: #000 1px 0 0, #000 0 1px 0, #000 -1px 0 0, #000 0 -1px 0; '; // 判定是否需要缩放 var length = this.strlen(value) || 1; style += 'font-size: ' + Math.min(1, 7 / length) + 'em; '; @@ -788,12 +897,13 @@ utils.prototype.setStatusBarInnerHTML = function (name, value, css) { if (value == _value) return; core.statusBar[name].children[0].innerText = value; } else { - core.statusBar[name].innerHTML = ""; + core.statusBar[name].innerHTML = + ""; core.statusBar[name].children[0].innerText = value; core.statusBar[name].setAttribute('_style', style); } - core.statusBar[name].setAttribute('_value', value);; -} + core.statusBar[name].setAttribute('_value', value); +}; utils.prototype.strlen = function (str) { var count = 0; @@ -805,67 +915,102 @@ utils.prototype.strlen = function (str) { utils.prototype.turnDirection = function (turn, direction) { direction = direction || core.getHeroLoc('direction'); - var directionList = ["left", "leftup", "up", "rightup", "right", "rightdown", "down", "leftdown"]; + var directionList = [ + 'left', + 'leftup', + 'up', + 'rightup', + 'right', + 'rightdown', + 'down', + 'leftdown' + ]; if (directionList.indexOf(turn) >= 0) return turn; if (turn == ':hero') return core.getHeroLoc('direction'); - if (turn == ':backhero') return this.turnDirection(':back', core.getHeroLoc('direction')); + if (turn == ':backhero') + return this.turnDirection(':back', core.getHeroLoc('direction')); if (typeof turn === 'number' && turn % 45 == 0) turn /= 45; else { switch (turn) { - case ':left': turn = 6; break; // turn left - case ':right': turn = 2; break; // turn right - case ':back': turn = 4; break; // turn back - default: turn = 0; break; + case ':left': + turn = 6; + break; // turn left + case ':right': + turn = 2; + break; // turn right + case ':back': + turn = 4; + break; // turn back + default: + turn = 0; + break; } } var index = directionList.indexOf(direction); if (index < 0) return direction; return directionList[(index + (turn || 0)) % directionList.length]; -} +}; utils.prototype.matchWildcard = function (pattern, string) { try { - return new RegExp('^' + pattern.split(/\*+/).map(function (s) { - return s.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&'); - }).join('.*') + '$').test(string); + return new RegExp( + '^' + + pattern + .split(/\*+/) + .map(function (s) { + return s.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&'); + }) + .join('.*') + + '$' + ).test(string); } catch (e) { return false; } -} +}; utils.prototype.matchRegex = function (pattern, string) { try { - if (pattern.startsWith("^")) pattern = pattern.substring(1); - if (pattern.endsWith("$")) pattern = pattern.substring(0, pattern.length - 1); - return new RegExp("^" + pattern + "$").test(string); + if (pattern.startsWith('^')) pattern = pattern.substring(1); + if (pattern.endsWith('$')) + pattern = pattern.substring(0, pattern.length - 1); + return new RegExp('^' + pattern + '$').test(string); } catch (e) { return false; } -} +}; ////// Base64加密 ////// utils.prototype.encodeBase64 = function (str) { - return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function (match, p1) { - return String.fromCharCode(parseInt(p1, 16)) - })) -} + return btoa( + encodeURIComponent(str).replace( + /%([0-9A-F]{2})/g, + function (match, p1) { + return String.fromCharCode(parseInt(p1, 16)); + } + ) + ); +}; ////// Base64解密 ////// utils.prototype.decodeBase64 = function (str) { - return decodeURIComponent(atob(str).split('').map(function (c) { - return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2); - }).join('')); -} + return decodeURIComponent( + atob(str) + .split('') + .map(function (c) { + return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2); + }) + .join('') + ); +}; utils.prototype.rand = function (num) { var rand = core.getFlag('__rand__'); rand = this.__next_rand(rand); core.setFlag('__rand__', rand); var ans = rand / 2147483647; - if (num && num > 0) - return Math.floor(ans * num); + if (num && num > 0) return Math.floor(ans * num); return ans; -} +}; ////// 生成随机数(录像方法) ////// utils.prototype.rand2 = function (num) { @@ -875,43 +1020,40 @@ utils.prototype.rand2 = function (num) { var value; if (core.isReplaying()) { var action = core.status.replay.toReplay.shift(); - if (action.indexOf("random:") == 0) { + if (action.indexOf('random:') == 0) { value = parseInt(action.substring(7)); if (isNaN(value) || value >= num || value < 0) { console.warn('错误!当前random:项超过范围。将重新随机生成!'); value = Math.floor(Math.random() * num); } - } - else { + } else { console.warn('错误!当前需要一个random:项。将重新随机生成!'); value = Math.floor(Math.random() * num); } - } - else { + } else { value = Math.floor(Math.random() * num); } - core.status.route.push("random:" + value); + core.status.route.push('random:' + value); return value; -} +}; utils.prototype.__init_seed = function () { - var rand = new Date().getTime() % 34834795 + 3534; + var rand = (new Date().getTime() % 34834795) + 3534; rand = this.__next_rand(rand); rand = this.__next_rand(rand); rand = this.__next_rand(rand); core.setFlag('__seed__', rand); core.setFlag('__rand__', rand); -} +}; utils.prototype.__next_rand = function (_rand) { _rand = (_rand % 127773) * 16807 - ~~(_rand / 127773) * 2836; _rand += _rand < 0 ? 2147483647 : 0; return _rand; -} +}; ////// 读取一个本地文件内容 ////// utils.prototype.readFile = function (success, error, accept, readType) { - core.platform.successCallback = success; core.platform.errorCallback = error; @@ -922,39 +1064,44 @@ utils.prototype.readFile = function (success, error, accept, readType) { // step 0: 不为http/https,直接不支持 if (!core.platform.isOnline) { - alert("离线状态下不支持文件读取!"); + alert('离线状态下不支持文件读取!'); if (error) error(); return; } // Step 1: 如果不支持FileReader,直接不支持 if (core.platform.fileReader == null) { - alert("当前浏览器不支持FileReader!"); + alert('当前浏览器不支持FileReader!'); if (error) error(); return; } if (core.platform.fileInput == null) { - core.platform.fileInput = document.createElement("input"); + core.platform.fileInput = document.createElement('input'); core.platform.fileInput.style.opacity = 0; core.platform.fileInput.type = 'file'; core.platform.fileInput.onchange = function () { var files = core.platform.fileInput.files; if (files.length == 0) { - if (core.platform.errorCallback) - core.platform.errorCallback(); + if (core.platform.errorCallback) core.platform.errorCallback(); return; } - if (!readType) core.platform.fileReader.readAsText(core.platform.fileInput.files[0]); - else core.platform.fileReader.readAsDataURL(core.platform.fileInput.files[0]); + if (!readType) + core.platform.fileReader.readAsText( + core.platform.fileInput.files[0] + ); + else + core.platform.fileReader.readAsDataURL( + core.platform.fileInput.files[0] + ); core.platform.fileInput.value = ''; - } + }; } core.platform.fileInput.value = ''; if (accept) core.platform.fileInput.accept = accept; core.platform.fileInput.click(); -} +}; ////// 读取文件完毕 ////// utils.prototype.readFileContent = function (content) { @@ -967,28 +1114,25 @@ utils.prototype.readFileContent = function (content) { // 检查base64 try { obj = JSON.parse(LZString.decompressFromBase64(content)); - } catch (e) { } + } catch (e) {} if (!obj) { try { obj = JSON.parse(content); } catch (e) { - console.error(e) + console.error(e); } } if (obj) { - if (core.platform.successCallback) - core.platform.successCallback(obj); + if (core.platform.successCallback) core.platform.successCallback(obj); return; } - if (core.platform.errorCallback) - core.platform.errorCallback(); -} + if (core.platform.errorCallback) core.platform.errorCallback(); +}; ////// 下载文件到本地 ////// utils.prototype.download = function (filename, content) { - if (window.jsinterface) { window.jsinterface.download(filename, content); return; @@ -996,29 +1140,36 @@ utils.prototype.download = function (filename, content) { // Step 0: 不为http/https,直接不支持 if (!core.platform.isOnline) { - alert("离线状态下不支持下载操作!"); + alert('离线状态下不支持下载操作!'); return; } // Step 1: 如果是iOS平台,直接不支持 if (core.platform.isIOS) { if (core.copy(content)) { - alert("iOS平台下不支持直接下载文件!\n所有应下载内容已经复制到您的剪切板,请自行创建空白文件并粘贴。"); - } - else { - alert("iOS平台下不支持下载操作!"); + alert( + 'iOS平台下不支持直接下载文件!\n所有应下载内容已经复制到您的剪切板,请自行创建空白文件并粘贴。' + ); + } else { + alert('iOS平台下不支持下载操作!'); } return; } // Step 2: 如果不是PC平台(Android),则只支持chrome if (!core.platform.isPC) { - if (!core.platform.isChrome || core.platform.isQQ || core.platform.isWeChat) { // 检测chrome + if ( + !core.platform.isChrome || + core.platform.isQQ || + core.platform.isWeChat + ) { + // 检测chrome if (core.copy(content)) { - alert("移动端只有Chrome浏览器支持直接下载文件!\n所有应下载内容已经复制到您的剪切板,请自行创建空白文件并粘贴。"); - } - else { - alert("该平台或浏览器暂不支持下载操作!"); + alert( + '移动端只有Chrome浏览器支持直接下载文件!\n所有应下载内容已经复制到您的剪切板,请自行创建空白文件并粘贴。' + ); + } else { + alert('该平台或浏览器暂不支持下载操作!'); } return; } @@ -1026,10 +1177,12 @@ utils.prototype.download = function (filename, content) { // Step 3: 如果是Safari浏览器,则提示并打开新窗口 if (core.platform.isSafari) { - alert("你当前使用的是Safari浏览器,不支持直接下载文件。\n即将打开一个新窗口为应下载内容,请自行全选复制然后创建空白文件并粘贴。"); + alert( + '你当前使用的是Safari浏览器,不支持直接下载文件。\n即将打开一个新窗口为应下载内容,请自行全选复制然后创建空白文件并粘贴。' + ); var blob = new Blob([content], { type: 'text/plain;charset=utf-8' }); var href = window.URL.createObjectURL(blob); - var opened = window.open(href, "_blank"); + var opened = window.open(href, '_blank'); window.URL.revokeObjectURL(href); return; } @@ -1038,8 +1191,7 @@ utils.prototype.download = function (filename, content) { var blob = new Blob([content], { type: 'text/plain;charset=utf-8' }); if (window.navigator.msSaveOrOpenBlob) { window.navigator.msSaveBlob(blob, filename); - } - else { + } else { var href = window.URL.createObjectURL(blob); var elem = window.document.createElement('a'); elem.href = href; @@ -1049,11 +1201,10 @@ utils.prototype.download = function (filename, content) { document.body.removeChild(elem); window.URL.revokeObjectURL(href); } -} +}; ////// 复制一段内容到剪切板 ////// utils.prototype.copy = function (data) { - if (window.jsinterface) { window.jsinterface.copy(data); return true; @@ -1061,7 +1212,7 @@ utils.prototype.copy = function (data) { if (!core.platform.supportCopy) return false; - var textArea = document.createElement("textarea"); + var textArea = document.createElement('textarea'); textArea.style.position = 'fixed'; textArea.style.top = 0; textArea.style.left = 0; @@ -1085,7 +1236,7 @@ utils.prototype.copy = function (data) { document.body.removeChild(textArea); return successful; -} +}; ////// 显示一段confirm ////// utils.prototype.myconfirm = function (hint, yesCallback, noCallback) { @@ -1098,14 +1249,14 @@ utils.prototype.myconfirm = function (hint, yesCallback, noCallback) { core.platform.successCallback = yesCallback; core.platform.errorCallback = noCallback; -} +}; ////// 让用户输入一段文字 ////// utils.prototype.myprompt = function (hint, value, callback) { main.dom.inputDiv.style.display = 'block'; main.dom.inputMessage.innerHTML = hint.replace(/\n/g, '
'); main.dom.inputBox.style.display = 'block'; - main.dom.inputBox.value = value == null ? "" : value; + main.dom.inputBox.value = value == null ? '' : value; main.dom.inputYes.blur(); main.dom.inputNo.blur(); setTimeout(function () { @@ -1114,7 +1265,7 @@ utils.prototype.myprompt = function (hint, value, callback) { core.status.holdingKeys = []; core.platform.successCallback = core.platform.errorCallback = callback; -} +}; ////// 动画显示某对象 ////// utils.prototype.showWithAnimate = function (obj, speed, callback) { @@ -1134,7 +1285,7 @@ utils.prototype.showWithAnimate = function (obj, speed, callback) { if (callback) callback(); } }, speed); -} +}; ////// 动画使某对象消失 ////// utils.prototype.hideWithAnimate = function (obj, speed, callback) { @@ -1154,33 +1305,39 @@ utils.prototype.hideWithAnimate = function (obj, speed, callback) { if (callback) callback(); } }, speed); -} +}; ////// 生成浏览器唯一的 guid ////// utils.prototype.getGuid = function () { var guid = localStorage.getItem('guid'); if (guid != null) return guid; - guid = 'xxxxxxxx_xxxx_4xxx_yxxx_xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { - var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); - return v.toString(16); - }); + guid = 'xxxxxxxx_xxxx_4xxx_yxxx_xxxxxxxxxxxx'.replace( + /[xy]/g, + function (c) { + var r = (Math.random() * 16) | 0, + v = c == 'x' ? r : (r & 0x3) | 0x8; + return v.toString(16); + } + ); localStorage.setItem('guid', guid); return guid; -} +}; utils.prototype.hashCode = function (obj) { if (typeof obj == 'string') { - var hash = 0, i, chr; + var hash = 0, + i, + chr; if (obj.length === 0) return hash; for (i = 0; i < obj.length; i++) { chr = obj.charCodeAt(i); - hash = ((hash << 5) - hash) + chr; + hash = (hash << 5) - hash + chr; hash |= 0; } return hash; } - return this.hashCode(JSON.stringify(obj).split("").sort().join("")); -} + return this.hashCode(JSON.stringify(obj).split('').sort().join('')); +}; utils.prototype.same = function (a, b) { if (a == null && b == null) return true; @@ -1203,57 +1360,96 @@ utils.prototype.same = function (a, b) { return true; } return false; -} +}; -utils.prototype.unzip = function (blobOrUrl, success, error, convertToText, onprogress) { +utils.prototype.unzip = function ( + blobOrUrl, + success, + error, + convertToText, + onprogress +) { var _error = function (msg) { console.error(msg); if (error) error(msg); - } + }; if (!window.zip) { - return _error("zip.js not exists!"); + return _error('zip.js not exists!'); } if (typeof blobOrUrl == 'string') { - return core.http('GET', blobOrUrl, null, function (data) { - core.unzip(data, success, error, convertToText); - }, _error, null, 'blob', onprogress); + return core.http( + 'GET', + blobOrUrl, + null, + function (data) { + core.unzip(data, success, error, convertToText); + }, + _error, + null, + 'blob', + onprogress + ); } if (!(blobOrUrl instanceof Blob)) { - return _error("Should use Blob or URL as input"); + return _error('Should use Blob or URL as input'); } - zip.createReader(new zip.BlobReader(blobOrUrl), function (reader) { - reader.getEntries(function (entries) { - core.utils._unzip_readEntries(entries, function (data) { - reader.close(function () { - if (success) success(data); - }); - }, convertToText); - }); - }, _error); -} + zip.createReader( + new zip.BlobReader(blobOrUrl), + function (reader) { + reader.getEntries(function (entries) { + core.utils._unzip_readEntries( + entries, + function (data) { + reader.close(function () { + if (success) success(data); + }); + }, + convertToText + ); + }); + }, + _error + ); +}; -utils.prototype._unzip_readEntries = function (entries, success, convertToText) { +utils.prototype._unzip_readEntries = function ( + entries, + success, + convertToText +) { var results = {}; if (entries == null || entries.length == 0) { return success(results); } var length = entries.length; entries.forEach(function (entry) { - entry.getData(convertToText ? new zip.TextWriter('utf8') : new zip.BlobWriter(), function (data) { - results[entry.filename] = data; - length--; - if (length == 0) { - success(results); + entry.getData( + convertToText ? new zip.TextWriter('utf8') : new zip.BlobWriter(), + function (data) { + results[entry.filename] = data; + length--; + if (length == 0) { + success(results); + } } - }); + ); }); -} +}; -utils.prototype.http = function (type, url, formData, success, error, mimeType, responseType, onprogress) { +utils.prototype.http = function ( + type, + url, + formData, + success, + error, + mimeType, + responseType, + onprogress +) { var xhr = new XMLHttpRequest(); xhr.open(type, url, true); if (mimeType) xhr.overrideMimeType(mimeType); @@ -1261,35 +1457,33 @@ utils.prototype.http = function (type, url, formData, success, error, mimeType, xhr.onload = function (e) { if (xhr.status == 200) { if (success) success(xhr.response); - } - else { - if (error) error("HTTP " + xhr.status); + } else { + if (error) error('HTTP ' + xhr.status); } }; xhr.onprogress = function (e) { if (e.lengthComputable) { if (onprogress) onprogress(e.loaded, e.total); } - } + }; xhr.onabort = function () { - if (error) error("Abort"); - } + if (error) error('Abort'); + }; xhr.ontimeout = function () { - if (error) error("Timeout"); - } + if (error) error('Timeout'); + }; xhr.onerror = function () { - if (error) error("Error on Connection"); - } - if (formData) - xhr.send(formData); + if (error) error('Error on Connection'); + }; + if (formData) xhr.send(formData); else xhr.send(); -} +}; // LZW-compress // https://gist.github.com/revolunet/843889 -function lzw_encode (s) { +function lzw_encode(s) { var dict = {}; - var data = (s + "").split(""); + var data = (s + '').split(''); var out = []; var currChar; var phrase = data[0]; @@ -1298,8 +1492,7 @@ function lzw_encode (s) { currChar = data[i]; if (dict[phrase + currChar] != null) { phrase += currChar; - } - else { + } else { out.push(phrase.length > 1 ? dict[phrase] : phrase.charCodeAt(0)); dict[phrase + currChar] = code; code++; @@ -1310,13 +1503,13 @@ function lzw_encode (s) { for (var i = 0; i < out.length; i++) { out[i] = String.fromCharCode(out[i]); } - return out.join(""); + return out.join(''); } // Decompress an LZW-encoded string -function lzw_decode (s) { +function lzw_decode(s) { var dict = {}; - var data = (s + "").split(""); + var data = (s + '').split(''); var currChar = data[0]; var oldPhrase = currChar; var out = [currChar]; @@ -1326,9 +1519,8 @@ function lzw_decode (s) { var currCode = data[i].charCodeAt(0); if (currCode < 256) { phrase = data[i]; - } - else { - phrase = dict[currCode] ? dict[currCode] : (oldPhrase + currChar); + } else { + phrase = dict[currCode] ? dict[currCode] : oldPhrase + currChar; } out.push(phrase); currChar = phrase.charAt(0); @@ -1336,5 +1528,5 @@ function lzw_decode (s) { code++; oldPhrase = phrase; } - return out.join(""); + return out.join(''); } diff --git a/public/main.js b/public/main.js index 80be0b1..ef3f0ff 100644 --- a/public/main.js +++ b/public/main.js @@ -374,7 +374,7 @@ main.prototype.loadFloors = function (callback) { // 高层塔优化 var script = document.createElement('script'); script.src = - '__all_floors__.js?v=' + + '/all/__all_floors__.js?v=' + this.version + '&id=' + main.floorIds.join(','); diff --git a/public/project/enemys.js b/public/project/enemys.js index 28de828..6d362dd 100644 --- a/public/project/enemys.js +++ b/public/project/enemys.js @@ -2,84 +2,84 @@ var enemys_fcae963b_31c9_42b4_b48c_bb48d09f3f80 = { "greenSlime": {"name":"绿头怪","hp":100,"atk":11,"def":3,"money":0,"exp":1,"point":0,"special":[]}, "redSlime": {"name":"红头怪","hp":120,"atk":16,"def":6,"money":0,"exp":2,"point":0,"special":[],"value":10}, - "blackSlime": {"name":"青头怪","hp":170,"atk":20,"def":8,"money":0,"exp":3,"point":0,"special":0}, + "blackSlime": {"name":"青头怪","hp":170,"atk":20,"def":8,"money":0,"exp":3,"point":0,"special":[]}, "slimelord": {"name":"粘液王","hp":200,"atk":58,"def":24,"money":0,"exp":8,"point":0,"special":[]}, "bat": {"name":"小蝙蝠","hp":60,"atk":15,"def":0,"money":0,"exp":2,"point":0,"special":[4]}, "bigBat": {"name":"大蝙蝠","hp":150,"atk":17,"def":5,"money":0,"exp":4,"point":0,"special":[4]}, "redBat": {"name":"恐怖蝙蝠","hp":1200,"atk":260,"def":110,"money":1,"exp":32,"point":0,"special":[5]}, - "vampire": {"name":"冥灵魔王","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "vampire": {"name":"冥灵魔王","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[]}, "skeleton": {"name":"骷髅人","hp":300,"atk":80,"def":10,"money":0,"exp":9,"point":0,"special":[1],"crit":300}, "skeletonCaptain": {"name":"骷髅队长","hp":750,"atk":200,"def":50,"money":0,"exp":21,"point":0,"special":[1],"crit":1000}, - "zombie": {"name":"兽人","hp":150,"atk":43,"def":14,"money":0,"exp":6,"point":0,"special":0}, - "zombieKnight": {"name":"兽人武士","hp":480,"atk":62,"def":30,"money":0,"exp":15,"point":0,"special":0}, + "zombie": {"name":"兽人","hp":150,"atk":43,"def":14,"money":0,"exp":6,"point":0,"special":[]}, + "zombieKnight": {"name":"兽人武士","hp":480,"atk":62,"def":30,"money":0,"exp":15,"point":0,"special":[]}, "rock": {"name":"洞穴巨石","hp":31,"atk":25,"def":0,"money":0,"exp":4,"point":0,"special":[3]}, - "bluePriest": {"name":"初级法师","hp":100,"atk":120,"def":0,"money":3,"exp":0,"point":1,"special":2}, - "redPriest": {"name":"高级法师","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, - "brownWizard": {"name":"初级巫师","hp":100,"atk":120,"def":0,"money":16,"exp":0,"point":0,"special":15,"value":100,"range":2}, - "redWizard": {"name":"高级巫师","hp":1000,"atk":1200,"def":0,"money":160,"exp":0,"point":0,"special":15,"value":200,"zoneSquare":true}, + "bluePriest": {"name":"初级法师","hp":100,"atk":120,"def":0,"money":3,"exp":0,"point":1,"special":[2]}, + "redPriest": {"name":"高级法师","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[]}, + "brownWizard": {"name":"初级巫师","hp":100,"atk":120,"def":0,"money":16,"exp":0,"point":0,"special":[15],"value":100,"range":2}, + "redWizard": {"name":"高级巫师","hp":1000,"atk":1200,"def":0,"money":160,"exp":0,"point":0,"special":[15],"value":200,"zoneSquare":true}, "swordsman": {"name":"野蛮剑士","hp":250,"atk":55,"def":27,"money":0,"exp":9,"point":0,"special":[15],"value":75}, - "soldier": {"name":"冥战士","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "soldier": {"name":"冥战士","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[]}, "yellowKnight": {"name":"勇气骑士","hp":2000,"atk":500,"def":250,"money":1,"exp":30,"point":0,"special":[11],"charge":500}, - "redKnight": {"name":"红骑士","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, - "darkKnight": {"name":"黑骑士","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, - "blueKnight": {"name":"蓝骑士","hp":100,"atk":120,"def":0,"money":9,"exp":0,"point":0,"special":8}, + "redKnight": {"name":"红骑士","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[]}, + "darkKnight": {"name":"黑骑士","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[]}, + "blueKnight": {"name":"蓝骑士","hp":100,"atk":120,"def":0,"money":9,"exp":0,"point":0,"special":[8]}, "goldSlime": {"name":"黄头怪","hp":1000,"atk":50,"def":50,"money":0,"exp":18,"point":0,"special":[2]}, - "poisonSkeleton": {"name":"紫骷髅","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "poisonSkeleton": {"name":"紫骷髅","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[]}, "poisonBat": {"name":"山间蝙蝠","hp":800,"atk":170,"def":50,"money":1,"exp":24,"point":0,"special":[5]}, - "skeletonPriest": {"name":"骷髅法师","hp":100,"atk":100,"def":0,"money":0,"exp":0,"point":0,"special":18,"value":20}, - "skeletonKing": {"name":"骷髅王","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, - "evilHero": {"name":"迷失勇者","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, - "demonPriest": {"name":"魔神法师","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "skeletonPriest": {"name":"骷髅法师","hp":100,"atk":100,"def":0,"money":0,"exp":0,"point":0,"special":[18],"value":20}, + "skeletonKing": {"name":"骷髅王","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[]}, + "evilHero": {"name":"迷失勇者","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[]}, + "demonPriest": {"name":"魔神法师","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[]}, "goldHornSlime": {"name":"尖角怪","hp":1500,"atk":366,"def":166,"money":1,"exp":35,"point":0,"special":[]}, "silverSlime": {"name":"银头怪","hp":250,"atk":50,"def":20,"money":0,"exp":11,"point":0,"special":[2]}, - "whiteHornSlime": {"name":"尖角怪","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "whiteHornSlime": {"name":"尖角怪","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[]}, "redSwordsman": {"name":"山间盗贼","hp":1000,"atk":175,"def":40,"money":1,"exp":24,"point":0,"special":[4],"n":8}, - "poisonZombie": {"name":"绿兽人","hp":100,"atk":120,"def":0,"money":13,"exp":0,"point":0,"special":12}, - "octopus": {"name":"血影","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, - "princessEnemy": {"name":"假公主","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, - "angel": {"name":"天使","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, - "elemental": {"name":"元素生物","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, - "steelGuard": {"name":"铁守卫","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":18,"value":20}, + "poisonZombie": {"name":"绿兽人","hp":100,"atk":120,"def":0,"money":13,"exp":0,"point":0,"special":[12]}, + "octopus": {"name":"血影","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[]}, + "princessEnemy": {"name":"假公主","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[]}, + "angel": {"name":"天使","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[]}, + "elemental": {"name":"元素生物","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[]}, + "steelGuard": {"name":"铁守卫","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[18],"value":20}, "evilBat": {"name":"邪恶蝙蝠","hp":1000,"atk":800,"def":350,"money":1,"exp":40,"point":0,"special":[2]}, - "frozenSkeleton": {"name":"冻死骨","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, - "silverSlimelord": {"name":"银怪王","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, - "goldSlimelord": {"name":"金怪王","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "frozenSkeleton": {"name":"冻死骨","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[]}, + "silverSlimelord": {"name":"银怪王","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[]}, + "goldSlimelord": {"name":"金怪王","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[]}, "skeletonWarrior": {"name":"骷髅士兵","hp":500,"atk":100,"def":20,"money":0,"exp":12,"point":0,"special":[1],"crit":500}, "whiteSlimeman": {"name":"水银史莱姆人","hp":750,"atk":100,"def":45,"money":0,"exp":20,"point":0,"special":[4]}, "slimeman": {"name":"莱姆人","hp":125,"atk":30,"def":10,"money":0,"exp":4,"point":0,"special":[4],"atkValue":2,"defValue":3}, "yellowGateKeeper": {"name":"神秘卫兵","hp":375,"atk":200,"def":15,"money":1,"exp":25,"point":0,"special":[1],"crit":5000}, "blueGateKeeper": {"name":"神秘雕像","hp":1000,"atk":275,"def":120,"money":1,"exp":38,"point":0,"special":[1],"crit":1000}, "redGateKeeper": {"name":"勇气卫兵","hp":1000,"atk":450,"def":250,"money":1,"exp":30,"point":0,"special":[1],"crit":2000}, - "magicMaster": {"name":"黑暗大法师","hp":100,"atk":120,"def":0,"money":12,"exp":0,"point":0,"special":11,"value":0.3333333333333333,"add":true,"notBomb":true}, - "devilWarrior": {"name":"魔神武士","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, - "fairyEnemy": {"name":"仙子","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, - "dragon": {"name":"魔龙","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, - "skeletonKnight": {"name":"骷髅武士","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, - "skeletonPresbyter": {"name":"骷髅巫师","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "magicMaster": {"name":"黑暗大法师","hp":100,"atk":120,"def":0,"money":12,"exp":0,"point":0,"special":[11],"value":0.3333333333333333,"add":true,"notBomb":true}, + "devilWarrior": {"name":"魔神武士","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[]}, + "fairyEnemy": {"name":"仙子","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[]}, + "dragon": {"name":"魔龙","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[]}, + "skeletonKnight": {"name":"骷髅武士","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[]}, + "skeletonPresbyter": {"name":"骷髅巫师","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[]}, "ironRock": {"name":"山间巨石","hp":750,"atk":150,"def":0,"money":0,"exp":20,"point":0,"special":[3]}, "grayRock": {"name":"林间巨石","hp":100,"atk":60,"def":0,"money":0,"exp":12,"point":0,"special":[3]}, - "yellowPriest": {"name":"中级法师","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, - "evilPrincess": {"name":"痛苦魔女","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, - "blademaster": {"name":"剑圣","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, - "evilFairy": {"name":"黑暗仙子","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, - "blueRock": {"name":"勇气之石","hp":2000,"atk":450,"def":230,"money":1,"exp":30,"point":0,"special":0}, + "yellowPriest": {"name":"中级法师","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[]}, + "evilPrincess": {"name":"痛苦魔女","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[]}, + "blademaster": {"name":"剑圣","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[]}, + "evilFairy": {"name":"黑暗仙子","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[]}, + "blueRock": {"name":"勇气之石","hp":2000,"atk":450,"def":230,"money":1,"exp":30,"point":0,"special":[]}, "skeletonLite": {"name":"骷髅精英","hp":2000,"atk":275,"def":240,"money":1,"exp":35,"point":0,"special":[9]}, - "greenKnight": {"name":"强盾骑士","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "greenKnight": {"name":"强盾骑士","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[]}, "bowman": {"name":"猎人","hp":500,"atk":100,"def":50,"money":0,"exp":16,"point":0,"special":[24],"value":75}, "liteBowman": {"name":"山间猎手","hp":1200,"atk":200,"def":60,"money":1,"exp":27,"point":0,"special":[24]}, "crimsonZombie": {"name":"勇气之兽","hp":1800,"atk":2000,"def":-100,"money":1,"exp":35,"point":0,"special":[]}, - "watcherSlime": {"name":"邪眼怪","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, - "mutantSlimeman": {"name":"变异史莱姆人","hp":350,"atk":70,"def":27,"money":0,"exp":13,"point":0,"special":0}, - "devilKnight": {"name":"恶灵骑士","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "watcherSlime": {"name":"邪眼怪","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[]}, + "mutantSlimeman": {"name":"变异史莱姆人","hp":350,"atk":70,"def":27,"money":0,"exp":13,"point":0,"special":[]}, + "devilKnight": {"name":"恶灵骑士","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[]}, "grayPriest": {"name":"智慧法王","hp":3000,"atk":600,"def":250,"money":1,"exp":40,"point":0,"special":[13]}, - "greenGateKeeper": {"name":"卫兵队长","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, - "ghostSoldier": {"name":"山间骷髅","hp":750,"atk":180,"def":40,"money":0,"exp":18,"point":0,"special":0}, - "frostBat": {"name":"寒蝙蝠","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, - "blackKing": {"name":"黑衣魔王","hp":1000,"atk":500,"def":0,"money":1000,"exp":1000,"point":0,"special":0,"notBomb":true}, - "yellowKing": {"name":"黄衣魔王","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, - "greenKing": {"name":"青衣武士","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, - "redKing": {"name":"红衣魔王","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, - "blueKing": {"name":"白衣武士","hp":100,"atk":120,"def":0,"money":17,"exp":0,"point":0,"special":16}, + "greenGateKeeper": {"name":"卫兵队长","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[]}, + "ghostSoldier": {"name":"山间骷髅","hp":750,"atk":180,"def":40,"money":0,"exp":18,"point":0,"special":[]}, + "frostBat": {"name":"寒蝙蝠","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[]}, + "blackKing": {"name":"黑衣魔王","hp":1000,"atk":500,"def":0,"money":1000,"exp":1000,"point":0,"special":[],"notBomb":true}, + "yellowKing": {"name":"黄衣魔王","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[]}, + "greenKing": {"name":"青衣武士","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[]}, + "redKing": {"name":"红衣魔王","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[]}, + "blueKing": {"name":"白衣武士","hp":100,"atk":120,"def":0,"money":17,"exp":0,"point":0,"special":[16]}, "E368": {"name":"绿头武装怪","hp":400,"atk":75,"def":30,"money":0,"exp":14,"point":0,"special":[]}, "E369": {"name":"红头武装怪","hp":450,"atk":85,"def":35,"money":0,"exp":17,"point":0,"special":[]}, "E370": {"name":"青头武装怪","hp":600,"atk":100,"def":50,"money":0,"exp":20,"point":0,"special":[1],"crit":400}, diff --git a/public/project/floors/MT2.js b/public/project/floors/MT2.js index 0e8f97e..f651b95 100644 --- a/public/project/floors/MT2.js +++ b/public/project/floors/MT2.js @@ -1,57 +1,79 @@ -main.floors.MT2= -{ - "floorId": "MT2", - "title": "洞穴", - "name": "2", - "width": 15, - "height": 15, - "canFlyTo": true, - "canFlyFrom": true, - "canUseQuickShop": true, - "cannotViewMap": false, - "images": [], - "ratio": 1, - "defaultGround": "T331", - "bgm": "cave.mp3", - "firstArrive": [], - "eachArrive": [], - "parallelDo": "", - "events": {}, - "changeFloor": { - "14,4": { - "floorId": "MT1", - "loc": [ - 0, - 4 - ] +main.floors.MT2 = { + floorId: 'MT2', + title: '洞穴', + name: '2', + width: 15, + height: 15, + canFlyTo: true, + canFlyFrom: true, + canUseQuickShop: true, + cannotViewMap: false, + images: [], + ratio: 1, + defaultGround: 'T331', + bgm: 'cave.mp3', + firstArrive: [], + eachArrive: [], + parallelDo: '', + events: {}, + changeFloor: { + '14,4': { + floorId: 'MT1', + loc: [0, 4] } }, - "afterBattle": {}, - "afterGetItem": {}, - "afterOpenDoor": {}, - "autoEvent": {}, - "cannotMove": {}, - "map": [ - [20041,20041,20044,20049,20049,20049,20049,20049,20049,20049,20049,20049,20049,20049,20043], - [20041,20041,20042,20057,20057,20057,20057,20057,20057,20057,20057,20057,20057,20057,20048], - [20041,20041,20042,20065,20065,20065,20065,20065,20065,20065,20065,20065,20065,20065,20056], - [20041,20041,20042, 0,336, 32, 0, 27, 0,206,141, 34,141, 0,20064], - [20041,20041,20042, 0,336,336,203,333,333, 0,141,203,141, 0, 94], - [20041,20041,20042, 0, 0, 31, 0, 0,205, 0,201, 34,201, 0,20032], - [20041,20041,20042,336,202,333,333, 0,340, 31,141,202,141,141,20040], - [20041,20041,20042, 34, 27, 0,333, 0,340, 0,141, 0, 31, 31,20040], - [20041,20041,20042,345,345,201,333,205,141,141,141,141,141, 0,20040], - [20041,20041,20042, 0,202, 0, 0, 31, 0, 0,206, 0,141,141,20040], - [20041,20041,20042, 0,336, 31, 0,336, 0, 31,141, 0, 28, 0,20040], - [20041,20041,20042, 28,336,336,336,336,345,202,141, 27, 0, 32,20040], - [20041,20041,20042, 0,336, 0, 32,345, 0, 0,141,141,141,141,20040], - [20041,20041,20042, 32,336, 28, 0,206, 0, 0,203, 0, 27, 31,20040], - [20041,20041,20036,20033,20033,20033,20033,20033,20033,20033,20033,20033,20033,20033,20035] -], - "bgmap": [ - -], - "fgmap": [ - -] -} \ No newline at end of file + afterBattle: {}, + afterGetItem: {}, + afterOpenDoor: {}, + autoEvent: {}, + cannotMove: {}, + map: [ + [ + 20041, 20041, 20044, 20049, 20049, 20049, 20049, 20049, 20049, + 20049, 20049, 20049, 20049, 20049, 20043 + ], + [ + 20041, 20041, 20042, 20057, 20057, 20057, 20057, 20057, 20057, + 20057, 20057, 20057, 20057, 20057, 20048 + ], + [ + 20041, 20041, 20042, 20065, 20065, 20065, 20065, 20065, 20065, + 20065, 20065, 20065, 20065, 20065, 20056 + ], + [ + 20041, 20041, 20042, 0, 336, 32, 0, 27, 0, 206, 141, 34, 141, 0, + 20064 + ], + [ + 20041, 20041, 20042, 0, 336, 336, 203, 333, 333, 0, 141, 203, 141, + 0, 94 + ], + [20041, 20041, 20042, 0, 0, 31, 0, 0, 205, 0, 201, 34, 201, 0, 20032], + [ + 20041, 20041, 20042, 336, 202, 333, 333, 0, 340, 31, 141, 202, 141, + 141, 20040 + ], + [20041, 20041, 20042, 34, 27, 0, 333, 0, 340, 0, 141, 0, 31, 31, 20040], + [ + 20041, 20041, 20042, 345, 345, 201, 333, 205, 141, 141, 141, 141, + 141, 0, 20040 + ], + [20041, 20041, 20042, 0, 202, 0, 0, 31, 0, 0, 206, 0, 141, 141, 20040], + [20041, 20041, 20042, 0, 336, 31, 0, 336, 0, 31, 141, 0, 28, 0, 20040], + [ + 20041, 20041, 20042, 28, 336, 336, 336, 336, 345, 202, 141, 27, 0, + 32, 20040 + ], + [ + 20041, 20041, 20042, 0, 336, 0, 32, 345, 0, 0, 141, 141, 141, 141, + 20040 + ], + [20041, 20041, 20042, 32, 336, 28, 0, 206, 0, 0, 203, 0, 27, 31, 20040], + [ + 20041, 20041, 20036, 20033, 20033, 20033, 20033, 20033, 20033, + 20033, 20033, 20033, 20033, 20033, 20035 + ] + ], + bgmap: [], + fgmap: [] +}; diff --git a/public/project/floors/tower4.js b/public/project/floors/tower4.js index 5910f47..11f42bd 100644 --- a/public/project/floors/tower4.js +++ b/public/project/floors/tower4.js @@ -1,82 +1,74 @@ -main.floors.tower4= -{ - "floorId": "tower4", - "title": "智慧之塔", - "name": "4", - "width": 15, - "height": 15, - "canFlyTo": true, - "canFlyFrom": true, - "canUseQuickShop": true, - "cannotViewMap": false, - "images": [], - "ratio": 2, - "defaultGround": "T526", - "bgm": "tower.mp3", - "firstArrive": [], - "eachArrive": [], - "parallelDo": "", - "events": {}, - "afterBattle": {}, - "afterGetItem": {}, - "afterOpenDoor": {}, - "autoEvent": {}, - "cannotMove": {}, - "map": [ - [527,527,527,527,527,527,527,543,527,527,527,527,527,527,527], - [527, 31, 31,536, 0,528, 0,547, 0, 31, 0,544, 0,381,527], - [527, 31, 31,528, 28,492, 29,528,528, 0, 28,528, 0,528,527], - [527,528,528,528, 0,528, 28, 34,492,492,528,528,547, 0,527], - [527,381, 0,550, 0,528,528,528,528, 0, 31,528, 0,528,527], - [527, 0,528, 0,528,528, 31, 0,536, 27, 0,556,381,378,527], - [527, 0,528, 27, 0,544, 0,403, 0,528,528, 0,528,528,527], - [527,550,528,528,528,528,492,528,550,528, 34,381,556,376,527], - [527, 0, 0, 31,492, 88,403,528, 31,528, 27, 32,528, 0,527], - [527,528,528, 0,528,403, 34,547, 0,492,492,528,528,556,527], - [527, 0,528,546,528,528,546,528,528,528, 0, 28, 0, 0,527], - [527, 0,544, 32, 0,536, 32,528, 32, 0,536,528,528,556,527], - [527, 27,492, 0, 27,528, 27,492, 0,528,528,528, 0, 0,527], - [527, 31,528, 32, 0,528, 32,546, 0,494, 87,381, 28, 0,527], - [527,527,527,527,527,527,527,540,527,527,527,527,527,527,527] -], - "beforeBattle": {}, - "bgmap": [ - -], - "fgmap": [ - -], - "bg2map": [], - "fg2map": [], - "cannotMoveIn": {}, - "changeFloor": { - "5,8": { - "floorId": "tower3", - "loc": [ - 5, - 8 - ] +main.floors.tower4 = { + floorId: 'tower4', + title: '智慧之塔', + name: '4', + width: 15, + height: 15, + canFlyTo: true, + canFlyFrom: true, + canUseQuickShop: true, + cannotViewMap: false, + images: [], + ratio: 2, + defaultGround: 'T526', + bgm: 'tower.mp3', + firstArrive: [], + eachArrive: [], + parallelDo: '', + events: {}, + afterBattle: {}, + afterGetItem: {}, + afterOpenDoor: {}, + autoEvent: {}, + cannotMove: {}, + map: [ + [ + 527, 527, 527, 527, 527, 527, 527, 543, 527, 527, 527, 527, 527, + 527, 527 + ], + [527, 31, 31, 536, 0, 528, 0, 547, 0, 31, 0, 544, 0, 381, 527], + [527, 31, 31, 528, 28, 492, 29, 528, 528, 0, 28, 528, 0, 528, 527], + [527, 528, 528, 528, 0, 528, 28, 34, 492, 492, 528, 528, 547, 0, 527], + [527, 381, 0, 550, 0, 528, 528, 528, 528, 0, 31, 528, 0, 528, 527], + [527, 0, 528, 0, 528, 528, 31, 0, 536, 27, 0, 556, 381, 378, 527], + [527, 0, 528, 27, 0, 544, 0, 403, 0, 528, 528, 0, 528, 528, 527], + [ + 527, 550, 528, 528, 528, 528, 492, 528, 550, 528, 34, 381, 556, 376, + 527 + ], + [527, 0, 0, 31, 492, 88, 403, 528, 31, 528, 27, 32, 528, 0, 527], + [527, 528, 528, 0, 528, 403, 34, 547, 0, 492, 492, 528, 528, 556, 527], + [527, 0, 528, 546, 528, 528, 546, 528, 528, 528, 0, 28, 0, 0, 527], + [527, 0, 544, 32, 0, 536, 32, 528, 32, 0, 536, 528, 528, 556, 527], + [527, 27, 492, 0, 27, 528, 27, 492, 0, 528, 528, 528, 0, 0, 527], + [527, 31, 528, 32, 0, 528, 32, 546, 0, 494, 87, 381, 28, 0, 527], + [ + 527, 527, 527, 527, 527, 527, 527, 540, 527, 527, 527, 527, 527, + 527, 527 + ] + ], + beforeBattle: {}, + bgmap: [], + fgmap: [], + bg2map: [], + fg2map: [], + cannotMoveIn: {}, + changeFloor: { + '5,8': { + floorId: 'tower3', + loc: [5, 8] }, - "7,0": { - "floorId": "tower6", - "loc": [ - 1, - 15 - ] + '7,0': { + floorId: 'tower6', + loc: [1, 15] }, - "7,14": { - "floorId": "tower6", - "loc": [ - 12, - 15 - ] + '7,14': { + floorId: 'tower6', + loc: [12, 15] }, - "10,13": { - "floorId": "tower5", - "loc": [ - 10, - 13 - ] + '10,13': { + floorId: 'tower5', + loc: [10, 13] } } -} \ No newline at end of file +}; diff --git a/public/project/floors/tower6.js b/public/project/floors/tower6.js index dec28ca..93b58e5 100644 --- a/public/project/floors/tower6.js +++ b/public/project/floors/tower6.js @@ -1,277 +1,853 @@ -main.floors.tower6= -{ - "floorId": "tower6", - "title": "智慧之塔", - "name": "1", - "width": 25, - "height": 60, - "canFlyTo": true, - "canFlyFrom": true, - "canUseQuickShop": true, - "cannotViewMap": false, - "images": null, - "ratio": 2, - "defaultGround": "T526", - "bgm": "tower.mp3", - "firstArrive": [ - "这一层有点卡......没办法,玩法需求", - "这一层在存读档界面的截图可能会有问题", - "这一层自动存档有问题,不会修...", - "但是你可以在这一层使用自动存档,但该层不会自动存档", - "自动存档可能不会显示,但可以使用(我也不知道为啥)", - "在本楼层,如果勇士朝向为向上或向下,在打败一个怪物后会强制前进一格,不然会出bug" +main.floors.tower6 = { + floorId: 'tower6', + title: '智慧之塔', + name: '1', + width: 25, + height: 60, + canFlyTo: true, + canFlyFrom: true, + canUseQuickShop: true, + cannotViewMap: false, + images: null, + ratio: 2, + defaultGround: 'T526', + bgm: 'tower.mp3', + firstArrive: [ + '这一层有点卡......没办法,玩法需求', + '这一层在存读档界面的截图可能会有问题', + '这一层自动存档有问题,不会修...', + '但是你可以在这一层使用自动存档,但该层不会自动存档', + '自动存档可能不会显示,但可以使用(我也不知道为啥)', + '在本楼层,如果勇士朝向为向上或向下,在打败一个怪物后会强制前进一格,不然会出bug' ], - "eachArrive": [], - "parallelDo": "", - "events": {}, - "changeFloor": { - "12,58": { - "floorId": "tower1", - "loc": [ - 14, - 7 - ], - "direction": "left" + eachArrive: [], + parallelDo: '', + events: {}, + changeFloor: { + '12,58': { + floorId: 'tower1', + loc: [14, 7], + direction: 'left' }, - "24,58": { - "floorId": "tower1", - "loc": [ - 0, - 7 - ], - "direction": "right" + '24,58': { + floorId: 'tower1', + loc: [0, 7], + direction: 'right' }, - "18,42": { - "floorId": "tower2", - "loc": [ - 7, - 14 - ], - "direction": "up" + '18,42': { + floorId: 'tower2', + loc: [7, 14], + direction: 'up' }, - "18,15": { - "floorId": "tower4", - "loc": [ - 7, - 14 - ], - "direction": "up" + '18,15': { + floorId: 'tower4', + loc: [7, 14], + direction: 'up' }, - "7,15": { - "floorId": "tower4", - "loc": [ - 7, - 0 - ], - "direction": "down" + '7,15': { + floorId: 'tower4', + loc: [7, 0], + direction: 'down' }, - "24,2": { - "floorId": "tower5", - "loc": [ - 14, - 7 - ], - "direction": "left" + '24,2': { + floorId: 'tower5', + loc: [14, 7], + direction: 'left' } }, - "afterBattle": {}, - "afterGetItem": {}, - "afterOpenDoor": {}, - "autoEvent": {}, - "cannotMove": {}, - "map": [ - [ 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17], - [ 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17], - [ 0,556,556, 32, 0, 0, 0, 32,537, 32,537, 32,537, 32,537, 32, 0,376,378,381, 34,556,556, 0,543], - [527,527,527,527,527,527,527,527,527,527,527,527,527,527,527,279,527,527,527,527,527,527,527,527,527], - [ 32, 0,537, 17, 0, 0, 17, 17, 0, 0, 17, 17, 0, 32, 0,376,550, 0, 17, 17, 17, 17, 17, 17, 17], - [527,527, 0, 17,527, 32, 0,537, 0,527, 17, 17,527,527,527, 0,527, 27, 32, 17, 17, 17, 17, 17, 17], - [ 17, 0, 27, 0,527,527,527,527, 0,546, 27, 32, 29, 17, 17, 0, 17,527, 28, 0, 17, 17, 17, 17, 17], - [ 32,547,527, 32, 17, 17, 17, 17, 34,527,527,527,527, 17, 17, 0, 17, 17,527,556, 0, 17, 17, 17, 17], - [ 32,527, 17,381,381, 0,544, 0, 0, 0, 27, 32, 32, 28,492,536, 17, 17, 17,527,378,376,381, 32, 17], - [527, 17, 17, 17,527,527,527,527,527,527,527,527,527,527,527, 0, 17, 17, 17, 17,527,527,527,527, 17], - [556, 32,381, 32, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,376,550, 0, 27, 32,381, 0, 0,556,556], - [527,527,527,527, 17, 17, 0, 32,547, 32, 0, 17, 17, 17, 17, 33,527,527,527,527,527,527,527,527,527], - [ 17, 17, 17, 17, 17, 0, 28,527,527,527,381, 0, 17, 17, 17, 0, 17,527, 32, 0,544, 0, 27, 32, 28], - [ 0, 17, 17, 17, 0, 27,527, 17, 17, 17,527,376,381, 32, 0,279,378,527,527,527,492,527,527,527,527], - [ 0, 27,381, 32,550,527, 17, 17, 17, 17, 17,527,527,527,527, 0,527, 17, 17, 17, 32, 17, 17, 17, 17], - [527,527,527,527,527, 0, 0,543, 0, 27,381, 32, 0, 17, 0, 32, 27, 0,543, 0,381, 0, 17, 17, 17], - [ 17, 17, 0,550, 32, 0,527,527,527,527, 0,527,527, 0,550,527,527,527,527,527,527,556, 17, 17, 17], - [ 28, 27, 32,527,527,527, 17, 17, 17, 0,546, 32,378,381,527, 17,378,381, 32,556, 32, 32, 17, 17, 17], - [527,527,527,527, 17, 17, 17, 17, 0, 32,527,527,527,527, 17, 0,381,527,527,527,527,556, 17, 17, 17], - [ 0, 17, 17, 17, 17, 17, 17, 0,376,527, 0, 27,381, 32, 0,546,527, 17, 0, 0,390,403,396, 0, 0], - [ 29, 0,537, 0, 17, 17, 0,547,527, 17,527,527,527,527, 0,527, 17, 17,527,527,527,279,527,527,527], - [527,527,527, 32,492, 29, 0,527, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,378, 17, 17, 17], - [ 17, 17,527,527,527, 0,527, 0, 32,544, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 17, 17, 17], - [ 32,556, 32, 29, 32,537,492, 27,527,527,527, 0, 0, 0, 17, 28, 0,536, 0, 27, 0,556, 17,376,556], - [527,527,527,527,527,527,527,381, 17, 17, 17,381,527,527, 17,527,492,527,527,527,527, 0, 17, 32,527], - [ 17, 17, 17, 17, 0, 0, 17, 28, 0,536, 32, 0, 0, 0, 17, 17,550, 17, 17, 17, 17, 17, 17,556, 17], - [ 0,381, 0,537,527,527, 17,527,527,527,527,527,537,527, 0, 0, 0,381, 32, 0, 17, 17, 28, 0, 0], - [527,527,527, 32, 0, 27, 0,544, 0, 0, 0, 17,492, 17, 28,527,527,527,527,527, 17, 32, 0,527,527], - [ 17, 17,527,527,527,527,527,527, 0,527,527, 17, 27, 34,550, 17, 17, 17, 17, 17, 17,527,527,527, 17], - [ 0, 17, 17, 17, 17, 17, 17, 0, 0, 28, 17, 17, 0,527,527, 0, 32, 0,546, 28, 17, 0,546, 0,381], - [381, 33, 17,441, 33,547, 0, 33,527,527, 17, 0,550, 0, 32,381,527,527,527, 0, 17, 0,527,527,527], - [527,527, 17,527,527,527,527,279,403,390, 17,527,527,527,527,527,527, 17, 17, 0, 17, 0, 17, 17, 17], - [ 17, 17, 17, 0, 0, 0, 17, 0,527,527, 17, 17, 17, 17, 17, 17, 17, 32, 0, 27,546, 0, 34,376, 0], - [ 17, 17, 17,527,537, 0, 32, 0,536, 0, 34,378, 32, 0, 17, 0,556,403,527,527,527,527,527,527, 0], - [381, 34, 28,547, 0,527,527,527,527,527,381,527,527,527, 17,527, 0,527, 17, 0, 0,544, 0, 32, 0], - [527,527,527,527, 0, 0,381, 0, 17, 0, 0, 0, 17, 0, 0, 32,381,376, 32,550,527,527,527,527,527], - [ 17, 17, 17,527,527,527,527,527, 17,527,527,527, 17,527,527,527,527,527,527, 0, 17, 17, 17, 17, 17], - [ 0,536, 34, 17, 32,537,381,537, 32, 29, 32,556, 0, 17, 0, 27, 32, 28, 0,550, 0, 32,378, 34, 0], - [527,492,527, 17,527, 0,527, 0,527,527,527,527,527, 17,527,527, 0,527,527,527,527,527,527,527,527], - [ 17, 34, 17, 17, 17, 0, 17, 0, 0,556,390,441,396,556, 0, 0,546, 34,376, 32,549, 0, 17, 17, 17], - [ 0,537, 0, 32, 28, 27,492, 32,527,527,527, 0,527,527,527,492,527,527,527,527,527, 0, 32, 0, 0], - [527,527,527,527,527,527,527,537,492, 0, 32,556, 0, 0, 0, 0, 0, 17, 17, 17,527,527,527,527,527], - [ 0, 17, 17, 17, 17, 17, 17, 34,527,527,527,527, 28,527,527,527,536,376,543,378,381,547, 0, 32, 32], - [550, 31, 31, 17, 0, 27, 34,381,556,492, 0, 0, 32, 17, 17,527,527,527,527,527,492,527,527,527,527], - [527,527,527, 17,527,527,527, 17,527,527,527,527, 0, 17, 17, 17, 17, 17, 17, 17,546, 17, 17, 17,527], - [ 17, 17, 17, 17, 17, 17, 17,494,556, 33, 27, 0,381, 0,547, 0,492, 33, 28, 33, 0, 17, 17, 17, 17], - [ 0, 27, 34,549, 34,376,381,378,527,527,527,527, 0,527,527,527,527,527,527,527, 0, 29, 0, 0, 0], - [527,527,527,527,527,527,527,527,527, 17, 17, 17,544, 0, 27, 33,381, 0,547,527,527,527,527, 0,527], - [ 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0,527,527,527,527,527, 0, 28, 33,381, 0,544, 17], - [ 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 29, 17, 17, 17, 17,527,527,527,527,527,527,492, 17], - [ 34,537, 34,381, 27,381, 34,550,492, 0, 34, 29, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 17], - [381,527,527,527,527,527,527,527,527,527,527,527,546, 34, 29, 27, 29, 34, 17, 17, 17, 17, 17, 0, 17], - [ 0,527, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,492,527,527,527,527,536, 0, 34, 28, 27,381, 34, 0], - [527,527, 0,381,378, 33,381, 0, 17, 17, 17, 17, 0, 17, 17, 17,527,527,527,527,527,527,527,547,527], - [ 0, 0,550,527,527,527,527,549, 0, 33, 0, 17, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0], - [527,527,527,527, 17, 17,527,527,527,527,527, 17,537, 0,381, 0,536, 34,376, 0,537, 0, 34,381, 34], - [527, 0,537, 0, 0, 34,492, 0, 27, 34, 0, 17, 0,527,527,527, 0,527,527,527,527,527,527,527,527], - [ 17,527, 0,527,527,527,527,550,527,527,527, 17, 17, 17, 17, 17, 0,546, 34, 17, 17, 17, 17, 17, 17], - [ 0,548, 34,537,381, 0, 34, 0, 27, 34,549, 0,543, 0, 33, 28, 0,527,378,381, 33,544, 27,494,543], - [528,528,528,528,528,528,528,528,528,528,528,528,528,528,528,528,528,528,528,528,528,528,528,528,528] -], - "bgmap": [ - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50057,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50057,50057], - [50057,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50057,50057], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50057,50057,50057,50041,50041,50041,50041,50041,50041,50041,50041,50057,50057,50057,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50057,50057,50057,50041,50041,50041,50041,50041,50041,50041,50041,50057,50057,50057,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50057,50057,50057,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50057,50057,50057,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,306], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041], - [50057,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50057,50057,50057,50041,50041,50041,50041,50041,50041,50041,50041,50041,50057,50057], - [50057,50041,50041,50041,50041,50041,50041,50041,50041,50041,50041,50057,50057,50057,50041,50041,50041,50041,50041,50041,50041,50041,50041,50057,50057], - [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] -], - "fgmap": [ - -], - "bg2map": [ - [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [50146, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,50144,50145], - [50154, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,50152,50153], - [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [ 0, 0,552, 0, 0, 0, 0, 0,552, 0, 0, 0, 0, 0, 0,552, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [ 0, 0,552, 0, 0, 0, 0, 0,552, 0, 0, 0, 0, 0, 0,552, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [ 0, 0,552, 0, 0, 0, 0, 0,552, 0, 0, 0, 0, 0, 0,552, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [ 0, 0, 0,552, 0, 0, 0, 0,552, 0, 0, 0, 0, 0, 0,552, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [ 0, 0, 0,552, 0, 0, 0, 0,552, 0, 0, 0, 0, 0, 0,552, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0, 0,552, 0, 0, 0, 0], - [ 0, 0, 0, 0, 0, 0,50144,50145,50146, 0, 0, 0, 0, 0, 0,552, 0,50144,50145,50146,552, 0, 0, 0, 0], - [ 0, 0, 0, 0, 0, 0,50152,50153,50154, 0, 0, 0, 0, 0, 0,552, 0,50152,50153,50154,552, 0, 0, 0, 0], - [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0], - [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0], - [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0], - [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0, 0, 0, 0,552, 0, 0, 0], - [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0, 0, 0, 0,552, 0, 0, 0], - [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0], - [ 0, 0, 0, 0, 0,552, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0], - [ 0, 0, 0, 0, 0,552, 0,552, 0, 0, 0,552, 0, 0, 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0], - [ 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0,552, 0, 0, 0, 0,552, 0, 0, 0, 0,552, 0,552, 0], - [ 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0,552, 0, 0, 0, 0,552, 0, 0, 0, 0, 0, 0,552, 0], - [ 0, 0, 0,552, 0, 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0,552, 0, 0, 0, 0, 0, 0,552, 0], - [ 0, 0, 0,552, 0, 0, 0, 0, 0, 0, 0, 0,552, 0,552, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [ 0, 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0,552, 0,552, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [ 0, 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0,552, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [ 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0, 0,552, 0, 0, 0, 0, 0, 0,552, 0,552, 0, 0, 0], - [ 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,552, 0,552, 0, 0, 0], - [ 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,552, 0,552, 0, 0, 0], - [ 0, 0, 0, 0,552, 0, 0,552, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,552], - [ 0, 0, 0, 0,552, 0, 0, 0, 0, 0,552, 0, 0, 0, 0, 0,552, 0, 0, 0, 0, 0, 0, 0,552], - [ 0, 0, 0, 0,552, 0, 0, 0, 0, 0,552, 0, 0, 0, 0, 0,552, 0, 0,552, 0, 0, 0, 0, 0], - [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0, 0, 0], - [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0, 0, 0], - [ 0,552, 0, 0, 0,552, 0,552, 0, 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0, 0, 0, 0, 0, 0], - [ 0,552, 0, 0, 0,552, 0,552, 0, 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0, 0, 0, 0, 0, 0], - [ 0,552, 0, 0, 0,552, 0,552, 0, 0, 0,552, 0, 0, 0,552, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [ 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0,552, 0, 0, 0,552, 0,50144,50145,50146, 0, 0, 0, 0, 0], - [ 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0, 0,552, 0, 0, 0, 0,50152,50153,50154, 0, 0, 0, 0, 0], - [ 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0, 0,552, 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0, 0], - [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0, 0], - [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0, 0], - [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0, 0, 0, 0, 0,552, 0, 0,552, 0], - [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,552, 0], - [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,552, 0], - [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,552, 0], - [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,552, 0], - [552, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,552, 0], - [552, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,552, 0], - [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,552, 0], - [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,552,50041], - [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,552, 0], - [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,552, 0, 0, 0,552, 0, 0, 0, 0, 0, 0, 0, 0], - [50146, 0,552, 0, 0, 0, 0,552, 0, 0, 0,50144,50145,50146, 0, 0,552, 0, 0, 0, 0, 0, 0,50144,50145], - [50154, 0,552, 0, 0, 0, 0,552, 0, 0, 0,50152,50153,50154, 0, 0,552, 0, 0, 0, 0, 0, 0,50152,50153], - [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] -], - "fg2map": [ - -], - "beforeBattle": {}, - "cannotMoveDirectly": true, - "cannotMoveIn": {} -} \ No newline at end of file + afterBattle: {}, + afterGetItem: {}, + afterOpenDoor: {}, + autoEvent: {}, + cannotMove: {}, + map: [ + [ + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17 + ], + [ + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17 + ], + [ + 0, 556, 556, 32, 0, 0, 0, 32, 537, 32, 537, 32, 537, 32, 537, 32, 0, + 376, 378, 381, 34, 556, 556, 0, 543 + ], + [ + 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, + 527, 527, 279, 527, 527, 527, 527, 527, 527, 527, 527, 527 + ], + [ + 32, 0, 537, 17, 0, 0, 17, 17, 0, 0, 17, 17, 0, 32, 0, 376, 550, 0, + 17, 17, 17, 17, 17, 17, 17 + ], + [ + 527, 527, 0, 17, 527, 32, 0, 537, 0, 527, 17, 17, 527, 527, 527, 0, + 527, 27, 32, 17, 17, 17, 17, 17, 17 + ], + [ + 17, 0, 27, 0, 527, 527, 527, 527, 0, 546, 27, 32, 29, 17, 17, 0, 17, + 527, 28, 0, 17, 17, 17, 17, 17 + ], + [ + 32, 547, 527, 32, 17, 17, 17, 17, 34, 527, 527, 527, 527, 17, 17, 0, + 17, 17, 527, 556, 0, 17, 17, 17, 17 + ], + [ + 32, 527, 17, 381, 381, 0, 544, 0, 0, 0, 27, 32, 32, 28, 492, 536, + 17, 17, 17, 527, 378, 376, 381, 32, 17 + ], + [ + 527, 17, 17, 17, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, + 527, 0, 17, 17, 17, 17, 527, 527, 527, 527, 17 + ], + [ + 556, 32, 381, 32, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 376, + 550, 0, 27, 32, 381, 0, 0, 556, 556 + ], + [ + 527, 527, 527, 527, 17, 17, 0, 32, 547, 32, 0, 17, 17, 17, 17, 33, + 527, 527, 527, 527, 527, 527, 527, 527, 527 + ], + [ + 17, 17, 17, 17, 17, 0, 28, 527, 527, 527, 381, 0, 17, 17, 17, 0, 17, + 527, 32, 0, 544, 0, 27, 32, 28 + ], + [ + 0, 17, 17, 17, 0, 27, 527, 17, 17, 17, 527, 376, 381, 32, 0, 279, + 378, 527, 527, 527, 492, 527, 527, 527, 527 + ], + [ + 0, 27, 381, 32, 550, 527, 17, 17, 17, 17, 17, 527, 527, 527, 527, 0, + 527, 17, 17, 17, 32, 17, 17, 17, 17 + ], + [ + 527, 527, 527, 527, 527, 0, 0, 543, 0, 27, 381, 32, 0, 17, 0, 32, + 27, 0, 543, 0, 381, 0, 17, 17, 17 + ], + [ + 17, 17, 0, 550, 32, 0, 527, 527, 527, 527, 0, 527, 527, 0, 550, 527, + 527, 527, 527, 527, 527, 556, 17, 17, 17 + ], + [ + 28, 27, 32, 527, 527, 527, 17, 17, 17, 0, 546, 32, 378, 381, 527, + 17, 378, 381, 32, 556, 32, 32, 17, 17, 17 + ], + [ + 527, 527, 527, 527, 17, 17, 17, 17, 0, 32, 527, 527, 527, 527, 17, + 0, 381, 527, 527, 527, 527, 556, 17, 17, 17 + ], + [ + 0, 17, 17, 17, 17, 17, 17, 0, 376, 527, 0, 27, 381, 32, 0, 546, 527, + 17, 0, 0, 390, 403, 396, 0, 0 + ], + [ + 29, 0, 537, 0, 17, 17, 0, 547, 527, 17, 527, 527, 527, 527, 0, 527, + 17, 17, 527, 527, 527, 279, 527, 527, 527 + ], + [ + 527, 527, 527, 32, 492, 29, 0, 527, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 378, 17, 17, 17 + ], + [ + 17, 17, 527, 527, 527, 0, 527, 0, 32, 544, 0, 0, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 0, 17, 17, 17 + ], + [ + 32, 556, 32, 29, 32, 537, 492, 27, 527, 527, 527, 0, 0, 0, 17, 28, + 0, 536, 0, 27, 0, 556, 17, 376, 556 + ], + [ + 527, 527, 527, 527, 527, 527, 527, 381, 17, 17, 17, 381, 527, 527, + 17, 527, 492, 527, 527, 527, 527, 0, 17, 32, 527 + ], + [ + 17, 17, 17, 17, 0, 0, 17, 28, 0, 536, 32, 0, 0, 0, 17, 17, 550, 17, + 17, 17, 17, 17, 17, 556, 17 + ], + [ + 0, 381, 0, 537, 527, 527, 17, 527, 527, 527, 527, 527, 537, 527, 0, + 0, 0, 381, 32, 0, 17, 17, 28, 0, 0 + ], + [ + 527, 527, 527, 32, 0, 27, 0, 544, 0, 0, 0, 17, 492, 17, 28, 527, + 527, 527, 527, 527, 17, 32, 0, 527, 527 + ], + [ + 17, 17, 527, 527, 527, 527, 527, 527, 0, 527, 527, 17, 27, 34, 550, + 17, 17, 17, 17, 17, 17, 527, 527, 527, 17 + ], + [ + 0, 17, 17, 17, 17, 17, 17, 0, 0, 28, 17, 17, 0, 527, 527, 0, 32, 0, + 546, 28, 17, 0, 546, 0, 381 + ], + [ + 381, 33, 17, 441, 33, 547, 0, 33, 527, 527, 17, 0, 550, 0, 32, 381, + 527, 527, 527, 0, 17, 0, 527, 527, 527 + ], + [ + 527, 527, 17, 527, 527, 527, 527, 279, 403, 390, 17, 527, 527, 527, + 527, 527, 527, 17, 17, 0, 17, 0, 17, 17, 17 + ], + [ + 17, 17, 17, 0, 0, 0, 17, 0, 527, 527, 17, 17, 17, 17, 17, 17, 17, + 32, 0, 27, 546, 0, 34, 376, 0 + ], + [ + 17, 17, 17, 527, 537, 0, 32, 0, 536, 0, 34, 378, 32, 0, 17, 0, 556, + 403, 527, 527, 527, 527, 527, 527, 0 + ], + [ + 381, 34, 28, 547, 0, 527, 527, 527, 527, 527, 381, 527, 527, 527, + 17, 527, 0, 527, 17, 0, 0, 544, 0, 32, 0 + ], + [ + 527, 527, 527, 527, 0, 0, 381, 0, 17, 0, 0, 0, 17, 0, 0, 32, 381, + 376, 32, 550, 527, 527, 527, 527, 527 + ], + [ + 17, 17, 17, 527, 527, 527, 527, 527, 17, 527, 527, 527, 17, 527, + 527, 527, 527, 527, 527, 0, 17, 17, 17, 17, 17 + ], + [ + 0, 536, 34, 17, 32, 537, 381, 537, 32, 29, 32, 556, 0, 17, 0, 27, + 32, 28, 0, 550, 0, 32, 378, 34, 0 + ], + [ + 527, 492, 527, 17, 527, 0, 527, 0, 527, 527, 527, 527, 527, 17, 527, + 527, 0, 527, 527, 527, 527, 527, 527, 527, 527 + ], + [ + 17, 34, 17, 17, 17, 0, 17, 0, 0, 556, 390, 441, 396, 556, 0, 0, 546, + 34, 376, 32, 549, 0, 17, 17, 17 + ], + [ + 0, 537, 0, 32, 28, 27, 492, 32, 527, 527, 527, 0, 527, 527, 527, + 492, 527, 527, 527, 527, 527, 0, 32, 0, 0 + ], + [ + 527, 527, 527, 527, 527, 527, 527, 537, 492, 0, 32, 556, 0, 0, 0, 0, + 0, 17, 17, 17, 527, 527, 527, 527, 527 + ], + [ + 0, 17, 17, 17, 17, 17, 17, 34, 527, 527, 527, 527, 28, 527, 527, + 527, 536, 376, 543, 378, 381, 547, 0, 32, 32 + ], + [ + 550, 31, 31, 17, 0, 27, 34, 381, 556, 492, 0, 0, 32, 17, 17, 527, + 527, 527, 527, 527, 492, 527, 527, 527, 527 + ], + [ + 527, 527, 527, 17, 527, 527, 527, 17, 527, 527, 527, 527, 0, 17, 17, + 17, 17, 17, 17, 17, 546, 17, 17, 17, 527 + ], + [ + 17, 17, 17, 17, 17, 17, 17, 494, 556, 33, 27, 0, 381, 0, 547, 0, + 492, 33, 28, 33, 0, 17, 17, 17, 17 + ], + [ + 0, 27, 34, 549, 34, 376, 381, 378, 527, 527, 527, 527, 0, 527, 527, + 527, 527, 527, 527, 527, 0, 29, 0, 0, 0 + ], + [ + 527, 527, 527, 527, 527, 527, 527, 527, 527, 17, 17, 17, 544, 0, 27, + 33, 381, 0, 547, 527, 527, 527, 527, 0, 527 + ], + [ + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 527, 527, 527, + 527, 527, 0, 28, 33, 381, 0, 544, 17 + ], + [ + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 29, 17, 17, 17, 17, + 527, 527, 527, 527, 527, 527, 492, 17 + ], + [ + 34, 537, 34, 381, 27, 381, 34, 550, 492, 0, 34, 29, 0, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 0, 17 + ], + [ + 381, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 546, 34, + 29, 27, 29, 34, 17, 17, 17, 17, 17, 0, 17 + ], + [ + 0, 527, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 492, 527, 527, 527, + 527, 536, 0, 34, 28, 27, 381, 34, 0 + ], + [ + 527, 527, 0, 381, 378, 33, 381, 0, 17, 17, 17, 17, 0, 17, 17, 17, + 527, 527, 527, 527, 527, 527, 527, 547, 527 + ], + [ + 0, 0, 550, 527, 527, 527, 527, 549, 0, 33, 0, 17, 0, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 0, 0 + ], + [ + 527, 527, 527, 527, 17, 17, 527, 527, 527, 527, 527, 17, 537, 0, + 381, 0, 536, 34, 376, 0, 537, 0, 34, 381, 34 + ], + [ + 527, 0, 537, 0, 0, 34, 492, 0, 27, 34, 0, 17, 0, 527, 527, 527, 0, + 527, 527, 527, 527, 527, 527, 527, 527 + ], + [ + 17, 527, 0, 527, 527, 527, 527, 550, 527, 527, 527, 17, 17, 17, 17, + 17, 0, 546, 34, 17, 17, 17, 17, 17, 17 + ], + [ + 0, 548, 34, 537, 381, 0, 34, 0, 27, 34, 549, 0, 543, 0, 33, 28, 0, + 527, 378, 381, 33, 544, 27, 494, 543 + ], + [ + 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, + 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528 + ] + ], + bgmap: [ + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50057, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50057, 50057 + ], + [ + 50057, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50057, 50057 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50057, 50057, 50057, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50057, + 50057, 50057, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50057, 50057, 50057, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50057, + 50057, 50057, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50057, + 50057, 50057, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50057, + 50057, 50057, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 306 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50041, 50041 + ], + [ + 50057, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50057, 50057, 50057, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50057, 50057 + ], + [ + 50057, 50041, 50041, 50041, 50041, 50041, 50041, 50041, 50041, + 50041, 50041, 50057, 50057, 50057, 50041, 50041, 50041, 50041, + 50041, 50041, 50041, 50041, 50041, 50057, 50057 + ], + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0 + ] + ], + fgmap: [], + bg2map: [ + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0 + ], + [ + 50146, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 50144, 50145 + ], + [ + 50154, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 50152, 50153 + ], + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 552, 0, 0, 0, 0, 0, 0, + 0, 0, 0 + ], + [ + 0, 0, 552, 0, 0, 0, 0, 0, 552, 0, 0, 0, 0, 0, 0, 552, 0, 0, 0, 0, 0, + 0, 0, 0, 0 + ], + [ + 0, 0, 552, 0, 0, 0, 0, 0, 552, 0, 0, 0, 0, 0, 0, 552, 0, 0, 0, 0, 0, + 0, 0, 0, 0 + ], + [ + 0, 0, 552, 0, 0, 0, 0, 0, 552, 0, 0, 0, 0, 0, 0, 552, 0, 0, 0, 0, 0, + 0, 0, 0, 0 + ], + [ + 0, 0, 0, 552, 0, 0, 0, 0, 552, 0, 0, 0, 0, 0, 0, 552, 0, 0, 0, 0, 0, + 0, 0, 0, 0 + ], + [ + 0, 0, 0, 552, 0, 0, 0, 0, 552, 0, 0, 0, 0, 0, 0, 552, 0, 0, 0, 0, 0, + 0, 0, 0, 0 + ], + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 552, 0, 0, 0, 0, 0, 0, + 0, 0, 0 + ], + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 552, 0, 0, 0, 0, 0, 0, + 0, 0, 0 + ], + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 552, 0, 0, 0, 0, 0, 0, + 0, 0, 0 + ], + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 552, 0, 0, 0, 0, 0, 0, + 0, 0, 0 + ], + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 552, 0, 0, 0, 0, 552, + 0, 0, 0, 0 + ], + [ + 0, 0, 0, 0, 0, 0, 50144, 50145, 50146, 0, 0, 0, 0, 0, 0, 552, 0, + 50144, 50145, 50146, 552, 0, 0, 0, 0 + ], + [ + 0, 0, 0, 0, 0, 0, 50152, 50153, 50154, 0, 0, 0, 0, 0, 0, 552, 0, + 50152, 50153, 50154, 552, 0, 0, 0, 0 + ], + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 552, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 552, 0, 0, 0 + ], + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 552, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 552, 0, 0, 0 + ], + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 552, + 0, 0, 0 + ], + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 552, 0, 0, 0, 0, 0, 0, + 552, 0, 0, 0 + ], + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 552, 0, 0, 0, 0, 0, 0, + 552, 0, 0, 0 + ], + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 552, + 0, 0, 0 + ], + [ + 0, 0, 0, 0, 0, 552, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 552, 0, 0, 0 + ], + [ + 0, 0, 0, 0, 0, 552, 0, 552, 0, 0, 0, 552, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 552, 0, 0, 0 + ], + [ + 0, 0, 0, 0, 0, 0, 0, 552, 0, 0, 0, 552, 0, 0, 0, 0, 552, 0, 0, 0, 0, + 552, 0, 552, 0 + ], + [ + 0, 0, 0, 0, 0, 0, 0, 552, 0, 0, 0, 552, 0, 0, 0, 0, 552, 0, 0, 0, 0, + 0, 0, 552, 0 + ], + [ + 0, 0, 0, 552, 0, 0, 0, 0, 0, 0, 0, 0, 552, 0, 0, 0, 552, 0, 0, 0, 0, + 0, 0, 552, 0 + ], + [ + 0, 0, 0, 552, 0, 0, 0, 0, 0, 0, 0, 0, 552, 0, 552, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0 + ], + [ + 0, 0, 0, 0, 0, 0, 0, 0, 552, 0, 0, 0, 552, 0, 552, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0 + ], + [ + 0, 0, 0, 0, 0, 0, 0, 0, 552, 0, 0, 0, 552, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0 + ], + [ + 0, 0, 0, 0, 0, 0, 0, 552, 0, 0, 0, 0, 552, 0, 0, 0, 0, 0, 0, 552, 0, + 552, 0, 0, 0 + ], + [ + 0, 0, 0, 0, 0, 0, 0, 552, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 552, 0, + 552, 0, 0, 0 + ], + [ + 0, 0, 0, 0, 0, 0, 0, 552, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 552, 0, + 552, 0, 0, 0 + ], + [ + 0, 0, 0, 0, 552, 0, 0, 552, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 552 + ], + [ + 0, 0, 0, 0, 552, 0, 0, 0, 0, 0, 552, 0, 0, 0, 0, 0, 552, 0, 0, 0, 0, + 0, 0, 0, 552 + ], + [ + 0, 0, 0, 0, 552, 0, 0, 0, 0, 0, 552, 0, 0, 0, 0, 0, 552, 0, 0, 552, + 0, 0, 0, 0, 0 + ], + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 552, 0, 0, + 0, 0, 0 + ], + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 552, 0, 0, + 0, 0, 0 + ], + [ + 0, 552, 0, 0, 0, 552, 0, 552, 0, 0, 0, 0, 0, 0, 0, 0, 552, 0, 0, 0, + 0, 0, 0, 0, 0 + ], + [ + 0, 552, 0, 0, 0, 552, 0, 552, 0, 0, 0, 0, 0, 0, 0, 0, 552, 0, 0, 0, + 0, 0, 0, 0, 0 + ], + [ + 0, 552, 0, 0, 0, 552, 0, 552, 0, 0, 0, 552, 0, 0, 0, 552, 0, 0, 0, + 0, 0, 0, 0, 0, 0 + ], + [ + 0, 0, 0, 0, 0, 0, 0, 552, 0, 0, 0, 552, 0, 0, 0, 552, 0, 50144, + 50145, 50146, 0, 0, 0, 0, 0 + ], + [ + 0, 0, 0, 0, 0, 0, 0, 552, 0, 0, 0, 0, 552, 0, 0, 0, 0, 50152, 50153, + 50154, 0, 0, 0, 0, 0 + ], + [ + 0, 0, 0, 0, 0, 0, 0, 552, 0, 0, 0, 0, 552, 0, 0, 0, 0, 0, 0, 0, 552, + 0, 0, 0, 0 + ], + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 552, 0, 0, 0, 0, 0, 0, 0, 552, + 0, 0, 0, 0 + ], + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 552, 0, 0, 0, 0, 0, 0, 0, 552, + 0, 0, 0, 0 + ], + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 552, 0, 0, 0, 0, 0, 0, 0, 552, + 0, 0, 552, 0 + ], + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 552, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 552, 0 + ], + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 552, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 552, 0 + ], + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 552, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 552, 0 + ], + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 552, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 552, 0 + ], + [ + 552, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 552, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 552, 0 + ], + [ + 552, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 552, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 552, 0 + ], + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 552, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 552, 0 + ], + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 552, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 552, 50041 + ], + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 552, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 552, 0 + ], + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 552, 0, 0, 0, 552, 0, 0, 0, 0, + 0, 0, 0, 0 + ], + [ + 50146, 0, 552, 0, 0, 0, 0, 552, 0, 0, 0, 50144, 50145, 50146, 0, 0, + 552, 0, 0, 0, 0, 0, 0, 50144, 50145 + ], + [ + 50154, 0, 552, 0, 0, 0, 0, 552, 0, 0, 0, 50152, 50153, 50154, 0, 0, + 552, 0, 0, 0, 0, 0, 0, 50152, 50153 + ], + [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0 + ] + ], + fg2map: [], + beforeBattle: {}, + cannotMoveDirectly: true, + cannotMoveIn: {} +}; diff --git a/public/project/plugins.js b/public/project/plugins.js index 5aa1d73..e47712b 100644 --- a/public/project/plugins.js +++ b/public/project/plugins.js @@ -9016,11 +9016,13 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { core.status.maps[data] = floor; delete core.status.mapBlockObjs[data]; core.extractBlocks(data); - core.drawMap(data); - core.setWeather( - core.animateFrame.weather.type, - core.animateFrame.weather.level - ); + if (data === core.status.floorId) { + core.drawMap(data); + core.setWeather( + core.animateFrame.weather.type, + core.animateFrame.weather.level + ); + } core.updateStatusBar(true, true); } console.log(`hot reload floor: ${data}`); @@ -9187,5 +9189,127 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { }, 1000); } })(); + }, + hide: function () { + if (main.mode === 'editor' || main.replayChecking) return; + /** + * 所有的会被视为房间的墙 + */ + const WALLS = [ + 'yellowWall', + 'yellowDoor', + 'blueDoor', + 'redDoor', + 'greenDoor' + ]; + /** + * 房间的最大大小 + */ + const MAX_AREA = 25; + /** + * 要隐藏的点 + */ + const HIDE_POS = [ + ['MT1', 2, 3], + ['MT2', 4, 5], + ['MT3', 7, 1] + ]; + + let showed = {}; + + /// 初始化游戏 + events.prototype.resetGame = function ( + hero, + hard, + floorId, + maps, + values + ) { + this.eventdata.resetGame(hero, hard, floorId, maps, values); + showed = core.getFlag('__showed__', {}); + flags.__showed__ = flags.__showed__ ?? {}; + hide(); + }; + + /** + * 显示一个区域 + * @param {string} floor + * @param {number} x + * @param {number} y + */ + this.showHidden = function (floor, x, y) { + const pos = bfs(floor, x, y); + for (const [x, y] of pos) { + core.setBgFgBlock('fg', 0, x, y, floor); + const id = `${floor}_${x}_${y}`; + showed[id] = true; + flags.__showed__[id] = true; + } + }; + + /** + * 隐藏 + */ + function hide() { + for (const pos of HIDE_POS) { + const id = pos.join('_'); + if (showed[id]) continue; + const p = bfs(...pos); + if (p.length >= MAX_AREA) continue; + for (const [x, y] of p) { + core.setBgFgBlock('fg', 4, x, y, pos[0]); + const id = `${pos[0]}_${x}_${y}`; + showed[id] = true; + flags.__showed__[id] = false; + } + } + } + + /** + * @returns {[number, number][]} + */ + function bfs(floorId, x, y) { + core.extractBlocks(floorId); + const blocks = core.getMapBlocksObj(floorId); + const mapped = { + [`${x},${y}`]: true + }; + const queue = [[x, y]]; + /** @type {[direction, number, number][]} */ + const dir = Object.entries(core.utils.scan).map(v => [ + v[0], + v[1].x, + v[1].y + ]); + const res = [[x, y]]; + + while (queue.length > 0) { + const [nx, ny] = queue.shift(); + dir.forEach(v => { + const [tx, ty] = [nx + v[1], ny + v[2]]; + const floor = core.status.maps[floorId]; + if ( + tx < 0 || + ty < 0 || + tx >= floor.width || + ty >= floor.height + ) + return; + const loc = `${tx},${ty}`; + if (mapped[loc]) return; + const block = blocks[loc]; + mapped[loc] = true; + if (!block) { + queue.push([tx, ty]); + res.push([tx, ty]); + return; + } + if (WALLS.includes(block.event.id)) return; + queue.push([tx, ty]); + res.push([tx, ty]); + }); + } + return res; + } } }; diff --git a/public/server.cjs b/public/server.cjs index 15d62b6..03e9091 100644 --- a/public/server.cjs +++ b/public/server.cjs @@ -263,7 +263,7 @@ async function extract(...dirs) { }); } else if (/\/\*.\w+$/.test(v)) { // 匹配文件夹中的后缀名 - const suffix = /.\w+$/.exec(v)[0]; + const suffix = /\.\w+$/.exec(v)[0]; const d = v.split(`/*${suffix}`)[0]; const dir = path.resolve(__dirname, d); fs.readdir(dir).then(files => { @@ -314,14 +314,12 @@ async function watch() { }); // 楼层,热重载 - const floors = await extract('project/floors/'); - floors.forEach(v => { - const dir = path.resolve(__dirname, v); - fss.watchFile(dir, option, () => { - const floorId = /\/\w+.js$/.exec(v)[0].slice(1, -3); - hotReloadData += `@@floor:${floorId}`; - console.log(`floor hot reload: ${floorId}`); - }); + fss.watch(path.resolve(__dirname, 'project/floors/'), (a, b) => { + if (!/^\w+\.js$/.test(b)) return; + const floorId = b.slice(0, -3); + if (hotReloadData.includes(`@@floor:${floorId}`)) return; + hotReloadData += `@@floor:${floorId}`; + console.log(`floor hot reload: ${floorId}`); }); // 脚本编辑 及 插件 热重载 diff --git a/src/App.vue b/src/App.vue index 95af9c0..09c8985 100644 --- a/src/App.vue +++ b/src/App.vue @@ -19,4 +19,11 @@ import { uiStack } from './plugin/uiController'; justify-content: center; overflow: hidden; } + +@media screen and(max-width:600px) { + #ui { + width: 100%; + height: 100%; + } +} diff --git a/src/components/bookOne.vue b/src/components/bookOne.vue deleted file mode 100644 index e69de29..0000000 diff --git a/src/components/boxAnimate.vue b/src/components/boxAnimate.vue index e69de29..d682ff8 100644 --- a/src/components/boxAnimate.vue +++ b/src/components/boxAnimate.vue @@ -0,0 +1,55 @@ + + + + + diff --git a/src/components/enemyOne.vue b/src/components/enemyOne.vue new file mode 100644 index 0000000..765ee0a --- /dev/null +++ b/src/components/enemyOne.vue @@ -0,0 +1,195 @@ + + + + + diff --git a/src/components/scroll.vue b/src/components/scroll.vue index eafcdd0..6dcd3f1 100644 --- a/src/components/scroll.vue +++ b/src/components/scroll.vue @@ -1,6 +1,6 @@ diff --git a/src/initPlugin.ts b/src/initPlugin.ts index b570cd1..95348eb 100644 --- a/src/initPlugin.ts +++ b/src/initPlugin.ts @@ -1,10 +1,13 @@ // 需要引入所有的插件 import pop from './plugin/pop'; import ui from './plugin/uiController'; +import use from './plugin/use'; +import animate from './plugin/animateController'; +import utils from './plugin/utils'; window.addEventListener('load', () => { // 每个引入的插件都要在这里执行,否则不会被转发 - const toForward: any[] = [pop(), ui()]; + const toForward: any[] = [pop(), ui(), use(), animate(), utils()]; // 初始化所有插件,并转发到core上 (async function () { diff --git a/src/main.ts b/src/main.ts index 3b6df23..7470915 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,5 +1,6 @@ import { createApp } from 'vue'; import App from './App.vue'; import './styles.less'; +import 'ant-design-vue/dist/antd.dark.css'; createApp(App).mount('#root'); diff --git a/src/plugin/animateController.ts b/src/plugin/animateController.ts new file mode 100644 index 0000000..3a13a16 --- /dev/null +++ b/src/plugin/animateController.ts @@ -0,0 +1,32 @@ +const animation: ((time: number) => void)[] = []; + +let animateTime = 0; + +export default function init() { + core.registerAnimationFrame('animate', true, time => { + if (time - animateTime <= core.values.animateSpeed) return; + for (const fn of animation) { + fn(time); + } + animateTime = core.animateFrame.animateTime; + }); + return { addAnimate, removeAnimate }; +} + +/** + * 添加一个动画 + * @param fn 要添加的函数 + */ +export function addAnimate(fn: (time: number) => void) { + animation.push(fn); +} + +/** + * 移除一个动画 + * @param fn 要移除的函数 + */ +export function removeAnimate(fn: (time: number) => void) { + const index = animation.findIndex(v => v === fn); + if (index === -1) + throw new ReferenceError('No such function in animation.'); +} diff --git a/src/plugin/use.ts b/src/plugin/use.ts index c071fc1..9f4946b 100644 --- a/src/plugin/use.ts +++ b/src/plugin/use.ts @@ -1,5 +1,5 @@ export default function init() { - return { useDrag, useWheel }; + return { useDrag, useWheel, isMobile }; } /** @@ -55,3 +55,8 @@ export function useWheel( fn(e.deltaX, e.deltaY, e.deltaZ, e); }); } + +/** + * 是否是移动设备 + */ +export const isMobile = matchMedia('(max-width: 600px)').matches; diff --git a/src/plugin/utils.ts b/src/plugin/utils.ts new file mode 100644 index 0000000..d278e13 --- /dev/null +++ b/src/plugin/utils.ts @@ -0,0 +1,27 @@ +import { isNil } from 'lodash'; + +export default function init() { + return { has, getDamageColor }; +} + +/** + * 判定一个值是否不是undefined或null + * @param value 要判断的值 + */ +export function has(value: T): value is NonNullable { + return !isNil(value); +} + +/** + * 根据伤害大小获取颜色 + * @param damage 伤害大小 + */ +export function getDamageColor(damage: number): string { + if (typeof damage !== 'number') return '#f00'; + if (damage === 0) return '#2f2'; + if (damage < 0) return '#7f7'; + if (damage < core.status.hero.hp / 3) return '#fff'; + if (damage < (core.status.hero.hp * 2) / 3) return '#ff4'; + if (damage < core.status.hero.hp) return '#f22'; + return '#f00'; +} diff --git a/src/types/core.d.ts b/src/types/core.d.ts index 0339b17..440033c 100644 --- a/src/types/core.d.ts +++ b/src/types/core.d.ts @@ -161,6 +161,10 @@ type Core = { readonly icons: { [x: string]: HTMLImageElement }; }; + readonly values: { + animateSpeed: number; + }; + readonly materials: string[]; readonly control: control; @@ -317,3 +321,7 @@ declare const main: main; declare const core: Core; declare const flags: { [x: string]: any }; declare const hero: HeroStatus; + +interface Window { + readonly core: Core; +} diff --git a/src/types/enemy.d.ts b/src/types/enemy.d.ts index c58016c..36b46dd 100644 --- a/src/types/enemy.d.ts +++ b/src/types/enemy.d.ts @@ -131,7 +131,7 @@ declare class enemys { * @param floorId 地图id,可选 * @returns 敌人集合,按伤害升序排列,支持多朝向怪合并 */ - getCurrentEnemys(floorId?: string): Enemy[]; + getCurrentEnemys(floorId?: string): (Enemy & DetailedEnemy)[]; /** * 检查某些楼层是否还有漏打的(某种)敌人 diff --git a/src/types/icon.d.ts b/src/types/icon.d.ts index 7176a09..22376c7 100644 --- a/src/types/icon.d.ts +++ b/src/types/icon.d.ts @@ -4,11 +4,17 @@ declare class icons { getIcons(): void; /** 根据ID获得其类型 */ - getClsFromId(id?: string): string; + getClsFromId(id?: string): BlockCls; /** 获得所有图标的ID */ getAllIconIds(): void; /** 根据图块数字或ID获得所在的tileset和坐标信息 */ getTilesetOffset(id?: string): void; + + /** + * 获取图块的帧数 + * @param cls 图块类型 + */ + getAnimateFrames(cls: BlockCls): 1 | 2 | 4; } diff --git a/src/types/plugin.d.ts b/src/types/plugin.d.ts index 760f4fb..73a683e 100644 --- a/src/types/plugin.d.ts +++ b/src/types/plugin.d.ts @@ -4,7 +4,7 @@ type Ref = { value: T; }; -interface PluginDeclaration { +interface PluginDeclaration extends PluginUtils { /** * 添加函数 例:添加弹出文字,像这个就可以使用core.addPop或core.plugin.addPop调用 * @param px 弹出的横坐标 @@ -25,6 +25,9 @@ interface PluginDeclaration { /** ui栈 */ readonly uiStack: Ref; + /** 是否是移动设备 */ + readonly isMobile: boolean; + /** * 向一个元素添加拖拽事件 * @param ele 目标元素 @@ -48,6 +51,32 @@ interface PluginDeclaration { ele: HTMLElement, fn: (x: number, y: number, z: number, e: WheelEvent) => void ): void; + + /** + * 添加一个动画 + * @param fn 要添加的函数 + */ + addAnimate(fn: (time: number) => void); + + /** + * 移除一个动画 + * @param fn 要移除的函数 + */ + removeAnimate(fn: (time: number) => void); +} + +interface PluginUtils { + /** + * 判定一个值是否不是undefined或null + * @param value 要判断的值 + */ + has(value: T): value is NonNullable; + + /** + * 根据伤害大小获取颜色 + * @param damage 伤害大小 + */ + getDamageColor(damage: number): string; } type Forward = { diff --git a/src/types/util.d.ts b/src/types/util.d.ts index 59f5422..d12eb72 100644 --- a/src/types/util.d.ts +++ b/src/types/util.d.ts @@ -100,7 +100,7 @@ declare class utils { * @param onMap 可选,true表示用于地图显伤,结果总字符数最多为5,否则最多为6 * @returns 格式化结果 */ - formatBigNumber(x: number, onMap?: boolean): string; + formatBigNumber(x: number, onMap?: boolean, onCritical?: boolean): string; /** 变速移动 */ applyEasing(mode?: string): (number) => number; @@ -402,6 +402,16 @@ type direction = 'up' | 'down' | 'left' | 'right'; type move = 'forward' | direction; type loc = { direction: direction; x: number; y: number }; type rgbarray = [number, number, number, number]; +type BlockCls = + | 'terrain' + | 'animate' + | 'enemy' + | 'item' + | 'enemy48' + | 'npcs' + | 'npc48' + | 'autotile' + | 'tilesets'; type Events = MotaAction[] | string; @@ -515,7 +525,7 @@ type Enemy = { id: string; name: string; displayIdInBook: string; - special: number | number[]; + special: number[]; hp: number; atk: number; def: number; @@ -525,6 +535,19 @@ type Enemy = { [key: string]: any; }; +type DetailedEnemy = { + name: string; + specialText: string[]; + specialColor: (string | rgbarray)[]; + damage: number; + critical: number; + criticalDamage: number; + defDamage: number; + toShowSpecial?: string[]; + toShowColor?: any[]; + damageColor?: string; +}; + type Item = { cls: string; [key: string]: any; diff --git a/src/ui/book.vue b/src/ui/book.vue index 51bc1f6..8e822c4 100644 --- a/src/ui/book.vue +++ b/src/ui/book.vue @@ -1,20 +1,87 @@ - diff --git a/vite.config.ts b/vite.config.ts index c5f68f0..24ed2c2 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -2,6 +2,7 @@ import { defineConfig } from 'vite'; import vue from '@vitejs/plugin-vue'; import legacy from '@vitejs/plugin-legacy'; import components from 'unplugin-vue-components/vite'; +import vuejsx from '@vitejs/plugin-vue-jsx' import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers'; import motaConfig from './mota.config'; @@ -11,6 +12,7 @@ const FSHOST = 'http://127.0.0.1:3000/'; export default defineConfig({ plugins: [ vue(), + vuejsx(), legacy({ targets: ['defaults', 'not IE 11'], polyfills: true,