Skip to content
This repository has been archived by the owner on Feb 3, 2024. It is now read-only.

Commit

Permalink
add sqlite support. format xaml code.
Browse files Browse the repository at this point in the history
  • Loading branch information
B1ackSand committed Oct 4, 2023
1 parent a356d7c commit f61c658
Show file tree
Hide file tree
Showing 49 changed files with 1,314 additions and 1,318 deletions.
2 changes: 1 addition & 1 deletion LiaoTian_Cup/Dictionary/I18n/Lang.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion LiaoTian_Cup/Dictionary/I18n/Lang.resx
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@
<value>you need to pick commander</value>
</data>
<data name="MainWindowTitle" xml:space="preserve">
<value>聊天杯 LiaoTian_Cup v0.2.2 - Programmed by B1ackSand</value>
<value>聊天杯 LiaoTian_Cup v0.2.3 - Programmed by B1ackSand</value>
</data>
<data name="ThreeMutatorsMode" xml:space="preserve">
<value>3 mutators mode</value>
Expand Down
2 changes: 1 addition & 1 deletion LiaoTian_Cup/Dictionary/I18n/Lang.zh.resx
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@
<value>未选择指挥官</value>
</data>
<data name="MainWindowTitle" xml:space="preserve">
<value>聊天杯 LiaoTian_Cup v0.2.2 - Programmed by B1ackSand</value>
<value>聊天杯 LiaoTian_Cup v0.2.3 - Programmed by B1ackSand</value>
</data>
<data name="ThreeMutatorsMode" xml:space="preserve">
<value>3因子模式</value>
Expand Down
3 changes: 1 addition & 2 deletions LiaoTian_Cup/Helper/CSVKit.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Text;

