diff --git a/play/character.js b/extension/character/extension.js similarity index 100% rename from play/character.js rename to extension/character/extension.js diff --git a/play/coin.js b/extension/coin/extension.js similarity index 100% rename from play/coin.js rename to extension/coin/extension.js diff --git a/play/soldier.js b/extension/soldier/extension.js similarity index 100% rename from play/soldier.js rename to extension/soldier/extension.js diff --git a/play/weather.js b/extension/weather/extension.js similarity index 100% rename from play/weather.js rename to extension/weather/extension.js diff --git a/play/wuxing.js b/extension/wuxing/extension.js similarity index 100% rename from play/wuxing.js rename to extension/wuxing/extension.js diff --git a/game/game.js b/game/game.js index 873e49d6c..66dc847c9 100755 --- a/game/game.js +++ b/game/game.js @@ -1238,261 +1238,6 @@ } } }, - extension:{ - name:'扩展', - config:{ - character:{ - name:'技能卡牌', - init:false, - restart:true, - onclick:function(bool){ - if(bool){ - lib.config.plays.add('character'); - } - else{ - lib.config.plays.remove('character'); - } - game.saveConfig('plays',lib.config.plays); - } - }, - character_num_playpackconfig:{ - name:'卡牌比例', - init:'0.05', - item:{ - '0.02':'2%', - '0.05':'5%', - '0.1':'10%', - '0.2':'20%', - } - }, - character_hide_playpackconfig:{ - name:'隐藏此扩展', - clear:true, - onclick:function(){ - lib.config.hiddenPlayPack.add('character'); - game.saveConfig('hiddenPlayPack',lib.config.hiddenPlayPack); - } - }, - soldier:{ - name:'士兵模式', - init:false, - restart:true, - onclick:function(bool){ - if(bool){ - lib.config.plays.add('soldier'); - } - else{ - lib.config.plays.remove('soldier'); - } - game.saveConfig('plays',lib.config.plays); - } - }, - soldier_hide_playpackconfig:{ - name:'隐藏此扩展', - clear:true, - onclick:function(){ - lib.config.hiddenPlayPack.add('soldier'); - game.saveConfig('hiddenPlayPack',lib.config.hiddenPlayPack); - } - }, - wuxing:{ - name:'五行生克', - init:false, - restart:true, - onclick:function(bool){ - if(bool){ - lib.config.plays.add('wuxing'); - } - else{ - lib.config.plays.remove('wuxing'); - } - game.saveConfig('plays',lib.config.plays); - } - }, - wuxing_num_playpackconfig:{ - name:'带属性卡牌', - init:'0.3', - item:{ - '0.1':'10%', - '0.2':'20%', - '0.3':'30%', - '0.5':'50%', - } - }, - wuxing_hide_playpackconfig:{ - name:'隐藏此扩展', - clear:true, - onclick:function(){ - lib.config.hiddenPlayPack.add('wuxing'); - game.saveConfig('hiddenPlayPack',lib.config.hiddenPlayPack); - } - }, - weather:{ - name:'天气变化', - init:false, - restart:true, - onclick:function(bool){ - if(bool){ - lib.config.plays.add('weather'); - } - else{ - lib.config.plays.remove('weather'); - } - game.saveConfig('plays',lib.config.plays); - } - }, - // weather_animation_playpackconfig:{ - // name:'天气动画', - // init:true - // }, - weather_noqing_playpackconfig:{ - name:'异常天气出现概率', - init:'0.5', - item:{ - '0.1':'10%', - '0.3':'30%', - '0.5':'50%', - '0.7':'70%', - '0.9':'90%', - } - }, - weather_chance_playpackconfig:{ - name:'天气效果触发概率', - init:'0.5', - item:{ - '0.1':'10%', - '0.2':'20%', - '0.3':'30%', - '0.5':'50%', - '0.8':'80%', - }, - onclick:function(item){ - game.saveConfig('weather_chance_playpackconfig',item); - _status.weatherchance=parseFloat(lib.config.weather_chance_playpackconfig)||0; - } - }, - weather_duration_playpackconfig:{ - name:'异常天气持续时间', - init:'[4,4]', - item:{ - '[2,4]':'1~3回合', - '[4,4]':'3~6回合', - '[4,7]':'3~9回合', - '[7,4]':'6~9回合', - '[7,7]':'6~12回合', - } - }, - weather_qingduration_playpackconfig:{ - name:'晴朗天气持续时间', - init:'[2,4]', - item:{ - '[2,4]':'1~3回合', - '[4,4]':'3~6回合', - '[4,7]':'3~9回合', - '[7,4]':'6~9回合', - '[7,7]':'6~12回合', - } - }, - weather_hide_playpackconfig:{ - name:'隐藏此扩展', - clear:true, - onclick:function(){ - lib.config.hiddenPlayPack.add('weather'); - game.saveConfig('hiddenPlayPack',lib.config.hiddenPlayPack); - } - }, - coin:{ - name:'富甲天下', - init:false, - restart:true, - onclick:function(bool){ - if(bool){ - lib.config.plays.add('coin'); - } - else{ - lib.config.plays.remove('coin'); - } - game.saveConfig('plays',lib.config.plays); - } - }, - coin_display_playpackconfig:{ - name:'金币显示', - init:'text', - item:{ - symbol:'符号', - text:'文字' - }, - onclick:function(item){ - game.saveConfig('coin_display_playpackconfig',item); - if(game.changeCoin) game.changeCoin(0); - } - }, - coin_canvas_playpackconfig:{ - name:'特效置顶', - init:false, - onclick:function(bool){ - game.saveConfig('coin_canvas_playpackconfig',bool); - if(bool){ - ui.window.classList.add('canvas_top'); - } - else{ - ui.window.classList.remove('canvas_top'); - } - } - }, - coin_hide_playpackconfig:{ - name:'隐藏此扩展', - clear:true, - onclick:function(){ - lib.config.hiddenPlayPack.add('coin'); - game.saveConfig('hiddenPlayPack',lib.config.hiddenPlayPack); - } - }, - update:function(config,map){ - for(var i in map){ - if(i.indexOf('extension_')==0) continue; - if(i.indexOf('_playpackconfig')!=-1){ - var packname=i.slice(0,i.indexOf('_')); - map[i].classList.add('indent'); - if(!lib.config.hiddenPlayPack.contains(packname)&& - lib.config.plays.contains(packname)){ - map[i].show(); - } - else{ - map[i].hide(); - } - } - else{ - if(lib.config.hiddenPlayPack.contains(i)){ - map[i].hide(); - } - else{ - if(lib.config.plays.contains(i)){ - map[i].classList.add('on'); - } - else{ - map[i].classList.remove('on'); - } - } - } - } - for(var i=0;i>',page,function(){ - if(importextensionexpanded){ - this.classList.remove('on'); - importExtension.style.display='none'; - } - else{ - this.classList.add('on'); - importExtension.style.display=''; - } - importextensionexpanded=!importextensionexpanded; - }); - importExtension=ui.create.div('.new_character.export.import',page); - importExtension.style.marginLeft='5px'; - importExtension.style.marginTop='5px'; - importExtension.style.display='none'; - ui.create.div('','',importExtension); - importExtension.firstChild.lastChild.onclick=function(){ - var fileToLoad=this.previousSibling.files[0]; - if(fileToLoad){ - var zipReady=function(){ - var fileReader = new FileReader(); - fileReader.onload = function(fileLoadedEvent) - { - var finishLoad=function(){ - extensionnode.innerHTML='导入成功,3秒后将重启'; - setTimeout(function(){ - extensionnode.innerHTML='导入成功,2秒后将重启'; - setTimeout(function(){ - extensionnode.innerHTML='导入成功,1秒后将重启'; - setTimeout(game.reload,1000); - },1000); - },1000); - }; - var data = fileLoadedEvent.target.result; - var zip=new JSZip(); - zip.load(data); - var str=zip.file('extension.js').asText(); - try{ - _status.importingExtension=true; - eval(str); - _status.importingExtension=false; - if(!game.importedPack) throw('err'); - var extname=game.importedPack.name; - lib.config.extensions.add(extname); - game.saveConfig('extensions',lib.config.extensions); - game.saveConfig('extension_'+extname,true); - for(var i in game.importedPack.config){ - if(game.importedPack.config[i]&&game.importedPack.config[i].hasOwnProperty('init')){ - game.saveConfig('extension_'+extname+'_'+i,game.importedPack.config[i].init); - } - } - - if(game.download){ - localStorage.removeItem(lib.configprefix+'extension_'+extname); - var filelist=[]; - for(var i in zip.files){ - if(i[0]!='.'&&i[0]!='_'){ - filelist.push(i); - } - } - if(lib.node&&lib.node.fs){ - var access=function(){ - var dirname=__dirname+'/extension/'+extname; - var finish=function(){ - dirname+='/'; - var writeFile=function(){ - if(filelist.length){ - var filename=filelist.shift(); - lib.node.fs.writeFile(dirname+filename,zip.files[filename].asNodeBuffer(),null,writeFile); - } - else{ - finishLoad(); - } - } - writeFile(); - }; - lib.node.fs.access(dirname,function(e){ - if(e){ - try{ - lib.node.fs.mkdir(dirname,finish); - } - catch(e){ - throw('err'); - } - } - else{ - finish(); - } - }); - }; - lib.node.fs.access(__dirname+'/extension',function(e){ - if(e){ - try{ - lib.node.fs.mkdir(__dirname+'/extension',access); - } - catch(e){ - throw('err'); - } - } - else{ - access(); - } - }); - } - else{ - window.resolveLocalFileSystemURL(lib.assetURL,function(entry){ - entry.getDirectory('extension',{create:true},function(dirEntry){ - var writeFile=function(){ - if(filelist.length){ - var filename=filelist.shift(); - dirEntry.getFile(filename,{create:true},function(fileEntry){ - fileEntry.createWriter(function(fileWriter){ - fileWriter.onwriteend=writeFile; - fileWriter.write(zip.files[filename].asNodeBuffer()); - }); - }); - } - else{ - finishLoad(); - } - }; - writeFile(); - }); - }); - } - } - else{ - localStorage.setItem(lib.configprefix+'extension_'+extname,str); - var imglist=[]; - for(var i in zip.files){ - if(i[0]!='.'&&i[0]!='_'){ - if(i.indexOf('.jpg')!=-1||i.indexOf('.png')!=-1){ - imglist.push(i); - } - } - } - if(imglist.length&&lib.db){ - lib.config.extensionInfo[extname]={ - image:imglist - } - game.saveConfig('extensionInfo',lib.config.extensionInfo); - for(var i=0;i>',page,function(){ @@ -19240,6 +19025,62 @@ for(var i in lib.configMenu){ createModeConfig(i,start.firstChild); } + for(var i in lib.help){ + var page=ui.create.div(''); + var node=ui.create.div('.menubutton.large',i,start.firstChild,clickMode); + node.type='help'; + node.link=page; + node.style.display='none'; + page.classList.add('menu-help'); + page.innerHTML=lib.help[i]; + } + + if(!connectMenu){ + var node=ui.create.div('.menubutton.large','帮助',start.firstChild,function(){ + var activex=start.firstChild.querySelector('.active'); + if(this.innerHTML=='帮助'){ + this.innerHTML='返回'; + for(var i=0;i>',page,function(){ + if(importextensionexpanded){ + this.classList.remove('on'); + importExtension.style.display='none'; + } + else{ + this.classList.add('on'); + importExtension.style.display=''; + } + importextensionexpanded=!importextensionexpanded; + }); + importExtension=ui.create.div('.new_character.export.import',page); + importExtension.style.marginLeft='5px'; + importExtension.style.marginTop='5px'; + importExtension.style.display='none'; + ui.create.div('','',importExtension); + + importExtension.firstChild.lastChild.onclick=function(){ + var fileToLoad=this.previousSibling.files[0]; + if(fileToLoad){ + var zipReady=function(){ + var fileReader = new FileReader(); + fileReader.onload = function(fileLoadedEvent) + { + var finishLoad=function(){ + extensionnode.innerHTML='导入成功,3秒后将重启'; + setTimeout(function(){ + extensionnode.innerHTML='导入成功,2秒后将重启'; + setTimeout(function(){ + extensionnode.innerHTML='导入成功,1秒后将重启'; + setTimeout(game.reload,1000); + },1000); + },1000); + }; + var data = fileLoadedEvent.target.result; + var zip=new JSZip(); + zip.load(data); + var str=zip.file('extension.js').asText(); + try{ + _status.importingExtension=true; + eval(str); + _status.importingExtension=false; + if(!game.importedPack) throw('err'); + var extname=game.importedPack.name; + if(lib.config.all.plays.contains('extname')){ + throw('err'); + } + if(lib.config.extensions.contains(extname)){ + game.removeExtension(extname,true); + } + lib.config.extensions.add(extname); + game.saveConfig('extensions',lib.config.extensions); + game.saveConfig('extension_'+extname+'_enable',true); + for(var i in game.importedPack.config){ + if(game.importedPack.config[i]&&game.importedPack.config[i].hasOwnProperty('init')){ + game.saveConfig('extension_'+extname+'_'+i,game.importedPack.config[i].init); + } + } + if(game.download){ + var filelist=[]; + for(var i in zip.files){ + if(i[0]!='.'&&i[0]!='_'){ + filelist.push(i); + } + } + if(lib.node&&lib.node.fs){ + var access=function(){ + var dirname=__dirname+'/extension/'+extname; + var finish=function(){ + dirname+='/'; + var writeFile=function(){ + if(filelist.length){ + var filename=filelist.shift(); + lib.node.fs.writeFile(dirname+filename,zip.files[filename].asNodeBuffer(),null,writeFile); + } + else{ + finishLoad(); + } + } + writeFile(); + }; + lib.node.fs.access(dirname,function(e){ + if(e){ + try{ + lib.node.fs.mkdir(dirname,finish); + } + catch(e){ + throw('err'); + } + } + else{ + finish(); + } + }); + }; + lib.node.fs.access(__dirname+'/extension',function(e){ + if(e){ + try{ + lib.node.fs.mkdir(__dirname+'/extension',access); + } + catch(e){ + throw('err'); + } + } + else{ + access(); + } + }); + } + else{ + window.resolveLocalFileSystemURL(lib.assetURL,function(entry){ + entry.getDirectory('extension/'+extname,{create:true},function(dirEntry){ + var writeFile=function(){ + if(filelist.length){ + var filename=filelist.shift(); + dirEntry.getFile(filename,{create:true},function(fileEntry){ + fileEntry.createWriter(function(fileWriter){ + fileWriter.onwriteend=writeFile; + fileWriter.write(zip.files[filename].asArrayBuffer()); + }); + }); + } + else{ + finishLoad(); + } + }; + writeFile(); + }); + }); + } + } + else{ + localStorage.setItem(lib.configprefix+'extension_'+extname,str); + var imglist=[]; + for(var i in zip.files){ + if(i[0]!='.'&&i[0]!='_'){ + if(i.indexOf('.jpg')!=-1||i.indexOf('.png')!=-1){ + imglist.push(i); + } + } + } + if(imglist.length&&lib.db){ + lib.config.extensionInfo[extname]={ + image:imglist + } + game.saveConfig('extensionInfo',lib.config.extensionInfo); + for(var i=0;i

'; + li2.innerHTML='素材版本:'+(lib.config.asset_version||'无')+'

'; + li3.innerHTML='更新源

'; + li3.querySelector('button').onclick=function(){ + lib.updateURL=this.previousSibling.value; + localStorage.setItem('noname_update_url',lib.updateURL); + } + + var button1,button2; + var span1,includeskin; + + game.checkForUpdate=function(forcecheck){ + if(button1.disabled){ + return; + } + else if(!game.download){ + alert('此版本不支持游戏内更新,请手动更新'); + return; + } + else{ + button1.innerHTML='正在检查更新'; + button1.disabled=true; + + var goupdate=function(){ + if(game.download){ + var script=lib.init.js(lib.updateURL,'game/source',function(){ + script.remove(); + var updates=window.noname_source_list; + delete window.noname_source_list; + for(var i=0;i

'; - li2.innerHTML='素材版本:'+(lib.config.asset_version||'无')+'

'; - li3.innerHTML='更新源

'; - li3.querySelector('button').onclick=function(){ - lib.updateURL=this.previousSibling.value; - localStorage.setItem('noname_update_url',lib.updateURL); - } - - var button1,button2; - var span1,includeskin; - - game.checkForUpdate=function(forcecheck){ - if(button1.disabled){ - return; - } - else if(!game.download){ - alert('此版本不支持游戏内更新,请手动更新'); - return; - } - else{ - button1.innerHTML='正在检查更新'; - button1.disabled=true; - - var goupdate=function(){ - if(game.download){ - var script=lib.init.js(lib.updateURL,'game/source',function(){ - script.remove(); - var updates=window.noname_source_list; - delete window.noname_source_list; - for(var i=0;i