FunGame-Testing/Library/Tests/SkillJSONTest.cs
2024-10-23 00:10:44 +08:00

240 lines
8.9 KiB
C#

using Milimoe.FunGame.Core.Api.Utility;
using Milimoe.FunGame.Core.Entity;
using Milimoe.FunGame.Core.Library.Constant;
using Milimoe.FunGame.Testing.Effects;
using Milimoe.FunGame.Testing.Items;
using Milimoe.FunGame.Testing.Skills;
using MilimoeFunGame.Testing.Characters;
namespace Milimoe.FunGame.Testing.Tests
{
internal class SkillJSONTest
{
public SkillJSONTest()
{
//EntityModuleConfig<Character> config = new(nameof(SkillJSONTest), nameof(Character))
//{
// { "Oshima", OshimaCharacters.Oshima },
// { "Xinyin", OshimaCharacters.Xinyin },
// { "Yang", OshimaCharacters.Yang },
// { "NanGanyu", OshimaCharacters.NanGanyu },
// { "NiuNan", OshimaCharacters.NiuNan },
// { "Mayor", OshimaCharacters.Mayor },
// { "马猴烧酒", OshimaCharacters.马猴烧酒 },
// { "QingXiang", OshimaCharacters.QingXiang },
// { "QWQAQW", OshimaCharacters.QWQAQW },
// { "ColdBlue", OshimaCharacters.ColdBlue },
// { "绿拱门", OshimaCharacters.绿拱门 },
// { "QuDuoduo", OshimaCharacters.QuDuoduo }
//};
//config.SaveConfig();
EntityModuleConfig<Skill> config2 = new(nameof(SkillJSONTest), nameof(Skill));
Character c = Factory.GetCharacter();
List<Skill> listSkill = [];
listSkill.Add(new (c));
foreach (Skill s in listSkill)
{
config2.Add(s.Name, s);
}
config2.SaveConfig();
config2.LoadConfig();
foreach (string key in config2.Keys)
{
Skill prev = config2[key];
Skill? next = GetSkill(prev.Id, prev.Name, prev.SkillType);
if (next != null)
{
config2[key] = next;
}
Skill skill = config2[key];
foreach (Effect effect in skill.Effects.ToList())
{
Effect? newEffect = GetEffect(effect.Id, effect.Name, skill);
if (newEffect != null)
{
skill.Effects.Remove(effect);
skill.Effects.Add(newEffect);
}
}
}
Console.WriteLine(string.Join("\r\n", config2.Values));
EntityModuleConfig<Item> config3 = new(nameof(SkillJSONTest), nameof(Item)); ;
//EntityModuleConfig<Item> config3 = new(nameof(SkillJSONTest), nameof(Item))
//{
// { "攻击之爪10", new 攻击之爪10() }
//};
//config3.SaveConfig();
config3.LoadConfig();
foreach (string key in config3.Keys)
{
Item prev = config3[key];
Item? next = GetItem(prev.Id, prev.Name, prev.ItemType);
if (next != null)
{
prev.SetPropertyToItemModuleNew(next);
config3[key] = next;
}
Item item = config3[key];
HashSet<Skill> skills = item.Skills.Passives;
if (item.Skills.Active != null) skills.Add(item.Skills.Active);
foreach (Skill skill in skills.ToList())
{
Skill? newSkill = GetSkill(skill.Id, skill.Name, skill.SkillType);
if (newSkill != null)
{
if (newSkill.IsActive)
{
item.Skills.Active = newSkill;
}
else
{
item.Skills.Passives.Remove(skill);
item.Skills.Passives.Add(newSkill);
}
}
Skill s = newSkill ?? skill;
foreach (Effect effect in s.Effects.ToList())
{
Effect? newEffect = GetEffect(effect.Id, effect.Name, skill);
if (newEffect != null)
{
skill.Effects.Remove(effect);
skill.Effects.Add(newEffect);
}
}
}
}
Console.WriteLine(string.Join("\r\n", config3.Values));
}
public static Item? GetItem(long id, string name, ItemType type)
{
if (type == ItemType.Accessory)
{
switch ((AccessoryID)id)
{
case AccessoryID.10:
return new 10();
case AccessoryID.30:
return new 30();
case AccessoryID.50:
return new 50();
}
}
return null;
}
public static Skill? GetSkill(long id, string name, SkillType type)
{
if (type == SkillType.Magic)
{
switch ((MagicID)id)
{
case MagicID.:
return new ();
}
}
if (type == SkillType.Skill)
{
switch ((SkillID)id)
{
case SkillID.:
return new ();
}
}
if (type == SkillType.SuperSkill)
{
switch ((SuperSkillID)id)
{
case SuperSkillID.:
return new ();
case SuperSkillID.:
return new ();
case SuperSkillID.:
return new ();
case SuperSkillID.:
return new ();
case SuperSkillID.:
return new ();
case SuperSkillID.:
return new ();
case SuperSkillID.:
return new ();
case SuperSkillID.:
return new ();
case SuperSkillID.:
return new ();
case SuperSkillID.:
return new ();
case SuperSkillID.:
return new ();
case SuperSkillID.:
return new ();
}
}
if (type == SkillType.Passive)
{
switch ((PassiveID)id)
{
case PassiveID.META马:
return new META马();
case PassiveID.:
return new ();
case PassiveID.:
return new ();
case PassiveID.:
return new ();
case PassiveID.:
return new ();
case PassiveID.:
return new ();
case PassiveID.:
return new ();
case PassiveID.:
return new ();
case PassiveID.:
return new ();
case PassiveID.:
return new ();
case PassiveID.:
return new ();
case PassiveID.:
return new ();
}
switch ((ItemPassiveID)id)
{
case ItemPassiveID.:
return new ();
}
}
return null;
}
public static Effect? GetEffect(long id, string name, Skill skill)
{
switch (id)
{
case 8001:
return new ExATK(skill, null, null);
case 8002:
return new ExDEF(skill, null, null);
case 8003:
return new ExSTR(skill, null, null);
default:
break;
}
return null;
}
}
}