namespace LiaoTian_Cup.Helper
{
class CSVKit
{
// TODO 读写锁的问题存在
// 已废弃使用
//两个实现
public static List<string[]> Csv2Dt(string filePath, List<string[]> list)
{
Expand Down
62 changes: 62 additions & 0 deletions LiaoTian_Cup/Helper/DbHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using System;
using System.Collections.Generic;
using System.Data.SQLite;

namespace LiaoTian_Cup.Helper;

public class DbHelper
{
private const string ConnectionString = @"Data Source=./Resources/database.db;";

private static readonly SQLiteConnection Conn = new SQLiteConnection(ConnectionString);

public static List<string> GetColumnData(string tableName, List<string> list)
{
Conn.Open();
try
{
using SQLiteCommand cmd = new SQLiteCommand(Conn);
cmd.CommandText = $"SELECT * FROM {tableName}";
using SQLiteDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
var str = Convert.ToString(reader[0]);
list.Add(str);
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}

Conn.Close();
return list;
}

public static List<string[]> GetListData(string tableName,int columnCount, List<string[]> list)
{
Conn.Open();
try
{
using SQLiteCommand cmd = new SQLiteCommand(Conn);
cmd.CommandText = $"SELECT * FROM {tableName}";
using SQLiteDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
string[] rowStrings = new string[columnCount];
for (int i = 0; i < columnCount; i++)
{
rowStrings[i] = Convert.ToString(reader[i]);
}
list.Add(rowStrings);
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}

Conn.Close();
return list;
}
}
80 changes: 51 additions & 29 deletions LiaoTian_Cup/Helper/FileData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,57 +12,79 @@ public class FileData
{
//公共信息提取
//存放从自选突变CSV中得到的数据
public List<string[]> mutationList = new List<string[]>();
public static List<string[]> mutationList = new List<string[]>();

//存放从突变因子CSV中得到的数据
public List<string> mutationFactorList = new List<string>();
public static List<string> mutationFactorList = new List<string>();

//存放先出指挥官CSV中得到的数据
public List<string> beforeCommanderInfo = new List<string>();
public static List<string> beforeCommanderInfo = new List<string>();
//存放后出指挥官CSV中得到的数据
public List<string> afterCommanderInfo = new List<string>();
public static List<string> afterCommanderInfo = new List<string>();

//存放所有的人机CSV中得到的数据
public List<string> botInfo = new List<string>();
public static List<string> botInfo = new List<string>();

//存放因子库CSV中得到的数据
public List<string> baseNegativeFactorInfo = new List<string>();
public List<string> baseMultiFactorInfo = new List<string>();
public List<string> negativeFactorInfo = new List<string>();
public List<string[]> scoreFactorList = new List<string[]>();
public static List<string> baseNegativeFactorInfo = new List<string>();
public static List<string> baseMultiFactorInfo = new List<string>();
public static List<string> negativeFactorInfo = new List<string>();
public static List<string[]> scoreFactorList = new List<string[]>();

//存放USuck模式的CSV数据
public List<string> usuckNegativeFactorInfo = new List<string>();
public List<string> usuckMultiFactorInfo = new List<string>();
public List<string> usuckFactorList = new List<string>();
public static List<string> usuckNegativeFactorInfo = new List<string>();
public static List<string> usuckMultiFactorInfo = new List<string>();
public static List<string> usuckFactorList = new List<string>();

//存放地图数据
public List<string> mapsInfo = new List<string>();
public static List<string> mapsInfo = new List<string>();

public FileData()
{
ReadCsv();
ReadDataBase();
}

//读取csv
private void ReadCsv()
//private void ReadCsv()
//{
// //初始化窗口时即拿数据
// CSVKit.Csv2Dt(Dictionary.FilePath.mutationFilePath, mutationList);
// CSVKit.Csv2Dt(Dictionary.FilePath.scoreFactorPath, scoreFactorList);
// CSVKit.Csv2Dt(Dictionary.FilePath.mutationFactorPath, mutationFactorList);
// CSVKit.Csv2Dt(Dictionary.FilePath.beforeCommanderFilePath, beforeCommanderInfo);
// CSVKit.Csv2Dt(Dictionary.FilePath.afterCommanderFilePath, afterCommanderInfo);
// CSVKit.Csv2Dt(Dictionary.FilePath.aIFilePath, botInfo);
// CSVKit.Csv2Dt(Dictionary.FilePath.baseNegativeFactorFilePath, baseNegativeFactorInfo);
// CSVKit.Csv2Dt(Dictionary.FilePath.baseMultiFactorFilePath, baseMultiFactorInfo);
// CSVKit.Csv2Dt(Dictionary.FilePath.mapsFilePath, mapsInfo);
// CSVKit.Csv2Dt(Dictionary.FilePath.negativeFactorFilePath, negativeFactorInfo);

// //USuck
// CSVKit.Csv2Dt(Dictionary.FilePath.usuckFactorPath, usuckFactorList);
// CSVKit.Csv2Dt(Dictionary.FilePath.usuckMultiPath, usuckMultiFactorInfo);
// CSVKit.Csv2Dt(Dictionary.FilePath.usuckNegativePath, usuckNegativeFactorInfo);
//}

//读取数据库
private void ReadDataBase()
{
//初始化窗口时即拿数据
CSVKit.Csv2Dt(Dictionary.FilePath.mutationFilePath, mutationList);
CSVKit.Csv2Dt(Dictionary.FilePath.mutationFactorPath, mutationFactorList);
CSVKit.Csv2Dt(Dictionary.FilePath.beforeCommanderFilePath, beforeCommanderInfo);
CSVKit.Csv2Dt(Dictionary.FilePath.afterCommanderFilePath, afterCommanderInfo);
CSVKit.Csv2Dt(Dictionary.FilePath.aIFilePath, botInfo);
CSVKit.Csv2Dt(Dictionary.FilePath.baseNegativeFactorFilePath, baseNegativeFactorInfo);
CSVKit.Csv2Dt(Dictionary.FilePath.baseMultiFactorFilePath, baseMultiFactorInfo);
CSVKit.Csv2Dt(Dictionary.FilePath.mapsFilePath, mapsInfo);
CSVKit.Csv2Dt(Dictionary.FilePath.negativeFactorFilePath, negativeFactorInfo);
CSVKit.Csv2Dt(Dictionary.FilePath.scoreFactorPath, scoreFactorList);
DbHelper.GetListData("global_weeklymutations", 5, mutationList);
DbHelper.GetListData("group_MutatorList_Cost", 3, scoreFactorList);

DbHelper.GetColumnData("global_mutatorlist", mutationFactorList);
DbHelper.GetColumnData("global_cmdroldlist", beforeCommanderInfo);
DbHelper.GetColumnData("global_cmdrnewlist", afterCommanderInfo);
DbHelper.GetColumnData("ai_table", botInfo);
DbHelper.GetColumnData("doubles_negativelist", baseNegativeFactorInfo);
DbHelper.GetColumnData("doubles_multilist", baseMultiFactorInfo);
DbHelper.GetColumnData("global_maplist", mapsInfo);
DbHelper.GetColumnData("global_negativelist", negativeFactorInfo);

//USuck
CSVKit.Csv2Dt(Dictionary.FilePath.usuckFactorPath, usuckFactorList);
CSVKit.Csv2Dt(Dictionary.FilePath.usuckMultiPath, usuckMultiFactorInfo);
CSVKit.Csv2Dt(Dictionary.FilePath.usuckNegativePath, usuckNegativeFactorInfo);
DbHelper.GetColumnData("usuck_mutatorlist", usuckFactorList);
DbHelper.GetColumnData("usuck_multilist", usuckMultiFactorInfo);
DbHelper.GetColumnData("usuck_negativelist", usuckNegativeFactorInfo);

}
}
}
39 changes: 0 additions & 39 deletions LiaoTian_Cup/Helper/MyImage.cs

This file was deleted.

3 changes: 0 additions & 3 deletions LiaoTian_Cup/Helper/RandomKit.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LiaoTian_Cup.Helper
{
Expand Down
67 changes: 0 additions & 67 deletions LiaoTian_Cup/Helper/RelayCommand.cs

This file was deleted.

Loading

0 comments on commit f61c658

Please sign in to comment.