editor_file.js的修改数据功能完成

通过了editor_file_test.html中的简单测试,有待更进一步的测试
This commit is contained in:
YouWei Zhao 2018-01-07 22:52:18 +08:00
parent 13aca79afb
commit 1854d96fce
3 changed files with 17 additions and 100 deletions

File diff suppressed because one or more lines are too long

View File

@ -392,10 +392,7 @@
if (value[0]!='change' && file!='icons' && file!='maps') throw('目前只支持change');
});
throw('尚未实现');
//throw('尚未实现');
if (file=='icons') {
actionList.forEach(function (value) {
if (value[0]!='add')return;
@ -406,10 +403,11 @@
fs.writeFile('project/icons.js',datastr,'utf-8',function(err, data){
callback(err);
});
return;
}
if (file=='maps') {
actionList.forEach(function (value) {
if (value[0]!='change')return;
if (value[0]!='add')return;
eval("maps_90f36752_8815_4be8_b32b_d7fad1d0542e"+value[1]+'='+JSON.stringify(value[2]));
});
var datastr='maps_90f36752_8815_4be8_b32b_d7fad1d0542e = \n';
@ -417,6 +415,7 @@
fs.writeFile('project/maps.js',datastr,'utf-8',function(err, data){
callback(err);
});
return;
}
if (file=='items') {
actionList.forEach(function (value) {
@ -428,6 +427,7 @@
fs.writeFile('project/items.js',datastr,'utf-8',function(err, data){
callback(err);
});
return;
}
if (file=='enemys') {
actionList.forEach(function (value) {
@ -439,7 +439,7 @@
fs.writeFile('project/enemys.js',datastr,'utf-8',function(err, data){
callback(err);
});
return;
}
if (file=='data') {
actionList.forEach(function (value) {
@ -451,6 +451,7 @@
fs.writeFile('project/data.js',datastr,'utf-8',function(err, data){
callback(err);
});
return;
}
if (file=='floors') {
actionList.forEach(function (value) {
@ -458,10 +459,11 @@
eval("editor.currentFloorData"+value[1]+'='+JSON.stringify(value[2]));
});
editor_file.saveFloorFile(editor,callback);
return;
}
callback('出错了,要设置的文件名不识别');
}
/*
$range((function(){typeof(thiseval)==typeof(0)||})())
if( 注释.indexof('$range(')!= -1){

View File

@ -17,20 +17,24 @@ pout.innerHTML='waiting\nwaiting waiting';
}); */
//查询
/*
editor_file.editItem(editor,'redJewel',[],function(a){console.log(a)});
editor_file.editEnemy(editor,'redBat',[],function(a){console.log(a)});
editor_file.editLoc(editor,2,0,[],function(a){console.log(a)});
editor_file.editFloor(editor,[],function(a){console.log(a)});
editor.file.editTower(editor,[],function(a){console.log(a)});
*/
//编辑
/*
editor.info={images: "terrains", y: 9};
editor.file.changeIdAndIdnum(editor,'huangqiang',16,editor.info,function(a){console.log(a)});
editor_file.editItem(editor,'redJewel',[["change","['items']['name']","红宝石的新名字"]],function(a){console.log(a)});
editor.file.changeIdAndIdnum(editor,'yellowWall2',16,editor.info,function(a){console.log(a)});
editor_file.editItem(editor,'book',[["change","['items']['name']","怪物手册的新名字"]],function(a){console.log(a)});
editor_file.editEnemy(editor,'redBat',[['change',"['atk']",20]],function(a){console.log(a)});
editor_file.editLoc(editor,2,0,[["change","['afterBattle']",null]],function(a){console.log(a)});
editor_file.editFloor(editor,[["change","['title']",'样板 3 层']],function(a){console.log(a)});
editor_file.editLoc(editor,2,6,[["change","['afterBattle']",null]],function(a){console.log(a)});
editor_file.editFloor(editor,[["change","['title']",'样板 33 层']],function(a){console.log(a)});
editor.file.editTower(editor,[["change","['values']['lavaDamage']",200]],function(a){console.log(a)});
*/
pout.innerHTML='succeed\nsucceed succeed';