添加毕业礼包

This commit is contained in:
milimoe 2025-04-29 01:30:35 +08:00
parent 175682db38
commit c0477dfde5
Signed by: milimoe
GPG Key ID: 05D280912DA6C69E
6 changed files with 74 additions and 28 deletions

View File

@ -130,6 +130,33 @@ namespace Oshima.FunGame.OshimaModules.Items
}
}
public class : Item, .GiftBox
{
public override long Id => (long)GiftBoxID.;
public override string Name => "毕业礼包";
public override string Description => Skills.Active?.Description ?? "";
public override QualityType QualityType => QualityType.Gold;
public Dictionary<string, int> Gifts { get; set; } = [];
public (User? user = null, int remainUseTimes = 1) : base(ItemType.GiftBox)
{
User = user;
.Init(this, new()
{
{ General.GameplayEquilibriumConstant.InGameCurrency, 290000 },
{ General.GameplayEquilibriumConstant.InGameMaterial, 2000 },
{ new ().Name, 33 },
{ new ().Name, 12 },
{ new ().Name, 2 },
{ new ().Name, 76 },
{ new ().Name, 35 },
{ new ().Name, 10 },
{ new ().Name, 2 },
{ new ().Name, 164 }
}, remainUseTimes);
}
}
public class : Skill
{
public override long Id => (long)ItemActiveID.;

View File

@ -39,6 +39,7 @@
{
= 20001,
= 20002,
= 20003
= 20003,
= 20004
}
}

View File

@ -52,6 +52,7 @@ namespace Oshima.FunGame.OshimaModules
(long)GiftBoxID. => new (),
(long)GiftBoxID. => new (),
(long)GiftBoxID. => new (),
(long)GiftBoxID. => new (),
_ => null,
};
};

View File

@ -48,7 +48,7 @@ namespace Oshima.FunGame.OshimaServers.Service
FunGameConstant.Items.AddRange(exItems.Values.Where(i => (int)i.ItemType > 4));
FunGameConstant.Items.AddRange([new (), new (), new (), new (), new (), new (), new (), new (), new (), new (),
new (), new (), new (), new 1(), new 2(), new 3(), new 1(), new 2(), new 3(), new (), new (), new ()]);
new (), new (), new (), new 1(), new 2(), new 3(), new 1(), new 2(), new 3(), new (), new (), new (), new ()]);
FunGameConstant.AllItems.AddRange(FunGameConstant.Equipment);
FunGameConstant.AllItems.AddRange(FunGameConstant.Items);
@ -1116,6 +1116,10 @@ namespace Oshima.FunGame.OshimaServers.Service
{
msg += "\r\n" + "新春纳福,喜乐安康!!";
}
else if (item.Name == nameof())
{
msg += "\r\n" + "咦?!!啊咧!!!";
}
item.RemainUseTimes--;
if (item.RemainUseTimes < 0) item.RemainUseTimes = 0;
if (item.RemainUseTimes == 0)

View File

