新技能、秘境挑战优化

This commit is contained in:
milimoe 2025-10-31 19:48:03 +08:00
parent d198718697
commit 34501cf7a8
Signed by: milimoe
GPG Key ID: 9554D37E4B8991D0
7 changed files with 154 additions and 61 deletions

View File

@ -128,6 +128,7 @@ namespace Oshima.FunGame.OshimaModules
(long)PassiveID. => new (), (long)PassiveID. => new (),
(long)PassiveID. => new (), (long)PassiveID. => new (),
(long)PassiveID. => new (), (long)PassiveID. => new (),
(long)PassiveID. => new (),
(long)ItemPassiveID. => new (), (long)ItemPassiveID. => new (),
(long)ItemActiveID. => new (), (long)ItemActiveID. => new (),
(long)ItemActiveID. => new (), (long)ItemActiveID. => new (),

View File

@ -26,7 +26,7 @@ namespace Oshima.FunGame.OshimaModules.Skills
{ {
public override long Id => Skill.Id; public override long Id => Skill.Id;
public override string Name => Skill.Name; public override string Name => Skill.Name;
public override string Description => $"连续3次普通攻击同一目标时造成额外的 {额外伤害系数 * 100:0.##}% 伤害并使其进入易损状态,后续承受伤害提升 {易损伤害提升百分比 * 100:0.##}%,持续 {易损持续时间:0.##} {GameplayEquilibriumConstant.InGameTime}。"; public override string Description => $"连续 3 次普通攻击同一目标时,造成额外的 {额外伤害系数 * 100:0.##}% 伤害并使其进入易损状态,后续承受伤害提升 {易损伤害提升百分比 * 100:0.##}%,持续 {易损持续时间:0.##} {GameplayEquilibriumConstant.InGameTime}。";
private double => Skill.Character != null ? 0.15 + Skill.Character.Level * 0.004 : 0.15; private double => Skill.Character != null ? 0.15 + Skill.Character.Level * 0.004 : 0.15;
private double => Skill.Character != null ? 0.06 + Skill.Character.Level * 0.005 : 0.06; private double => Skill.Character != null ? 0.06 + Skill.Character.Level * 0.005 : 0.06;

View File

@ -0,0 +1,71 @@
using Milimoe.FunGame.Core.Entity;
using Milimoe.FunGame.Core.Library.Constant;
namespace Oshima.FunGame.OshimaModules.Skills
{
public class : Skill
{
public override long Id => (long)PassiveID.;
public override string Name => "黑暗收割";
public override string Description => Effects.Count > 0 ? Effects.First().Description : "";
public override string DispelDescription => Effects.Count > 0 ? Effects.First().DispelDescription : "";
public (Character? character = null) : base(SkillType.Passive, character)
{
Effects.Add(new (this));
}
public override IEnumerable<Effect> AddPassiveEffectToCharacter()
{
return Effects;
}
}
public class (Skill skill) : Effect(skill)
{
public override long Id => Skill.Id;
public override string Name => Skill.Name;
public override string Description => $"对一半以下生命值的目标造成伤害时,将收集其灵魂以永久提升自身伤害,每个灵魂提供 {额外伤害提升 * 100:0.##}% 伤害加成。最多收集 {最多灵魂数量} 个灵魂。" +
$"若自身死亡,灵魂将损失一半。(当前灵魂数量:{当前灵魂数量} 个;伤害提升:{当前灵魂数量 * 额外伤害提升 * 100:0.##}%";
private static double => 0.02;
private int { get; set; } = 0;
private int => Skill.Character != null ? 10 + Skill.Character.Level / 10 * 5 : 10;
private bool { get; set; } = false;
public override double AlterExpectedDamageBeforeCalculation(Character character, Character enemy, double damage, bool isNormalAttack, DamageType damageType, MagicType magicType, Dictionary<Effect, double> totalDamageBonus)
{
if (character == Skill.Character && (enemy.HP / enemy.MaxHP) < 0.5)
{
= true;
return damage * * ;
}
return 0;
}
public override void AfterDamageCalculation(Character character, Character enemy, double damage, double actualDamage, bool isNormalAttack, DamageType damageType, MagicType magicType, DamageResult damageResult)
{
if ( && character == Skill.Character && (damageResult == DamageResult.Normal || damageResult == DamageResult.Critical) && < )
{
= false;
++;
WriteLine($"[ {character} ] 通过黑暗收割收集了一个灵魂!当前灵魂数:{当前灵魂数量}");
}
}
public override void AfterDeathCalculation(Character death, Character? killer, Dictionary<Character, int> continuousKilling, Dictionary<Character, int> earnedMoney)
{
if (death == Skill.Character && > 0)
{
int lost = / 2;
-= lost;
WriteLine($"[ {death} ] 因死亡损失了 [ {lost} ] 个灵魂!");
}
}
public override void OnTurnEnd(Character character)
{
= false;
}
}
}

View File

@ -52,7 +52,7 @@ namespace Oshima.FunGame.OshimaServers.Service
FunGameConstant.PassiveSkills.AddRange([new META马(), new (), new (), new (), new (), new (), new (), new (), new (), new (), new (), new ()]); FunGameConstant.PassiveSkills.AddRange([new META马(), new (), new (), new (), new (), new (), new (), new (), new (), new (), new (), new ()]);
FunGameConstant.CommonPassiveSkills.AddRange([new (), new (), new (), new ()]); FunGameConstant.CommonPassiveSkills.AddRange([new (), new (), new (), new (), new ()]);
FunGameConstant.Magics.AddRange([new (), new (), new (), new (), new (), new (), new (), new (), FunGameConstant.Magics.AddRange([new (), new (), new (), new (), new (), new (), new (), new (),
new (), new (), new (), new (), new (), new (), new (), new (), new (), new (), new (), new (), new (), new (), new (), new (), new (), new (), new (), new (), new (), new (),
@ -3594,7 +3594,7 @@ namespace Oshima.FunGame.OshimaServers.Service
if (toActivitiesCache) ActivitiesItemCache.Add(item.Name); if (toActivitiesCache) ActivitiesItemCache.Add(item.Name);
} }
public static async Task<string> FightInstance(InstanceType type, int difficulty, User user, Character[] squad) public static async Task<(bool, string)> FightInstance(InstanceType type, int difficulty, User user, Character[] squad)
{ {
if (difficulty <= 0) difficulty = 1; if (difficulty <= 0) difficulty = 1;
else if (difficulty > 5) difficulty = 5; else if (difficulty > 5) difficulty = 5;
@ -3736,7 +3736,8 @@ namespace Oshima.FunGame.OshimaServers.Service
int characterCount = squad.Length; int characterCount = squad.Length;
builder.AppendLine($"☆--- {team2.Name}挑战 ---☆"); builder.AppendLine($"☆--- {team2.Name}挑战 ---☆");
builder.AppendLine(string.Join("\r\n", msgs)); builder.AppendLine(string.Join("\r\n", msgs));
if (enemys.All(c => c.HP <= 0)) bool result = enemys.All(c => c.HP <= 0);
if (result)
{ {
builder.Append($"小队战胜了敌人!获得了:"); builder.Append($"小队战胜了敌人!获得了:");
switch (type) switch (type)
@ -4112,7 +4113,7 @@ namespace Oshima.FunGame.OshimaServers.Service
} }
} }
return builder.ToString().Trim(); return (result, builder.ToString().Trim());
} }
public static Store? GetRegionStore(EntityModuleConfig<Store> stores, User user, string storeRegion, string storeName) public static Store? GetRegionStore(EntityModuleConfig<Store> stores, User user, string storeRegion, string storeName)

View File

@ -16,6 +16,7 @@ using Oshima.FunGame.OshimaModules.Models;
using Oshima.FunGame.OshimaModules.Regions; using Oshima.FunGame.OshimaModules.Regions;
using Oshima.FunGame.OshimaServers.Model; using Oshima.FunGame.OshimaServers.Model;
using Oshima.FunGame.OshimaServers.Service; using Oshima.FunGame.OshimaServers.Service;
using ProjectRedbud.FunGame.SQLQueryExtension;
namespace Oshima.FunGame.WebAPI.Controllers namespace Oshima.FunGame.WebAPI.Controllers
{ {
@ -440,53 +441,74 @@ namespace Oshima.FunGame.WebAPI.Controllers
} }
[HttpPost("createsaved")] [HttpPost("createsaved")]
public string CreateSaved([FromQuery] long? uid = null, [FromQuery] string? name = null) public string CreateSaved([FromQuery] long? uid = null, [FromQuery] string? openid = null)
{ {
string username = FunGameService.GenerateRandomChineseUserName();
using SQLHelper? sqlHelper = Factory.OpenFactory.GetSQLHelper(); using SQLHelper? sqlHelper = Factory.OpenFactory.GetSQLHelper();
if (name != null && sqlHelper != null) if (openid is null || openid.Trim() == "")
{
return "创建存档失败未提供接入ID";
}
if (sqlHelper != null)
{ {
try try
{ {
if (name.Trim() == "") Logger.LogInformation("[Reg] 接入ID{openid}", openid);
{ sqlHelper.ExecuteDataSet(FunGameService.Select_CheckAutoKey(sqlHelper, openid));
return "未提供接入ID";
}
Logger.LogInformation("[Reg] 接入ID{name}", name);
sqlHelper.ExecuteDataSet(FunGameService.Select_CheckAutoKey(sqlHelper, name));
if (sqlHelper.Success) if (sqlHelper.Success)
{ {
return "你已经创建过存档!"; return "你已经创建过存档!请使用【还原存档】指令或联系管理员处理。";
} }
string password = name.Encrypt(name);
sqlHelper.NewTransaction(); sqlHelper.NewTransaction();
sqlHelper.Execute(UserQuery.Insert_Register(sqlHelper, username, password, "", "", name)); // 检查UID的用户在数据库中是否存在如果已经存在则将OpenID对应AutoKey字段绑定到此用户上而不是创建新用户
if (sqlHelper.Result == SQLResult.Success) User? user = sqlHelper.GetUserById(uid ?? 0);
string username = "";
if (user is null)
{ {
sqlHelper.ExecuteDataSet(FunGameService.Select_CheckAutoKey(sqlHelper, name)); bool exist = true;
if (sqlHelper.Success) do
{ {
User user = Factory.GetUser(sqlHelper.DataSet); username = "FunOsm-" + Verification.CreateVerifyCode(VerifyCodeType.MixVerifyCode, 8);
sqlHelper.Commit(); if (sqlHelper.ExecuteDataRow(UserQuery.Select_IsExistUsername(sqlHelper, username)) is null)
user.Inventory.Credits = 5000; {
Character character = new CustomCharacter(FunGameConstant.CustomCharacterId, username, nickname: username); exist = false;
character.Recovery(); }
user.Inventory.Characters.Add(character); } while (exist);
FunGameConstant.UserIdAndUsername[user.Id] = user; // 使用这种方法注册的用户没有邮箱和UserKey因此无法通过常规方式登录FunGame标准系统
PluginConfig pc = FunGameService.GetUserConfig(user.Id, out _); string password = Verification.CreateVerifyCode(VerifyCodeType.MixVerifyCode, 6).Encrypt(openid);
FunGameService.SetUserConfigAndReleaseSemaphoreSlim(user.Id, pc, user); sqlHelper.RegisterUser(username, password, "", "", openid);
return $"创建存档成功!你的昵称是【{username}】。"; if (sqlHelper.Result == SQLResult.Success)
{
sqlHelper.ExecuteDataSet(FunGameService.Select_CheckAutoKey(sqlHelper, openid));
if (sqlHelper.Success)
{
user = Factory.GetUser(sqlHelper.DataSet);
}
else
{
sqlHelper.Rollback();
return "无法处理注册,创建存档失败!";
}
} }
else else
{ {
sqlHelper.Rollback();
return "无法处理注册,创建存档失败!"; return "无法处理注册,创建存档失败!";
} }
} }
else username = user.Username;
{ user.AutoKey = openid;
sqlHelper.Rollback(); user.Inventory.Credits = 5000;
} Character character = new CustomCharacter(FunGameConstant.CustomCharacterId, username, nickname: username);
character.Recovery();
user.Inventory.Characters.Add(character);
FunGameConstant.UserIdAndUsername[user.Id] = user;
sqlHelper.UpdateUser(user);
sqlHelper.Commit();
PluginConfig pc = FunGameService.GetUserConfig(user.Id, out _);
FunGameService.SetUserConfigAndReleaseSemaphoreSlim(user.Id, pc, user);
return $"创建存档成功!你的昵称是【{username}】。";
} }
catch (Exception e) catch (Exception e)
{ {
@ -495,26 +517,8 @@ namespace Oshima.FunGame.WebAPI.Controllers
} }
return "无法处理注册,创建存档失败!"; return "无法处理注册,创建存档失败!";
} }
else if (uid != null && uid != 0)
{
PluginConfig pc = FunGameService.GetUserConfig(uid.Value, out _);
if (pc.Count == 0) return "创建存档失败SQL 服务不可用!";
{
User user = Factory.GetUser(uid.Value, username, DateTime.Now, DateTime.Now, uid + "@qq.com", username);
user.Inventory.Credits = 5000;
user.Inventory.Characters.Add(new CustomCharacter(uid.Value, username));
FunGameConstant.UserIdAndUsername[uid.Value] = user;
FunGameService.SetUserConfigAndReleaseSemaphoreSlim(uid.Value, pc, user);
return $"创建存档成功!你的昵称是【{username}】。";
}
else
{
FunGameService.ReleaseUserSemaphoreSlim(uid.Value);
return "你已经创建过存档!";
}
}
return "创建存档失败!";
} }
[HttpPost("restoresaved")] [HttpPost("restoresaved")]
@ -7685,6 +7689,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
{ {
PluginConfig pc = FunGameService.GetUserConfig(userid, out _); PluginConfig pc = FunGameService.GetUserConfig(userid, out _);
bool result = false;
string msg = ""; string msg = "";
if (pc.Count > 0) if (pc.Count > 0)
{ {
@ -7732,10 +7737,17 @@ namespace Oshima.FunGame.WebAPI.Controllers
if (msg == "") if (msg == "")
{ {
exploreTimes -= reduce; (result, msg) = await FunGameService.FightInstance((InstanceType)type, difficulty, user, squad);
msg = await FunGameService.FightInstance((InstanceType)type, difficulty, user, squad);
if (msg != "") msg += "\r\n"; if (msg != "") msg += "\r\n";
msg += $"本次秘境挑战消耗探索许可 {reduce} 个,你的剩余探索许可:{exploreTimes} 个。"; if (result)
{
exploreTimes -= reduce;
msg += $"本次秘境挑战消耗探索许可 {reduce} 个,你的剩余探索许可:{exploreTimes} 个。";
}
else
{
msg += $"本次秘境挑战失败,不消耗任何探索许可,请继续加油!你的剩余探索许可:{exploreTimes} 个。";
}
} }
pc.Add("exploreTimes", exploreTimes); pc.Add("exploreTimes", exploreTimes);
@ -8234,8 +8246,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
} }
} }
double points = 0; if (pc.TryGetValue("forgepoints", out object? value) && double.TryParse(value.ToString(), out double points))
if (pc.TryGetValue("forgepoints", out object? value) && double.TryParse(value.ToString(), out points))
{ {
points += model.ResultPoints; points += model.ResultPoints;
} }

View File

@ -58,7 +58,7 @@ namespace Oshima.FunGame.WebAPI
Timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") Timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
}; };
bool result = bot.Handler(message).GetAwaiter().GetResult(); bool result = bot.HandlerByConsole(message).GetAwaiter().GetResult();
if (!result || message.IsCompleted) if (!result || message.IsCompleted)
{ {

View File

@ -624,7 +624,7 @@ namespace Oshima.FunGame.WebAPI.Services
if (e.Detail == "创建存档") if (e.Detail == "创建存档")
{ {
e.UseNotice = false; e.UseNotice = false;
string msg = Controller.CreateSaved(name: openid); string msg = Controller.CreateSaved(uid, openid);
if (msg != "") if (msg != "")
{ {
await SendAsync(e, "创建存档", "\r\n" + msg); await SendAsync(e, "创建存档", "\r\n" + msg);
@ -1455,7 +1455,7 @@ namespace Oshima.FunGame.WebAPI.Services
string itemIdsString = match.Groups["itemIds"].Value; string itemIdsString = match.Groups["itemIds"].Value;
string characterId = match.Groups["characterId"].Value; string characterId = match.Groups["characterId"].Value;
int[] characterIds = characterId != "" ? [int.Parse(characterId)] : [1]; int[] characterIds = characterId != "" ? [int.Parse(characterId)] : [1];
int[] itemIds = itemIdsString.Split(FunGameConstant.SplitChars, StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray(); int[] itemIds = [.. itemIdsString.Split(FunGameConstant.SplitChars, StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries).Select(int.Parse)];
if (itemIds.Length > 0) if (itemIds.Length > 0)
{ {
string msg = Controller.UseItem4(uid, (itemIds, characterIds)); string msg = Controller.UseItem4(uid, (itemIds, characterIds));
@ -3648,6 +3648,15 @@ namespace Oshima.FunGame.WebAPI.Services
return false; return false;
} }
public async Task<bool> HandlerByConsole(IBotMessage e)
{
if (MemoryCache.Get(e.AuthorOpenId) is null)
{
MemoryCache.Set(e.AuthorOpenId, 1L, TimeSpan.FromMinutes(10));
}
return await Handler(e);
}
public List<string> MergeMessages(List<string> msgs) public List<string> MergeMessages(List<string> msgs)
{ {
List<string> real = []; List<string> real = [];