添加更多内容

This commit is contained in:
milimoe 2024-11-18 22:10:24 +08:00
parent 91f092fa31
commit ea4100e518
Signed by: milimoe
GPG Key ID: 05D280912DA6C69E
4 changed files with 676 additions and 255 deletions

View File

@ -7,7 +7,6 @@ using Milimoe.FunGame.Core.Library.Constant;
using Oshima.Core.Configs;
using Oshima.Core.Models;
using Oshima.Core.Utils;
using Oshima.FunGame.OshimaModules.Skills;
namespace Oshima.Core.Controllers
{
@ -16,6 +15,8 @@ namespace Oshima.Core.Controllers
public class FunGameController(ILogger<FunGameController> logger) : ControllerBase
{
private readonly ILogger<FunGameController> _logger = logger;
private const int drawCardReduce = 2000;
private const int drawCardReduce_Material = 10;
private const string noSaved = "你还没有创建存档!请发送【创建存档】创建。";
[HttpGet("test")]
@ -219,193 +220,14 @@ namespace Oshima.Core.Controllers
}
[HttpGet("cjs")]
public string GetCharacterIntroduce([FromQuery] int? id = null)
public string GetCharacterInfo([FromQuery] int? id = null)
{
if (id != null && id > 0 && id <= FunGameService.Characters.Count)
{
Character c = FunGameService.Characters[Convert.ToInt32(id) - 1].Copy();
c.Level = General.GameplayEquilibriumConstant.MaxLevel;
c.NormalAttack.Level = General.GameplayEquilibriumConstant.MaxNormalAttackLevel;
if (id == 1)
{
Skill META马 = new META马(c)
{
Level = 1
};
c.Skills.Add(META马);
Skill = new (c)
{
Level = General.GameplayEquilibriumConstant.MaxMagicLevel
};
c.Skills.Add();
}
if (id == 2)
{
Skill = new (c)
{
Level = 1
};
c.Skills.Add();
Skill = new (c)
{
Level = General.GameplayEquilibriumConstant.MaxSkillLevel
};
c.Skills.Add();
}
if (id == 3)
{
Skill = new (c)
{
Level = 1
};
c.Skills.Add();
Skill = new (c)
{
Level = General.GameplayEquilibriumConstant.MaxSkillLevel
};
c.Skills.Add();
}
if (id == 4)
{
Skill = new (c)
{
Level = 1
};
c.Skills.Add();
Skill = new (c)
{
Level = General.GameplayEquilibriumConstant.MaxSkillLevel
};
c.Skills.Add();
}
if (id == 5)
{
Skill = new (c)
{
Level = 1
};
c.Skills.Add();
Skill = new (c)
{
Level = General.GameplayEquilibriumConstant.MaxSkillLevel
};
c.Skills.Add();
}
if (id == 6)
{
Skill = new (c)
{
Level = 1
};
c.Skills.Add();
Skill = new (c)
{
Level = General.GameplayEquilibriumConstant.MaxSkillLevel
};
c.Skills.Add();
}
if (id == 7)
{
Skill = new (c)
{
Level = 1
};
c.Skills.Add();
Skill = new (c)
{
Level = General.GameplayEquilibriumConstant.MaxSkillLevel
};
c.Skills.Add();
}
if (id == 8)
{
Skill = new (c)
{
Level = 1
};
c.Skills.Add();
Skill = new (c)
{
Level = General.GameplayEquilibriumConstant.MaxSkillLevel
};
c.Skills.Add();
}
if (id == 9)
{
Skill = new (c)
{
Level = 1
};
c.Skills.Add();
Skill = new (c)
{
Level = General.GameplayEquilibriumConstant.MaxSkillLevel
};
c.Skills.Add();
}
if (id == 10)
{
Skill = new (c)
{
Level = 1
};
c.Skills.Add();
Skill = new (c)
{
Level = General.GameplayEquilibriumConstant.MaxSkillLevel
};
c.Skills.Add();
}
if (id == 11)
{
Skill = new (c)
{
Level = 1
};
c.Skills.Add();
Skill = new (c)
{
Level = General.GameplayEquilibriumConstant.MaxSkillLevel
};
c.Skills.Add();
}
if (id == 12)
{
Skill = new (c)
{
Level = 1
};
c.Skills.Add();
Skill = new (c)
{
Level = General.GameplayEquilibriumConstant.MaxSkillLevel
};
c.Skills.Add();
}
FunGameService.AddCharacterSkills(c, 1, General.GameplayEquilibriumConstant.MaxSkillLevel, General.GameplayEquilibriumConstant.MaxSuperSkillLevel);
return NetworkUtility.JsonSerialize(c.GetInfo().Trim());
}
@ -487,7 +309,7 @@ namespace Oshima.Core.Controllers
if (pc.Count == 0)
{
User user = Factory.GetUser(userid, username, DateTime.Now, DateTime.Now, userid + "@qq.com", username);
user.Inventory.Credits = 100;
user.Inventory.Credits = 5000;
pc.Add("user", user);
pc.SaveConfig();
return NetworkUtility.JsonSerialize($"创建存档成功!你的用户名是【{username}】。");
@ -549,8 +371,7 @@ namespace Oshima.Core.Controllers
int characterCount = 0;
int itemCount = 0;
int characterSequence = characters.Take((showPage - 1) * 10).Count();
int itemSequence = items.Take((showPage - 1) * 10).Count() - characterSequence;
int prevSequence = dict.Take((showPage - 1) * 10).Count();
foreach (int index in seq)
{
@ -564,7 +385,7 @@ namespace Oshima.Core.Controllers
showCharacter = false;
list.Add("======= 角色 =======");
}
str = $"{characterSequence + characterCount}. {character.ToStringWithLevelWithOutUser()}";
str = $"{prevSequence + characterCount}. {character.ToStringWithLevelWithOutUser()}";
}
if (obj is Item item)
{
@ -574,7 +395,7 @@ namespace Oshima.Core.Controllers
showItem = false;
list.Add("======= 物品 =======");
}
str = $"{itemSequence + itemCount}. [{ItemSet.GetQualityTypeName(item.QualityType)}|{ItemSet.GetItemTypeName(item.ItemType)}] {item.Name}\r\n";
str = $"{index - (characterCount > 0 ? prevSequence + characterCount : characters.Count)}. [{ItemSet.GetQualityTypeName(item.QualityType)}|{ItemSet.GetItemTypeName(item.ItemType)}] {item.Name}\r\n";
str += $"{item.ToStringInventory(false).Trim()}";
}
list.Add(str);
@ -593,9 +414,93 @@ namespace Oshima.Core.Controllers
}
return list;
}
[HttpPost("ckkc3")]
public List<string> GetInventoryInfo3([FromQuery] long? qq = null, [FromQuery] int? page = null, [FromQuery] int? order = null, [FromQuery] int? orderqty = null)
{
long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11));
int showPage = page ?? 1;
if (showPage <= 0) showPage = 1;
PluginConfig pc = new("saved", userid.ToString());
pc.LoadConfig();
List<string> list = [];
if (pc.Count > 0)
{
User user = FunGameService.GetUser(pc);
list.Add($"☆★☆ {user.Inventory.Name} ☆★☆");
list.Add($"{General.GameplayEquilibriumConstant.InGameCurrency}{user.Inventory.Credits:0.00}");
list.Add($"{General.GameplayEquilibriumConstant.InGameMaterial}{user.Inventory.Materials:0.00}");
List<Item> items = [.. user.Inventory.Items];
Dictionary<string, List<Item>> itemCategory = [];
foreach (Item item in items)
{
if (!itemCategory.TryAdd(item.GetIdName(), [item]))
{
itemCategory[item.GetIdName()].Add(item);
}
}
if (orderqty != 0)
{
IOrderedEnumerable<KeyValuePair<string, List<Item>>>? orderEnum = null;
if (order != 0)
{
orderEnum = order switch
{
1 => itemCategory.OrderBy(kv => kv.Value.FirstOrDefault()?.QualityType ?? 0),
2 => itemCategory.OrderByDescending(kv => kv.Value.FirstOrDefault()?.QualityType ?? 0),
3 => itemCategory.OrderBy(kv => kv.Value.FirstOrDefault()?.ItemType ?? 0),
4 => itemCategory.OrderByDescending(kv => kv.Value.FirstOrDefault()?.ItemType ?? 0),
_ => itemCategory.OrderBy(kv => 0)
};
}
if (orderEnum != null)
{
if (orderqty == 1)
{
orderEnum = orderEnum.ThenBy(kv => kv.Value.Count);
}
else
{
orderEnum = orderEnum.ThenByDescending(kv => kv.Value.Count);
}
itemCategory = orderEnum.ToDictionary();
}
}
int maxPage = (int)Math.Ceiling((double)itemCategory.Count / 10);
if (showPage <= maxPage)
{
List<string> keys = [.. FunGameService.GetPage(itemCategory.Keys, showPage, 10)];
int itemCount = 0;
list.Add("======= 物品 =======");
foreach (string key in keys)
{
itemCount++;
List<Item> objs = itemCategory[key];
string str = $"{itemCount}. [{ItemSet.GetQualityTypeName(objs[0].QualityType)}|{ItemSet.GetItemTypeName(objs[0].ItemType)}] {objs[0].Name}\r\n";
str += $"物品序号:{string.Join("", objs.Select(i => items.IndexOf(i) + 1))}\r\n";
str += $"拥有数量:{objs.Count}(可出售数量:{objs.Count(i => i.IsSellable)},可交易数量:{objs.Count(i => i.IsTradable)}";
list.Add(str);
}
list.Add($"页数:{showPage} / {maxPage}");
}
else
{
list.Add($"没有这么多页!当前总页数为 {maxPage},但你请求的是第 {showPage} 页。");
}
}
else
{
list.Add(noSaved);
}
return list;
}
[HttpPost("ck")]
public string DrawCards([FromQuery] long? qq = null)
public string DrawCard([FromQuery] long? qq = null)
{
long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11));
@ -606,8 +511,8 @@ namespace Oshima.Core.Controllers
{
User user = FunGameService.GetUser(pc);
int reduce = 1;
if (user.Inventory.Credits > 0)
int reduce = drawCardReduce;
if (user.Inventory.Credits >= reduce)
{
user.Inventory.Credits -= reduce;
}
@ -619,77 +524,13 @@ namespace Oshima.Core.Controllers
double dice = Random.Shared.NextDouble();
if (dice > 0.8)
{
string msg = $"消耗 {reduce} {General.GameplayEquilibriumConstant.InGameCurrency},恭喜你抽到了:";
int r = Random.Shared.Next(7);
switch (r)
{
case 1:
Item[] = FunGameService.Equipment.Where(i => i.Id.ToString().StartsWith("11")).ToArray();
Item a = [Random.Shared.Next(.Length)].Copy();
user.Inventory.Items.Add(a);
msg += ItemSet.GetQualityTypeName(a.QualityType) + ItemSet.GetItemTypeName(a.ItemType) + "【" + a.Name + "】!\r\n" + a.Description;
break;
case 2:
Item[] = FunGameService.Equipment.Where(i => i.Id.ToString().StartsWith("12")).ToArray();
Item b = [Random.Shared.Next(.Length)].Copy();
user.Inventory.Items.Add(b);
msg += ItemSet.GetQualityTypeName(b.QualityType) + ItemSet.GetItemTypeName(b.ItemType) + "【" + b.Name + "】!\r\n" + b.Description;
break;
case 3:
Item[] = FunGameService.Equipment.Where(i => i.Id.ToString().StartsWith("13")).ToArray();
Item c = [Random.Shared.Next(.Length)].Copy();
user.Inventory.Items.Add(c);
msg += ItemSet.GetQualityTypeName(c.QualityType) + ItemSet.GetItemTypeName(c.ItemType) + "【" + c.Name + "】!\r\n" + c.Description;
break;
case 4:
Item[] = FunGameService.Equipment.Where(i => i.Id.ToString().StartsWith("14")).ToArray();
Item d = [Random.Shared.Next(.Length)].Copy();
user.Inventory.Items.Add(d);
msg += ItemSet.GetQualityTypeName(d.QualityType) + ItemSet.GetItemTypeName(d.ItemType) + "【" + d.Name + "】!\r\n" + d.Description;
break;
case 5:
Character character = FunGameService.Characters[Random.Shared.Next(FunGameService.Characters.Count)].Copy();
if (user.Inventory.Characters.Any(c => c.Id == character.Id))
{
user.Inventory.Materials += 50;
msg += "【" + character.ToStringWithOutUser() + "】!\r\n但是你已经拥有此角色转换为【50】" + General.GameplayEquilibriumConstant.InGameMaterial + "";
}
else
{
user.Inventory.Characters.Add(character);
msg += "【" + character.ToStringWithOutUser() + "】!\r\n输入【查角色" + character.Id + "】可以获取此角色完整信息。";
}
break;
case 6:
Item mfk = FunGameService.GenerateMagicCard();
user.Inventory.Items.Add(mfk);
msg += ItemSet.GetQualityTypeName(mfk.QualityType) + ItemSet.GetItemTypeName(mfk.ItemType) + "【" + mfk.Name + "】!\r\n" + mfk.Description;
break;
case 0:
default:
Item? mfkb = FunGameService.GenerateMagicCardPack(3);
if (mfkb != null)
{
mfkb.IsTradable = false;
mfkb.NextTradableTime = DateTimeUtility.GetTradableTime();
user.Inventory.Items.Add(mfkb);
msg += ItemSet.GetQualityTypeName(mfkb.QualityType) + ItemSet.GetItemTypeName(mfkb.ItemType) + "【" + mfkb.Name + "】!\r\n" + mfkb.Description;
}
break;
}
string msg = FunGameService.GetDrawCardResult(reduce, user);
pc.Add("user", user);
pc.SaveConfig();
return NetworkUtility.JsonSerialize(msg);
}
else
{
pc.Add("user", user);
pc.SaveConfig();
return NetworkUtility.JsonSerialize($"消耗 {reduce} {General.GameplayEquilibriumConstant.InGameCurrency},你什么也没抽中……");
}
@ -699,6 +540,243 @@ namespace Oshima.Core.Controllers
return NetworkUtility.JsonSerialize(noSaved);
}
}
[HttpPost("ck10")]
public List<string> DrawCards([FromQuery] long? qq = null)
{
long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11));
PluginConfig pc = new("saved", userid.ToString());
pc.LoadConfig();
if (pc.Count > 0)
{
User user = FunGameService.GetUser(pc);
int reduce = drawCardReduce * 10;
if (user.Inventory.Credits >= reduce)
{
user.Inventory.Credits -= reduce;
}
else
{
return [$"你的{General.GameplayEquilibriumConstant.InGameCurrency}不足 {reduce} 呢,无法十连抽卡!"];
}
List<string> result = [$"消耗 {reduce} {General.GameplayEquilibriumConstant.InGameCurrency},恭喜你抽到了:"];
int count = 0;
for (int i = 0; i < 10; i++)
{
double dice = Random.Shared.NextDouble();
if (dice > 0.8)
{
count++;
result.Add(FunGameService.GetDrawCardResult(reduce, user, true, count));
}
}
if (result.Count == 1)
{
result[0] = $"消耗 {reduce} {General.GameplayEquilibriumConstant.InGameCurrency},你什么也没抽中……";
}
pc.Add("user", user);
pc.SaveConfig();
return result;
}
else
{
return [noSaved];
}
}
[HttpPost("clck")]
public string DrawCard_Material([FromQuery] long? qq = null)
{
long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11));
PluginConfig pc = new("saved", userid.ToString());
pc.LoadConfig();
if (pc.Count > 0)
{
User user = FunGameService.GetUser(pc);
int reduce = drawCardReduce_Material;
if (user.Inventory.Materials >= reduce)
{
user.Inventory.Materials -= reduce;
}
else
{
return NetworkUtility.JsonSerialize($"你的{General.GameplayEquilibriumConstant.InGameMaterial}不足 {reduce} 呢,无法抽卡!");
}
double dice = Random.Shared.NextDouble();
if (dice > 0.8)
{
string msg = FunGameService.GetDrawCardResult(reduce, user);
pc.Add("user", user);
pc.SaveConfig();
return NetworkUtility.JsonSerialize(msg);
}
else
{
pc.SaveConfig();
return NetworkUtility.JsonSerialize($"消耗 {reduce} {General.GameplayEquilibriumConstant.InGameMaterial},你什么也没抽中……");
}
}
else
{
return NetworkUtility.JsonSerialize(noSaved);
}
}
[HttpPost("clck10")]
public List<string> DrawCards_Material([FromQuery] long? qq = null)
{
long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11));
PluginConfig pc = new("saved", userid.ToString());
pc.LoadConfig();
if (pc.Count > 0)
{
User user = FunGameService.GetUser(pc);
int reduce = drawCardReduce_Material * 10;
if (user.Inventory.Materials >= reduce)
{
user.Inventory.Materials -= reduce;
}
else
{
return [$"你的{General.GameplayEquilibriumConstant.InGameMaterial}不足 {reduce} 呢,无法十连抽卡!"];
}
List<string> result = [$"消耗 {reduce} {General.GameplayEquilibriumConstant.InGameMaterial},恭喜你抽到了:"];
int count = 0;
for (int i = 0; i < 10; i++)
{
double dice = Random.Shared.NextDouble();
if (dice > 0.8)
{
count++;
result.Add(FunGameService.GetDrawCardResult(reduce, user, true, count));
}
}
if (result.Count == 1)
{
result[0] = $"消耗 {reduce} {General.GameplayEquilibriumConstant.InGameMaterial},你什么也没抽中……";
}
pc.Add("user", user);
pc.SaveConfig();
return result;
}
else
{
return [noSaved];
}
}
[HttpPost("dhjb")]
public string ExchangeCredits([FromQuery] long? qq = null, [FromQuery] double? materials = null)
{
long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11));
double useMaterials = materials ?? 0;
PluginConfig pc = new("saved", userid.ToString());
pc.LoadConfig();
if (pc.Count > 0)
{
User user = FunGameService.GetUser(pc);
int reduce = useMaterials > 0 && useMaterials > 10 ? (int)useMaterials : 10;
if (reduce % 10 != 0 && reduce > reduce % 10)
{
reduce -= reduce % 10;
}
else
{
return NetworkUtility.JsonSerialize($"你的{General.GameplayEquilibriumConstant.InGameMaterial}不足 {reduce},兑换失败!");
}
if (user.Inventory.Materials >= reduce)
{
int reward = reduce / 10 * 2000;
user.Inventory.Credits += reward;
user.Inventory.Materials -= reduce;
pc.Add("user", user);
pc.SaveConfig();
return NetworkUtility.JsonSerialize($"兑换成功!你消耗了 {reduce} {General.GameplayEquilibriumConstant.InGameMaterial},增加了 {reward} {General.GameplayEquilibriumConstant.InGameCurrency}");
}
else
{
return NetworkUtility.JsonSerialize($"你的{General.GameplayEquilibriumConstant.InGameMaterial}不足 {reduce},兑换失败!");
}
}
else
{
return NetworkUtility.JsonSerialize(noSaved);
}
}
[HttpPost("cckjs")]
public string GetCharacterInfoFromInventory([FromQuery] long? qq = null, [FromQuery] int? index = null)
{
long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11));
int itemIndex = index ?? 0;
PluginConfig pc = new("saved", userid.ToString());
pc.LoadConfig();
if (pc.Count > 0)
{
User user = FunGameService.GetUser(pc);
if (itemIndex > 0 && itemIndex <= user.Inventory.Characters.Count)
{
Character character = user.Inventory.Characters.ToList()[itemIndex - 1];
return NetworkUtility.JsonSerialize($"这是你库存中序号为 {itemIndex} 的角色详细信息:\r\n{character.GetInfo().Trim()}");
}
else
{
return NetworkUtility.JsonSerialize($"没有找到与这个序号相对应的角色!");
}
}
else
{
return NetworkUtility.JsonSerialize(noSaved);
}
}
[HttpPost("cckwp")]
public string GetItemInfoFromInventory([FromQuery] long? qq = null, [FromQuery] int? index = null)
{
long userid = qq ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11));
int itemIndex = index ?? 0;
PluginConfig pc = new("saved", userid.ToString());
pc.LoadConfig();
if (pc.Count > 0)
{
User user = FunGameService.GetUser(pc);
if (itemIndex > 0 && itemIndex <= user.Inventory.Items.Count)
{
Item item = user.Inventory.Items.ToList()[itemIndex - 1];
return NetworkUtility.JsonSerialize($"这是你库存中序号为 {itemIndex} 的物品详细信息:\r\n{item.ToStringInventory(true).Trim()}");
}
else
{
return NetworkUtility.JsonSerialize($"没有找到与这个序号相对应的物品!");
}
}
else
{
return NetworkUtility.JsonSerialize(noSaved);
}
}
[HttpGet("reload")]
public string Relaod([FromQuery] long? master = null)