@ -5023,7 +5023,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
}
[HttpPost("creategiftbox")]
public string CreateGiftBox([FromQuery] long? uid = null, [FromQuery] string? name = null)
public string CreateGiftBox([FromQuery] long? uid = null, [FromQuery] string? name = null, [FromQuery] bool? checkRepeat = null)
{
long userid = uid ?? Convert.ToInt64("10" + Verification.CreateVerifyCode(VerifyCodeType.NumberVerifyCode, 11));
string itemName = name ?? "";
@ -5037,18 +5037,25 @@ namespace Oshima.FunGame.WebAPI.Controllers
if (FunGameConstant.AllItems.FirstOrDefault(i => i.Name == itemName) is Item item)
{
PluginConfig pc2 = new("giftbox", "giftbox");
pc2.LoadConfig();
List<long> list = [];
if (pc2.TryGetValue(itemName, out object? value) && value is List<long> tempList)
if (checkRepeat ?? false)
{
list = [.. tempList];
}
PluginConfig pc2 = new("giftbox", "giftbox");
pc2.LoadConfig();
if (list.Contains(user.Id))
{
return NetworkUtility.JsonSerialize($"你已经领取过这个礼包【{itemName}】啦,不能重复领取哦!");
List<long> list = [];
if (pc2.TryGetValue(itemName, out object? value) && value is List<long> tempList)
{
list = [.. tempList];
}
if (list.Contains(user.Id))
{
return $"你已经领取过这个礼包【{itemName}】啦,不能重复领取哦!";
}
list.Add(user.Id);
pc2.Add(itemName, list);
pc2.SaveConfig();
}
Item newItem = item.Copy();
@ -5058,24 +5065,20 @@ namespace Oshima.FunGame.WebAPI.Controllers
user.Inventory.Items.Add(newItem);
string msg = $"恭喜你获得礼包【{itemName}】一份!";
list.Add(user.Id);
pc2.Add(itemName, list);
pc2.SaveConfig();
user.LastTime = DateTime.Now;
pc.Add("user", user);
pc.SaveConfig();
return NetworkUtility.JsonSerialize(msg);
return msg;
}
else
{
return NetworkUtility.JsonSerialize("没有找到这个礼包,可能已经过期。");
return "没有找到这个礼包,可能已经过期。";
}
}
else
{
return NetworkUtility.JsonSerialize(noSaved);
return noSaved;
}
}
@ -5168,9 +5171,9 @@ namespace Oshima.FunGame.WebAPI.Controllers
int halfdown = user.Inventory.Characters.Count(c => (c.HP / c.MaxHP) < 0.5 && c.HP > 0);
int halfup = user.Inventory.Characters.Count(c => (c.HP / c.MaxHP) >= 0.5 && c.HP != c.MaxHP);
double deadNeed = 10000 * dead;
double halfdownNeed = 6000 * halfdown;
double halfupNeed = 2000 * halfup;
double deadNeed = 3000 * dead;
double halfdownNeed = 1500 * halfdown;
double halfupNeed = 500 * halfup;
double total = deadNeed + halfdownNeed + halfupNeed;
if (total == 0)
@ -5197,9 +5200,9 @@ namespace Oshima.FunGame.WebAPI.Controllers
}
msg += $"{dead} 个死亡角色,{halfdown} 个 50% 以下的角色,{halfup} 个 50% 以上的角色)\r\n" +
$"收费标准:\r\n10000 {General.GameplayEquilibriumConstant.InGameCurrency} / 死亡角色\r\n" +
$"6000 {General.GameplayEquilibriumConstant.InGameCurrency} / 50% 生命值以下的角色\r\n" +
$"2000 {General.GameplayEquilibriumConstant.InGameCurrency} / 50% 生命值以上的角色";
$"收费标准:\r\n3000 {General.GameplayEquilibriumConstant.InGameCurrency} / 死亡角色\r\n" +
$"1500 {General.GameplayEquilibriumConstant.InGameCurrency} / 50% 生命值以下的角色\r\n" +
$"500 {General.GameplayEquilibriumConstant.InGameCurrency} / 50% 生命值以上的角色";
return msg;
}
@ -5241,9 +5244,9 @@ namespace Oshima.FunGame.WebAPI.Controllers
{
FunGameService.Reload();
FunGameSimulation.InitFunGameSimulation();
return NetworkUtility.JsonSerialize("FunGame已重新加载。");
return "FunGame已重新加载。";
}
return NetworkUtility.JsonSerialize("提供的参数不正确。");
return "提供的参数不正确。";
}
}
}

View File

@ -2005,6 +2005,16 @@ namespace Oshima.FunGame.WebAPI.Services
return result;
}
if (e.Detail == "毕业礼包")
{
string msg = Controller.CreateGiftBox(uid, "毕业礼包");
if (msg != "")
{
await SendAsync(e, "毕业礼包", string.Join("\r\n", msg));
}
return result;
}
if (uid == GeneralSettings.Master && e.Detail.StartsWith("重载FunGame", StringComparison.CurrentCultureIgnoreCase))
{
string msg = Controller.Relaod(uid);