Commit 2dedd3a8 authored by 九江月's avatar 九江月

ocg filefetch pug

parent 6d65f5e9
No preview for this file type
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using System.Collections.Generic;
namespace cardvisa
{
public class FileHandle
{
#region API函数声明
#region 获得ini文件下的所有section
/// 获取所有节点名称(Section)
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
private static extern uint GetPrivateProfileSectionNames(IntPtr lpszReturnBuffer, uint nSize, string lpFileName);
#endregion
#region 获得ini文件下section下所有的key
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
private static extern uint GetPrivateProfileSection(string lpAppName, IntPtr lpReturnedString, uint nSize, string lpFileName);
#endregion
#region 获得ini文件下面sectionkey的值
//读取INI文件中指定的Key的值
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
private static extern uint GetPrivateProfileString(string lpAppName, string lpKeyName, string lpDefault, [In, Out] char[] lpReturnedString, uint nSize, string lpFileName);
//另一种声明方式,使用 StringBuilder 作为缓冲区类型的缺点是不能接受\0字符,会将\0及其后的字符截断,
//所以对于lpAppName或lpKeyName为null的情况就不适用
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
private static extern uint GetPrivateProfileString(string lpAppName, string lpKeyName, string lpDefault, StringBuilder lpReturnedString, uint nSize, string lpFileName);
//再一种声明,使用string作为缓冲区的类型同char[]
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
private static extern uint GetPrivateProfileString(string lpAppName, string lpKeyName, string lpDefault, string lpReturnedString, uint nSize, string lpFileName);
#endregion
#region 修改写入
/// 将指定的键值对写到指定的节点,如果已经存在则替换。
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
[return: MarshalAs(UnmanagedType.Bool)] //可以没有此行
private static extern bool WritePrivateProfileSection(string lpAppName, string lpString, string lpFileName);
/// 将指定的键和值写到指定的节点,如果已经存在则替换。
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool WritePrivateProfileString(string lpAppName, string lpKeyName, string lpString, string lpFileName);
#endregion
#endregion
#region 读取方法
/// 读取INI文件中指定INI文件中的所有节点名称(Section)
public static string[] INIGetAllSectionNames(string iniFile)
{
uint MAX_BUFFER = 32767; //默认为32767
string[] sections = new string[0]; //返回值
//申请内存
IntPtr pReturnedString = Marshal.AllocCoTaskMem((int)MAX_BUFFER * sizeof(char));
uint bytesReturned = GetPrivateProfileSectionNames(pReturnedString, MAX_BUFFER, iniFile);
if (bytesReturned != 0)
{
//读取指定内存的内容
string local = Marshal.PtrToStringAuto(pReturnedString, (int)bytesReturned).ToString();
//每个节点之间用\0分隔,末尾有一个\0
sections = local.Split(new char[] { '\0' }, StringSplitOptions.RemoveEmptyEntries);
}
//释放内存
Marshal.FreeCoTaskMem(pReturnedString);
return sections;
}
/// 获取INI文件中指定节点(Section)中所有的Key的名称
public static string[] INIGetAllItemKeys(string iniFile, string section)
{
string[] value = new string[0];
const int SIZE = 1024 * 10;
if (string.IsNullOrEmpty(section))
{
throw new ArgumentException("必须指定节点名称", "section");
}
char[] chars = new char[SIZE];
uint bytesReturned = GetPrivateProfileString(section, null, null, chars, SIZE, iniFile);
if (bytesReturned != 0)
{
value = new string(chars).Split(new char[] { '\0' }, StringSplitOptions.RemoveEmptyEntries);
}
chars = null;
return value;
}
/// 获取INI文件中指定节点(Section)中的所有条目(key=value形式)
public static string[] INIGetAllItems(string iniFile, string section)
{
//返回值形式为 key=value,例如 Color=Red
uint MAX_BUFFER = 32767; //默认为32767
string[] items = new string[0]; //返回值
//分配内存
IntPtr pReturnedString = Marshal.AllocCoTaskMem((int)MAX_BUFFER * sizeof(char));
uint bytesReturned = GetPrivateProfileSection(section, pReturnedString, MAX_BUFFER, iniFile);
if (!(bytesReturned == MAX_BUFFER - 2) || (bytesReturned == 0))
{
string returnedString = Marshal.PtrToStringAuto(pReturnedString, (int)bytesReturned);
items = returnedString.Split(new char[] { '\0' }, StringSplitOptions.RemoveEmptyEntries);
}
Marshal.FreeCoTaskMem(pReturnedString); //释放内存
return items;
}
/// 获取INI文件中指定节点(Section)中的所有条目(key=value形式)
public static string[] INIGetAllItemsWithoutKeys(string iniFile, string section)
{
string[] items = INIGetAllItems(iniFile,section);
for (int index = 0; index < items.Length; index++)
{
string[] xxx = items[index].Split('=');
if (xxx.Length > 1)
{
items[index] = xxx[1];
}
}
return items;
}
/// 读取INI文件中指定节点(Section)下指定KEY的值
public static string INIGetStringValue(string iniFile, string section, string key, string defaultValue)
{
string value = defaultValue;
const int SIZE = 1024 * 10;
if (string.IsNullOrEmpty(section))
{
throw new ArgumentException("必须指定节点名称", "section");
}
if (string.IsNullOrEmpty(key))
{
throw new ArgumentException("必须指定键名称(key)", "key");
}
StringBuilder sb = new StringBuilder(SIZE);
uint bytesReturned = GetPrivateProfileString(section, key, defaultValue, sb, SIZE, iniFile);
if (bytesReturned != 0)
{
value = sb.ToString();
}
sb = null;
return value;
}
#endregion
#region 修改方法
/// <summary>
/// 在INI文件中,将指定的键值对写到指定的节点,如果已经存在则替换
/// </summary>
/// <param name="iniFile">INI文件</param>
/// <param name="section">节点,如果不存在此节点,则创建此节点</param>
/// <param name="items">键值对,多个用\0分隔,形如key1=value1\0key2=value2</param>
/// <returns></returns>
public static bool INIWriteItems(string iniFile, string section, string items)
{
if (string.IsNullOrEmpty(section))
{
throw new ArgumentException("必须指定节点名称", "section");
}
if (string.IsNullOrEmpty(items))
{
throw new ArgumentException("必须指定键值对", "items");
}
return WritePrivateProfileSection(section, items, iniFile);
}
/// <summary>
/// 在INI文件中,指定节点写入指定的键及值。如果已经存在,则替换。如果没有则创建。
/// </summary>
/// <param name="iniFile">INI文件</param>
/// <param name="section">节点</param>
/// <param name="key">键</param>
/// <param name="value">值</param>
/// <returns>操作是否成功</returns>
public static bool INIWriteValue(string iniFile, string section, string key, string value)
{
if (string.IsNullOrEmpty(section))
{
throw new ArgumentException("必须指定节点名称", "section");
}
if (string.IsNullOrEmpty(key))
{
throw new ArgumentException("必须指定键名称", "key");
}
if (value == null)
{
throw new ArgumentException("值不能为null", "value");
}
return WritePrivateProfileString(section, key, value, iniFile);
}
#endregion
#region 删除方法
/// <summary>
/// 在INI文件中,删除指定节点中的指定的键。
/// </summary>
/// <param name="iniFile">INI文件</param>
/// <param name="section">节点</param>
/// <param name="key">键</param>
/// <returns>操作是否成功</returns>
public static bool INIDeleteKey(string iniFile, string section, string key)
{
if (string.IsNullOrEmpty(section))
{
throw new ArgumentException("必须指定节点名称", "section");
}
if (string.IsNullOrEmpty(key))
{
throw new ArgumentException("必须指定键名称", "key");
}
return WritePrivateProfileString(section, key, null, iniFile);
}
/// <summary>
/// 在INI文件中,删除指定的节点。
/// </summary>
/// <param name="iniFile">INI文件</param>
/// <param name="section">节点</param>
/// <returns>操作是否成功</returns>
public static bool INIDeleteSection(string iniFile, string section)
{
if (string.IsNullOrEmpty(section))
{
throw new ArgumentException("必须指定节点名称", "section");
}
return WritePrivateProfileString(section, null, null, iniFile);
}
/// <summary>
/// 在INI文件中,删除指定节点中的所有内容。
/// </summary>
/// <param name="iniFile">INI文件</param>
/// <param name="section">节点</param>
/// <returns>操作是否成功</returns>
public static bool INIEmptySection(string iniFile, string section)
{
if (string.IsNullOrEmpty(section))
{
throw new ArgumentException("必须指定节点名称", "section");
}
return WritePrivateProfileSection(section, string.Empty, iniFile);
}
#endregion
}
}
...@@ -158,7 +158,7 @@ namespace cardvisa ...@@ -158,7 +158,7 @@ namespace cardvisa
this.button8.Name = "button8"; this.button8.Name = "button8";
this.button8.Size = new System.Drawing.Size(75, 23); this.button8.Size = new System.Drawing.Size(75, 23);
this.button8.TabIndex = 11; this.button8.TabIndex = 11;
this.button8.Text = "拼图小游戏"; this.button8.Text = "更新器";
this.button8.UseVisualStyleBackColor = true; this.button8.UseVisualStyleBackColor = true;
this.button8.Click += new System.EventHandler(this.button8_Click); this.button8.Click += new System.EventHandler(this.button8_Click);
// //
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Configuration;
using System.Data; using System.Data;
using System.Data.Linq; using System.Data.Linq;
using System.Data.Linq.Mapping; using System.Data.Linq.Mapping;
...@@ -14,6 +15,7 @@ using System.Dynamic; ...@@ -14,6 +15,7 @@ using System.Dynamic;
using System.IO; using System.IO;
using System.IO.Compression; using System.IO.Compression;
using System.Linq; using System.Linq;
using System.Net.Http;
using System.Reflection; using System.Reflection;
using System.Reflection.Emit; using System.Reflection.Emit;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
...@@ -384,10 +386,46 @@ namespace cardvisa ...@@ -384,10 +386,46 @@ namespace cardvisa
// //
*/ */
} }
private void button8_Click(object sender, EventArgs e) private async void button8_Click(object sender, EventArgs e)
{ {
PuzzleGame pzg = GenericSingleton<PuzzleGame>.CreateInstrance(); //PuzzleGame pzg = GenericSingleton<PuzzleGame>.CreateInstrance();
pzg.Show(); //pzg.Show();
string ygoroot = Path.GetDirectoryName(settings.ygopath);
string remoteroot = settings.url; //"https://cdn02.moecube.com:444/koishipro/contents/";
string filelistpath = ygoroot + "\\update-hakune\\filelist.txt";
if (!File.Exists(filelistpath)) {
CommonHandler.FetchFile(remoteroot, ygoroot, "filelist.txt");
CommonHandler.FetchFile(remoteroot, ygoroot, "cards.cdb");
}
else
{
string[] filesets = File.ReadAllLines(filelistpath);
for (int i = 0;i< filesets.Length; i++) {
string[] xxx = filesets[i].Split('\t');
string md5 = CommonHandler.GetMD5(ygoroot + "\\" + xxx[0].Replace('/', '\\'));
if (md5 != xxx[1] && (xxx[0].IndexOf("pics") >= 0 || xxx[0].IndexOf("script") >= 0))
{
using (var client = new HttpClient())
{
var res = await client.GetAsync(remoteroot + xxx[0]);
if (res.IsSuccessStatusCode)
{
using (var fs = File.Create(ygoroot + "\\update-hakune\\" + xxx[0].Replace('/', '\\')))
{
await res.Content.CopyToAsync(fs);
}
Console.WriteLine("File downloaded successfully.");
richTextBox1.Text += "\r\n" + xxx[0];
}
else
{
Console.WriteLine("Failed to download file.");
}
}
}
}
richTextBox1.Text += "\r\nMission complete.";
}
} }
public void refreshlist() public void refreshlist()
{ {
...@@ -1483,6 +1521,9 @@ namespace cardvisa ...@@ -1483,6 +1521,9 @@ namespace cardvisa
{ {
try try
{ {
if (!File.Exists(path)) {
return "#null-file-not-found";
}
using (FileStream fStream = new FileStream(path,System.IO.FileMode.Open)) using (FileStream fStream = new FileStream(path,System.IO.FileMode.Open))
{ {
MD5 md5 = new MD5CryptoServiceProvider(); MD5 md5 = new MD5CryptoServiceProvider();
...@@ -1492,7 +1533,7 @@ namespace cardvisa ...@@ -1492,7 +1533,7 @@ namespace cardvisa
{ {
sb.Append(retVal[i].ToString("X2")); sb.Append(retVal[i].ToString("X2"));
} }
return sb.ToString(); return sb.ToString().ToLower();
} }
} }
catch (Exception ex) catch (Exception ex)
...@@ -1545,6 +1586,29 @@ namespace cardvisa ...@@ -1545,6 +1586,29 @@ namespace cardvisa
} }
} }
} }
public static async void FetchFile(string remoteroot, string ygoroot, string filename)
{
string filepath = ygoroot + "\\update-hakune\\" + filename.Replace('/','\\');
if (!File.Exists(filepath))
{
using (var client = new HttpClient())
{
var res = await client.GetAsync(remoteroot + (filename == "filelist.txt" ? "/update/filelist.txt" : filename));
if (res.IsSuccessStatusCode)
{
using (var fs = File.Create(filepath))
{
await res.Content.CopyToAsync(fs);
}
Console.WriteLine("File downloaded successfully.");
}
else
{
Console.WriteLine("Failed to download file.");
}
}
}
}
} }
public class SqliteDataContext : DataContext public class SqliteDataContext : DataContext
{ {
...@@ -1568,6 +1632,7 @@ namespace cardvisa ...@@ -1568,6 +1632,7 @@ namespace cardvisa
public class SettingData public class SettingData
{ {
public string ygopath { get; set; } = ""; public string ygopath { get; set; } = "";
public string url { get; set; } = "";
public bool pathcheck { get; set; } = false; public bool pathcheck { get; set; } = false;
public bool packDIY { get; set; } = true; public bool packDIY { get; set; } = true;
public bool checkfiles { get; set; } = false; public bool checkfiles { get; set; } = false;
......
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection.Emit;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static cardvisa.MoeScript;
namespace cardvisa
{
public class MoeScript
{
static string path { get; set; }
internal static string[] script { get; set; }//这是用来储存脚本的数组
internal static int mainIndicator { get; set; }//这是逻辑指针
//脚本变量字典
public static Dictionary<string, string> varsdic = new Dictionary<string, string>();
public class Interpreter
{
public string cmd { get; set; }
public class logicObject : IDisposable
{
public static string name { get; set; }
public static List<string> atb { get; set; }
public logicObject() { }
public logicObject(string name, List<string> atb) {
switch (logicObject.name)
{
case "read":
break;
case "write":
break;
case "var":
break;
}
}
public void Dispose()
{
GC.SuppressFinalize(this);
}
}
public void ScriptAnalyze(string moepath) {
script = fileReader(moepath);//载入脚本
string rdGuid = System.Guid.NewGuid().ToString();
for (mainIndicator = 0; mainIndicator < script.Length; mainIndicator++) {
cmd = script[mainIndicator];//获取当前命令
if (cmd.IndexOf("\\<", 0) >= 0 || cmd.IndexOf("\\>", 0) >= 0)
{
rdGuid = System.Guid.NewGuid().ToString();
cmd = cmd.Replace("\\<", "@01@" + rdGuid + "@");
cmd = cmd.Replace("\\>", "@02@" + rdGuid + "@");
cmd = cmd.Replace("\\\\", "@03@" + rdGuid + "@");
}
//解析对象
if (cmd.IndexOf("<", 0) >= 0)
{
cmd = getReg("<[^<>]+>", cmd);//以"<"和">",获得该行脚本
//对[和]进行预翻译
while (cmd.IndexOf("[", 0) >= 0 && cmd.IndexOf("]", 0) >= 0)
{
string s0 = getReg("\\[[^\\[\\]]+\\]", cmd);
string s1 = getReg("[^\\[\\]]+", s0);
varsdic.TryGetValue(s1, out s1);
cmd = cmd.Replace(s0, s1);
}
if (cmd.IndexOf(" ", 0) >= 0 || cmd.IndexOf("@01@", 0) >= 0 || cmd.IndexOf("@02@", 0) >= 0)
{
logicObject.name = getReg("\\w+ ", cmd);
logicObject.name = logicObject.name.Replace(" ", "");
cmd = cmd.Replace(logicObject.name, "");
cmd = cmd.Replace("@01@" + rdGuid + "@", "<");
cmd = cmd.Replace("@02@" + rdGuid + "@", ">");
cmd = cmd.Replace("@03@" + rdGuid + "@", "\\");
logicObject.atb = getRegs("[^\" ]+=\"[^\"]+\"", cmd);
}
else
{
cmd = cmd.Replace("<", "");
cmd = cmd.Replace(">", "");
logicObject.name = cmd;
}
}
//分支预测
flowControl.moeIf.estimate(logicObject.atb);
flowControl.moeIf.flow(logicObject.name);
//预编译方法判断
flowControl.moeFunction.estimate(logicObject.atb);
flowControl.moeFunction.flow(logicObject.name);
//语句执行层
if (flowControl.moeIf.flag){
Executer.execute();
}
//循环执行-设置返回点
flowControl.moeFor.estimate(logicObject.atb);
flowControl.moeFor.flow(logicObject.name);
}
}
}
public class Executer {
public static void execute() {
var items = Interpreter.logicObject.atb;
Action<object> func = (obj) => {
//using (var item = ) { item.execute(); }
};
}
}
#region 辅助方法
public static string clsHandle(string exp)
{
string result = "exp";
char[] compair = { '+', '-', '*', '/' };
string[] exptmp = exp.Split(',');
List<string> rescom = new List<string>();
foreach (var item in exptmp)
{
string expro = item;
if (expro.IndexOf("-", 0) == 0)
{
expro = "0" + expro;
}
/*
#region 进入四则运算判断
if (item.IndexOfAny(compair, 0) > -1)
{
try
{
GrammerAnalyzer ga = new GrammerAnalyzer(expro);
ga.Analyze();
Token[] toks = ga.TokenList;
SyntaxAnalyzer sa = new SyntaxAnalyzer(toks);
sa.Analyze();
Calculator calc = new Calculator(sa.SyntaxTree);
double value = calc.Calc();
rescom.Add(value.ToString());//加入到list中
}
catch
{
}
}
else
{
rescom.Add(item.ToString());
}
#endregion
*/
}
result = string.Join(",", rescom);
return result;
}
public static string[] fileReader(string path)
{
if (File.Exists(path))
{
return File.ReadAllLines(path, Encoding.GetEncoding("GB2312"));
}
else
{
string[] a = new string[1];
a[0] = "初始化";
return a;
}
}
public static string getReg(string exp, string str)
{
string text = "";
var reg = new Regex(exp, RegexOptions.IgnoreCase);
var m = reg.Match(str);
text = m.Value;
return text;
}
public static List<string> getRegs(string exp, string str)
{
List<string> text = new List<string>();
var reg = new Regex(exp, RegexOptions.IgnoreCase);
MatchCollection m = reg.Matches(str);
foreach (Match mc in m)
{
text.Add(mc.Value);
}
return text;
}
public static List<string> getString(string str1)
{
int startIndex = 0;
int endIndex = str1.IndexOf("=", 0);
List<string> lst = new List<string>();
if (endIndex > 0)
{
string atbName = str1.Substring(0, endIndex);
lst.Add(atbName);
startIndex = str1.IndexOf("\"", 0);
endIndex = str1.IndexOf("\"", startIndex + 1);
string value = str1.Substring(startIndex + 1, endIndex - startIndex - 1);
value = MoeScript.clsHandle(value);
lst.Add(value);
}
return lst;
}
public static class Transformer
{
public static void EscapeCharacterEncode(string cmd, string rdGuid)
{
string charType = getReg("\\\\w+", cmd);
switch (charType)
{
default:
break;
}
cmd = cmd.Replace("\\<", "@01@" + rdGuid + "@");
cmd = cmd.Replace("\\>", "@02@" + rdGuid + "@");
cmd = cmd.Replace("\\\\", "@03@" + rdGuid + "@");
}
public static void EscapeCharacterDecode() { }
}
#endregion
}
internal static class ioInterface
{
public class moeReader
{
int endIndex;
string varname = "变量" + MoeScript.varsdic.Count;
string strpath = "";
string strsection = "";
string strkey = "";
string strtext = "默认文本";
public void setValues(List<string> atb)
{
foreach (var str1 in atb)
{
//初始化预设属性值
//判断是否需要赋值
endIndex = str1.IndexOf("=", 0);
if (endIndex > 0)
{
#region 设置逻辑对象属性
string atbName = MoeScript.getString(str1)[0];
string value = MoeScript.getString(str1)[1];
//设置属性
switch (atbName)
{
case "名字":
varname = value;
break;
case "路径":
strpath = value;
break;
case "键名":
strsection = value;
break;
case "值名":
strkey = value;
break;
case "内容":
strtext = value;
break;
default:
break;
}
#endregion
}
}
}
public void read()
{
strtext = FileHandle.INIGetStringValue(strpath, strsection, strkey, strtext);
if (MoeScript.varsdic.ContainsKey(varname))
{
MoeScript.varsdic.Remove(varname);
MoeScript.varsdic.Add(varname, strtext);
}
else
{
MoeScript.varsdic.Add(varname, strtext);
}
}
}
public class moeWriter
{
int endIndex;
string strpath = "";
string strsection = "";
string strkey = "";
string strtext = "默认文本";
public void setValues(List<string> atb)
{
foreach (var str1 in atb)
{
//初始化预设属性值
//判断是否需要赋值
endIndex = str1.IndexOf("=", 0);
if (endIndex > 0)
{
#region 设置逻辑对象属性
string atbName = MoeScript.getString(str1)[0];
string value = MoeScript.getString(str1)[1];
//设置属性
switch (atbName)
{
case "路径":
strpath = value;
break;
case "键名":
strsection = value;
break;
case "值名":
strkey = value;
break;
case "内容":
strtext = value;
break;
default:
break;
}
#endregion
}
}
}
public void write()
{
FileHandle.INIWriteValue(strpath, strsection, strkey, strtext);
}
}
public class moeVar: Interpreter.logicObject
{
int endIndex;
string tname;
string tvalue;
char split = '@';
string[] sLine;
List<string> temp = new List<string>();
public moeVar() { }
public moeVar(List<string> atb) { setValues(atb);}
public void setValues(List<string> atb)
{
temp.Clear();
foreach (var str1 in atb)
{
//初始化预设属性值
//判断是否需要赋值
endIndex = str1.IndexOf("=", 0);
if (endIndex > 0)
{
#region 设置逻辑对象属性
string atbName = MoeScript.getString(str1)[0];
string value = MoeScript.getString(str1)[1];
//设置属性
switch (atbName)
{
case "名字":
tname = value;
break;
case "内容":
tvalue = value;
break;
case "分隔符":
split = value.ToCharArray()[0];
break;
}
#endregion
}
}
}
public void execute()
{
sLine = tvalue.Split(split);
temp.AddRange(sLine);
int i = 1;
if (split == '@')
{
if (MoeScript.varsdic.ContainsKey(tname))
{
MoeScript.varsdic[tname] = tvalue;
}
else
{
MoeScript.varsdic.Add(tname, tvalue);
}
}
else
{
foreach (var item in temp)
{
if (MoeScript.varsdic.ContainsKey(tname + 1))
{
MoeScript.varsdic[tname + i] = item;
}
else
{
MoeScript.varsdic.Add(tname + i, item);
}
i++;
}
}
}
public void setssort()
{
int i = 1;
while (MoeScript.varsdic.ContainsKey(tname + i))
{
temp.Add(MoeScript.varsdic[tname + i]);
i++;
}
temp.Sort();
i = 1;
foreach (var item in temp)
{
MoeScript.varsdic[tname + i] = item;
i++;
}
}
}
}
internal static class flowControl
{
internal class moeIf
{
public static List<bool> result = new List<bool>();
public static bool resTemp;
public static bool flag = true;//最终结果
public static void flow(string keyword)
{
switch (keyword)
{
default:
break;
case "否则":
if (result.Count != 0)
{
result[result.Count - 1] = (result[result.Count - 1] == true ? false : true);
}
break;
case "结束":
if (result.Count != 0)
{
result.Remove(result[result.Count - 1]);
}
flag = true;
break;
case "如果":
result.Add(resTemp);
break;
}
foreach (var item in result)
{
flag = (item == true ? true : false);
}
}
public static void estimate(List<string> atb)
{
int endIndex;
string A = "";
int a = 0;
string B = "";
int b = 0;
string C = "等于";
if (atb != null)
{
foreach (var str1 in atb)
{
//初始化预设属性值
//判断是否需要赋值
endIndex = str1.IndexOf("=", 0);
if (endIndex > 0)
{
#region 设置逻辑对象属性
string atbName = MoeScript.getString(str1)[0];
string value = MoeScript.getString(str1)[1];
//设置属性
switch (atbName)
{
case "A":
A = value;
break;
case "B":
B = value;
break;
case "条件":
C = value;
break;
default:
break;
}
#endregion
}
}
int.TryParse(A, out a);
int.TryParse(B, out b);
#region 这里进行判断
switch (C)
{
case "等于":
if (A == B) { resTemp = true; } else { resTemp = false; }
break;
case "不等于":
if (A != B) { resTemp = true; } else { resTemp = false; }
break;
case "大于":
if (a > b) { resTemp = true; } else { resTemp = false; }
break;
case "小于":
if (a < b) { resTemp = true; } else { resTemp = false; }
break;
case "大于等于":
if (a >= b) { resTemp = true; } else { resTemp = false; }
break;
case "小于等于":
if (a <= b) { resTemp = true; } else { resTemp = false; }
break;
case "不大于":
if (a <= b) { resTemp = true; } else { resTemp = false; }
break;
case "不小于":
if (a >= b) { resTemp = true; } else { resTemp = false; }
break;
}
#endregion}
}
}
}
internal class moeFor
{
public static List<int> index = new List<int>();//这里是返回点
public static List<int> times = new List<int>();//这里是执行次数
public static void flow(string keyword)
{
switch (keyword)
{
default:
break;
case "循环":
index.Add(MoeScript.mainIndicator);
break;
case "跳出":
if (index.Count != 0 && times.Count != 0)
{
if (times[times.Count - 1] > 1)
{
MoeScript.mainIndicator = index[index.Count - 1];
times[times.Count - 1]--;
}
else
{
times.Remove(times[times.Count - 1]);
index.Remove(index[index.Count - 1]);
}
}
break;
}
}
public static void estimate(List<string> atb)
{
int endIndex;
int tryTimes = 0;//这是声明执行次数
if (atb != null)
{
foreach (var str1 in atb)
{
//初始化预设属性值
//判断是否需要赋值
endIndex = str1.IndexOf("=", 0);
if (endIndex > 0)
{
#region 设置逻辑对象属性
string atbName = MoeScript.getString(str1)[0];
string value = MoeScript.getString(str1)[1];
//设置属性
switch (atbName)
{
case "次数":
if (MoeScript.Interpreter.logicObject.name == "循环")
{
int.TryParse(value, out tryTimes);
times.Add(tryTimes);
}
break;
}
#endregion
}
}
}
}
}
internal class moeFunction
{
public static List<int> index = new List<int>();//这里是返回点
public static Dictionary<string, int> fDic = new Dictionary<string, int>();
static string fName;
static int jmp = 0;
public static void flow(string keyword)
{
string tname = fName;
int tvalue = MoeScript.mainIndicator;
switch (keyword)
{
case "声明方法":
moeIf.flag = false;
if (moeFor.index.Count == 0 || moeIf.result.Count == 0)
{
if (fDic.ContainsKey(tname))
{
//方法名重复
fDic[tname] = tvalue;
}
else
{
fDic.Add(tname, tvalue);
}
tvalue = 0;
}
break;
case "调用方法":
if (moeIf.flag)
{
if (fDic.ContainsKey(tname))
{
jmp = fDic[tname];
index.Add(MoeScript.mainIndicator);
if (jmp != 0)
{
MoeScript.mainIndicator = jmp;
}
jmp = 0;
}
else
{
for (int i = MoeScript.mainIndicator; i < MoeScript.script.Length; i++)
{
if (MoeScript.script[i].IndexOf("声明方法") > 0)
{
if (MoeScript.script[i].IndexOf("名字=" + "\"" + tname + "\"") > 0)
{
MoeScript.mainIndicator = i;
break;
}
}
}
}
}
break;
case "返回":
if (index.Count != 0)
{
MoeScript.mainIndicator = index[index.Count - 1];
index.Remove(index[index.Count - 1]);
}
else
{
moeIf.flag = true;
}
break;
}
}
public static void estimate(List<string> atb)
{
int endIndex;
if (atb != null)
{
foreach (var str1 in atb)
{
//初始化预设属性值
//判断是否需要赋值
endIndex = str1.IndexOf("=", 0);
if (endIndex > 0)
{
#region 设置逻辑对象属性
string atbName = MoeScript.getString(str1)[0];
string value = MoeScript.getString(str1)[1];
//设置属性
switch (atbName)
{
case "名字":
fName = value;
break;
}
#endregion
}
}
}
}
}
}
}
{"ygopath":"D:\\MyCardLibrary\\ygopro\\ygopro.exe","pathcheck":false,"packDIY":true,"regs":null,"checkfiles": false} {"ygopath":"C:\\MyCardLibrary\\ygopro\\ygopro.exe","pathcheck":false,"packDIY":true,"regs":null,"checkfiles": false,"url":"https://cdn02.moecube.com:444/koishipro/contents/"}
\ No newline at end of file \ No newline at end of file
...@@ -122,12 +122,14 @@ ...@@ -122,12 +122,14 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="FileHandle.cs" />
<Compile Include="Form1.cs"> <Compile Include="Form1.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
<Compile Include="Form1.Designer.cs"> <Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon> <DependentUpon>Form1.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Moecraft.cs" />
<Compile Include="MyListBox.cs"> <Compile Include="MyListBox.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
......
82ee7007c2ed7a5765c90a144ea7ebd66d6b4faf830bf39b7baeaf603aeb3916 7ed4376bae93b6b0798a952a02914c98205c6b638f23432bf10b540a3b79d477
...@@ -57,3 +57,19 @@ E:\project\visa\cardvisa\cardvisa\obj\Debug\cardvisa.PuzzleGame.resources ...@@ -57,3 +57,19 @@ E:\project\visa\cardvisa\cardvisa\obj\Debug\cardvisa.PuzzleGame.resources
E:\project\visa\cardvisa\cardvisa\obj\Debug\cardvisa.MyListBox.resources E:\project\visa\cardvisa\cardvisa\obj\Debug\cardvisa.MyListBox.resources
C:\Users\Administrator\source\repos\cardvisa\cardvisa\obj\Debug\cardvisa.MyListBox.resources C:\Users\Administrator\source\repos\cardvisa\cardvisa\obj\Debug\cardvisa.MyListBox.resources
C:\Users\Administrator\source\repos\cardvisa\cardvisa\obj\Debug\cardvisa.PuzzleGame.resources C:\Users\Administrator\source\repos\cardvisa\cardvisa\obj\Debug\cardvisa.PuzzleGame.resources
C:\Users\HanamomoHakune\source\repos\cardvisa\cardvisa\obj\Debug\cardvisa.csproj.AssemblyReference.cache
C:\Users\HanamomoHakune\source\repos\cardvisa\cardvisa\obj\Debug\cardvisa.Form1.resources
C:\Users\HanamomoHakune\source\repos\cardvisa\cardvisa\obj\Debug\cardvisa.MyListBox.resources
C:\Users\HanamomoHakune\source\repos\cardvisa\cardvisa\obj\Debug\cardvisa.PicViewer.resources
C:\Users\HanamomoHakune\source\repos\cardvisa\cardvisa\obj\Debug\cardvisa.Properties.Resources.resources
C:\Users\HanamomoHakune\source\repos\cardvisa\cardvisa\obj\Debug\cardvisa.PuzzleGame.resources
C:\Users\HanamomoHakune\source\repos\cardvisa\cardvisa\obj\Debug\cardvisa.csproj.GenerateResource.cache
C:\Users\HanamomoHakune\source\repos\cardvisa\cardvisa\obj\Debug\cardvisa.csproj.CoreCompileInputs.cache
C:\Users\HanamomoHakune\source\repos\cardvisa\cardvisa\obj\Debug\cardvisa.exe
C:\Users\HanamomoHakune\source\repos\cardvisa\cardvisa\obj\Debug\cardvisa.pdb
C:\Users\HanamomoHakune\source\repos\cardvisa\cardvisa\bin\Debug\lua54.dll
C:\Users\HanamomoHakune\source\repos\cardvisa\cardvisa\bin\Debug\liblua54.dylib
C:\Users\HanamomoHakune\source\repos\cardvisa\cardvisa\bin\Debug\liblua54.so
C:\Users\HanamomoHakune\source\repos\cardvisa\cardvisa\bin\Debug\cardvisa.exe.config
C:\Users\HanamomoHakune\source\repos\cardvisa\cardvisa\bin\Debug\cardvisa.exe
C:\Users\HanamomoHakune\source\repos\cardvisa\cardvisa\bin\Debug\cardvisa.pdb
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