prompt context: announce kind byte, record 23 bytes, STOC 0x44 24 bytes (TICKET-451, v1.7.0)
u8 announce_kind after chain_link, set only while MSG_ANNOUNCE_NUMBER is open: 1 when the script called Duel.AnnounceLevel (it passes playerid + 0x10000 to the unit), else 2 when the asking effect has CATEGORY_DICE and is visible to the answering player, else 0. Contract, changelog, binding PromptContext.AnnounceKind + AnnouncePlain / Level / Dice, codec 24 bytes, probe: plain 0, AnnounceLevel 1, a dice effect's AnnounceNumber 2. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3f84b0b50b
commit
954fbfc65b
12 files changed
+70
-40
No files matched your search
@@ -287,27 +287,28 @@ namespace YGOLegacy.Protocol.Tests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PromptContext_Id_Flag_Protocol_AndRoundTrip_ArePinned_0x44_0x8000_12_23()
|
||||
public void PromptContext_Id_Flag_Protocol_AndRoundTrip_ArePinned_0x44_0x8000_12_24()
|
||||
{
|
||||
Assert.That((int)StocCodecs.PromptContext.Id, Is.EqualTo(0x44));
|
||||
Assert.That((int)StocMessage.PromptContext, Is.EqualTo(0x44));
|
||||
Assert.That(FeatureFlags.PromptContext, Is.EqualTo(0x8000));
|
||||
Assert.That(FeatureFlags.All & FeatureFlags.PromptContext, Is.EqualTo(FeatureFlags.PromptContext));
|
||||
Assert.That(Capability.ProtocolVersion, Is.EqualTo(12));
|
||||
Assert.That(PromptContextCodec.Size, Is.EqualTo(23));
|
||||
Assert.That(PromptContextCodec.Size, Is.EqualTo(24));
|
||||
Assert.That(new[] { PromptContext.AnnouncePlain, PromptContext.AnnounceLevel, PromptContext.AnnounceDice }, Is.EqualTo(new byte[] { 0, 1, 2 }));
|
||||
Assert.That(new[] { PromptContext.PhaseOther, PromptContext.PhaseCost, PromptContext.PhaseTarget, PromptContext.PhaseOperation, PromptContext.PhaseAsk }, Is.EqualTo(new byte[] { 0, 1, 2, 3, 4 }));
|
||||
|
||||
const ulong description = 12960005233ul;
|
||||
var payload = new PromptContext(true, 16178681u, 1, 0x04, 2, 0x1, description, 3, PromptContext.PhaseOperation, 2, 13);
|
||||
var payload = new PromptContext(true, 16178681u, 1, 0x04, 2, 0x1, description, 3, PromptContext.PhaseOperation, 2, PromptContext.AnnounceDice, 143);
|
||||
var bytes = Bytes(w => StocCodecs.PromptContext.Write(w, payload));
|
||||
Assert.That(bytes.Length, Is.EqualTo(23));
|
||||
Assert.That(bytes.Length, Is.EqualTo(24));
|
||||
Assert.That(bytes[0], Is.EqualTo(1));
|
||||
Assert.That(bytes[1], Is.EqualTo(1));
|
||||
Assert.That(BitConverter.ToUInt32(bytes, 2), Is.EqualTo(16178681u));
|
||||
Assert.That(bytes.Skip(6).Take(4).ToArray(), Is.EqualTo(new byte[] { 1, 0x04, 2, 0x1 }));
|
||||
Assert.That(BitConverter.ToUInt64(bytes, 10), Is.EqualTo(description));
|
||||
Assert.That(BitConverter.ToUInt16(bytes, 18), Is.EqualTo(3));
|
||||
Assert.That(bytes.Skip(20).ToArray(), Is.EqualTo(new byte[] { 3, 2, 13 }));
|
||||
Assert.That(bytes.Skip(20).ToArray(), Is.EqualTo(new byte[] { 3, 2, 2, 143 }));
|
||||
|
||||
var read = StocCodecs.PromptContext.Read(Reader(bytes));
|
||||
Assert.That(read.Version, Is.EqualTo(1));
|
||||
@@ -322,15 +323,16 @@ namespace YGOLegacy.Protocol.Tests
|
||||
Assert.That(read.EffectIndex, Is.EqualTo(3));
|
||||
Assert.That(read.Phase, Is.EqualTo(PromptContext.PhaseOperation));
|
||||
Assert.That(read.ChainLink, Is.EqualTo(2));
|
||||
Assert.That(read.Prompt, Is.EqualTo(13));
|
||||
Assert.That(read.AnnounceKind, Is.EqualTo(PromptContext.AnnounceDice));
|
||||
Assert.That(read.Prompt, Is.EqualTo(143));
|
||||
|
||||
var none = Bytes(w => StocCodecs.PromptContext.Write(w, PromptContext.None(10)));
|
||||
Assert.That(none, Is.EqualTo(new byte[] { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0, 0, 10 }));
|
||||
Assert.That(none, Is.EqualTo(new byte[] { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0, 0, 0, 10 }));
|
||||
Assert.That(StocCodecs.PromptContext.Read(Reader(none)).HasEffect, Is.False);
|
||||
var hidden = StocCodecs.PromptContext.Read(Reader(Bytes(w => StocCodecs.PromptContext.Write(w, new PromptContext(true, 0, 1, 0x02, 0, 0x8, 0, PromptContext.UnknownIndex, PromptContext.PhaseCost, 1, 13)))));
|
||||
var hidden = StocCodecs.PromptContext.Read(Reader(Bytes(w => StocCodecs.PromptContext.Write(w, new PromptContext(true, 0, 1, 0x02, 0, 0x8, 0, PromptContext.UnknownIndex, PromptContext.PhaseCost, 1, PromptContext.AnnouncePlain, 13)))));
|
||||
Assert.That(hidden.IsHidden, Is.True);
|
||||
Assert.That(hidden.EffectIndex, Is.EqualTo(PromptContext.UnknownIndex));
|
||||
Assert.Throws<EndOfStreamException>(() => StocCodecs.PromptContext.Read(Reader(bytes.Take(22).ToArray())));
|
||||
Assert.Throws<EndOfStreamException>(() => StocCodecs.PromptContext.Read(Reader(bytes.Take(23).ToArray())));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -214,10 +214,10 @@ namespace YGOLegacy.Protocol.Codecs
|
||||
}
|
||||
}
|
||||
|
||||
// The 22-byte ygol_query_prompt_context record (version, has effect, uint32 code, controller, location, sequence, position, uint64 description, uint16 effect index, phase, chain link) + the prompt's MSG id; no sender stamp (v1.7.0, TICKET-451).
|
||||
// The 23-byte ygol_query_prompt_context record (version, has effect, uint32 code, controller, location, sequence, position, uint64 description, uint16 effect index, phase, chain link, announce kind) + the prompt's MSG id; no sender stamp (v1.7.0, TICKET-451).
|
||||
public sealed class PromptContextCodec : IStocCodec<PromptContext>
|
||||
{
|
||||
public const int Size = 23;
|
||||
public const int Size = 24;
|
||||
|
||||
public StocMessage Id => StocMessage.PromptContext;
|
||||
|
||||
@@ -235,8 +235,9 @@ namespace YGOLegacy.Protocol.Codecs
|
||||
var effectIndex = reader.ReadUInt16();
|
||||
var phase = reader.ReadByte();
|
||||
var chainLink = reader.ReadByte();
|
||||
var announceKind = reader.ReadByte();
|
||||
var prompt = reader.ReadByte();
|
||||
return new PromptContext(version, hasEffect, code, controller, location, sequence, position, description, effectIndex, phase, chainLink, prompt);
|
||||
return new PromptContext(version, hasEffect, code, controller, location, sequence, position, description, effectIndex, phase, chainLink, announceKind, prompt);
|
||||
}
|
||||
|
||||
public void Write(BinaryWriter writer, PromptContext payload)
|
||||
@@ -252,6 +253,7 @@ namespace YGOLegacy.Protocol.Codecs
|
||||
writer.Write(payload.EffectIndex);
|
||||
writer.Write(payload.Phase);
|
||||
writer.Write(payload.ChainLink);
|
||||
writer.Write(payload.AnnounceKind);
|
||||
writer.Write(payload.Prompt);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -598,6 +598,9 @@ namespace YGOLegacy.Protocol.Contracts
|
||||
public const byte PhaseTarget = 2;
|
||||
public const byte PhaseOperation = 3;
|
||||
public const byte PhaseAsk = 4;
|
||||
public const byte AnnouncePlain = 0;
|
||||
public const byte AnnounceLevel = 1;
|
||||
public const byte AnnounceDice = 2;
|
||||
|
||||
public byte Version { get; }
|
||||
// False: no effect function runs (battle and idle commands, a plain summon); every other value is zero and EffectIndex is UnknownIndex.
|
||||
@@ -616,13 +619,15 @@ namespace YGOLegacy.Protocol.Contracts
|
||||
public byte Phase { get; }
|
||||
// The chain link the effect is, 0 when it is not on the chain.
|
||||
public byte ChainLink { get; }
|
||||
// MSG_ANNOUNCE_NUMBER only: AnnounceLevel (the script called Duel.AnnounceLevel), AnnounceDice (the asking effect is a visible dice effect); AnnouncePlain everywhere else.
|
||||
public byte AnnounceKind { get; }
|
||||
// The MSG_* id of the prompt this context belongs to.
|
||||
public byte Prompt { get; }
|
||||
|
||||
public PromptContext(bool hasEffect, uint code, byte controller, byte location, byte sequence, byte position, ulong description, ushort effectIndex, byte phase, byte chainLink, byte prompt)
|
||||
: this(CurrentVersion, hasEffect, code, controller, location, sequence, position, description, effectIndex, phase, chainLink, prompt) { }
|
||||
public PromptContext(bool hasEffect, uint code, byte controller, byte location, byte sequence, byte position, ulong description, ushort effectIndex, byte phase, byte chainLink, byte announceKind, byte prompt)
|
||||
: this(CurrentVersion, hasEffect, code, controller, location, sequence, position, description, effectIndex, phase, chainLink, announceKind, prompt) { }
|
||||
|
||||
public PromptContext(byte version, bool hasEffect, uint code, byte controller, byte location, byte sequence, byte position, ulong description, ushort effectIndex, byte phase, byte chainLink, byte prompt)
|
||||
public PromptContext(byte version, bool hasEffect, uint code, byte controller, byte location, byte sequence, byte position, ulong description, ushort effectIndex, byte phase, byte chainLink, byte announceKind, byte prompt)
|
||||
{
|
||||
Version = version;
|
||||
HasEffect = hasEffect;
|
||||
@@ -635,10 +640,11 @@ namespace YGOLegacy.Protocol.Contracts
|
||||
EffectIndex = effectIndex;
|
||||
Phase = phase;
|
||||
ChainLink = chainLink;
|
||||
AnnounceKind = announceKind;
|
||||
Prompt = prompt;
|
||||
}
|
||||
|
||||
public static PromptContext None(byte prompt) => new PromptContext(false, 0, 0, 0, 0, 0, 0, UnknownIndex, PhaseOther, 0, prompt);
|
||||
public static PromptContext None(byte prompt) => new PromptContext(false, 0, 0, 0, 0, 0, 0, UnknownIndex, PhaseOther, 0, AnnouncePlain, prompt);
|
||||
|
||||
public bool IsHidden => HasEffect && Code == 0;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user