Files
SVSimServer/SVSim.BattleEngine/Engine/Wizard/UserGoods.cs
gamer147 2d9a6eea4b engine cleanup passes 4-7 + multi-instancing ambient rip
Squashes 146 commits from battle-engine-extraction. Net: 2,045 files changed,
+11,896 / -158,687 lines. Ships engine passes 4-7 (dead-code cull, view-layer
stub, receive-path shrink) plus the Phase-5 AsyncLocal ambient deletion that
turns concurrent battles into a type-system property rather than a scope
contract.

## What landed

**Passes 4-7 (chunks 1-34):** Extended the Phase-4 const-false collapse into a
cascading cull across the skill graph, view layer, and receive-path periphery.
Six mode flags (IsWatchBattle/IsReplayBattle/IsAdmin/IsAdminWatch/IsPuzzleQuest/
IsAINetwork) became `const false`, every guarded block deleted. Field*.cs
subclass ctors + BackGroundBase + ObjectChecker culled to no-ops. Mulligan
family reworked to take a mgr param through IMulliganMgr.InitMulligan.
Emotion/Recovery/Resource clusters null-stubbed. Prediction/OperationSimulator/
skill filters converted from static ambient reads to per-mgr reads via
SkillPrm.ownerCard.SelfBattlePlayer.BattleMgr / ins.BattleMgr / this.BattleMgr.

**Phase-5 ambient rip (chunks 35-47):** Deleted BattleAmbient / BattleAmbient-
Context / TestBattleScope in full. Every per-battle mutable slot now lives on
the mgr instance itself:
  mgr.InstanceIsForecast / InstanceIsRandomDraw / InstanceRecoveryInfo /
  InstanceViewerId / InstanceNetworkAgent / GameMgr
BattleManagerBase.GetIns() returns null unconditionally; the residual static
flags + 3 façades (Certification.ViewerId, Data.BattleRecoveryInfo,
ToolboxGame.RealTimeNetworkAgent) are null-tolerant defaults kept for the
handful of engine-internal readers that still reference their types. Zero
BattleAmbient references anywhere in engine + node + tests.

Added pre-seeded GameMgr ctor overload threaded through the mgr chain
(BattleManagerBase → SingleBattleMgr / NetworkBattleManagerBase → NetworkStandard-
BattleMgr → HeadlessBattleMgr / HeadlessNetworkBattleMgr). Fixtures build a
GameMgr, seed it via HeadlessEngineEnv.SeedCharaIds/SeedNetUser, and pass it
to the mgr's ctor — no ambient reach.

Node side (SVSim.BattleNode/SessionBattleEngine): _ctx replaced with a plain
GameMgr field; 34 `using var _ambient = BattleAmbient.Enter(_ctx)` scope wraps
ripped from every accessor and mutator; EngineGlobalInit.WirePerSessionGameMgr
takes GameMgr as a param and runs from SessionBattleEngine.SetupInternal
BEFORE mgr construction.

Test side: TestBattleScope deleted; 18 fixture [SetUp]s migrated to
`HeadlessEngineEnv.EnsureProcessGlobals()`; MultiInstanceEngineTests rewritten
around per-mgr construction (GetIns() → null is the pinned invariant).

## Regression fixes

- **chunk-48** (MulliganCtrl): chunk-35's `= null` stubs on card lookups broke
  the live receive-driven Deal path (BattlePlayerBase.DrawCard NRE'd downstream
  of NetworkPlayerMulliganCtrl.StartMulliganVfx). Restored the three lookups
  via `_battlePlayer.BattleMgr.GetBattleCardIdx`. Engine tests were satisfied
  by the WireMulliganPhase seam; unit tests exposed the live-path gap.

## Ship state

- SVSim.BattleEngine.Tests: 56/56 pass, 2 skip
- SVSim.UnitTests: 1554/1554 pass (was 1523/31-fail before chunk 48)
- Solution build: 0 source warnings (40 pre-existing NU1902 MessagePack CVEs
  in SVSim.EmulatedEntrypoint, unrelated)
- Sequential PVP smoke: verified live (two back-to-back battles, no regression
  on cleanup/spinup)
- Concurrent PVP smoke: verified live

Adds tools/engine-port/ClosureAnalyzer/ — the Roslyn transitive-type-closure
analyzer needed to make future cascade cleanup safe (per feedback memory
"Engine cleanup needs closure tool" from the 2026-06-28 pass-3 failure).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-07-03 19:18:54 -04:00

184 lines
4.8 KiB
C#

