Commit c34b128b authored by nanahira's avatar nanahira

test

parent 1c7b883a
...@@ -73,6 +73,10 @@ public string GetScript(string id) ...@@ -73,6 +73,10 @@ public string GetScript(string id)
{ {
return MyPath.Combine(luapath, "c" + id + ".lua"); return MyPath.Combine(luapath, "c" + id + ".lua");
} }
public string GetModuleScript(string modulescript)
{
return MyPath.Combine(luapath, modulescript + ".lua");
}
public string[] GetCardfiles(long id) public string[] GetCardfiles(long id)
{ {
......
...@@ -258,10 +258,15 @@ public bool OpenScript(bool openinthis, string addrequire) ...@@ -258,10 +258,15 @@ public bool OpenScript(bool openinthis, string addrequire)
if (!dataform.CheckOpen()) if (!dataform.CheckOpen())
return false; return false;
Card c = dataform.GetCard(); Card c = dataform.GetCard();
if (c.id <= 0)//卡片密码不能小于等于0
return false;
long id = c.id; long id = c.id;
string lua = dataform.GetPath().GetScript(id); string lua;
if (c.id > 0) {
lua = dataform.GetPath().GetScript(id);
} else if (addrequire.Length > 0) {
lua = dataform.GetPath().GetModuleScript(addrequire);
} else {
return false;
}
if (!File.Exists(lua)) if (!File.Exists(lua))
{ {
MyPath.CreateDirByFile(lua); MyPath.CreateDirByFile(lua);
...@@ -271,14 +276,18 @@ public bool OpenScript(bool openinthis, string addrequire) ...@@ -271,14 +276,18 @@ public bool OpenScript(bool openinthis, string addrequire)
FileMode.OpenOrCreate,FileAccess.Write)) FileMode.OpenOrCreate,FileAccess.Write))
{ {
StreamWriter sw = new StreamWriter(fs, new UTF8Encoding(false)); StreamWriter sw = new StreamWriter(fs, new UTF8Encoding(false));
sw.WriteLine("--" + c.name); if (c.id > 0) { //card script
sw.WriteLine("local m=" + id.ToString()); sw.WriteLine("--" + c.name);
sw.WriteLine("local cm=_G[\"c\"..m]"); sw.WriteLine("local m=" + id.ToString());
if (addrequire.Length > 0) sw.WriteLine("local cm=_G[\"c\"..m]");
sw.WriteLine("xpcall(function() require(\"expansions/script/" + addrequire + "\") end,function() require(\"script/" + addrequire + "\") end)"); if (addrequire.Length > 0)
sw.WriteLine("function cm.initial_effect(c)"); sw.WriteLine("xpcall(function() require(\"expansions/script/" + addrequire + "\") end,function() require(\"script/" + addrequire + "\") end)");
sw.WriteLine("\t"); sw.WriteLine("function cm.initial_effect(c)");
sw.WriteLine("end"); sw.WriteLine("\t");
sw.WriteLine("end");
} else { //module script
sw.WriteLine("--Module script \"" + addrequire + "\"");
}
sw.Close(); sw.Close();
fs.Close(); fs.Close();
} }
......
...@@ -350,10 +350,9 @@ public void ExportData(string path, string zipname, string _cdbfile, string modu ...@@ -350,10 +350,9 @@ public void ExportData(string path, string zipname, string _cdbfile, string modu
//新卡ydk //新卡ydk
string deckydk = ygopath.GetYdk(name); string deckydk = ygopath.GetYdk(name);
//module scripts //module scripts
string script_path = MyPath.Combine(path, "script");
string extra_script = ""; string extra_script = "";
if (modulescript.Length > 0) if (modulescript.Length > 0)
extra_script = MyPath.Combine(script_path, modulescript + ".lua"); extra_script = ygopath.GetModuleScript(modulescript);
File.Delete(cdbfile); File.Delete(cdbfile);
DataBase.Create(cdbfile); DataBase.Create(cdbfile);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment