diff --git a/game/game.js b/game/game.js index c36c54b1d..747c248ae 100755 --- a/game/game.js +++ b/game/game.js @@ -9,6 +9,7 @@ } } else{ + alert(document.head.outerHTML) if(confirm('游戏似乎未正常载入,是否重置游戏?')){ localStorage.clear(); if(indexedDB) indexedDB.deleteDatabase('noname_0.9_data'); @@ -2989,7 +2990,15 @@ lib.init.js(lib.assetURL+'card',lib.config.all.cards); lib.init.js(lib.assetURL+'character',lib.config.all.characters); lib.init.js(lib.assetURL+'play',lib.config.plays); - lib.init.js(lib.assetURL+'character','rank'); + lib.init.js(lib.assetURL+'character','rank',function(){ + if(_status.windowLoaded){ + delete _status.windowLoaded; + lib.init.onload(); + } + else{ + _status.packLoaded=true; + } + }); ui.css={}; lib.init.css(lib.assetURL+'layout/default','menu'); var layout=lib.config.layout; @@ -3207,6 +3216,448 @@ } } }, + onload:function(){ + if(lib.device){ + var script=document.createElement('script'); + script.src='cordova.js'; + document.body.appendChild(script); + document.addEventListener('deviceready',function(){ + if(lib.init.cordovaReady){ + lib.init.cordovaReady(); + delete lib.init.cordovaReady; + } + }); + } + ui.background=ui.create.div('.background'); + ui.background.style.backgroundSize="cover"; + if(lib.config.image_background&&lib.config.image_background!='default'&&lib.config.image_background!='custom'){ + ui.background.setBackgroundImage('image/background/'+lib.config.image_background+'.jpg'); + switch (lib.config.image_background_filter){ + case 'blur': + ui.background.style.filter='blur(8px)'; + ui.background.style.webkitFilter='blur(8px)'; + ui.background.style.transform='scale(1.05)'; + break; + case 'gray': + ui.background.style.filter='grayscale(1)'; + ui.background.style.webkitFilter='grayscale(1)'; + break; + case 'sepia': + ui.background.style.filter='sepia(0.5)'; + ui.background.style.webkitFilter='sepia(0.5)'; + break; + case 'invert': + ui.background.style.filter='invert(1)'; + ui.background.style.webkitFilter='invert(1)'; + break; + case 'saturate': + ui.background.style.filter='saturate(5)'; + ui.background.style.webkitFilter='saturate(5)'; + break; + case 'contrast': + ui.background.style.filter='contrast(1.4)'; + ui.background.style.webkitFilter='contrast(1.4)'; + break; + case 'hue': + ui.background.style.filter='hue-rotate(180deg)'; + ui.background.style.webkitFilter='hue-rotate(180deg)'; + break; + case 'brightness': + ui.background.style.filter='brightness(5)'; + ui.background.style.webkitFilter='brightness(5)'; + break; + default: + ui.background.style.webkitFilter=''; + } + } + document.body.insertBefore(ui.background,document.body.firstChild); + + document.body.onresize=ui.updatex; + if(lib.config.touchscreen){ + document.body.addEventListener('touchstart',function(e){ + this.startX=e.touches[0].clientX; + this.startY=e.touches[0].clientY; + _status.dragged=false; + }); + document.body.addEventListener('touchmove',function(e){ + if(_status.dragged) return; + if (Math.abs(e.touches[0].clientX - this.startX) > 10 || + Math.abs(e.touches[0].clientY - this.startY) > 10) { + _status.dragged=true; + } + }); + } + + lib.onDB(function(){ + if(lib.config.image_background=='custom'){ + ui.background.style.backgroundImage="none"; + game.getDB('image','background',function(fileToLoad){ + if(!fileToLoad) return; + var fileReader = new FileReader(); + fileReader.onload = function(fileLoadedEvent) + { + var data = fileLoadedEvent.target.result; + ui.background.style.backgroundImage='url('+data+')'; + }; + fileReader.readAsDataURL(fileToLoad, "UTF-8"); + }); + } + }); + + var proceed=function(){ + var i,j,k; + for(i in mode[lib.config.mode].element){ + if(!lib.element[i]) lib.element[i]=[]; + for(j in mode[lib.config.mode].element[i]){ + if(j=='init'){ + if(!lib.element[i].inits) lib.element[i].inits=[]; + lib.element[i].inits.push(lib.init.eval(mode[lib.config.mode].element[i][j])); + } + else{ + lib.element[i][j]=lib.init.eval(mode[lib.config.mode].element[i][j]); + } + } + } + for(i in mode[lib.config.mode].ai){ + if(typeof mode[lib.config.mode].ai[i]=='object'){ + if(ai[i]==undefined) ai[i]={}; + for(j in mode[lib.config.mode].ai[i]){ + ai[i][j]=lib.init.eval(mode[lib.config.mode].ai[i][j]); + } + } + else{ + ai[i]=lib.init.eval(mode[lib.config.mode].ai[i]); + } + } + for(i in mode[lib.config.mode].ui){ + if(typeof mode[lib.config.mode].ui[i]=='object'){ + if(ui[i]==undefined) ui[i]={}; + for(j in mode[lib.config.mode].ui[i]){ + ui[i][j]=lib.init.eval(mode[lib.config.mode].ui[i][j]); + } + } + else{ + ui[i]=lib.init.eval(mode[lib.config.mode].ui[i]); + } + } + for(i in mode[lib.config.mode].game){ + game[i]=lib.init.eval(mode[lib.config.mode].game[i]); + } + for(i in mode[lib.config.mode].get){ + get[i]=lib.init.eval(mode[lib.config.mode].get[i]); + } + lib.init.start=mode[lib.config.mode].start; + if(game.onwash){ + lib.onwash.push(game.onwash); + delete game.onwash; + } + if(game.onover){ + lib.onover.push(game.onover); + delete game.onover; + } + lib.config.current_mode=mode[lib.config.mode].config||[]; + lib.config.banned=get.config('banned')||[]; + lib.config.bannedcards=get.config('bannedcards')||[]; + + lib.rank=window.characterRank; + delete window.characterRank; + for(i in mode[lib.config.mode]){ + if(i=='element') continue; + if(i=='game') continue; + if(i=='ai') continue; + if(i=='ui') continue; + if(i=='get') continue; + if(i=='config') continue; + if(i=='start') continue; + if(lib[i]==undefined) lib[i]=(get.objtype(mode[lib.config.mode][i])=='array')?[]:{}; + for(j in mode[lib.config.mode][i]){ + lib[i][j]=lib.init.eval(mode[lib.config.mode][i][j]); + } + } + for(i in character){ + if(character[i].character){ + lib.characterPack[i]=character[i].character + } + if(character[i].forbid&&character[i].forbid.contains(lib.config.mode)) continue; + if(character[i].mode&&character[i].mode.contains(lib.config.mode)==false) continue; + for(j in character[i]){ + if(j=='mode'||j=='forbid') continue; + if(j=='character'&&!lib.config.characters.contains(i)){ + if(lib.config.mode=='chess'&&get.config('chess_mode')=='leader'){ + for(k in character[i][j]){ + lib.hiddenCharacters.push(k); + } + } + else if(lib.config.mode!='boss'||i!='boss'){ + continue; + } + } + for(k in character[i][j]){ + if(j=='character'){ + if(!character[i][j][k][4]){ + character[i][j][k][4]=[]; + } + if(character[i][j][k][4].contains('boss')|| + character[i][j][k][4].contains('hiddenboss')){ + lib.config.forbidai.add(k); + } + if(lib.config.banned.contains(k)){ + if(lib.config.mode=='chess'&&get.config('chess_mode')=='leader'){ + lib.hiddenCharacters.push(k); + } + else{ + continue; + } + } + for(var l=0;lb?1:-1; }); + var list2=[]; var skills=lib.character[list[0][0]][3]; for(var i=0;i 10 || - Math.abs(e.touches[0].clientY - this.startY) > 10) { - _status.dragged=true; - } - }); - } - - lib.onDB(function(){ - if(lib.config.image_background=='custom'){ - ui.background.style.backgroundImage="none"; - game.getDB('image','background',function(fileToLoad){ - if(!fileToLoad) return; - var fileReader = new FileReader(); - fileReader.onload = function(fileLoadedEvent) - { - var data = fileLoadedEvent.target.result; - ui.background.style.backgroundImage='url('+data+')'; - }; - fileReader.readAsDataURL(fileToLoad, "UTF-8"); - }); - } - }); - - var proceed=function(){ - var i,j,k; - for(i in mode[lib.config.mode].element){ - if(!lib.element[i]) lib.element[i]=[]; - for(j in mode[lib.config.mode].element[i]){ - if(j=='init'){ - if(!lib.element[i].inits) lib.element[i].inits=[]; - lib.element[i].inits.push(lib.init.eval(mode[lib.config.mode].element[i][j])); - } - else{ - lib.element[i][j]=lib.init.eval(mode[lib.config.mode].element[i][j]); - } - } - } - for(i in mode[lib.config.mode].ai){ - if(typeof mode[lib.config.mode].ai[i]=='object'){ - if(ai[i]==undefined) ai[i]={}; - for(j in mode[lib.config.mode].ai[i]){ - ai[i][j]=lib.init.eval(mode[lib.config.mode].ai[i][j]); - } - } - else{ - ai[i]=lib.init.eval(mode[lib.config.mode].ai[i]); - } - } - for(i in mode[lib.config.mode].ui){ - if(typeof mode[lib.config.mode].ui[i]=='object'){ - if(ui[i]==undefined) ui[i]={}; - for(j in mode[lib.config.mode].ui[i]){ - ui[i][j]=lib.init.eval(mode[lib.config.mode].ui[i][j]); - } - } - else{ - ui[i]=lib.init.eval(mode[lib.config.mode].ui[i]); - } - } - for(i in mode[lib.config.mode].game){ - game[i]=lib.init.eval(mode[lib.config.mode].game[i]); - } - for(i in mode[lib.config.mode].get){ - get[i]=lib.init.eval(mode[lib.config.mode].get[i]); - } - lib.init.start=mode[lib.config.mode].start; - if(game.onwash){ - lib.onwash.push(game.onwash); - delete game.onwash; - } - if(game.onover){ - lib.onover.push(game.onover); - delete game.onover; - } - lib.config.current_mode=mode[lib.config.mode].config||[]; - lib.config.banned=get.config('banned')||[]; - lib.config.bannedcards=get.config('bannedcards')||[]; - - lib.rank=window.characterRank; - delete window.characterRank; - for(i in mode[lib.config.mode]){ - if(i=='element') continue; - if(i=='game') continue; - if(i=='ai') continue; - if(i=='ui') continue; - if(i=='get') continue; - if(i=='config') continue; - if(i=='start') continue; - if(lib[i]==undefined) lib[i]=(get.objtype(mode[lib.config.mode][i])=='array')?[]:{}; - for(j in mode[lib.config.mode][i]){ - lib[i][j]=lib.init.eval(mode[lib.config.mode][i][j]); - } - } - for(i in character){ - if(character[i].character){ - lib.characterPack[i]=character[i].character - } - if(character[i].forbid&&character[i].forbid.contains(lib.config.mode)) continue; - if(character[i].mode&&character[i].mode.contains(lib.config.mode)==false) continue; - for(j in character[i]){ - if(j=='mode'||j=='forbid') continue; - if(j=='character'&&!lib.config.characters.contains(i)){ - if(lib.config.mode=='chess'&&get.config('chess_mode')=='leader'){ - for(k in character[i][j]){ - lib.hiddenCharacters.push(k); - } - } - else if(lib.config.mode!='boss'||i!='boss'){ - continue; - } - } - for(k in character[i][j]){ - if(j=='character'){ - if(!character[i][j][k][4]){ - character[i][j][k][4]=[]; - } - if(character[i][j][k][4].contains('boss')|| - character[i][j][k][4].contains('hiddenboss')){ - lib.config.forbidai.add(k); - } - if(lib.config.banned.contains(k)){ - if(lib.config.mode=='chess'&&get.config('chess_mode')=='leader'){ - lib.hiddenCharacters.push(k); - } - else{ - continue; - } - } - for(var l=0;lcanvas.fun{