feat(battlenode): emit engine-resolved clan/tribe on knownList entries (M-HC-4e)
Prod always emits clan (int ClanType) + tribe (comma-joined int TribeType string, "0" for none) on every knownList entry (battle-traffic_tk2_regular .ndjson). Source both off the resolved engine (SessionBattleEngine.PlayedCardClan/ PlayedCardTribe -> BattleCardBase.Clan/Tribe), so skill-applied clan/tribe changes ride the wire rather than the static card-master value. Thread through KnownListBuilder.BuildPlayedCard + PlayActionsHandler; add clan/tribe to the KnownCardEntry DTO (always present, non-null). Node-side only; no engine edits, drift clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -43,15 +43,27 @@ public sealed record SelectCardEntry(
|
||||
/// the played card's accumulated spell-charge count read straight off the resolved engine
|
||||
/// (<c>SessionBattleEngine.PlayedCardSpellboost</c>); the wire-derived spellboost bookkeeping is retired.
|
||||
/// Cost already folds the discount in by construction; the count rides the entry only to stay prod-faithful
|
||||
/// (prod sends the real count). attachTarget stays ""; clan/tribe remain deferred (receiver re-derives
|
||||
/// them from cardId).</summary>
|
||||
/// (prod sends the real count).
|
||||
/// <para><c>clan</c> and <c>tribe</c> are likewise ENGINE-SOURCED (M-HC-4e) — read off the resolved card's
|
||||
/// <c>BattleCardBase.Clan</c>/<c>BattleCardBase.Tribe</c> getters (via
|
||||
/// <c>SessionBattleEngine.PlayedCardClan</c>/<c>PlayedCardTribe</c>), which fold in
|
||||
/// any skill-applied clan/tribe CHANGE/ADD (e.g. <c>change_affiliation</c>), so the wire carries the LIVE
|
||||
/// clan/tribe the engine resolved, not the static card-master value. PROD ALWAYS EMITS BOTH on every
|
||||
/// knownList entry (tk2 capture <c>battle-traffic_tk2_regular.ndjson</c>, e.g.
|
||||
/// <c>{idx:17,cardId:128821011,...,clan:8,tribe:"7,16",...}</c>): <c>clan</c> is the int <c>ClanType</c>
|
||||
/// ordinal (present even when 0); <c>tribe</c> is the comma-joined int <c>TribeType</c> ordinals as a
|
||||
/// STRING, <c>"0"</c> when the card has no tribe (== <c>ClanType/TribeType.ALL == 0</c>, never empty/omitted —
|
||||
/// the client reads it via <c>item.Value.ToString()</c>, NetworkBattleReceiver.cs:2382). Both are always
|
||||
/// present (non-null string for tribe), so neither is null-omitted. attachTarget stays "".</para></summary>
|
||||
public sealed record KnownCardEntry(
|
||||
[property: JsonPropertyName("idx")] int Idx,
|
||||
[property: JsonPropertyName("cardId")] long CardId,
|
||||
[property: JsonPropertyName("to")] int To,
|
||||
[property: JsonPropertyName("spellboost")] int Spellboost,
|
||||
[property: JsonPropertyName("attachTarget")] string AttachTarget,
|
||||
[property: JsonPropertyName("cost")] int Cost);
|
||||
[property: JsonPropertyName("cost")] int Cost,
|
||||
[property: JsonPropertyName("clan")] int Clan,
|
||||
[property: JsonPropertyName("tribe")] string Tribe);
|
||||
|
||||
/// <summary>Renamed <c>targetList</c> entry. <c>isSelf</c> is actor-relative and passes through
|
||||
/// verbatim — no perspective flip (bullet-3 audit F2).</summary>
|
||||
|
||||
@@ -56,8 +56,16 @@ internal sealed class PlayActionsHandler : IFrameHandler
|
||||
// to stay prod-faithful (prod sends the real count). Same senderSeat mapping as the cost read.
|
||||
int playedSpellboost = ctx.Engine.PlayedCardSpellboost(senderSeat, playIdx, fallback: 0);
|
||||
|
||||
// clan/tribe are ALSO engine-sourced (M-HC-4e) — read off the resolved card's Clan/Tribe getters, so
|
||||
// any skill-applied clan/tribe change (e.g. change_affiliation) rides the wire (the static card-master
|
||||
// value would miss it). Prod always emits both on every knownList entry: clan as the int ClanType
|
||||
// ordinal, tribe as the comma-joined int TribeType string ("0" for none). Same senderSeat mapping.
|
||||
int playedClan = ctx.Engine.PlayedCardClan(senderSeat, playIdx, fallback: 0);
|
||||
string playedTribe = ctx.Engine.PlayedCardTribe(senderSeat, playIdx);
|
||||
|
||||
var played = KnownListBuilder.BuildPlayedCard(
|
||||
deckMap, playIdx, orderList, cost: playedCost, spellboost: playedSpellboost);
|
||||
deckMap, playIdx, orderList, cost: playedCost, spellboost: playedSpellboost,
|
||||
clan: playedClan, tribe: playedTribe);
|
||||
var oppoTargets = KnownListBuilder.RenameTargets(entries.GetValueOrDefault(WireKeys.TargetList));
|
||||
|
||||
// Deck-sourced movements (fetch / search / summon-from-deck) ride the uList — a verbatim,
|
||||
|
||||
@@ -10,25 +10,28 @@ namespace SVSim.BattleNode.Sessions.Dispatch;
|
||||
internal static class KnownListBuilder
|
||||
{
|
||||
/// <summary>The played card's knownList entry, or null when its identity can't be synthesized
|
||||
/// (token idx not in the deck map, or no matching move op). <paramref name="cost"/> and
|
||||
/// <paramref name="spellboost"/> are both ENGINE-SOURCED (M-HC-3a/3b) — the handler reads the played
|
||||
/// card's resolved play-time cost (<c>SessionBattleEngine.PlayedCardCost</c>) and accumulated
|
||||
/// spell-charge count (<c>SessionBattleEngine.PlayedCardSpellboost</c>) off the shadow engine and passes
|
||||
/// them in; both land on the entry verbatim. The wire-derived spellboost bookkeeping is retired —
|
||||
/// the engine owns both cost and count by construction (cost folds the spellboost discount in already;
|
||||
/// the count rides the entry only to stay prod-faithful, prod sends the real count here). Prod's client
|
||||
/// reads cost straight into the card's cost model (<c>NetworkBattleReceiver</c>), so a vanilla play
|
||||
/// resolves to its base cost and count 0. attachTarget stays ""; clan/tribe remain deferred (receiver
|
||||
/// re-derives from cardId).</summary>
|
||||
/// (token idx not in the deck map, or no matching move op). <paramref name="cost"/>,
|
||||
/// <paramref name="spellboost"/>, <paramref name="clan"/> and <paramref name="tribe"/> are ALL
|
||||
/// ENGINE-SOURCED (M-HC-3a/3b/4e) — the handler reads them off the shadow engine
|
||||
/// (<c>SessionBattleEngine.PlayedCardCost</c>/<c>PlayedCardSpellboost</c>/<c>PlayedCardClan</c>/
|
||||
/// <c>PlayedCardTribe</c>) and passes them in; all land on the entry verbatim. The wire-derived
|
||||
/// spellboost bookkeeping is retired — the engine owns cost and count by construction (cost folds the
|
||||
/// spellboost discount in already; the count rides the entry only to stay prod-faithful, prod sends the
|
||||
/// real count here). <paramref name="clan"/>/<paramref name="tribe"/> are the LIVE (skill-applied)
|
||||
/// values the engine resolved — prod always sends both on every knownList entry (clan int, tribe the
|
||||
/// comma-joined int string, "0" for none). Prod's client reads cost straight into the card's cost model
|
||||
/// (<c>NetworkBattleReceiver</c>), so a vanilla play resolves to its base cost and count 0. attachTarget
|
||||
/// stays "".</summary>
|
||||
public static KnownCardEntry? BuildPlayedCard(
|
||||
IReadOnlyDictionary<int, long> deckMap, int playIdx, object? orderList,
|
||||
int cost = 0, int spellboost = 0)
|
||||
int cost = 0, int spellboost = 0, int clan = 0, string tribe = "0")
|
||||
{
|
||||
if (!deckMap.TryGetValue(playIdx, out var cardId)) return null;
|
||||
var to = ExtractMoveTo(orderList, playIdx);
|
||||
if (to is null) return null;
|
||||
return new KnownCardEntry(
|
||||
Idx: playIdx, CardId: cardId, To: to.Value, Spellboost: spellboost, AttachTarget: "", Cost: cost);
|
||||
Idx: playIdx, CardId: cardId, To: to.Value, Spellboost: spellboost, AttachTarget: "", Cost: cost,
|
||||
Clan: clan, Tribe: tribe);
|
||||
}
|
||||
|
||||
/// <summary>The <c>to</c> place-state of the FIRST <c>move</c> op whose <c>idx</c> list contains
|
||||
|
||||
@@ -279,6 +279,44 @@ internal sealed class SessionBattleEngine
|
||||
return card?.SpellChargeCount ?? fallback;
|
||||
}
|
||||
|
||||
/// <summary>The engine-RESOLVED clan of the card whose engine <c>Index</c> == <paramref name="idx"/> on
|
||||
/// <paramref name="playerSeat"/> (M-HC-4e), as the int <c>ClanType</c> ordinal prod sends on the
|
||||
/// knownList entry (e.g. <c>clan:8</c> in the tk2 capture). Reads <see cref="BattleCardBase.Clan"/>, whose
|
||||
/// getter returns the skill-applied clan (<c>SkillApplyInformation.ClanSkinInfo.Last()</c> when a skill
|
||||
/// changed it, else <c>BaseParameter.Clan</c>) — so a <c>change_affiliation</c> is reflected, which is WHY
|
||||
/// the engine value (not the static card-master clan) is the faithful one to emit.
|
||||
/// <para>Same post-resolution zone search + degrade-to-<paramref name="fallback"/> contract as
|
||||
/// <see cref="PlayedCardCost"/>: no engine / no card → fallback, so a non-engine session never crashes.</para></summary>
|
||||
public int PlayedCardClan(bool playerSeat, int idx, int fallback = 0)
|
||||
{
|
||||
if (_mgr is null) return fallback;
|
||||
var card = FindByIndex(Seat(playerSeat), idx);
|
||||
return card is null ? fallback : (int)card.Clan;
|
||||
}
|
||||
|
||||
/// <summary>The engine-RESOLVED tribe of the card whose engine <c>Index</c> == <paramref name="idx"/> on
|
||||
/// <paramref name="playerSeat"/> (M-HC-4e), in the EXACT wire string form prod sends: the comma-joined
|
||||
/// int <c>TribeType</c> ordinals (e.g. <c>tribe:"7,16"</c> for MACHINE+SCHOOL in the tk2 capture), and
|
||||
/// <c>"0"</c> when the card has no tribe (== <c>TribeType.ALL == 0</c> — prod never sends empty/omitted;
|
||||
/// the client reads it via <c>item.Value.ToString()</c>, NetworkBattleReceiver.cs:2382). Reads
|
||||
/// <see cref="BattleCardBase.Tribe"/>, whose getter folds in any skill-applied tribe CHANGE/ADD over
|
||||
/// <c>BaseParameter.Tribe</c> (and drops ALL when the resolved list has ≥2 entries) — so the wire carries
|
||||
/// the LIVE tribe, the faithful value over the static card-master one.
|
||||
/// <para>Same post-resolution zone search as <see cref="PlayedCardCost"/>; no engine / no card → "" (an
|
||||
/// engine that isn't owned this session emits no card, so the caller's BuildPlayedCard never fires).</para></summary>
|
||||
public string PlayedCardTribe(bool playerSeat, int idx)
|
||||
{
|
||||
if (_mgr is null) return string.Empty;
|
||||
var card = FindByIndex(Seat(playerSeat), idx);
|
||||
if (card is null) return string.Empty;
|
||||
var tribe = card.Tribe;
|
||||
// Prod's no-tribe form is the single "0" (TribeType.ALL == 0), never an empty string; an empty list
|
||||
// (defensive) renders the same "0".
|
||||
return tribe is null || tribe.Count == 0
|
||||
? "0"
|
||||
: string.Join(",", tribe.Select(t => (int)t));
|
||||
}
|
||||
|
||||
// Locate the card with the given engine Index across the seat's post-resolution zones. Order matters
|
||||
// only for disambiguation; Index is unique per card so the first hit is the card. In-play (followers)
|
||||
// and cemetery (spells) are where a just-resolved play lands; hand is the pre-resolution fallback.
|
||||
|
||||
Reference in New Issue
Block a user