mirror of
https://github.com/milimoe/FunGame-Testing.git
synced 2025-04-22 04:09:34 +08:00
new
This commit is contained in:
parent
e8334b30d0
commit
2e5479bed8
149
Library/Main.cs
149
Library/Main.cs
@ -1,74 +1,103 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Data;
|
|
||||||
using ConverterExample;
|
|
||||||
using Milimoe.FunGame.Core.Api.Utility;
|
using Milimoe.FunGame.Core.Api.Utility;
|
||||||
using Milimoe.FunGame.Core.Entity;
|
using Milimoe.FunGame.Core.Entity;
|
||||||
using Milimoe.FunGame.Core.Library.Common.JsonConverter;
|
using Milimoe.FunGame.Core.Library.Common.Addon;
|
||||||
|
using Milimoe.FunGame.Core.Library.Common.Event;
|
||||||
|
using Milimoe.FunGame.Core.Library.Constant;
|
||||||
|
using Milimoe.FunGame.Testing.Solutions;
|
||||||
|
|
||||||
DataSet ds = new();
|
PluginLoader plugins = PluginLoader.LoadPlugins([]);
|
||||||
DataTable table = new("SampleTable1");
|
foreach (string plugin in plugins.Plugins.Keys)
|
||||||
table.Columns.Add("Id", typeof(int));
|
|
||||||
table.Columns.Add("Name", typeof(string));
|
|
||||||
table.Columns.Add("Age", typeof(int));
|
|
||||||
table.Rows.Add(1, "John", 30);
|
|
||||||
table.Rows.Add(2, "Jane", 25);
|
|
||||||
table.Rows.Add(3, "Bob", 40);
|
|
||||||
ds.Tables.Add(table);
|
|
||||||
|
|
||||||
table = new("SampleTable2");
|
|
||||||
table.Columns.Add("Id", typeof(int));
|
|
||||||
table.Columns.Add("Name", typeof(string));
|
|
||||||
table.Columns.Add("Age", typeof(int));
|
|
||||||
table.Rows.Add(1, "John", 30);
|
|
||||||
table.Rows.Add(2, "Jane", 25);
|
|
||||||
table.Rows.Add(3, "Bob", 40);
|
|
||||||
ds.Tables.Add(table);
|
|
||||||
|
|
||||||
JsonTool JsonTool = new();
|
|
||||||
JsonTool.AddConverters(new System.Text.Json.Serialization.JsonConverter[] { new UserConverter(), new RoomConverter(), new PersonConverter(), new AddressConverter() });
|
|
||||||
|
|
||||||
Room r = Factory.GetRoom(1294367, "w5rtvh8".ToUpper(), DateTime.Now, Factory.GetUser(), Milimoe.FunGame.Core.Library.Constant.RoomType.Mix, "", "", Milimoe.FunGame.Core.Library.Constant.RoomState.Created);
|
|
||||||
User u = Factory.GetUser(1, "LUOLI", DateTime.Now, DateTime.Now, "LUOLI@66.COM", "QWQAQW");
|
|
||||||
|
|
||||||
Hashtable hashtable = new()
|
|
||||||
{
|
{
|
||||||
{ "table", table },
|
Console.WriteLine(plugin + " is loaded.");
|
||||||
{ "room", r },
|
}
|
||||||
{ "user", u }
|
|
||||||
};
|
|
||||||
|
|
||||||
string json = JsonTool.GetString(hashtable);
|
Dictionary<string, string> plugindllsha512 = [];
|
||||||
|
foreach (string pfp in PluginLoader.PluginFilePaths.Keys)
|
||||||
Hashtable hashtable2 = JsonTool.GetObject<Hashtable>(json) ?? new();
|
|
||||||
|
|
||||||
DataTable table2 = JsonTool.GetObject<DataTable>(json) ?? new();
|
|
||||||
User u2 = JsonTool.GetObject<User>(hashtable2, "user") ?? Factory.GetUser();
|
|
||||||
Room r2 = JsonTool.GetObject<Room>(hashtable2, "room") ?? Factory.GetRoom();
|
|
||||||
|
|
||||||
table2.AsEnumerable().ToList().ForEach(row =>
|
|
||||||
{
|
{
|
||||||
Console.WriteLine("Id: " + row["Id"] + ", Name: "+ row["Name"] + ", Age: " + row["Age"]);
|
string text = Encryption.FileSha512(PluginLoader.PluginFilePaths[pfp]);
|
||||||
});
|
plugindllsha512.Add(pfp, text);
|
||||||
|
Console.WriteLine(pfp + $" is {text}.");
|
||||||
|
}
|
||||||
|
|
||||||
Console.WriteLine(u2.Username + " 进入了 " + r2.Roomid + " 房间");
|
LoginEventArgs e = new();
|
||||||
|
plugins.OnBeforeLoginEvent(plugins, e);
|
||||||
Person p = new()
|
if (!e.Cancel)
|
||||||
{
|
{
|
||||||
Age = (int)r2.Id,
|
plugins.OnSucceedLoginEvent(plugins, e);
|
||||||
Name = u2.Username,
|
plugins.OnFailedLoginEvent(plugins, e);
|
||||||
Address = new()
|
}
|
||||||
|
plugins.OnAfterLoginEvent(plugins, e);
|
||||||
|
|
||||||
|
List<Character> list = [];
|
||||||
|
|
||||||
|
GameModuleLoader modules = GameModuleLoader.LoadGameModules(FunGameInfo.FunGame.FunGame_Desktop, []);
|
||||||
|
foreach (CharacterModule cm in modules.Characters.Values)
|
||||||
|
{
|
||||||
|
foreach (Character c in cm.Characters)
|
||||||
{
|
{
|
||||||
State = "呵呵州(Hehe State)",
|
Console.WriteLine(c.Name);
|
||||||
City = "哈哈市(Haha City)"
|
list.Add(c);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
json = JsonTool.GetString(p);
|
Dictionary<string, string> moduledllsha512 = [];
|
||||||
|
foreach (string mfp in GameModuleLoader.ModuleFilePaths.Keys)
|
||||||
|
{
|
||||||
|
string text = Encryption.FileSha512(GameModuleLoader.ModuleFilePaths[mfp]);
|
||||||
|
moduledllsha512.Add(mfp, text);
|
||||||
|
Console.WriteLine(mfp + $" is {text}.");
|
||||||
|
}
|
||||||
|
|
||||||
Person p2 = JsonTool.GetObject<Person>(json) ?? new();
|
foreach (string moduledll in moduledllsha512.Keys)
|
||||||
|
{
|
||||||
|
string server = moduledllsha512[moduledll];
|
||||||
|
if (plugindllsha512.TryGetValue(moduledll, out string? client) && client != "" && server == client)
|
||||||
|
{
|
||||||
|
Console.WriteLine(moduledll + $" is checked pass.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Console.WriteLine("My name is " + p2.Name + ", I am " + p2.Age + "-year-old. I live at " + p2.Address.State + " " + p2.Address.City);
|
if (list.Count > 3)
|
||||||
Console.WriteLine("摆烂了86");
|
{
|
||||||
|
Console.WriteLine();
|
||||||
|
Console.WriteLine("Start!!!");
|
||||||
|
Console.WriteLine();
|
||||||
|
|
||||||
// 生成一对公钥秘钥
|
Character character1 = list[0].Copy();
|
||||||
//TwoFactorAuthenticator.CreateSecretKey();
|
Character character2 = list[1].Copy();
|
||||||
|
Character character3 = list[2].Copy();
|
||||||
|
Character character4 = list[3].Copy();
|
||||||
|
|
||||||
|
ActionQueue actionQueue = new();
|
||||||
|
List<Character> characters = [character1, character2, character3, character4];
|
||||||
|
|
||||||
|
// 初始顺序表排序
|
||||||
|
actionQueue.CalculateInitialOrder(characters);
|
||||||
|
Console.WriteLine();
|
||||||
|
|
||||||
|
// 显示初始顺序表
|
||||||
|
actionQueue.DisplayQueue();
|
||||||
|
Console.WriteLine();
|
||||||
|
|
||||||
|
// 模拟时间流逝
|
||||||
|
int i = 1;
|
||||||
|
while (i < 10)
|
||||||
|
{
|
||||||
|
// 检查是否有角色可以行动
|
||||||
|
Character? characterToAct = actionQueue.NextCharacter();
|
||||||
|
if (characterToAct != null)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"=== Round {i++} ===");
|
||||||
|
actionQueue.ProcessTurn(characterToAct);
|
||||||
|
actionQueue.DisplayQueue();
|
||||||
|
Console.WriteLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
//Thread.Sleep(1); // 模拟时间流逝
|
||||||
|
actionQueue.ReduceHardnessTimes();
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("--- End ---");
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.ReadKey();
|
||||||
|
157
Library/Solutions/ActionQueue.cs
Normal file
157
Library/Solutions/ActionQueue.cs
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
using Milimoe.FunGame.Core.Entity;
|
||||||
|
|
||||||
|
namespace Milimoe.FunGame.Testing.Solutions;
|
||||||
|
|
||||||
|
public class ActionQueue
|
||||||
|
{
|
||||||
|
private readonly List<Character> _Queue = [];
|
||||||
|
private readonly Dictionary<Character, double> _HardnessTimes = [];
|
||||||
|
|
||||||
|
public void AddCharacter(Character character, double hardnessTime)
|
||||||
|
{
|
||||||
|
// 插队机制:按硬直时间排序
|
||||||
|
int insertIndex = _Queue.FindIndex(c => _HardnessTimes[c] > hardnessTime);
|
||||||
|
if (insertIndex == -1)
|
||||||
|
{
|
||||||
|
_Queue.Add(character);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_Queue.Insert(insertIndex, character);
|
||||||
|
}
|
||||||
|
_HardnessTimes[character] = hardnessTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CalculateInitialOrder(List<Character> characters)
|
||||||
|
{
|
||||||
|
// 排序时,时间会流逝
|
||||||
|
int nowTime = 1;
|
||||||
|
|
||||||
|
// 初始排序:按速度排序
|
||||||
|
List<IGrouping<double, Character>> groupedBySpeed = [.. characters
|
||||||
|
.GroupBy(c => c.SPD)
|
||||||
|
.OrderByDescending(g => g.Key)];
|
||||||
|
|
||||||
|
Random random = new();
|
||||||
|
|
||||||
|
foreach (IGrouping<double, Character> group in groupedBySpeed)
|
||||||
|
{
|
||||||
|
if (group.Count() == 1)
|
||||||
|
{
|
||||||
|
// 如果只有一个角色,直接加入队列
|
||||||
|
AddCharacter(group.First(), _Queue.Count + nowTime);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 如果有多个角色,进行先行决定
|
||||||
|
List<Character> sortedList = [.. group];
|
||||||
|
|
||||||
|
while (sortedList.Count > 0)
|
||||||
|
{
|
||||||
|
Character? selectedCharacter = null;
|
||||||
|
bool decided = false;
|
||||||
|
if (sortedList.Count == 1)
|
||||||
|
{
|
||||||
|
selectedCharacter = sortedList[0];
|
||||||
|
decided = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (!decided)
|
||||||
|
{
|
||||||
|
// 每个角色进行两次随机数抽取
|
||||||
|
var randomNumbers = sortedList.Select(c => new
|
||||||
|
{
|
||||||
|
Character = c,
|
||||||
|
FirstRoll = random.Next(1, 21),
|
||||||
|
SecondRoll = random.Next(1, 21)
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
randomNumbers.ForEach(a => Console.WriteLine(a.Character.Name + ": " + a.FirstRoll + " / " + a.SecondRoll));
|
||||||
|
|
||||||
|
nowTime++;
|
||||||
|
|
||||||
|
// 找到两次都大于其他角色的角色
|
||||||
|
int maxFirstRoll = randomNumbers.Max(r => r.FirstRoll);
|
||||||
|
int maxSecondRoll = randomNumbers.Max(r => r.SecondRoll);
|
||||||
|
|
||||||
|
var candidates = randomNumbers
|
||||||
|
.Where(r => r.FirstRoll == maxFirstRoll && r.SecondRoll == maxSecondRoll)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
if (candidates.Count == 1)
|
||||||
|
{
|
||||||
|
selectedCharacter = candidates.First().Character;
|
||||||
|
decided = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将决定好的角色加入顺序表
|
||||||
|
if (selectedCharacter != null)
|
||||||
|
{
|
||||||
|
AddCharacter(selectedCharacter, _Queue.Count + nowTime);
|
||||||
|
Console.WriteLine("decided: " + selectedCharacter.Name + "\r\n");
|
||||||
|
sortedList.Remove(selectedCharacter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Character? NextCharacter()
|
||||||
|
{
|
||||||
|
if (_Queue.Count == 0) return null;
|
||||||
|
|
||||||
|
// 硬直时间为0的角色将执行行动
|
||||||
|
Character? character = _Queue.FirstOrDefault(c => _HardnessTimes[c] == 0);
|
||||||
|
if (character != null)
|
||||||
|
{
|
||||||
|
_Queue.Remove(character);
|
||||||
|
return character;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ProcessTurn(Character character)
|
||||||
|
{
|
||||||
|
double baseTime = 15; // 假设基础硬直时间为15
|
||||||
|
if (character.Name == "A")
|
||||||
|
{
|
||||||
|
baseTime = 10; // A的硬直
|
||||||
|
}
|
||||||
|
double newHardnessTime = Math.Round(baseTime * (1 - character.ActionCoefficient), 2, MidpointRounding.AwayFromZero);
|
||||||
|
|
||||||
|
AddCharacter(character, newHardnessTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ReduceHardnessTimes()
|
||||||
|
{
|
||||||
|
if (_Queue.Count == 0) return;
|
||||||
|
|
||||||
|
// 获取第一个角色的硬直时间
|
||||||
|
double timeToReduce = _HardnessTimes[_Queue[0]];
|
||||||
|
|
||||||
|
Console.WriteLine("Time Lapse: " + timeToReduce);
|
||||||
|
|
||||||
|
// 减少所有角色的硬直时间
|
||||||
|
foreach (Character character in _Queue)
|
||||||
|
{
|
||||||
|
_HardnessTimes[character] = Math.Round(_HardnessTimes[character] - timeToReduce, 2, MidpointRounding.AwayFromZero);
|
||||||
|
|
||||||
|
// 回血回蓝
|
||||||
|
double douHP = Math.Round(character.HR * timeToReduce, 2, MidpointRounding.AwayFromZero);
|
||||||
|
double douMP = Math.Round(character.MR * timeToReduce, 2, MidpointRounding.AwayFromZero);
|
||||||
|
Console.WriteLine("角色 " + character.Name + " 回血:" + douHP + " / "+ "回蓝:" + douMP);
|
||||||
|
}
|
||||||
|
Console.WriteLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DisplayQueue()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Current ActionQueue:");
|
||||||
|
foreach (var character in _Queue)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"{character.Name}: Hardness Time {_HardnessTimes[character]}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -7,7 +7,7 @@ namespace FunGame.Testing.Solutions
|
|||||||
{
|
{
|
||||||
public class MyPlugin : Plugin, ILoginEvent, IConnectEvent, IIntoRoomEvent
|
public class MyPlugin : Plugin, ILoginEvent, IConnectEvent, IIntoRoomEvent
|
||||||
{
|
{
|
||||||
public override string Name => "测试插件";
|
public override string Name => "milimoe.fungame.testplugin";
|
||||||
|
|
||||||
public override string Description => "My First Plugin";
|
public override string Description => "My First Plugin";
|
||||||
|
|
||||||
|
@ -19,7 +19,12 @@ namespace ConverterExample
|
|||||||
|
|
||||||
public class AddressConverter : BaseEntityConverter<Address>
|
public class AddressConverter : BaseEntityConverter<Address>
|
||||||
{
|
{
|
||||||
public override void ReadPropertyName(ref Utf8JsonReader reader, string propertyName, JsonSerializerOptions options, ref Address? result)
|
public override Address NewInstance()
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void ReadPropertyName(ref Utf8JsonReader reader, string propertyName, JsonSerializerOptions options, ref Address result)
|
||||||
{
|
{
|
||||||
result ??= new();
|
result ??= new();
|
||||||
switch (propertyName)
|
switch (propertyName)
|
||||||
@ -47,7 +52,12 @@ namespace ConverterExample
|
|||||||
|
|
||||||
public class PersonConverter : BaseEntityConverter<Person>
|
public class PersonConverter : BaseEntityConverter<Person>
|
||||||
{
|
{
|
||||||
public override void ReadPropertyName(ref Utf8JsonReader reader, string propertyName, JsonSerializerOptions options, ref Person? result)
|
public override Person NewInstance()
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void ReadPropertyName(ref Utf8JsonReader reader, string propertyName, JsonSerializerOptions options, ref Person result)
|
||||||
{
|
{
|
||||||
result ??= new();
|
result ??= new();
|
||||||
switch (propertyName)
|
switch (propertyName)
|
||||||
|
84
Library/Solutions/TestModule.cs
Normal file
84
Library/Solutions/TestModule.cs
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
using Milimoe.FunGame.Core.Api.Utility;
|
||||||
|
using Milimoe.FunGame.Core.Entity;
|
||||||
|
using Milimoe.FunGame.Core.Library.Common.Addon;
|
||||||
|
using Milimoe.FunGame.Core.Library.Constant;
|
||||||
|
|
||||||
|
namespace Addons
|
||||||
|
{
|
||||||
|
public class ExampleGameModuleConstant
|
||||||
|
{
|
||||||
|
public const string Example = "fungame.example.gamemode";
|
||||||
|
public const string ExampleCharacter = "fungame.example.character";
|
||||||
|
public const string ExampleSkill = "fungame.example.skill";
|
||||||
|
public const string ExampleItem = "fungame.example.item";
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ExampleCharacterModule : CharacterModule
|
||||||
|
{
|
||||||
|
public override string Name => ExampleGameModuleConstant.ExampleCharacter;
|
||||||
|
|
||||||
|
public override string Description => "My First CharacterModule";
|
||||||
|
|
||||||
|
public override string Version => "1.0.0";
|
||||||
|
|
||||||
|
public override string Author => "FunGamer";
|
||||||
|
|
||||||
|
public override List<Character> Characters
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
EntityModuleConfig<Character> config = new(ExampleGameModuleConstant.Example, ExampleGameModuleConstant.ExampleCharacter);
|
||||||
|
config.LoadConfig();
|
||||||
|
return [.. config.Values];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ExampleSkillModule : SkillModule
|
||||||
|
{
|
||||||
|
public override string Name => ExampleGameModuleConstant.ExampleSkill;
|
||||||
|
|
||||||
|
public override string Description => "My First SkillModule";
|
||||||
|
|
||||||
|
public override string Version => "1.0.0";
|
||||||
|
|
||||||
|
public override string Author => "FunGamer";
|
||||||
|
|
||||||
|
public override List<Skill> Skills
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
List<Skill> list = [];
|
||||||
|
Skill s = Factory.GetSkill();
|
||||||
|
s.Name = "Example Skill";
|
||||||
|
s.MagicType = MagicType.PurityNatural;
|
||||||
|
list.Add(s);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ExampleItemModule : ItemModule
|
||||||
|
{
|
||||||
|
public override string Name => ExampleGameModuleConstant.ExampleItem;
|
||||||
|
|
||||||
|
public override string Description => "My First ItemModule";
|
||||||
|
|
||||||
|
public override string Version => "1.0.0";
|
||||||
|
|
||||||
|
public override string Author => "FunGamer";
|
||||||
|
|
||||||
|
public override List<Item> Items
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
List<Item> list = [];
|
||||||
|
Item i = Factory.GetItem();
|
||||||
|
i.Name = "Example Item";
|
||||||
|
i.Price = 20;
|
||||||
|
list.Add(i);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
112
Library/Solutions/TestPlugin.cs
Normal file
112
Library/Solutions/TestPlugin.cs
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
using Milimoe.FunGame.Core.Api.Utility;
|
||||||
|
using Milimoe.FunGame.Core.Entity;
|
||||||
|
using Milimoe.FunGame.Core.Interface;
|
||||||
|
using Milimoe.FunGame.Core.Library.Common.Addon;
|
||||||
|
using Milimoe.FunGame.Core.Library.Common.Event;
|
||||||
|
using Milimoe.FunGame.Core.Library.Constant;
|
||||||
|
|
||||||
|
namespace Addons
|
||||||
|
{
|
||||||
|
public class TestPlugin : Plugin, ILoginEvent
|
||||||
|
{
|
||||||
|
public override string Name => "fungame.example.plugin";
|
||||||
|
|
||||||
|
public override string Description => "My First Plugin";
|
||||||
|
|
||||||
|
public override string Version => "1.0.0";
|
||||||
|
|
||||||
|
public override string Author => "FunGamer";
|
||||||
|
|
||||||
|
protected override bool BeforeLoad()
|
||||||
|
{
|
||||||
|
EntityModuleConfig<Character> config = new(ExampleGameModuleConstant.Example, ExampleGameModuleConstant.ExampleCharacter);
|
||||||
|
// 构建一个你想要的角色
|
||||||
|
Character c = Factory.GetCharacter();
|
||||||
|
c.Name = "Oshima";
|
||||||
|
c.FirstName = "Shiya";
|
||||||
|
c.NickName = "OSM";
|
||||||
|
c.MagicType = MagicType.PurityNatural;
|
||||||
|
c.BaseHP = 30;
|
||||||
|
c.BaseSTR = 20;
|
||||||
|
c.BaseAGI = 10;
|
||||||
|
c.BaseINT = 5;
|
||||||
|
c.BaseATK = 100;
|
||||||
|
c.BaseDEF = 10;
|
||||||
|
c.SPD = 250;
|
||||||
|
c.Init();
|
||||||
|
config.Add("OSM", c);
|
||||||
|
c = Factory.GetCharacter();
|
||||||
|
c.Name = "A";
|
||||||
|
c.FirstName = "测试1";
|
||||||
|
c.NickName = "A";
|
||||||
|
c.MagicType = MagicType.Particle;
|
||||||
|
c.BaseHP = 25;
|
||||||
|
c.BaseSTR = 15;
|
||||||
|
c.BaseAGI = 5;
|
||||||
|
c.BaseINT = 10;
|
||||||
|
c.BaseATK = 80;
|
||||||
|
c.BaseDEF = 15;
|
||||||
|
c.SPD = 290;
|
||||||
|
c.Init();
|
||||||
|
config.Add("A", c);
|
||||||
|
c = Factory.GetCharacter();
|
||||||
|
c.Name = "B";
|
||||||
|
c.FirstName = "测试2";
|
||||||
|
c.NickName = "B";
|
||||||
|
c.MagicType = MagicType.Fleabane;
|
||||||
|
c.BaseHP = 355;
|
||||||
|
c.BaseSTR = 5;
|
||||||
|
c.BaseAGI = 5;
|
||||||
|
c.BaseINT = 25;
|
||||||
|
c.BaseATK = 75;
|
||||||
|
c.BaseDEF = 20;
|
||||||
|
c.SPD = 320;
|
||||||
|
c.Init();
|
||||||
|
config.Add("B", c);
|
||||||
|
c = Factory.GetCharacter();
|
||||||
|
c.Name = "C";
|
||||||
|
c.FirstName = "测试3";
|
||||||
|
c.NickName = "B的复制人";
|
||||||
|
c.MagicType = MagicType.Fleabane;
|
||||||
|
c.BaseHP = 355;
|
||||||
|
c.BaseSTR = 5;
|
||||||
|
c.BaseAGI = 5;
|
||||||
|
c.BaseINT = 25;
|
||||||
|
c.BaseATK = 75;
|
||||||
|
c.BaseDEF = 20;
|
||||||
|
c.SPD = 320;
|
||||||
|
c.Init();
|
||||||
|
config.Add("C", c);
|
||||||
|
config.SaveConfig();
|
||||||
|
PluginConfig config2 = new(Name, "config")
|
||||||
|
{
|
||||||
|
{ "flush", 10000 },
|
||||||
|
{ "oshima", "呵呵了" }
|
||||||
|
};
|
||||||
|
config2.SaveConfig();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AfterLoginEvent(object sender, LoginEventArgs e)
|
||||||
|
{
|
||||||
|
Console.WriteLine("after");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void BeforeLoginEvent(object sender, LoginEventArgs e)
|
||||||
|
{
|
||||||
|
Console.WriteLine("before");
|
||||||
|
// 如果这里设置Cancel = true,将终止登录
|
||||||
|
e.Cancel = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void FailedLoginEvent(object sender, LoginEventArgs e)
|
||||||
|
{
|
||||||
|
Console.WriteLine("failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SucceedLoginEvent(object sender, LoginEventArgs e)
|
||||||
|
{
|
||||||
|
Console.WriteLine("succeed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
66
Library/Tests/CheckDLL.cs
Normal file
66
Library/Tests/CheckDLL.cs
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
using Milimoe.FunGame.Core.Api.Utility;
|
||||||
|
using Milimoe.FunGame.Core.Entity;
|
||||||
|
using Milimoe.FunGame.Core.Library.Common.Addon;
|
||||||
|
using Milimoe.FunGame.Core.Library.Common.Event;
|
||||||
|
using Milimoe.FunGame.Core.Library.Constant;
|
||||||
|
|
||||||
|
namespace Milimoe.FunGame.Testing.Tests
|
||||||
|
{
|
||||||
|
internal class CheckDLL
|
||||||
|
{
|
||||||
|
internal CheckDLL()
|
||||||
|
{
|
||||||
|
PluginLoader plugins = PluginLoader.LoadPlugins([]);
|
||||||
|
foreach (string plugin in plugins.Plugins.Keys)
|
||||||
|
{
|
||||||
|
Console.WriteLine(plugin + " is loaded.");
|
||||||
|
}
|
||||||
|
|
||||||
|
Dictionary<string, string> plugindllsha512 = [];
|
||||||
|
foreach (string pfp in PluginLoader.PluginFilePaths.Keys)
|
||||||
|
{
|
||||||
|
string text = Encryption.FileSha512(PluginLoader.PluginFilePaths[pfp]);
|
||||||
|
plugindllsha512.Add(pfp, text);
|
||||||
|
Console.WriteLine(pfp + $" is {text}.");
|
||||||
|
}
|
||||||
|
|
||||||
|
LoginEventArgs e = new();
|
||||||
|
plugins.OnBeforeLoginEvent(plugins, e);
|
||||||
|
if (!e.Cancel)
|
||||||
|
{
|
||||||
|
plugins.OnSucceedLoginEvent(plugins, e);
|
||||||
|
plugins.OnFailedLoginEvent(plugins, e);
|
||||||
|
}
|
||||||
|
plugins.OnAfterLoginEvent(plugins, e);
|
||||||
|
|
||||||
|
List<Character> list = [];
|
||||||
|
|
||||||
|
GameModuleLoader modules = GameModuleLoader.LoadGameModules(FunGameInfo.FunGame.FunGame_Desktop, []);
|
||||||
|
foreach (CharacterModule cm in modules.Characters.Values)
|
||||||
|
{
|
||||||
|
foreach (Character c in cm.Characters)
|
||||||
|
{
|
||||||
|
Console.WriteLine(c.Name);
|
||||||
|
list.Add(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Dictionary<string, string> moduledllsha512 = [];
|
||||||
|
foreach (string mfp in GameModuleLoader.ModuleFilePaths.Keys)
|
||||||
|
{
|
||||||
|
string text = Encryption.FileSha512(GameModuleLoader.ModuleFilePaths[mfp]);
|
||||||
|
moduledllsha512.Add(mfp, text);
|
||||||
|
Console.WriteLine(mfp + $" is {text}.");
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (string moduledll in moduledllsha512.Keys)
|
||||||
|
{
|
||||||
|
string server = moduledllsha512[moduledll];
|
||||||
|
if (plugindllsha512.TryGetValue(moduledll, out string? client) && client != "" && server == client)
|
||||||
|
{
|
||||||
|
Console.WriteLine(moduledll + $" is checked pass.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
83
Library/Tests/Old.cs
Normal file
83
Library/Tests/Old.cs
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Data;
|
||||||
|
using ConverterExample;
|
||||||
|
using Milimoe.FunGame.Core.Api.Utility;
|
||||||
|
using Milimoe.FunGame.Core.Entity;
|
||||||
|
using Milimoe.FunGame.Core.Library.Common.JsonConverter;
|
||||||
|
|
||||||
|
namespace Milimoe.FunGame.Testing.Tests
|
||||||
|
{
|
||||||
|
internal class Old
|
||||||
|
{
|
||||||
|
internal Old()
|
||||||
|
{
|
||||||
|
DataSet ds = new();
|
||||||
|
DataTable table = new("SampleTable1");
|
||||||
|
table.Columns.Add("Id", typeof(int));
|
||||||
|
table.Columns.Add("Name", typeof(string));
|
||||||
|
table.Columns.Add("Age", typeof(int));
|
||||||
|
table.Rows.Add(1, "John", 30);
|
||||||
|
table.Rows.Add(2, "Jane", 25);
|
||||||
|
table.Rows.Add(3, "Bob", 40);
|
||||||
|
ds.Tables.Add(table);
|
||||||
|
|
||||||
|
table = new("SampleTable2");
|
||||||
|
table.Columns.Add("Id", typeof(int));
|
||||||
|
table.Columns.Add("Name", typeof(string));
|
||||||
|
table.Columns.Add("Age", typeof(int));
|
||||||
|
table.Rows.Add(1, "John", 30);
|
||||||
|
table.Rows.Add(2, "Jane", 25);
|
||||||
|
table.Rows.Add(3, "Bob", 40);
|
||||||
|
ds.Tables.Add(table);
|
||||||
|
|
||||||
|
JsonTool JsonTool = new();
|
||||||
|
JsonTool.AddConverters(new System.Text.Json.Serialization.JsonConverter[] { new UserConverter(), new RoomConverter(), new PersonConverter(), new AddressConverter() });
|
||||||
|
|
||||||
|
Room r = Factory.GetRoom(1294367, "w5rtvh8".ToUpper(), DateTime.Now, Factory.GetUser(), Milimoe.FunGame.Core.Library.Constant.RoomType.Mix, "", "", Milimoe.FunGame.Core.Library.Constant.RoomState.Created);
|
||||||
|
User u = Factory.GetUser(1, "LUOLI", DateTime.Now, DateTime.Now, "LUOLI@66.COM", "QWQAQW");
|
||||||
|
|
||||||
|
Hashtable hashtable = new()
|
||||||
|
{
|
||||||
|
{ "table", table },
|
||||||
|
{ "room", r },
|
||||||
|
{ "user", u }
|
||||||
|
};
|
||||||
|
|
||||||
|
string json = JsonTool.GetString(hashtable);
|
||||||
|
|
||||||
|
Hashtable hashtable2 = JsonTool.GetObject<Hashtable>(json) ?? new();
|
||||||
|
|
||||||
|
DataTable table2 = JsonTool.GetObject<DataTable>(json) ?? new();
|
||||||
|
User u2 = JsonTool.GetObject<User>(hashtable2, "user") ?? Factory.GetUser();
|
||||||
|
Room r2 = JsonTool.GetObject<Room>(hashtable2, "room") ?? Factory.GetRoom();
|
||||||
|
|
||||||
|
table2.AsEnumerable().ToList().ForEach(row =>
|
||||||
|
{
|
||||||
|
Console.WriteLine("Id: " + row["Id"] + ", Name: " + row["Name"] + ", Age: " + row["Age"]);
|
||||||
|
});
|
||||||
|
|
||||||
|
Console.WriteLine(u2.Username + " 进入了 " + r2.Roomid + " 房间");
|
||||||
|
|
||||||
|
Person p = new()
|
||||||
|
{
|
||||||
|
Age = (int)r2.Id,
|
||||||
|
Name = u2.Username,
|
||||||
|
Address = new()
|
||||||
|
{
|
||||||
|
State = "呵呵州(Hehe State)",
|
||||||
|
City = "哈哈市(Haha City)"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
json = JsonTool.GetString(p);
|
||||||
|
|
||||||
|
Person p2 = JsonTool.GetObject<Person>(json) ?? new();
|
||||||
|
|
||||||
|
Console.WriteLine("My name is " + p2.Name + ", I am " + p2.Age + "-year-old. I live at " + p2.Address.State + " " + p2.Address.City);
|
||||||
|
Console.WriteLine("摆烂了86");
|
||||||
|
|
||||||
|
// 生成一对公钥秘钥
|
||||||
|
//TwoFactorAuthenticator.CreateSecretKey();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user