添加助攻系统,修复一些BUG

This commit is contained in:
milimoe 2024-09-10 00:54:15 +08:00
parent 3d02cb3db3
commit 81753d5e2f
Signed by: milimoe
GPG Key ID: 05D280912DA6C69E
9 changed files with 275 additions and 68 deletions

View File

@ -1,5 +1,4 @@
using System.Text; using Milimoe.FunGame.Core.Entity;
using Milimoe.FunGame.Core.Entity;
using Milimoe.FunGame.Core.Library.Constant; using Milimoe.FunGame.Core.Library.Constant;
namespace Milimoe.FunGame.Core.Api.Utility namespace Milimoe.FunGame.Core.Api.Utility
@ -42,7 +41,7 @@ namespace Milimoe.FunGame.Core.Api.Utility
/// <summary> /// <summary>
/// 角色目前赚取的金钱 /// 角色目前赚取的金钱
/// </summary> /// </summary>
protected readonly Dictionary<Character, double> _earnedMoney = []; protected readonly Dictionary<Character, int> _earnedMoney = [];
/// <summary> /// <summary>
/// 角色目前的连杀数 /// 角色目前的连杀数
@ -53,6 +52,11 @@ namespace Milimoe.FunGame.Core.Api.Utility
/// 角色被插队次数 /// 角色被插队次数
/// </summary> /// </summary>
protected readonly Dictionary<Character, int> _cutCount = []; protected readonly Dictionary<Character, int> _cutCount = [];
/// <summary>
/// 助攻伤害
/// </summary>
protected readonly Dictionary<Character, AssistDetail> _assistDamage = [];
/// <summary> /// <summary>
/// 游戏是否结束 /// 游戏是否结束
@ -84,7 +88,9 @@ namespace Milimoe.FunGame.Core.Api.Utility
if (group.Count() == 1) if (group.Count() == 1)
{ {
// 如果只有一个角色,直接加入队列 // 如果只有一个角色,直接加入队列
AddCharacter(group.First(), Calculation.Round2Digits(_queue.Count * 0.1), false); Character character = group.First();
AddCharacter(character, Calculation.Round2Digits(_queue.Count * 0.1), false);
_assistDamage.Add(character, new AssistDetail(character, characters.Where(c => c != character)));
} }
else else
{ {
@ -132,6 +138,7 @@ namespace Milimoe.FunGame.Core.Api.Utility
if (selectedCharacter != null) if (selectedCharacter != null)
{ {
AddCharacter(selectedCharacter, Calculation.Round2Digits(_queue.Count * 0.1), false); AddCharacter(selectedCharacter, Calculation.Round2Digits(_queue.Count * 0.1), false);
_assistDamage.Add(selectedCharacter, new AssistDetail(selectedCharacter, characters.Where(c => c != selectedCharacter)));
WriteLine("decided: " + selectedCharacter.Name + "\r\n"); WriteLine("decided: " + selectedCharacter.Name + "\r\n");
sortedList.Remove(selectedCharacter); sortedList.Remove(selectedCharacter);
} }
@ -164,14 +171,33 @@ namespace Milimoe.FunGame.Core.Api.Utility
// 如果没有找到满足条件的角色,返回 -1 // 如果没有找到满足条件的角色,返回 -1
int protectIndex = list.Select(x => x.Index).LastOrDefault(-1); int protectIndex = list.Select(x => x.Index).LastOrDefault(-1);
// 判断是否需要插入到受保护角色的后面 if (protectIndex != -1)
if (protectIndex != -1 && (insertIndex != -1 && insertIndex <= protectIndex))
{ {
// 如果按硬直时间插入的位置在受保护角色之前或相同,则插入到受保护角色的后面一位 // 获取最后一个符合条件的角色
insertIndex = protectIndex + 1; Character lastProtectedCharacter = list.Last().Character;
hardnessTime = _hardnessTimes[list.Select(x => x.Character).Last()]; double lastProtectedHardnessTime = _hardnessTimes[lastProtectedCharacter];
// 列出受保护角色的名单
WriteLine($"由于 [ {string.Join(" ][ ", list.Select(x => x.Character))} ] 受到行动保护,因此角色 [ {character} ] 将插入至顺序表第 {insertIndex + 1} 位。"); // 查找与最后一个受保护角色相同硬直时间的其他角色
var sameHardnessList = _queue
.Select((c, index) => new { Character = c, Index = index })
.Where(x => _hardnessTimes[x.Character] == lastProtectedHardnessTime && x.Index > protectIndex);
// 如果找到了相同硬直时间的角色,更新 protectIndex 为它们中最后一个的索引
if (sameHardnessList.Any())
{
protectIndex = sameHardnessList.Select(x => x.Index).Last();
}
// 判断是否需要插入到受保护角色的后面
if (insertIndex != -1 && insertIndex <= protectIndex)
{
// 如果按硬直时间插入的位置在受保护角色之前或相同,则插入到受保护角色的后面一位
insertIndex = protectIndex + 1;
hardnessTime = lastProtectedHardnessTime;
// 列出受保护角色的名单
WriteLine($"由于 [ {string.Join(" ][ ", list.Select(x => x.Character))} ] 受到行动保护,因此角色 [ {character} ] 将插入至顺序表第 {insertIndex + 1} 位。");
}
} }
} }
@ -225,23 +251,11 @@ namespace Milimoe.FunGame.Core.Api.Utility
/// </summary> /// </summary>
public void DisplayQueue() public void DisplayQueue()
{ {
StringBuilder text = new(); WriteLine("==== 角色状态 ====");
text.AppendLine("==== 角色状态 ====");
foreach (Character c in _queue) foreach (Character c in _queue)
{ {
text.AppendLine("角色 [ " + c + " ]"); WriteLine(c.GetInBattleInfo(_hardnessTimes[c]));
text.AppendLine($"生命值:{c.HP} / {c.MaxHP}" + (c.ExHP + c.ExHP2 > 0 ? $" [{c.BaseHP} + {c.ExHP + c.ExHP2}]" : ""));
text.AppendLine($"魔法值:{c.MP} / {c.MaxMP}" + (c.ExMP + c.ExMP2 > 0 ? $" [{c.BaseMP} + {c.ExMP + c.ExMP2}]" : ""));
text.AppendLine($"能量值:{c.EP} / 200");
if (c.CharacterState != CharacterState.Actionable)
{
text.AppendLine(CharacterSet.GetCharacterState(c.CharacterState));
}
text.AppendLine($"硬直时间:{_hardnessTimes[c]}");
} }
WriteLine(text.ToString());
} }
/// <summary> /// <summary>
@ -274,13 +288,13 @@ namespace Milimoe.FunGame.Core.Api.Utility
double baseTime = new Random().Next(10, 30); double baseTime = new Random().Next(10, 30);
// 敌人列表 // 敌人列表
List<Character> enemys = [.. _queue.Where(c => c != character && c.CharacterState != CharacterState.Neutral)]; List<Character> enemys = [.. _queue.Where(c => c != character && !c.IsUnselectable)];
// 队友列表 // 队友列表
List<Character> teammates = []; List<Character> teammates = [];
// 技能列表 // 技能列表
List<Skill> skills = [.. character.Skills.Where(s => s.Level > 0 && s.IsActive && s.Enable && s.CurrentCD == 0 && List<Skill> skills = [.. character.Skills.Where(s => s.Level > 0 && s.IsActive && s.Enable && !s.IsInEffect && s.CurrentCD == 0 &&
((s.IsSuperSkill && s.EPCost <= character.EP) || (!s.IsSuperSkill && s.IsMagic && s.MPCost <= character.MP) || (!s.IsSuperSkill && !s.IsMagic && s.EPCost <= character.EP)))]; ((s.IsSuperSkill && s.EPCost <= character.EP) || (!s.IsSuperSkill && s.IsMagic && s.MPCost <= character.MP) || (!s.IsSuperSkill && !s.IsMagic && s.EPCost <= character.EP)))];
// 作出了什么行动 // 作出了什么行动
@ -394,8 +408,7 @@ namespace Milimoe.FunGame.Core.Api.Utility
{ {
Character enemy = enemys[new Random().Next(enemys.Count)]; Character enemy = enemys[new Random().Next(enemys.Count)];
character.NormalAttack.Attack(this, character, enemy); character.NormalAttack.Attack(this, character, enemy);
// 普通攻击的默认硬直时间为7 baseTime = character.NormalAttack.HardnessTime;
baseTime = 7;
foreach (Effect effect in character.Effects.Where(e => e.Level > 0)) foreach (Effect effect in character.Effects.Where(e => e.Level > 0))
{ {
if (effect.AlterHardnessTimeAfterNormalAttack(character, baseTime, out double newTime)) if (effect.AlterHardnessTimeAfterNormalAttack(character, baseTime, out double newTime))
@ -618,6 +631,7 @@ namespace Milimoe.FunGame.Core.Api.Utility
// 移除到时间的特效 // 移除到时间的特效
foreach (Effect effect in character.Effects.ToList()) foreach (Effect effect in character.Effects.ToList())
{ {
if (!effect.Skill.IsActive) continue;
if (!effect.Durative || effect.Level == 0) if (!effect.Durative || effect.Level == 0)
{ {
character.Effects.Remove(effect); character.Effects.Remove(effect);
@ -666,6 +680,9 @@ namespace Milimoe.FunGame.Core.Api.Utility
else WriteLine("[ " + enemy + $" ] 受到了 {damage} 点物理伤害!"); else WriteLine("[ " + enemy + $" ] 受到了 {damage} 点物理伤害!");
enemy.HP = Calculation.Round2Digits(enemy.HP - damage); enemy.HP = Calculation.Round2Digits(enemy.HP - damage);
// 计算助攻
_assistDamage[actor][enemy] += damage;
// 造成伤害和受伤都可以获得能量 // 造成伤害和受伤都可以获得能量
double ep = GetEP(damage, 0.2, 40); double ep = GetEP(damage, 0.2, 40);
foreach (Effect effect in actor.Effects) foreach (Effect effect in actor.Effects)
@ -677,7 +694,7 @@ namespace Milimoe.FunGame.Core.Api.Utility
} }
actor.EP += ep; actor.EP += ep;
ep = GetEP(damage, 0.1, 20); ep = GetEP(damage, 0.1, 20);
foreach (Effect effect in actor.Effects.Where(e => e.Level > 0)) foreach (Effect effect in enemy.Effects.Where(e => e.Level > 0))
{ {
if (effect.AlterEPAfterGetDamage(enemy, ep, out double newep)) if (effect.AlterEPAfterGetDamage(enemy, ep, out double newep))
{ {
@ -698,7 +715,7 @@ namespace Milimoe.FunGame.Core.Api.Utility
{ {
effect.AfterDeathCalculation(enemy, actor, _continuousKilling, _earnedMoney); effect.AfterDeathCalculation(enemy, actor, _continuousKilling, _earnedMoney);
} }
if (_queue.Remove(enemy) && (!_queue.Where(c => c != actor && c.CharacterState != CharacterState.Neutral).Any())) if (_queue.Remove(enemy) && (!_queue.Where(c => c != actor).Any()))
{ {
// 没有其他的角色了,游戏结束 // 没有其他的角色了,游戏结束
EndGameInfo(actor); EndGameInfo(actor);
@ -844,17 +861,46 @@ namespace Milimoe.FunGame.Core.Api.Utility
public void DeathCalculation(Character killer, Character death) public void DeathCalculation(Character killer, Character death)
{ {
if (!_continuousKilling.TryAdd(killer, 1)) _continuousKilling[killer] += 1; if (!_continuousKilling.TryAdd(killer, 1)) _continuousKilling[killer] += 1;
double money = new Random().Next(200, 400); int money = new Random().Next(250, 350);
Character[] assists = _assistDamage.Keys.Where(c => c != death && _assistDamage[c].GetPercentage(death) > 0.10).ToArray();
double totalDamagePercentage = Calculation.Round4Digits(_assistDamage.Keys.Where(assists.Contains).Select(c => _assistDamage[c].GetPercentage(death)).Sum());
int totalMoney = Math.Min(Convert.ToInt32(money * totalDamagePercentage), 425); // 防止刷伤害设置金钱上限
// 按伤害比分配金钱 只有造成10%伤害以上才能参与
foreach (Character assist in assists)
{
int cmoney = Convert.ToInt32(_assistDamage[assist].GetPercentage(death) / totalDamagePercentage * totalMoney);
if (assist != killer)
{
if (!_earnedMoney.TryAdd(assist, cmoney)) _earnedMoney[assist] += cmoney;
}
else
{
money = cmoney;
}
}
// 终结击杀的奖励仍然是全额的
if (_continuousKilling.TryGetValue(death, out int coefficient) && coefficient > 1) if (_continuousKilling.TryGetValue(death, out int coefficient) && coefficient > 1)
{ {
money = Calculation.Round(money + ((coefficient + 1) * new Random().Next(100, 200)), 0); money += (coefficient + 1) * new Random().Next(100, 200);
string termination = CharacterSet.GetContinuousKilling(coefficient); string termination = CharacterSet.GetContinuousKilling(coefficient);
WriteLine("[ " + killer + " ] 终结了 [ " + death + " ]" + (termination != "" ? " 的" + termination : "") + $",获得 {money} 金钱!"); string msg = $"[ {killer} ] 终结了 [ {death} ] {(termination != "" ? " " + termination : "")},获得 {money} 金钱!";
if (assists.Length > 1)
{
msg += "助攻:[ " + string.Join(" ] / [ ", assists.Where(c => c != killer)) + " ]";
}
WriteLine(msg);
} }
else else
{ {
WriteLine("[ " + killer + " ] 杀死了 [ " + death + $" ],获得 {money} 金钱!"); string msg = $"[ {killer} ] 杀死了 [ {death} ],获得 {money} 金钱!";
if (assists.Length > 1)
{
msg += "助攻:[ " + string.Join(" ] / [ ", assists.Where(c => c != killer)) + " ]";
}
WriteLine(msg);
} }
int kills = _continuousKilling[killer]; int kills = _continuousKilling[killer];
@ -875,7 +921,7 @@ namespace Milimoe.FunGame.Core.Api.Utility
{ {
WriteLine("[ " + killer + " ] 已经" + continuousKilling + "!拜托谁去杀了他吧!!!"); WriteLine("[ " + killer + " ] 已经" + continuousKilling + "!拜托谁去杀了他吧!!!");
} }
if (!_earnedMoney.TryAdd(killer, money)) _earnedMoney[killer] += money; if (!_earnedMoney.TryAdd(killer, money)) _earnedMoney[killer] += money;
_eliminated.Add(death); _eliminated.Add(death);
@ -894,7 +940,7 @@ namespace Milimoe.FunGame.Core.Api.Utility
WriteLine("=== 排名 ==="); WriteLine("=== 排名 ===");
for (int i = _eliminated.Count - 1; i >= 0; i--) for (int i = _eliminated.Count - 1; i >= 0; i--)
{ {
string topCharacter = _eliminated[i].ToString() + (_earnedMoney.TryGetValue(_eliminated[i], out double earned) ? $" [ 已赚取 {earned} 金钱 ]" : ""); string topCharacter = _eliminated[i].ToString() + (_continuousKilling.TryGetValue(_eliminated[i], out int kills) && kills > 1 ? $" [ {CharacterSet.GetContinuousKilling(kills)} ]" : "") + (_earnedMoney.TryGetValue(_eliminated[i], out int earned) ? $" [ 已赚取 {earned} 金钱 ]" : "");
if (top == 1) if (top == 1)
{ {
WriteLine("冠军:" + topCharacter); WriteLine("冠军:" + topCharacter);
@ -960,14 +1006,14 @@ namespace Milimoe.FunGame.Core.Api.Utility
/// <returns></returns> /// <returns></returns>
public void WillPreCastSuperSkill(Character character) public void WillPreCastSuperSkill(Character character)
{ {
CharacterState[] checkStates = [CharacterState.Actionable, CharacterState.Neutral]; CharacterState[] checkStates = [CharacterState.Actionable];
// 选取在顺序表一半之后的角色 // 选取在顺序表一半之后的角色
foreach (Character other in _queue.Where(c => c != character && checkStates.Contains(c.CharacterState) && _queue.IndexOf(c) >= _queue.Count / 2).ToList()) foreach (Character other in _queue.Where(c => c != character && checkStates.Contains(c.CharacterState) && _queue.IndexOf(c) >= _queue.Count / 2).ToList())
{ {
// 有 65% 欲望插队 // 有 65% 欲望插队
if (new Random().NextDouble() < 0.65) if (new Random().NextDouble() < 0.65)
{ {
List<Skill> skills = other.Skills.Where(s => s.IsSuperSkill && s.Level > 0 && s.IsActive && s.Enable && s.CurrentCD == 0 && other.EP >= s.EPCost).ToList(); List<Skill> skills = other.Skills.Where(s => s.IsSuperSkill && s.Level > 0 && s.IsActive && s.Enable && !s.IsInEffect && s.CurrentCD == 0 && other.EP >= s.EPCost).ToList();
if (skills.Count > 0) if (skills.Count > 0)
{ {
Skill skill = skills[new Random().Next(skills.Count)]; Skill skill = skills[new Random().Next(skills.Count)];
@ -979,9 +1025,9 @@ namespace Milimoe.FunGame.Core.Api.Utility
WriteLine("[ " + other + " ] 预释放了爆发技!!"); WriteLine("[ " + other + " ] 预释放了爆发技!!");
foreach (Character c in _hardnessTimes.Keys) foreach (Character c in _hardnessTimes.Keys)
{ {
if (c != other) if (_hardnessTimes[c] != 0)
{ {
_hardnessTimes[c] += 0.01; _hardnessTimes[c] = Calculation.Round2Digits(_hardnessTimes[c] + 0.01);
} }
} }
foreach (Effect effect in character.Effects.Where(e => e.Level > 0)) foreach (Effect effect in character.Effects.Where(e => e.Level > 0))

View File

@ -0,0 +1,59 @@
using Milimoe.FunGame.Core.Api.Utility;
namespace Milimoe.FunGame.Core.Entity
{
/// <summary>
/// 用于记录对哪个角色造成了多少伤害
/// </summary>
public class AssistDetail : Dictionary<Character, double>
{
/// <summary>
/// 此详情类属于哪个角色
/// </summary>
public Character Character { get; }
/// <summary>
/// 初始化一个助攻详情类
/// </summary>
/// <param name="character"></param>
/// <param name="enemys"></param>
public AssistDetail(Character character, IEnumerable<Character> enemys)
{
Character = character;
foreach (Character enemy in enemys)
{
this[enemy] = 0;
}
}
/// <summary>
/// 获取和设置对 <paramref name="enemy"/> 的伤害
/// </summary>
/// <param name="enemy"></param>
/// <returns></returns>
public new double this[Character enemy]
{
get
{
return base[enemy];
}
set
{
if (!base.TryAdd(enemy, Calculation.Round2Digits(value)))
{
base[enemy] = Calculation.Round2Digits(value);
}
}
}
/// <summary>
/// 获取对 <paramref name="enemy"/> 的伤害
/// </summary>
/// <param name="enemy"></param>
/// <returns>目标的 <see cref="Character.MaxHP"/> 的百分比形式</returns>
public double GetPercentage(Character enemy)
{
return Calculation.Round2Digits(base[enemy] / enemy.MaxHP);
}
}
}

View File

@ -1,5 +1,4 @@
using System.Collections.Generic; using System.Text;
using System.Text;
using Milimoe.FunGame.Core.Api.Utility; using Milimoe.FunGame.Core.Api.Utility;
using Milimoe.FunGame.Core.Interface.Entity; using Milimoe.FunGame.Core.Interface.Entity;
using Milimoe.FunGame.Core.Library.Constant; using Milimoe.FunGame.Core.Library.Constant;
@ -136,6 +135,16 @@ namespace Milimoe.FunGame.Core.Entity
/// </summary> /// </summary>
public CharacterState CharacterState { get; set; } = CharacterState.Actionable; public CharacterState CharacterState { get; set; } = CharacterState.Actionable;
/// <summary>
/// 角色是否是中立的/无敌的 [ 战斗相关 ]
/// </summary>
public bool IsNeutral { get; set; } = false;
/// <summary>
/// 角色是否是不可选中的 [ 战斗相关 ]
/// </summary>
public bool IsUnselectable { get; set; } = false;
/// <summary> /// <summary>
/// 初始生命值 [ 初始设定 ] /// 初始生命值 [ 初始设定 ]
/// </summary> /// </summary>
@ -655,7 +664,7 @@ namespace Milimoe.FunGame.Core.Entity
/// 角色的技能列表 /// 角色的技能列表
/// </summary> /// </summary>
public HashSet<Skill> Skills { get; } = []; public HashSet<Skill> Skills { get; } = [];
/// <summary> /// <summary>
/// 角色的持续性特效列表 /// 角色的持续性特效列表
/// </summary> /// </summary>
@ -674,7 +683,7 @@ namespace Milimoe.FunGame.Core.Entity
/// 等级 /// 等级
/// </summary> /// </summary>
private int _Level = 1; private int _Level = 1;
/// <summary> /// <summary>
/// 能量值 /// 能量值
/// </summary> /// </summary>
@ -840,6 +849,7 @@ namespace Milimoe.FunGame.Core.Entity
builder.AppendLine($"暴击伤害:{CritDMG * 100:f2}%"); builder.AppendLine($"暴击伤害:{CritDMG * 100:f2}%");
builder.AppendLine($"闪避率:{EvadeRate * 100:f2}%"); builder.AppendLine($"闪避率:{EvadeRate * 100:f2}%");
builder.AppendLine($"冷却缩减:{CDR * 100:f2}%"); builder.AppendLine($"冷却缩减:{CDR * 100:f2}%");
builder.AppendLine($"加速系数:{AccelerationCoefficient * 100:f2}%");
builder.AppendLine($"物理穿透:{PhysicalPenetration * 100:f2}%"); builder.AppendLine($"物理穿透:{PhysicalPenetration * 100:f2}%");
builder.AppendLine($"魔法穿透:{MagicalPenetration * 100:f2}%"); builder.AppendLine($"魔法穿透:{MagicalPenetration * 100:f2}%");
@ -848,6 +858,16 @@ namespace Milimoe.FunGame.Core.Entity
builder.AppendLine(CharacterSet.GetCharacterState(CharacterState)); builder.AppendLine(CharacterSet.GetCharacterState(CharacterState));
} }
if (IsNeutral)
{
builder.AppendLine("角色是无敌的");
}
if (IsUnselectable)
{
builder.AppendLine("角色是不可选中的");
}
builder.AppendLine("== 普通攻击 =="); builder.AppendLine("== 普通攻击 ==");
builder.Append(NormalAttack.ToString()); builder.Append(NormalAttack.ToString());
@ -872,6 +892,44 @@ namespace Milimoe.FunGame.Core.Entity
return builder.ToString(); return builder.ToString();
} }
public string GetInBattleInfo(double hardnessTimes)
{
StringBuilder builder = new();
builder.AppendLine(ToStringWithLevel());
builder.AppendLine($"生命值:{HP} / {MaxHP}" + (ExHP + ExHP2 > 0 ? $" [{BaseHP} + {ExHP + ExHP2}]" : ""));
builder.AppendLine($"魔法值:{MP} / {MaxMP}" + (ExMP + ExMP2 > 0 ? $" [{BaseMP} + {ExMP + ExMP2}]" : ""));
builder.AppendLine($"能量值:{EP} / 200");
if (CharacterState != CharacterState.Actionable)
{
builder.AppendLine(CharacterSet.GetCharacterState(CharacterState));
}
if (IsNeutral)
{
builder.AppendLine("角色是无敌的");
}
if (IsUnselectable)
{
builder.AppendLine("角色是不可选中的");
}
builder.AppendLine($"硬直时间:{hardnessTimes}");
if (Effects.Count > 0)
{
builder.AppendLine("== 状态栏 ==");
foreach (Effect effect in Effects)
{
builder.Append(effect.ToString());
}
}
return builder.ToString();
}
/// <summary> /// <summary>
/// 复制一个角色 /// 复制一个角色
/// [ 推荐从模组中复制后使用对象 ] /// [ 推荐从模组中复制后使用对象 ]

View File

@ -1,4 +1,5 @@
using Milimoe.FunGame.Core.Api.Utility; using System.Text;
using Milimoe.FunGame.Core.Api.Utility;
using Milimoe.FunGame.Core.Interface.Entity; using Milimoe.FunGame.Core.Interface.Entity;
using Milimoe.FunGame.Core.Library.Constant; using Milimoe.FunGame.Core.Library.Constant;
@ -28,7 +29,7 @@ namespace Milimoe.FunGame.Core.Entity
/// 作用范围 /// 作用范围
/// </summary> /// </summary>
public virtual double TargetRange { get; } = 0; public virtual double TargetRange { get; } = 0;
/// <summary> /// <summary>
/// 持续性的<para/> /// 持续性的<para/>
/// 配合 <see cref="Duration"/> 使用,而不是 <see cref="DurationTurn"/>。 /// 配合 <see cref="Duration"/> 使用,而不是 <see cref="DurationTurn"/>。
@ -40,18 +41,23 @@ namespace Milimoe.FunGame.Core.Entity
/// 配合 <see cref="Durative"/> 使用。 /// 配合 <see cref="Durative"/> 使用。
/// </summary> /// </summary>
public virtual double Duration { get; } = 0; public virtual double Duration { get; } = 0;
/// <summary> /// <summary>
/// 持续时间(回合)<para/> /// 持续时间(回合)<para/>
/// 使用此属性需要将 <see cref="Durative"/> 设置为 false。 /// 使用此属性需要将 <see cref="Durative"/> 设置为 false。
/// </summary> /// </summary>
public virtual double DurationTurn { get; } = 0; public virtual double DurationTurn { get; } = 0;
/// <summary> /// <summary>
/// 剩余持续时间 /// 剩余持续时间
/// </summary> /// </summary>
public double RemainDuration { get; set; } = 0; public double RemainDuration { get; set; } = 0;
/// <summary>
/// 剩余持续时间(回合)
/// </summary>
public double RemainDurationTurn { get; set; } = 0;
/// <summary> /// <summary>
/// 魔法类型 /// 魔法类型
/// </summary> /// </summary>
@ -137,7 +143,7 @@ namespace Milimoe.FunGame.Core.Entity
newHardnessTime = baseHardnessTime; newHardnessTime = baseHardnessTime;
return false; return false;
} }
/// <summary> /// <summary>
/// 在完成释放技能动作之后修改硬直时间 /// 在完成释放技能动作之后修改硬直时间
/// </summary> /// </summary>
@ -240,7 +246,7 @@ namespace Milimoe.FunGame.Core.Entity
{ {
} }
/// <summary> /// <summary>
/// 在特效持有者的回合开始后 /// 在特效持有者的回合开始后
/// </summary> /// </summary>
@ -277,7 +283,7 @@ namespace Milimoe.FunGame.Core.Entity
/// <param name="killer"></param> /// <param name="killer"></param>
/// <param name="continuousKilling"></param> /// <param name="continuousKilling"></param>
/// <param name="earnedMoney"></param> /// <param name="earnedMoney"></param>
public virtual void AfterDeathCalculation(Character death, Character? killer, Dictionary<Character, int> continuousKilling, Dictionary<Character, double> earnedMoney) public virtual void AfterDeathCalculation(Character death, Character? killer, Dictionary<Character, int> continuousKilling, Dictionary<Character, int> earnedMoney)
{ {
} }
@ -304,6 +310,24 @@ namespace Milimoe.FunGame.Core.Entity
} }
public override string ToString()
{
StringBuilder builder = new();
string isDurative = "";
if (Durative)
{
isDurative = "(剩余:" + RemainDuration + " 时间)";
}
else if (DurationTurn > 0)
{
isDurative = "(剩余:" + RemainDurationTurn + " 回合)";
}
builder.AppendLine("【" + Name + " - 等级 " + Level + "】" + Description + isDurative);
return builder.ToString();
}
public override bool Equals(IBaseEntity? other) public override bool Equals(IBaseEntity? other)
{ {
return other is Effect c && c.Name == Name; return other is Effect c && c.Name == Name;

View File

@ -55,7 +55,7 @@ namespace Milimoe.FunGame.Core.Entity
/// <summary> /// <summary>
/// 硬直时间 /// 硬直时间
/// </summary> /// </summary>
public double HardnessTime { get; } = 7; public double HardnessTime { get; } = 10;
/// <summary> /// <summary>
/// 对目标(或多个目标)发起普通攻击 /// 对目标(或多个目标)发起普通攻击
@ -86,7 +86,7 @@ namespace Milimoe.FunGame.Core.Entity
{ {
StringBuilder builder = new(); StringBuilder builder = new();
builder.AppendLine(Name + " - " + "等级:" + Level); builder.AppendLine(Name + " - 等级 " + Level);
builder.AppendLine("技能描述:" + Description); builder.AppendLine("技能描述:" + Description);
builder.AppendLine("硬直时间:" + HardnessTime); builder.AppendLine("硬直时间:" + HardnessTime);

View File

@ -42,24 +42,29 @@ namespace Milimoe.FunGame.Core.Entity
} }
/// <summary> /// <summary>
/// 是否是主动技能 /// 是否是主动技能 [ 此项为最高优先级 ]
/// </summary> /// </summary>
[InitRequired] [InitRequired]
public bool IsActive { get; set; } = true; public bool IsActive { get; set; } = true;
/// <summary> /// <summary>
/// 是否可用 /// 是否可用 [ 此项为最高优先级 ]
/// </summary> /// </summary>
public bool Enable { get; set; } = true; public bool Enable { get; set; } = true;
/// <summary> /// <summary>
/// 是否是爆发技 [ 此项为最高优先级 ] /// 效果持续生效中 [ 此项设置为true后不允许再次释放防止重复释放 ]
/// </summary>
public bool IsInEffect { get; set; } = false;
/// <summary>
/// 是否是爆发技 [ 此项为高优先级 ]
/// </summary> /// </summary>
[InitRequired] [InitRequired]
public bool IsSuperSkill { get; set; } = false; public bool IsSuperSkill { get; set; } = false;
/// <summary> /// <summary>
/// 是否属于魔法 [ <see cref="IsActive"/> 会失效 ],反之为战技 /// 是否属于魔法 [ <see cref="IsActive"/> 必须为 true ],反之为战技
/// </summary> /// </summary>
[InitRequired] [InitRequired]
public bool IsMagic { get; set; } = true; public bool IsMagic { get; set; } = true;
@ -152,7 +157,7 @@ namespace Milimoe.FunGame.Core.Entity
} }
} }
} }
/// <summary> /// <summary>
/// 触发技能效果 /// 触发技能效果
/// </summary> /// </summary>
@ -178,8 +183,21 @@ namespace Milimoe.FunGame.Core.Entity
StringBuilder builder = new(); StringBuilder builder = new();
string type = IsSuperSkill ? "【爆发技】" : (IsMagic ? "【魔法】" : (IsActive ? "【主动】" : "【被动】")); string type = IsSuperSkill ? "【爆发技】" : (IsMagic ? "【魔法】" : (IsActive ? "【主动】" : "【被动】"));
builder.AppendLine(type + Name + " - " + "等级 " + Level); string level = Level > 0 ? " - 等级 " + Level : " - 尚未学习";
builder.AppendLine(type + Name + level);
builder.AppendLine("技能描述:" + Description); builder.AppendLine("技能描述:" + Description);
if (CurrentCD > 0)
{
builder.AppendLine("正在冷却:剩余 " + CurrentCD + " 秒");
}
if (!Enable)
{
builder.AppendLine("技能当前不可用");
}
if (IsInEffect)
{
builder.AppendLine("效果结束前不可用");
}
if (IsActive) if (IsActive)
{ {
if (IsSuperSkill) if (IsSuperSkill)

View File

@ -50,6 +50,12 @@ namespace Milimoe.FunGame.Core.Library.Common.JsonConverter
case nameof(Character.EXP): case nameof(Character.EXP):
result.EXP = reader.GetDouble(); result.EXP = reader.GetDouble();
break; break;
case nameof(Character.IsNeutral):
result.IsNeutral = reader.GetBoolean();
break;
case nameof(Character.IsUnselectable):
result.IsUnselectable = reader.GetBoolean();
break;
case nameof(Character.InitialHP): case nameof(Character.InitialHP):
result.InitialHP = reader.GetDouble(); result.InitialHP = reader.GetDouble();
break; break;
@ -175,6 +181,8 @@ namespace Milimoe.FunGame.Core.Library.Common.JsonConverter
writer.WriteNumber(nameof(Character.PrimaryAttribute), (int)value.PrimaryAttribute); writer.WriteNumber(nameof(Character.PrimaryAttribute), (int)value.PrimaryAttribute);
writer.WriteNumber(nameof(Character.Level), value.Level); writer.WriteNumber(nameof(Character.Level), value.Level);
writer.WriteNumber(nameof(Character.EXP), value.EXP); writer.WriteNumber(nameof(Character.EXP), value.EXP);
writer.WriteBoolean(nameof(Character.IsNeutral), value.IsNeutral);
writer.WriteBoolean(nameof(Character.IsUnselectable), value.IsUnselectable);
writer.WriteNumber(nameof(Character.CharacterState), (int)value.CharacterState); writer.WriteNumber(nameof(Character.CharacterState), (int)value.CharacterState);
writer.WriteNumber(nameof(Character.InitialHP), value.InitialHP); writer.WriteNumber(nameof(Character.InitialHP), value.InitialHP);
writer.WriteNumber(nameof(Character.ExHP2), value.ExHP2); writer.WriteNumber(nameof(Character.ExHP2), value.ExHP2);

View File

@ -350,7 +350,6 @@ namespace Milimoe.FunGame.Core.Library.Constant
CharacterState.ActionRestricted => "角色现在行动受限", CharacterState.ActionRestricted => "角色现在行动受限",
CharacterState.BattleRestricted => "角色现在战斗不能", CharacterState.BattleRestricted => "角色现在战斗不能",
CharacterState.SkillRestricted => "角色现在技能受限", CharacterState.SkillRestricted => "角色现在技能受限",
CharacterState.Neutral => "角色现在是无敌的",
_ => "角色现在完全行动不能" _ => "角色现在完全行动不能"
}; };
} }

View File

@ -296,16 +296,11 @@ namespace Milimoe.FunGame.Core.Library.Constant
/// 处于吟唱中 [ 战斗相关 ] [ 技能相关 ] /// 处于吟唱中 [ 战斗相关 ] [ 技能相关 ]
/// </summary> /// </summary>
Casting, Casting,
/// <summary> /// <summary>
/// 预释放爆发技(插队) [ 战斗相关 ] [ 技能相关 ] /// 预释放爆发技(插队) [ 战斗相关 ] [ 技能相关 ]
/// </summary> /// </summary>
PreCastSuperSkill, PreCastSuperSkill
/// <summary>
/// 是中立单位(无敌的) [ 战斗相关 ]
/// </summary>
Neutral
} }
public enum PrimaryAttribute public enum PrimaryAttribute