将一些非初始化的属性移出角色复制方法;OfferItems SQL 优化

This commit is contained in:
milimoe 2025-07-07 21:52:15 +08:00
parent 8b3d4aa0d7
commit 72d29cff5f
Signed by: milimoe
GPG Key ID: 9554D37E4B8991D0
2 changed files with 37 additions and 17 deletions

View File

@ -1939,7 +1939,7 @@ namespace Milimoe.FunGame.Core.Entity
/// [ 推荐从模组中复制后使用对象 ] /// [ 推荐从模组中复制后使用对象 ]
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public Character Copy(bool copyEx = false) public Character Copy(bool copyEx = false, bool copyMagic = false, bool copyItem = false)
{ {
Character c = new() Character c = new()
{ {
@ -1949,13 +1949,11 @@ namespace Milimoe.FunGame.Core.Entity
FirstName = FirstName, FirstName = FirstName,
NickName = NickName, NickName = NickName,
Profile = Profile.Copy(), Profile = Profile.Copy(),
MagicType = MagicType,
FirstRoleType = FirstRoleType, FirstRoleType = FirstRoleType,
SecondRoleType = SecondRoleType, SecondRoleType = SecondRoleType,
ThirdRoleType = ThirdRoleType, ThirdRoleType = ThirdRoleType,
Promotion = Promotion, Promotion = Promotion,
PrimaryAttribute = PrimaryAttribute, PrimaryAttribute = PrimaryAttribute,
ImmuneType = ImmuneType,
Level = Level, Level = Level,
LevelBreak = LevelBreak, LevelBreak = LevelBreak,
EXP = EXP, EXP = EXP,
@ -1964,9 +1962,6 @@ namespace Milimoe.FunGame.Core.Entity
EP = EP, EP = EP,
InitialATK = InitialATK, InitialATK = InitialATK,
InitialDEF = InitialDEF, InitialDEF = InitialDEF,
MDF = MDF.Copy(),
PhysicalPenetration = PhysicalPenetration,
MagicalPenetration = MagicalPenetration,
InitialHR = InitialHR, InitialHR = InitialHR,
InitialMR = InitialMR, InitialMR = InitialMR,
ER = ER, ER = ER,
@ -1976,10 +1971,7 @@ namespace Milimoe.FunGame.Core.Entity
STRGrowth = STRGrowth, STRGrowth = STRGrowth,
AGIGrowth = AGIGrowth, AGIGrowth = AGIGrowth,
INTGrowth = INTGrowth, INTGrowth = INTGrowth,
InitialSPD = InitialSPD, InitialSPD = InitialSPD
ATR = ATR,
Lifesteal = Lifesteal,
Shield = Shield.Copy()
}; };
if (copyEx) if (copyEx)
{ {
@ -2006,19 +1998,33 @@ namespace Milimoe.FunGame.Core.Entity
c.ExCritRate = ExCritRate; c.ExCritRate = ExCritRate;
c.ExCritDMG = ExCritDMG; c.ExCritDMG = ExCritDMG;
c.ExEvadeRate = ExEvadeRate; c.ExEvadeRate = ExEvadeRate;
c.PhysicalPenetration = PhysicalPenetration;
c.MagicalPenetration = MagicalPenetration;
c.MDF = MDF.Copy();
c.Lifesteal = Lifesteal;
c.Shield = Shield.Copy();
c.ATR = ATR;
c.MagicType = MagicType;
c.ImmuneType = ImmuneType;
} }
foreach (Skill skill in Skills) foreach (Skill skill in Skills)
{
if (skill.SkillType != SkillType.Magic || copyMagic)
{ {
Skill newskill = skill.Copy(); Skill newskill = skill.Copy();
newskill.Character = c; newskill.Character = c;
c.Skills.Add(newskill); c.Skills.Add(newskill);
} }
}
if (copyItem)
{
foreach (Item item in Items) foreach (Item item in Items)
{ {
Item newitem = item.Copy(); Item newitem = item.Copy();
newitem.Character = c; newitem.Character = c;
c.Items.Add(newitem); c.Items.Add(newitem);
} }
}
c.Recovery(); c.Recovery();
return c; return c;
} }

View File

@ -65,5 +65,19 @@ namespace Milimoe.FunGame.Core.Library.SQLScript.Entity
SQLHelper.Parameters["@OfferId"] = OfferId; SQLHelper.Parameters["@OfferId"] = OfferId;
return $"{Command_Delete} {Command_From} {TableName_Backup} {Command_Where} {Column_OfferId} = @OfferId"; return $"{Command_Delete} {Command_From} {TableName_Backup} {Command_Where} {Column_OfferId} = @OfferId";
} }
public static string Delete_OfferItemsByOfferIdAndItemGuid(SQLHelper SQLHelper, long OfferId, Guid ItemGuid)
{
SQLHelper.Parameters["@OfferId"] = OfferId;
SQLHelper.Parameters["@ItemGuid"] = ItemGuid.ToString();
return $"{Command_Delete} {Command_From} {TableName} {Command_Where} {Column_OfferId} = @OfferId {Command_And} {Column_ItemGuid} = @ItemGuid";
}
public static string Delete_OfferItemsBackupByOfferIdAndItemGuid(SQLHelper SQLHelper, long OfferId, Guid ItemGuid)
{
SQLHelper.Parameters["@OfferId"] = OfferId;
SQLHelper.Parameters["@ItemGuid"] = ItemGuid.ToString();
return $"{Command_Delete} {Command_From} {TableName_Backup} {Command_Where} {Column_OfferId} = @OfferId {Command_And} {Column_ItemGuid} = @ItemGuid";
}
} }
} }