using System;
using System.Collections.Generic;
namespace Wizard;
public class UserGoods
{
public enum Type
{
RedEther = 1,
Crystal = 2,
Item = 4,
Card = 5,
Sleeve = 6,
Emblem = 7,
Degree = 8,
Rupy = 9,
Skin = 10,
SpotCard = 11,
SpotCardPoint = 12,
SpotCardOnlyLatestCardPack = 13,
FreeGachaCount = 14,
MyPageBG = 15
}
private static readonly Dictionary<Type, Func<long, string>> UserGoodsNameFuncTable = new Dictionary<Type, Func<long, string>>
{
[Type.RedEther] = (long id) => Data.SystemText.Get("Common_0205"),
[Type.Crystal] = (long id) => Data.SystemText.Get("Common_0201"),
[Type.Item] = GetItemName,
[Type.Card] = GetCardName,
[Type.Sleeve] = GetSleeveName,
[Type.Emblem] = GetEmblemName,
[Type.Degree] = GetDegreeName,
[Type.Rupy] = (long id) => Data.SystemText.Get("Common_0115"),
[Type.Skin] = GetSkinName,
[Type.SpotCard] = GetSpotCardName,
[Type.SpotCardOnlyLatestCardPack] = GetSpotCardName,
[Type.SpotCardPoint] = (long id) => Data.SystemText.Get("Common_0161"),
[Type.MyPageBG] = GetMyPageBGName
};
public Type GoodsType { get; private set; }
public long Id { get; private set; }
public string Thumbnail => GetUserGoodsImageName(GoodsType, Id);
public UserGoods(Type type, long userGoodsId)
{
GoodsType = type;
Id = userGoodsId;
}
public static string GetUserGoodsImageName(Type userGoodsType, long userGoodsId = 0L)
{
switch (userGoodsType)
{
case Type.Crystal:
return "thumbnail_crystal";
case Type.RedEther:
return "thumbnail_liquid";
case Type.Item:
{
string result = "";
Item itemData = Item.GetItemData(userGoodsType, (int)userGoodsId);
if (itemData != null)
{
result = itemData.thumbnail;
}
return result;
}
case Type.Sleeve:
return "thumbnail_card";
case Type.Card:
case Type.SpotCard:
case Type.SpotCardOnlyLatestCardPack:
return "thumbnail_card";
case Type.Emblem:
return "thumbnail_emblem";
case Type.Degree:
return "thumbnail_title";
case Type.Rupy:
return "thumbnail_rupy";
case Type.Skin:
return "thumbnail_leader";
case Type.SpotCardPoint:
return "thumbnail_spotpoint";
case Type.MyPageBG:
return "thumbnail_mypage_custom_bg";
default:
return "";
}
}
public string GetUserGoodsIndividualImageName()
{
return GoodsType switch
{
Type.Sleeve => "thumbnail_sleeve_" + Id,
Type.Emblem => "thumbnail_emblem_" + Id,
Type.Skin => "thumbnail_leader_" + Id,
_ => Thumbnail,
};
}
public static string getUserGoodsName(Type userGoodsType, long userGoodsId)
{
string text = null;
if (UserGoodsNameFuncTable.TryGetValue(userGoodsType, out var value))
{
text = value(userGoodsId);
}
if (text == null)
{
text = string.Empty;
}
return text;
}
private static string GetItemName(long id)
{
return Item.GetItemData(Type.Item, (int)id)?.name;
}
private static string GetMyPageBGName(long id)
{
return Data.Master.MyPageCustomBGMaster[id.ToString()].Name;
}
private static string GetCardName(long id)
{
CardParameter cardParameterFromId = CardMaster.GetInstance(CardMaster.CardMasterId.Default).GetCardParameterFromId((int)id);
if (!cardParameterFromId.IsFoil)
{
return cardParameterFromId.CardName;
}
return cardParameterFromId.CardName + " " + Data.SystemText.Get("Mail_0054");
}
private static string GetSleeveName(long id)
{
string text = (Data.Master.SleeveMgr.Get(id).IsPremiumSleeve ? Data.SystemText.Get("Mail_0061") : Data.SystemText.Get("Mail_0055"));
if (!Data.Master.SleeveMgr.IsContainsInMaster(id))
{
return Data.SystemText.Get("Common_0203");
}
return Data.Master.SleeveMgr.Get(id).sleeve_name + " " + text;
}
private static string GetEmblemName(long id)
{
if (!Data.Master.EmblemMgr.IsContainsInMaster(id))
{
return Data.SystemText.Get("Mail_0036");
}
return Data.Master.EmblemMgr.Get(id)._name + " " + Data.SystemText.Get("Mail_0057");
}
private static string GetDegreeName(long id)
{
if (!Data.Master.DegreeMgr.IsContainsInMaster((int)id))
{
return Data.SystemText.Get("Mail_0039");
}
return Data.Master.DegreeMgr.Get((int)id)._name + " " + Data.SystemText.Get("Mail_0056");
}
private static string GetSkinName(long id)
{
ClassCharacterMasterData charaPrmBySkinId = null; // Pre-Phase-5b: no chara master headless
if (charaPrmBySkinId == null)
{
return null;
}
return charaPrmBySkinId.chara_name + " " + Data.SystemText.Get("Mail_0058");
}
private static string GetSpotCardName(long id)
{
return CardMaster.GetInstance(CardMaster.CardMasterId.Default).GetCardParameterFromId((int)id).CardName + " " + Data.SystemText.Get("Mail_0062");
}
}