修复游戏结束偶现的崩溃问题;修复物品没有复制 Others 字典的问题;地区新增掉落物绑定

This commit is contained in:
milimoe 2025-06-26 01:09:48 +08:00
parent 0a1bb0b2a5
commit b5a12ad18d
Signed by: milimoe
GPG Key ID: 9554D37E4B8991D0
3 changed files with 30 additions and 8 deletions

View File

@ -650,6 +650,10 @@ namespace Milimoe.FunGame.Core.Entity
item.Skills.Magics.Add(newskill); item.Skills.Magics.Add(newskill);
} }
} }
foreach (string key in itemDefined.Others.Keys)
{
item.Others[key] = itemDefined.Others[key];
}
return item; return item;
} }

View File

@ -11,6 +11,7 @@ namespace Milimoe.FunGame.Core.Entity
public HashSet<Character> Characters { get; } = []; public HashSet<Character> Characters { get; } = [];
public HashSet<Unit> Units { get; } = []; public HashSet<Unit> Units { get; } = [];
public HashSet<Item> Crops { get; } = []; public HashSet<Item> Crops { get; } = [];
public HashSet<Item> Items { get; } = [];
public string Weather { get; set; } = ""; public string Weather { get; set; } = "";
public int Temperature { get; set; } = 15; public int Temperature { get; set; } = 15;
public Dictionary<string, int> Weathers { get; } = []; public Dictionary<string, int> Weathers { get; } = [];
@ -53,19 +54,31 @@ namespace Milimoe.FunGame.Core.Entity
if (Characters.Count > 0) if (Characters.Count > 0)
{ {
builder.AppendLine($"== 头目 =="); builder.AppendLine($"== 头目 ==");
builder.AppendLine(string.Join("", Characters.Select(o => o.Name))); builder.AppendLine(string.Join("", Characters.Select(c => c.Name)));
} }
if (Units.Count > 0) if (Units.Count > 0)
{ {
builder.AppendLine($"== 生物 =="); builder.AppendLine($"== 生物 ==");
builder.AppendLine(string.Join("", Units.Select(o => o.Name))); builder.AppendLine(string.Join("", Units.Select(u => u.Name)));
} }
if (Crops.Count > 0) if (Crops.Count > 0)
{ {
builder.AppendLine($"== 作物 =="); builder.AppendLine($"== 作物 ==");
builder.AppendLine(string.Join("", Crops.Select(c => c.Name))); builder.AppendLine(string.Join("", Crops.Select(c => c.Name + (c.Description != "" ? $"{c.Description}" : "") + (c.BackgroundStory != "" ? $"\"{c.BackgroundStory}\"" : ""))));
}
if (Items.Count > 0)
{
builder.AppendLine($"== 掉落 ==");
builder.AppendLine(string.Join("", Items.Select(i =>
{
string itemquality = ItemSet.GetQualityTypeName(i.QualityType);
string itemtype = ItemSet.GetItemTypeName(i.ItemType) + (i.ItemType == ItemType.Weapon && i.WeaponType != WeaponType.None ? "-" + ItemSet.GetWeaponTypeName(i.WeaponType) : "");
if (itemtype != "") itemtype = $"|{itemtype}";
return $"[{itemquality + itemtype}]{i.Name}";
})));
} }
builder.AppendLine($"探索难度:{CharacterSet.GetRarityTypeName(Difficulty)}"); builder.AppendLine($"探索难度:{CharacterSet.GetRarityTypeName(Difficulty)}");

View File

@ -290,6 +290,15 @@ namespace Milimoe.FunGame.Core.Model
_original.Add(original.Guid, original); _original.Add(original.Guid, original);
} }
// 完全初始化
foreach (Character character in _allCharacters)
{
// 添加统计数据
_stats[character] = new();
// 添加助攻对象
_assistDetail[character] = new AssistDetail(character, _allCharacters.Where(c => c != character));
}
// 获取 HP 小于等于 0 的角色 // 获取 HP 小于等于 0 的角色
List<Character> deadCharacters = [.. characters.Where(c => c.HP <= 0)]; List<Character> deadCharacters = [.. characters.Where(c => c.HP <= 0)];
foreach (Character death in deadCharacters) foreach (Character death in deadCharacters)
@ -325,8 +334,6 @@ namespace Milimoe.FunGame.Core.Model
// 如果只有一个角色,直接加入队列 // 如果只有一个角色,直接加入队列
Character character = group.First(); Character character = group.First();
AddCharacter(character, Calculation.Round2Digits(_queue.Count * 0.1), false); AddCharacter(character, Calculation.Round2Digits(_queue.Count * 0.1), false);
_assistDetail.Add(character, new AssistDetail(character, _allCharacters.Where(c => c != character)));
_stats.Add(character, new());
// 初始化技能 // 初始化技能
foreach (Skill skill in character.Skills) foreach (Skill skill in character.Skills)
{ {
@ -379,8 +386,6 @@ namespace Milimoe.FunGame.Core.Model
if (selectedCharacter != null) if (selectedCharacter != null)
{ {
AddCharacter(selectedCharacter, Calculation.Round2Digits(_queue.Count * 0.1), false); AddCharacter(selectedCharacter, Calculation.Round2Digits(_queue.Count * 0.1), false);
_assistDetail.Add(selectedCharacter, new AssistDetail(selectedCharacter, _allCharacters.Where(c => c != selectedCharacter)));
_stats.Add(selectedCharacter, new());
// 初始化技能 // 初始化技能
foreach (Skill skill in selectedCharacter.Skills) foreach (Skill skill in selectedCharacter.Skills)
{ {