diff --git a/README.md b/README.md index bf22c60d..db47a83d 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ HTML5 canvas制作的魔塔样板,支持全平台游戏! ## 更新说明 -### 2017.12.31 V1.3 +### 2018.1.1 V1.3 * [x] 支持全键盘操作。 * [x] 支持将某个图片作为某层的背景素材。 diff --git a/docs/api.md b/docs/api.md index ebd28f99..c62c21c7 100644 --- a/docs/api.md +++ b/docs/api.md @@ -1,6 +1,6 @@ # 附录:API列表 -?> 上次更新时间:* {docsify-updated} * +?> 上次更新时间:* {docsify-updated} * 如不是最新版,请Ctrl+F5强制刷新缓存。 所有系统支持的API都列在了这里。所有可能被用到的API都在前面用\*标记。 diff --git a/docs/index.html b/docs/index.html index 4c8311fa..79028c98 100644 --- a/docs/index.html +++ b/docs/index.html @@ -6,6 +6,7 @@ + @@ -41,6 +42,9 @@ mergeNavbar: true, formatUpdated: '{YYYY}-{MM}-{DD} {HH}:{mm}:{ss}', } + if (typeof navigator.serviceWorker !== 'undefined') { + navigator.serviceWorker.register('serviceWorker.js') + } diff --git a/docs/serviceWorker.js b/docs/serviceWorker.js new file mode 100644 index 00000000..34634e1e --- /dev/null +++ b/docs/serviceWorker.js @@ -0,0 +1,75 @@ +const RUNTIME = 'docsify' +const HOSTNAME_WHITELIST = [ + self.location.hostname, + 'fonts.gstatic.com', + 'fonts.googleapis.com', + 'cdn.bootcss.com' +] + +// The Util Function to hack URLs of intercepted requests +const getFixedUrl = (req) => { + var now = Date.now() + var url = new URL(req.url) + + // 1. fixed http URL + // Just keep syncing with location.protocol + // fetch(httpURL) belongs to active mixed content. + // And fetch(httpRequest) is not supported yet. + url.protocol = self.location.protocol + + // 2. add query for caching-busting. + // Github Pages served with Cache-Control: max-age=600 + // max-age on mutable content is error-prone, with SW life of bugs can even extend. + // Until cache mode of Fetch API landed, we have to workaround cache-busting with query string. + // Cache-Control-Bug: https://bugs.chromium.org/p/chromium/issues/detail?id=453190 + if (url.hostname === self.location.hostname) { + url.search += (url.search ? '&' : '?') + 'cache-bust=' + now + } + return url.href +} + +/** + * @Lifecycle Activate + * New one activated when old isnt being used. + * + * waitUntil(): activating ====> activated + */ +self.addEventListener('activate', event => { + event.waitUntil(self.clients.claim()) +}) + +/** + * @Functional Fetch + * All network requests are being intercepted here. + * + * void respondWith(Promise r) + */ +self.addEventListener('fetch', event => { + // Skip some of cross-origin requests, like those for Google Analytics. + if (HOSTNAME_WHITELIST.indexOf(new URL(event.request.url).hostname) > -1) { + // Stale-while-revalidate + // similar to HTTP's stale-while-revalidate: https://www.mnot.net/blog/2007/12/12/stale + // Upgrade from Jake's to Surma's: https://gist.github.com/surma/eb441223daaedf880801ad80006389f1 + const cached = caches.match(event.request) + const fixedUrl = getFixedUrl(event.request) + const fetched = fetch(fixedUrl, { cache: 'no-store' }) + const fetchedCopy = fetched.then(resp => resp.clone()) + + // Call respondWith() with whatever we get first. + // If the fetch fails (e.g disconnected), wait for the cache. + // If there’s nothing in cache, wait for the fetch. + // If neither yields a response, return offline pages. + event.respondWith( + Promise.race([fetched.catch(_ => cached), cached]) +.then(resp => resp || fetched) +.catch(_ => { /* eat any errors */ }) +) + + // Update the cache with the version we fetched (only for ok status) + event.waitUntil( + Promise.all([fetchedCopy, caches.open(RUNTIME)]) + .then(([response, cache]) => response.ok && cache.put(event.request, response)) + .catch(_ => { /* eat any errors */ }) +) +} +}) \ No newline at end of file diff --git a/drawMapGUI.html b/drawMapGUI.html index 0ea0b61f..bddabf11 100644 --- a/drawMapGUI.html +++ b/drawMapGUI.html @@ -206,7 +206,7 @@ editor.prototype.loadAllImgs = function(icons){ return Promise.all(p); } editor.prototype.idsInit = function(maps, icons){ - editor.ids = []; + editor.ids = [0]; editor.indexs = []; var MAX_NUM = 400; var getInfoById = function(id){ diff --git a/libs/core.js b/libs/core.js index 1e8dd4db..26977f69 100644 --- a/libs/core.js +++ b/libs/core.js @@ -202,6 +202,8 @@ core.prototype.showStartAnimate = function (callback) { core.dom.startButtonGroup.style.display = 'none'; core.dom.startButtons.style.display = 'block'; core.dom.levelChooseButtons.style.display = 'none'; + core.dom.curtain.style.background = "#000000"; + core.dom.curtain.style.opacity = 0; core.status.played = false; core.clearStatus(); core.clearMap('all'); diff --git a/libs/data.js b/libs/data.js index 870ffb38..e82b3603 100644 --- a/libs/data.js +++ b/libs/data.js @@ -141,11 +141,11 @@ data.prototype.init = function() { this.flags = { /****** 状态栏相关 ******/ "enableFloor": true, // 是否在状态栏显示当前楼层 - "enableLv": false, // 是否在状态栏显示当前等级 + "enableLv": true, // 是否在状态栏显示当前等级 "enableMDef": true, // 是否在状态栏及战斗界面显示魔防(护盾) "enableMoney": true, // 是否在状态栏、怪物手册及战斗界面显示金币 "enableExperience": true, // 是否在状态栏、怪物手册及战斗界面显示经验 - "enableLevelUp": false, // 是否允许等级提升(进阶);如果上面enableExperience为false,则此项恒视为false + "enableLevelUp": true, // 是否允许等级提升(进阶);如果上面enableExperience为false,则此项恒视为false "enableDebuff": true, // 是否涉及毒衰咒;如果此项为false则不会在状态栏中显示毒衰咒的debuff ////// 上述的几个开关将直接影响状态栏的显示效果 ////// /****** 道具相关 ******/ diff --git a/libs/enemys.js b/libs/enemys.js index 1738102d..8b492099 100644 --- a/libs/enemys.js +++ b/libs/enemys.js @@ -22,7 +22,7 @@ enemys.prototype.init = function () { 'zombieKnight': {'name': '兽人武士', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0, 'experience': 0, 'special': 0}, 'rock': {'name': '石头人', 'hp': 100, 'atk': 120, 'def': 0, 'money': 4, 'experience': 0, 'special': 3}, 'slimeMan': {'name': '影子战士', 'hp': 100, 'atk': 0, 'def': 0, 'money': 11, 'experience': 0, 'special': 10}, // 模仿怪的攻防设为0就好 - 'bluePriest': {'name': '初级法师', 'hp': 100, 'atk': 120, 'def': 0, 'money': 3, 'experience': 0, 'special': 2}, + 'bluePriest': {'name': '初级法师', 'hp': 100, 'atk': 120, 'def': 0, 'money': 3, 'experience': 0, 'special': 2, 'point': 1}, // 'point'可以在打败怪物后进行加点,详见文档说明。 'redPriest': {'name': '高级法师', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0, 'experience': 0, 'special': 0}, 'brownWizard': {'name': '初级巫师', 'hp': 100, 'atk': 120, 'def': 0, 'money': 16, 'experience': 0, 'special': 15, 'value': 100, 'zoneSquare': true}, // 领域怪需要加value表示领域伤害的数值;zoneSquare代表是否九宫格伤害 'redWizard': {'name': '高级巫师', 'hp': 1000, 'atk': 1200, 'def': 0, 'money': 160, 'experience': 0, 'special': 15, 'value': 200, 'range': 2}, // range可选,代表领域伤害的范围;不加默认为1 diff --git a/libs/floors/sample0.js b/libs/floors/sample0.js index 45f5e3fb..bbc54cd8 100644 --- a/libs/floors/sample0.js +++ b/libs/floors/sample0.js @@ -21,7 +21,7 @@ main.floors.sample0 = { [224, 254, 212, 232, 204, 5, 0, 1, 31, 32, 34, 33, 36], [201, 205, 217, 215, 207, 5, 0, 1, 27, 28, 29, 30, 35], [5, 5, 125, 5, 5, 5, 0, 1, 21, 22, 23, 24, 25], - [0, 0, 0, 0, 0, 0, 45, 1, 1, 1, 121, 1, 1], + [0, 0, 237, 0, 0, 0, 45, 1, 1, 1, 121, 1, 1], [4, 4, 126, 4, 4, 4, 0, 0, 0, 0, 0, 85, 124], [87, 11, 12, 13, 14, 4, 4, 2, 2, 2, 122, 2, 2], [88, 89, 90, 91, 92, 93, 94, 2, 81, 82, 83, 84, 86], @@ -54,7 +54,7 @@ main.floors.sample0 = { {"type": "hide", "time": 500} ], "2,8": [ // 守着第一批怪物的老人 - "\t[老人,magician]这些都是各种各样的怪物,所有怪物的数据都在enemys.js中设置。\n\n每个怪物最多只能有一个特殊属性。", + "\t[老人,magician]这些都是各种各样的怪物,所有怪物的数据都在enemys.js中设置。", "\t[老人,magician]这批怪物分别为:普通、先攻、魔攻、坚固、2连击、3连击、4连击、破甲、反击、净化。", "\t[老人,magician]打败怪物后可触发 afterBattle 事件。\n\n有关事件的各种信息在下一层会有更为详细的说明。", {"type": "hide", "time": 500}