View File

@ -82,6 +82,7 @@ namespace Oshima.Core.WebAPI
check9 = false;
Console.ForegroundColor = ConsoleColor.Magenta;
Console.WriteLine("\r重置物品交易冷却时间。");
await FunGameService.AllowSellAndTrade();
Console.ForegroundColor = ConsoleColor.Gray;
Console.Write("\r> ");
}
@ -94,6 +95,7 @@ namespace Oshima.Core.WebAPI
check15 = false;
Console.ForegroundColor = ConsoleColor.Magenta;
Console.WriteLine("\r重置物品交易冷却时间。");
await FunGameService.AllowSellAndTrade();
Console.ForegroundColor = ConsoleColor.Gray;
Console.Write("\r> ");
}

View File

@ -480,5 +480,345 @@ namespace Oshima.Core.Utils
{
return list.Skip((showPage - 1) * pageSize).Take(pageSize).ToList();
}
public static string GetDrawCardResult(int reduce, User user, bool isMulti = false, int multiCount = 1)
{
string msg = "";
if (!isMulti)
{
msg = $"消耗 {reduce} {General.GameplayEquilibriumConstant.InGameCurrency},恭喜你抽到了:";
}
int r = Random.Shared.Next(7);
double q = Random.Shared.NextDouble() * 100;
QualityType type = q switch
{
<= 37.21 => QualityType.White,
<= 37.21 + 27.94 => QualityType.Green,
<= 37.21 + 27.94 + 16.68 => QualityType.Blue,
<= 37.21 + 27.94 + 16.68 + 9.79 => QualityType.Purple,
<= 37.21 + 27.94 + 16.68 + 9.79 + 5.05 => QualityType.Orange,
<= 37.21 + 27.94 + 16.68 + 9.79 + 5.05 + 2.73 => QualityType.Red,
_ => QualityType.Gold
};
switch (r)
{
case 1:
if ((int)type > (int)QualityType.Orange) type = QualityType.Orange;
Item[] = Equipment.Where(i => i.Id.ToString().StartsWith("11") && i.QualityType == type).ToArray();
Item a = [Random.Shared.Next(.Length)].Copy();
SetSellAndTradeTime(a);
user.Inventory.Items.Add(a);
msg += ItemSet.GetQualityTypeName(a.QualityType) + ItemSet.GetItemTypeName(a.ItemType) + "【" + a.Name + "】!\r\n" + a.Description;
break;
case 2:
if ((int)type > (int)QualityType.Green) type = QualityType.Green;
Item[] = Equipment.Where(i => i.Id.ToString().StartsWith("12") && i.QualityType == type).ToArray();
Item b = [Random.Shared.Next(.Length)].Copy();
SetSellAndTradeTime(b);
user.Inventory.Items.Add(b);
msg += ItemSet.GetQualityTypeName(b.QualityType) + ItemSet.GetItemTypeName(b.ItemType) + "【" + b.Name + "】!\r\n" + b.Description;
break;
case 3:
if ((int)type > (int)QualityType.Green) type = QualityType.Green;
Item[] = Equipment.Where(i => i.Id.ToString().StartsWith("13") && i.QualityType == type).ToArray();
Item c = [Random.Shared.Next(.Length)].Copy();
SetSellAndTradeTime(c);
user.Inventory.Items.Add(c);
msg += ItemSet.GetQualityTypeName(c.QualityType) + ItemSet.GetItemTypeName(c.ItemType) + "【" + c.Name + "】!\r\n" + c.Description;
break;
case 4:
if ((int)type > (int)QualityType.Purple) type = QualityType.Purple;
Item[] = Equipment.Where(i => i.Id.ToString().StartsWith("14") && i.QualityType == type).ToArray();
Item d = [Random.Shared.Next(.Length)].Copy();
SetSellAndTradeTime(d);
user.Inventory.Items.Add(d);
msg += ItemSet.GetQualityTypeName(d.QualityType) + ItemSet.GetItemTypeName(d.ItemType) + "【" + d.Name + "】!\r\n" + d.Description;
break;
case 5:
Character character = Characters[Random.Shared.Next(Characters.Count)].Copy();
AddCharacterSkills(character, 1, 0, 0);
if (user.Inventory.Characters.Any(c => c.Id == character.Id))
{
user.Inventory.Materials += 50;
msg += "【" + character.ToStringWithOutUser() + "】!\r\n但是你已经拥有此角色转换为【50】" + General.GameplayEquilibriumConstant.InGameMaterial + "";
}
else
{
user.Inventory.Characters.Add(character);
msg += "【" + character.ToStringWithOutUser() + "】!\r\n输入【查角色" + character.Id + "】可以获取此角色完整信息。";
}
break;
case 6:
Item mfk = GenerateMagicCard(type);
SetSellAndTradeTime(mfk);
user.Inventory.Items.Add(mfk);
msg += ItemSet.GetQualityTypeName(mfk.QualityType) + ItemSet.GetItemTypeName(mfk.ItemType) + "【" + mfk.Name + "】!\r\n" + mfk.Description;
break;
case 0:
default:
Item? mfkb = GenerateMagicCardPack(3, type);
if (mfkb != null)
{
SetSellAndTradeTime(mfkb);
user.Inventory.Items.Add(mfkb);
msg += ItemSet.GetQualityTypeName(mfkb.QualityType) + ItemSet.GetItemTypeName(mfkb.ItemType) + "【" + mfkb.Name + "】!\r\n" + mfkb.Description;
}
break;
}
if (isMulti) msg = $"{multiCount}. \r\n{msg}";
return msg;
}
public static void SetSellAndTradeTime(Item item, bool sell = false, bool trade = true, DateTime? nextSell = null, DateTime? nextTrade = null)
{
if (sell)
{
item.IsSellable = false;
item.NextSellableTime = DateTimeUtility.GetTradableTime(nextSell);
}
if (trade)
{
item.IsTradable = false;
item.NextTradableTime = DateTimeUtility.GetTradableTime(nextTrade);
}
}
public static async Task<string> AllowSellAndTrade()
{
string msg;
string dpath = $@"{AppDomain.CurrentDomain.BaseDirectory}configs/saved";
if (Directory.Exists(dpath))
{
string[] jsonFiles = Directory.GetFiles(dpath, "*.json");
List<Task> tasks = [];
foreach (string file in jsonFiles)
{
tasks.Add(Task.Run(() =>
{
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(file);
PluginConfig pc = new("saved", fileNameWithoutExtension);
pc.LoadConfig();
if (pc.Count > 0)
{
User user = GetUser(pc);
foreach (Item item in user.Inventory.Items)
{
if (!item.IsSellable && item.NextSellableTime != DateTime.MinValue && DateTime.Now >= item.NextSellableTime)
{
item.NextSellableTime = DateTime.MinValue;
item.IsSellable = true;
}
if (!item.IsTradable && item.NextTradableTime != DateTime.MinValue && DateTime.Now >= item.NextTradableTime)
{
item.NextTradableTime = DateTime.MinValue;
item.IsTradable = true;
}
}
pc.Add("user", user);
pc.SaveConfig();
}
}));
}
await Task.WhenAll(tasks);
msg = "已清理所有玩家的物品交易时间。";
}
else
{
msg = "存档目录不存在,无法清理交易时间。";
}
return msg;
}
public static void AddCharacterSkills(Character character, int passiveLevel, int skillLevel, int superLevel)
{
long id = character.Id;
Math.Sign(skillLevel);
if (id == 1)
{
Skill META马 = new META马(character)
{
Level = passiveLevel
};
character.Skills.Add(META马);
Skill = new (character)
{
Level = superLevel
};
character.Skills.Add();
}
if (id == 2)
{
Skill = new (character)
{
Level = passiveLevel
};
character.Skills.Add();
Skill = new (character)
{
Level = superLevel
};
character.Skills.Add();
}
if (id == 3)
{
Skill = new (character)
{
Level = passiveLevel
};
character.Skills.Add();
Skill = new (character)
{
Level = superLevel
};
character.Skills.Add();
}
if (id == 4)
{
Skill = new (character)
{
Level = passiveLevel
};
character.Skills.Add();
Skill = new (character)
{
Level = superLevel
};
character.Skills.Add();
}
if (id == 5)
{
Skill = new (character)
{
Level = passiveLevel
};
character.Skills.Add();
Skill = new (character)
{
Level = superLevel
};
character.Skills.Add();
}
if (id == 6)
{
Skill = new (character)
{
Level = passiveLevel
};
character.Skills.Add();
Skill = new (character)
{
Level = superLevel
};
character.Skills.Add();
}
if (id == 7)
{
Skill = new (character)
{
Level = passiveLevel
};
character.Skills.Add();
Skill = new (character)
{
Level = superLevel
};
character.Skills.Add();
}
if (id == 8)
{
Skill = new (character)
{
Level = passiveLevel
};
character.Skills.Add();
Skill = new (character)
{
Level = superLevel
};
character.Skills.Add();
}
if (id == 9)
{
Skill = new (character)
{
Level = passiveLevel
};
character.Skills.Add();
Skill = new (character)
{
Level = superLevel
};
character.Skills.Add();
}
if (id == 10)
{
Skill = new (character)
{
Level = passiveLevel
};
character.Skills.Add();
Skill = new (character)
{
Level = superLevel
};
character.Skills.Add();
}
if (id == 11)
{
Skill = new (character)
{
Level = passiveLevel
};
character.Skills.Add();
Skill = new (character)
{
Level = superLevel
};
character.Skills.Add();
}
if (id == 12)
{
Skill = new (character)
{
Level = passiveLevel
};
character.Skills.Add();
Skill = new (character)
{
Level = superLevel
};
character.Skills.Add();
}
}
}
}

View File

@ -50,6 +50,7 @@ namespace Oshima.FunGame.OshimaModules.Skills
if (enemy == Skill.Character && damageResult != DamageResult.Evaded)
{
WriteLine($"[ {enemy} ] 发动了绝对领域,巧妙的化解了此伤害!");
isEvaded = true;
return 0;
}
return 0;