使用新版随机回合奖励

This commit is contained in:
milimoe 2025-04-15 00:32:28 +08:00
parent aeab4bc067
commit 2438bcd5b6
Signed by: milimoe
GPG Key ID: 05D280912DA6C69E
4 changed files with 38 additions and 173 deletions

View File

@ -57,7 +57,7 @@ namespace Oshima.FunGame.OshimaModules.Skills
public override double AlterActualDamageAfterCalculation(Character character, Character enemy, double damage, bool isNormalAttack, bool isMagicDamage, MagicType magicType, DamageResult damageResult, ref bool isEvaded, Dictionary<Effect, double> totalDamageBonus) public override double AlterActualDamageAfterCalculation(Character character, Character enemy, double damage, bool isNormalAttack, bool isMagicDamage, MagicType magicType, DamageResult damageResult, ref bool isEvaded, Dictionary<Effect, double> totalDamageBonus)
{ {
if (character == Skill.Character && ) if (character == Skill.Character && damageResult != DamageResult.Evaded && )
{ {
= false; = false;
= true; = true;

View File

@ -49,7 +49,18 @@ namespace Oshima.FunGame.OshimaServers.Service
int maxRound = 999; int maxRound = 999;
// 随机回合奖励 // 随机回合奖励
Dictionary<int, List<Skill>> roundRewards = FunGameService.GenerateRoundRewards(maxRound); Dictionary<long, bool> effects = [];
foreach (EffectID id in FunGameConstant.RoundRewards.Keys)
{
long effectID = (long)id;
bool isActive = false;
if (effectID > (long)EffectID.Active_Start)
{
isActive = true;
}
effects.Add(effectID, isActive);
}
actionQueue.InitRoundRewards(maxRound, 1, effects, id => FunGameConstant.RoundRewards[(EffectID)id]);
int i = 1; int i = 1;
while (i < maxRound) while (i < maxRound)
@ -82,67 +93,11 @@ namespace Oshima.FunGame.OshimaServers.Service
// 处理回合 // 处理回合
if (characterToAct != null) if (characterToAct != null)
{ {
// 获取回合奖励
List<Skill> skillRewards = [];
if (roundRewards.TryGetValue(i, out List<Skill>? effectList) && effectList != null)
{
skillRewards = [.. effectList];
}
WriteLine($"=== Round {i++} ==="); WriteLine($"=== Round {i++} ===");
WriteLine($"现在是 [ {characterToAct} ] 的回合!"); WriteLine($"现在是 [ {characterToAct} ] 的回合!");
// 实际的回合奖励
List<Skill> realSkillRewards = [];
if (skillRewards.Count > 0)
{
foreach (Skill skill in skillRewards)
{
Dictionary<string, object> effectArgs = [];
if (FunGameConstant.RoundRewards.TryGetValue((EffectID)skill.Id, out Dictionary<string, object>? dict) && dict != null)
{
effectArgs = new(dict);
}
Dictionary<string, object> args = new()
{
{ "skill", skill },
{ "values", effectArgs }
};
skill.GamingQueue = actionQueue;
skill.Effects.Add(Factory.OpenFactory.GetInstance<Effect>(skill.Id, "", args));
skill.Character = characterToAct;
skill.Level = 1;
actionQueue.LastRound.RoundRewards.Add(skill);
WriteLine($"[ {characterToAct} ] 获得了回合奖励!{skill.Description}".Trim());
if (skill.IsActive)
{
actionQueue.LastRound.Targets.Add(characterToAct);
skill.OnSkillCasted(actionQueue, characterToAct, [characterToAct]);
}
else
{
characterToAct.Skills.Add(skill);
realSkillRewards.Add(skill);
}
}
}
bool isGameEnd = await actionQueue.ProcessTurnAsync(characterToAct); bool isGameEnd = await actionQueue.ProcessTurnAsync(characterToAct);
if (realSkillRewards.Count > 0)
{
foreach (Skill skill in realSkillRewards)
{
foreach (Effect e in skill.Effects)
{
e.OnEffectLost(characterToAct);
characterToAct.Effects.Remove(e);
}
characterToAct.Skills.Remove(skill);
skill.Character = null;
}
}
if (isGameEnd) if (isGameEnd)
{ {
Result.Add(_msg); Result.Add(_msg);
@ -308,7 +263,18 @@ namespace Oshima.FunGame.OshimaServers.Service
int maxRound = 9999; int maxRound = 9999;
// 随机回合奖励 // 随机回合奖励
Dictionary<int, List<Skill>> roundRewards = FunGameService.GenerateRoundRewards(maxRound); Dictionary<long, bool> effects = [];
foreach (EffectID id in FunGameConstant.RoundRewards.Keys)
{
long effectID = (long)id;
bool isActive = false;
if (effectID > (long)EffectID.Active_Start)
{
isActive = true;
}
effects.Add(effectID, isActive);
}
actionQueue.InitRoundRewards(maxRound, 1, effects, id => FunGameConstant.RoundRewards[(EffectID)id]);
int i = 1; int i = 1;
while (i < maxRound) while (i < maxRound)
@ -326,67 +292,11 @@ namespace Oshima.FunGame.OshimaServers.Service
// 处理回合 // 处理回合
if (characterToAct != null) if (characterToAct != null)
{ {
// 获取回合奖励
List<Skill> skillRewards = [];
if (roundRewards.TryGetValue(i, out List<Skill>? effectList) && effectList != null)
{
skillRewards = [.. effectList];
}
WriteLine($"=== Round {i++} ==="); WriteLine($"=== Round {i++} ===");
WriteLine("现在是 [ " + characterToAct + "" + (actionQueue.GetTeam(characterToAct)?.Name ?? "") + "" + " ] 的回合!"); WriteLine("现在是 [ " + characterToAct + "" + (actionQueue.GetTeam(characterToAct)?.Name ?? "") + "" + " ] 的回合!");
// 实际的回合奖励
List<Skill> realSkillRewards = [];
if (skillRewards.Count > 0)
{
foreach (Skill skill in skillRewards)
{
Dictionary<string, object> effectArgs = [];
if (FunGameConstant.RoundRewards.TryGetValue((EffectID)skill.Id, out Dictionary<string, object>? dict) && dict != null)
{
effectArgs = new(dict);
}
Dictionary<string, object> args = new()
{
{ "skill", skill },
{ "values", effectArgs }
};
skill.GamingQueue = actionQueue;
skill.Effects.Add(Factory.OpenFactory.GetInstance<Effect>(skill.Id, "", args));
skill.Character = characterToAct;
skill.Level = 1;
actionQueue.LastRound.RoundRewards.Add(skill);
WriteLine($"[ {characterToAct} ] 获得了回合奖励!{skill.Description}".Trim());
if (skill.IsActive)
{
actionQueue.LastRound.Targets.Add(characterToAct);
skill.OnSkillCasted(actionQueue, characterToAct, [characterToAct]);
}
else
{
characterToAct.Skills.Add(skill);
realSkillRewards.Add(skill);
}
}
}
bool isGameEnd = await actionQueue.ProcessTurnAsync(characterToAct); bool isGameEnd = await actionQueue.ProcessTurnAsync(characterToAct);
if (realSkillRewards.Count > 0)
{
foreach (Skill skill in realSkillRewards)
{
foreach (Effect e in skill.Effects)
{
e.OnEffectLost(characterToAct);
characterToAct.Effects.Remove(e);
}
characterToAct.Skills.Remove(skill);
skill.Character = null;
}
}
if (isGameEnd) if (isGameEnd)
{ {
Result.Add(_msg); Result.Add(_msg);

View File

@ -221,7 +221,7 @@ namespace Oshima.FunGame.OshimaServers.Service
} }
}; };
public static Dictionary<EffectID, Dictionary<string, object>> RoundRewards { get; } = new() public static Dictionary<EffectID, Dictionary<string, object>> RoundRewards => new()
{ {
{ {
EffectID.ExATK, EffectID.ExATK,

View File

@ -213,7 +213,18 @@ namespace Oshima.FunGame.OshimaServers.Service
int maxRound = isTeam ? 9999 : 999; int maxRound = isTeam ? 9999 : 999;
// 随机回合奖励 // 随机回合奖励
Dictionary<int, List<Skill>> roundRewards = FunGameService.GenerateRoundRewards(maxRound); Dictionary<long, bool> effects = [];
foreach (EffectID id in FunGameConstant.RoundRewards.Keys)
{
long effectID = (long)id;
bool isActive = false;
if (effectID > (long)EffectID.Active_Start)
{
isActive = true;
}
effects.Add(effectID, isActive);
}
actionQueue.InitRoundRewards(maxRound, 1, effects, id => FunGameConstant.RoundRewards[(EffectID)id]);
int i = 1; int i = 1;
while (i < maxRound) while (i < maxRound)
@ -254,67 +265,11 @@ namespace Oshima.FunGame.OshimaServers.Service
// 处理回合 // 处理回合
if (characterToAct != null) if (characterToAct != null)
{ {
// 获取回合奖励
List<Skill> skillRewards = [];
if (roundRewards.TryGetValue(i, out List<Skill>? effectList) && effectList != null)
{
skillRewards = [.. effectList];
}
WriteLine($"=== Round {i++} ==="); WriteLine($"=== Round {i++} ===");
WriteLine("现在是 [ " + characterToAct + (isTeam ? "" + (actionQueue.GetTeam(characterToAct)?.Name ?? "") + "" : "") + " ] 的回合!"); WriteLine("现在是 [ " + characterToAct + (isTeam ? "" + (actionQueue.GetTeam(characterToAct)?.Name ?? "") + "" : "") + " ] 的回合!");
// 实际的回合奖励
List<Skill> realSkillRewards = [];
if (skillRewards.Count > 0)
{
foreach (Skill skill in skillRewards)
{
Dictionary<string, object> effectArgs = [];
if (FunGameConstant.RoundRewards.TryGetValue((EffectID)skill.Id, out Dictionary<string, object>? dict) && dict != null)
{
effectArgs = new(dict);
}
Dictionary<string, object> args = new()
{
{ "skill", skill },
{ "values", effectArgs }
};
skill.GamingQueue = actionQueue;
skill.Effects.Add(Factory.OpenFactory.GetInstance<Effect>(skill.Id, "", args));
skill.Character = characterToAct;
skill.Level = 1;
actionQueue.LastRound.RoundRewards.Add(skill);
WriteLine($"[ {characterToAct} ] 获得了回合奖励!{skill.Description}".Trim());
if (skill.IsActive)
{
actionQueue.LastRound.Targets.Add(characterToAct);
skill.OnSkillCasted(actionQueue, characterToAct, [characterToAct]);
}
else
{
characterToAct.Skills.Add(skill);
realSkillRewards.Add(skill);
}
}
}
bool isGameEnd = await actionQueue.ProcessTurnAsync(characterToAct); bool isGameEnd = await actionQueue.ProcessTurnAsync(characterToAct);
if (realSkillRewards.Count > 0)
{
foreach (Skill skill in realSkillRewards)
{
foreach (Effect e in skill.Effects)
{
e.OnEffectLost(characterToAct);
characterToAct.Effects.Remove(e);
}
characterToAct.Skills.Remove(skill);
skill.Character = null;
}
}
if (isGameEnd) if (isGameEnd)
{ {
result.Add(Msg); result.Add(Msg);