contract: Tag shared Extra Deck rows, changelog v1.6.0, probe suite (TICKET-433)
The suite plays a pair-present and a pair-absent Tag room: a Summon of the waiting partner's monster, the partner value across a move, and the replay played back through the library. The contract states that bit 0x100000 stays unused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c0dfa8ef19
commit
4cd908d7af
3 files changed
+449
-18
No files matched your search
@@ -5,6 +5,17 @@ wire protocol, the engine message stream, the setup pairs and the Lua API. A row
|
||||
change first shipped in the Unity repo, the ticket, and the contract part it touched. Rows 0001-0024
|
||||
are the fork patches replayed into this repo as commits (`git log --oneline -- server/gframe core`).
|
||||
|
||||
## v1.6.0 — 2026-11-02
|
||||
|
||||
Tag shared Extra Deck (proposal 53): a setup pair gives a Tag team one Extra Deck, and each card keeps the partner who
|
||||
brought it. No new export or message; capability `0x4000`, protocol 11: exports 335 / 856 / 850, capabilities `0x77FF`.
|
||||
|
||||
| Date | Change | Ticket | Contract part |
|
||||
|---|---|---|---|
|
||||
| 2026-11-02 | Core: option `DUEL_TAG_SHARED_EXTRA` `0x200`: `start_duel` moves `tag_list_extra` into `list_extra` and renumbers, for both teams; `tag_swap` skips its Extra block. `card::tag_member` (0 `new_card`, 1 `new_tag_card`), `QUERY_TAG_MEMBER` `0x1000000` written last in `get_infos`. Bit `0x100000` stays unused: old flags set it with no value. | TICKET-433 | (a) `start_duel` option; (c) Query records |
|
||||
| 2026-11-02 | Server: `ygol.tag.extra=shared` is the fourth server-read pair. `TagDuel` sets the option in `opt`, sends the sum of both partners' Extra Decks in the opening `MSG_START`, runs the opening `RefreshExtra` after `start_duel`, and adds `QUERY_TAG_MEMBER` in `RefreshExtra`. `FEATURE_TAG_SHARED_EXTRA` `0x4000` advertised by Single and Tag rooms, protocol 10 -> 11; a Tag room refuses a joiner without the bit. | TICKET-433 | Wire: capability bit `0x4000`, protocol 11; (d) setup pair `ygol.tag.extra`; `0x5F` Extra count 0 in such a duel |
|
||||
| 2026-11-02 | Binding: `FeatureFlags.TagSharedExtra` (in `All`), `Capability.ProtocolVersion` 11. Probe: the tag shared Extra Deck rooms (pair present, pair absent, a Summon of the waiting partner's monster, the replay played back through the library, the Tag refusal, the Single room that keeps an old client). | TICKET-433 | (e) C# binding |
|
||||
|
||||
## v1.5.0 — 2026-10-24
|
||||
|
||||
Tag two Field slots (proposal 45): a Tag team on Master Rule 4/5 holds one Field Spell per partner. No new
|
||||
|
||||
+28
-10
@@ -26,8 +26,8 @@ next to the library (`out/win64/engine.json` on Windows):
|
||||
{
|
||||
"version": "v0.0.1",
|
||||
"exports": 335,
|
||||
"protocol": 10,
|
||||
"capabilities": 14335,
|
||||
"protocol": 11,
|
||||
"capabilities": 30719,
|
||||
"binding": "v0.0.1"
|
||||
}
|
||||
```
|
||||
@@ -36,8 +36,8 @@ next to the library (`out/win64/engine.json` on Windows):
|
||||
|---|---|---|
|
||||
| `version` | string | The `-Version` the build was given; `local` when none. The same string `ygol_engine_version()` returns. |
|
||||
| `exports` | integer | The library's export count after the gate passed (Windows: 335). |
|
||||
| `protocol` | integer | `FEATURE_PROTOCOL` in `server/gframe/network.h` (10 as of 2026-10-24). |
|
||||
| `capabilities` | integer | The OR of every `FEATURE_*` bit `SendServerCapability` advertises (`single_duel.cpp` and `tag_duel.cpp` must agree), as a decimal integer. 14335 = `0x37FF` = bits `0x1` to `0x400` plus `0x1000` and `0x2000` (`0x800` is reserved by proposal 44). |
|
||||
| `protocol` | integer | `FEATURE_PROTOCOL` in `server/gframe/network.h` (11 as of 2026-11-02). |
|
||||
| `capabilities` | integer | The OR of every `FEATURE_*` bit `SendServerCapability` advertises (`single_duel.cpp` and `tag_duel.cpp` must agree), as a decimal integer. 30719 = `0x77FF` = bits `0x1` to `0x400` plus `0x1000`, `0x2000` and `0x4000` (`0x800` is reserved by proposal 44). |
|
||||
| `binding` | string | The version of the C# binding released with this engine (section (e)); the same string as `version`. |
|
||||
|
||||
The build reads `protocol` and `capabilities` from the source every time; nothing types them in.
|
||||
@@ -93,7 +93,7 @@ The host string is space-separated tokens, in this order (`server/gframe/gframe.
|
||||
| `create_duel_v2` | `intptr_t create_duel_v2(uint32_t seed_sequence[])` | Upstream (`SEED_COUNT` = 8 words) |
|
||||
| `create_duel_ex` | `intptr_t create_duel_ex(uint_fast32_t seed, uint32_t create_flags)` | Upstream |
|
||||
| `create_duel_v2_ex` | `intptr_t create_duel_v2_ex(uint32_t seed_sequence[], uint32_t create_flags)` | Upstream |
|
||||
| `start_duel` | `void start_duel(intptr_t pduel, uint32_t options)` | Upstream |
|
||||
| `start_duel` | `void start_duel(intptr_t pduel, uint32_t options)` | Upstream. v1.6.0: option `DUEL_TAG_SHARED_EXTRA` `0x200` with `DUEL_TAG_MODE` merges each team's Extra Decks (section (b), behaviour v1.6.0). |
|
||||
| `end_duel` | `void end_duel(intptr_t pduel)` | Upstream |
|
||||
| `set_player_info` | `void set_player_info(intptr_t pduel, int32_t playerid, int32_t lp, int32_t startcount, int32_t drawcount)` | Upstream |
|
||||
| `get_log_message` | `void get_log_message(intptr_t pduel, char* buf)` | Upstream |
|
||||
@@ -165,11 +165,11 @@ the server itself speaks. The STOC form of a relayed message is always the CTOS
|
||||
stamp in front. "Stamp" in the tables below says whether the STOC message carries one.
|
||||
|
||||
**Capability.** The server sends `STOC_CAPABILITY` (stamp `0xFF`) to every connection between
|
||||
`STOC_JOIN_GAME` and `STOC_TYPE_CHANGE`: `protocol` = `FEATURE_PROTOCOL` (10) and `flags` = the OR of
|
||||
the bits below (`0x37FF`). A client sends its own `CTOS_CAPABILITY` after joining. A client refuses a
|
||||
`STOC_JOIN_GAME` and `STOC_TYPE_CHANGE`: `protocol` = `FEATURE_PROTOCOL` (11) and `flags` = the OR of
|
||||
the bits below (`0x77FF`). A client sends its own `CTOS_CAPABILITY` after joining. A client refuses a
|
||||
host without bit `0x4` as out of date, and without bit `0x1000` too (v1.5.0). A Tag room refuses a
|
||||
client whose `CTOS_CAPABILITY` lacks `0x1000`: `STOC_ERROR_MSG` `ERRMSG_VERERROR` (code =
|
||||
`FEATURE_PROTOCOL`), then the connection is closed; a Single room keeps it.
|
||||
client whose `CTOS_CAPABILITY` lacks `0x1000` or `0x4000` (v1.6.0): `STOC_ERROR_MSG` `ERRMSG_VERERROR`
|
||||
(code = `FEATURE_PROTOCOL`), then the connection is closed; a Single room keeps it.
|
||||
|
||||
**Join snapshot.** A joiner gets, per occupied seat, right after that seat's `STOC_HS_PLAYER_ENTER`:
|
||||
the seat's stored capability, appearance (0006), seat state (0013) and profile (0020) when present,
|
||||
@@ -236,6 +236,7 @@ duelist's own side (v1.2.0), both sides for an observer when spectators see all
|
||||
| `0x800` | reserved | - | - | Proposal 44 (agreed, not shipped) |
|
||||
| `0x1000` | `FEATURE_TAG_TWO_FIELDS` | 10 | v1.5.0 | Tag two Field slots: Spell/Trap sequence 6 is a team's second Field Zone (no message); a Tag room refuses a joiner without it |
|
||||
| `0x2000` | `FEATURE_TAG_PARTNER_CARDS` | 9 | v1.2.0 | Tag partner cards (`STOC_TAG_PARTNER_CARDS`, `ygol_query_tag_cards`) |
|
||||
| `0x4000` | `FEATURE_TAG_SHARED_EXTRA` | 11 | v1.6.0 | Tag shared Extra Deck: the setup pair `ygol.tag.extra=shared`, `QUERY_TAG_MEMBER` on Extra Deck refreshes; a Tag room refuses a joiner without it |
|
||||
|
||||
`FEATURE_PROTOCOL` is bumped by every patch that adds a message a client must understand; the join
|
||||
list hides hosts older than the client's number. Rule 4 (proposal 47): one feature, one door. Never
|
||||
@@ -255,6 +256,7 @@ carry a new feature inside another feature's message.
|
||||
| v1.3.0 | Tag partner cards reach observers: when spectators see all, `STOC_TAG_PARTNER_CARDS` goes to every observer for both sides at every send point, plus both sides in an observer's resync and the late-watcher snapshot. Same id, same payload, no new capability bit (TICKET-412). |
|
||||
| v1.4.0 | Life points per side: with the setup pair `ygol.side.b.lp=<n>` (section (d)) seat side B (seat 1; Tag seats 2 and 3) starts at `n` LP and side A at slot 8; without it both sides start at slot 8, as before. `set_player_info` gets each duel player its own LP, and `MSG_START` (the start and the late-watcher snapshot) carries `lp[0]`, `lp[1]` in duel player order: the side that goes first is player 0, so the two values swap when side B won the toss. `STOC_JOIN_GAME`'s `start_lp` stays side A's. Single, Match (every duel) and Tag; no new message, no capability bit. |
|
||||
| v1.5.0 | Tag two Field slots (proposal 45, TICKET-384; core `field::has_two_fields` = `DUEL_TAG_MODE` on Master Rule 4 or 5): a team has a Field slot per partner, Spell/Trap sequence 5 for the partner who plays the team's first turn and 6 for the other (`player_info::tag_partner` flips in `tag_swap`). A Field Spell that lands (activated, Set, `Duel.MoveToField` to `LOCATION_FZONE`) goes to the playing partner's slot and replaces only the card there; one that changes control while that slot is taken and the other is free takes the free one. A Set opens only the landing slot's bit in `MSG_SELECT_PLACE`. `LOCATION_FZONE` covers both slots (`Card.IsLocation`, `Duel.GetMatchingGroup` and the other filters, `Duel.IsEnvironment`, `Duel.CheckLocation(p, LOCATION_FZONE, 0/1)`), `Duel.GetFieldCard(p, LOCATION_FZONE, 0)` is the playing partner's field, else the other one, and sequence 1 the remaining one; `Duel.GetFieldCard(p, LOCATION_SZONE, 6)` works. The second field reaches a client as `MSG_MOVE` to Spell/Trap sequence 6 and in `MSG_RELOAD_FIELD`'s sixth Spell/Trap entry: no new message. Singles, Match and Master Rule 3 (where slot 6 is a Pendulum Zone) are unchanged. Scripts that name Spell/Trap sequence 5 by number see one field (the TICKET-384 closing note lists them). Capability `0x1000`, protocol 9 -> 10. |
|
||||
| v1.6.0 | Tag shared Extra Deck (proposal 53, TICKET-433): with the setup pair `ygol.tag.extra=shared` (section (d)) `TagDuel` sets the duel option `DUEL_TAG_SHARED_EXTRA` `0x200`. `start_duel` moves each team's `tag_list_extra` into `list_extra` (the first partner's cards first) and renumbers the sequences, so either partner can Summon any of the cards; `tag_swap` leaves the Extra Deck alone, `MSG_TAG_SWAP` keeps its layout and sends the one list, and `ygol_query_tag_cards` / `0x5F` report an Extra count of 0. The opening `MSG_START` carries the sum of both partners' Extra Decks, and the opening Extra Deck refreshes run after `start_duel`. The core has one `owner` per team, so each card has `card::tag_member`, set once when it is loaded (0 `new_card`, 1 `new_tag_card`), and `RefreshExtra` adds `QUERY_TAG_MEMBER` to its flag in such a duel (section (c), Query records). Replays need no format change: `opt` holds the option and every reader passes `opt` to `start_duel`; a reader that writes its own `MSG_START` before `start_duel` must add the partner's Extra count. An older engine ignores the option and plays such a replay wrongly. Without the pair every stream is unchanged. Capability `0x4000`, protocol 10 -> 11. |
|
||||
|
||||
### Replay
|
||||
|
||||
@@ -379,6 +381,21 @@ fork-related rows are marked.
|
||||
Ids 6, 7 and 34 are server-side (`network.h`); the core's `common.h` lists the rest. Any other id is
|
||||
an error for the consumer.
|
||||
|
||||
### Query records
|
||||
|
||||
`query_card`, `query_field_card` and the query buffer of `MSG_UPDATE_DATA` / `MSG_UPDATE_CARD` hold one
|
||||
record per card: `i32 length`, `u32 flag`, then one value per set `QUERY_*` bit in bit order, the bits
|
||||
in `core/common.h`. The fork adds one bit:
|
||||
|
||||
| Bit | Name | Value | Since |
|
||||
|---|---|---|---|
|
||||
| `0x1000000` | `QUERY_TAG_MEMBER` | `u32`, written LAST, after `QUERY_LINK`: the partner who brought the card, 0 from `new_card`, 1 from `new_tag_card`. It never changes when the card moves. The core writes it for any caller that sets the bit; the server sets it only on `RefreshExtra` in a duel with `ygol.tag.extra=shared` | v1.6.0 |
|
||||
|
||||
**Bit `0x100000` stays unused.** Old flags set it with no value after it: `RefreshSingle`'s default
|
||||
`0xf81fff`, the hand refresh `0x181fff` and YGOSharp's `0xFFFFFF` mask, and saved `.yrp3d` replays are
|
||||
recorded streams of them. A value for that bit would shift every later field of those records, with no
|
||||
error.
|
||||
|
||||
## (d) Setup pairs and the Lua API
|
||||
|
||||
### Setup pairs (patch 0009, TICKET-258; ADR 0004 in the Unity repo)
|
||||
@@ -390,13 +407,14 @@ never interprets a pair: it stores the ordered list (max 64 pairs, 512 bytes eac
|
||||
`0x40000000`) and sends them to every joiner as `STOC_SETUP_PAIRS` (`0x43`). Values that need `,`,
|
||||
`=`, `%` or a space are percent-encoded by the client (`MatchSetup.cs`).
|
||||
|
||||
Three pairs ARE read by the server itself:
|
||||
Four pairs ARE read by the server itself:
|
||||
|
||||
| Key | Value | Read by |
|
||||
|---|---|---|
|
||||
| `ygol.room.watchers` | `0` = no observers: every observer join and HsToObserver is refused | 0012 |
|
||||
| `ygol.room.spectatorview` | `hidden` = the stock masked observer stream; absent = spectators see all | 0018, 0019 |
|
||||
| `ygol.side.b.lp` | a positive integer: seat side B's start LP (seat 1; Tag seats 2 and 3); side A keeps slot 8. Absent, `0`, negative or not a number = both sides at slot 8 | v1.4.0 |
|
||||
| `ygol.tag.extra` | `shared` = a Tag team has one Extra Deck (option `0x200`, section (b) v1.6.0); anything else or absent = separate Extra Decks. A Single or Match room ignores it | v1.6.0 |
|
||||
|
||||
Keys the Unity client sends today (`Assets/YGOLegacy/Scripts/Core/Duel/MatchSetup.cs`,
|
||||
`SetupPairKeys`); the rules Lua reads them from the registry:
|
||||
|
||||
@@ -160,6 +160,19 @@
|
||||
# Duel.GetFieldCard(tp, LOCATION_FZONE, 0) is the playing partner's field and 1
|
||||
# the other, Duel.IsEnvironment and Card.IsLocation see sequence 6.
|
||||
#
|
||||
# With --dll it also gates v1.6.0 (proposal 53 / TICKET-433, Tag shared Extra Deck):
|
||||
# the capability says protocol 11 + flag 0x4000 (single and tag); a Tag room
|
||||
# refuses a joiner whose CTOS_CAPABILITY lacks 0x4000, a Single room keeps it. With
|
||||
# ygol.tag.extra=shared MSG_START carries the sum of both partners' Extra Decks,
|
||||
# the opening Extra Deck refresh lists all of them with QUERY_TAG_MEMBER 0x1000000
|
||||
# (0 from seat 0 / 2, 1 from seat 1 / 3; the other team's masked copy has flag 0),
|
||||
# 0x5F reports an Extra count of 0, seat 0 Summons seat 1's monster on turn 1,
|
||||
# seat 1 returns it on turn 3, and the value is still 1 in the refresh after the
|
||||
# swap of turn 5; a late watcher's snapshot refresh has the values; no
|
||||
# other query carries the bit; the replay has option 0x200 and plays back through
|
||||
# the library to the same Summons. Without the pair the partners' lists stay
|
||||
# apart and no query carries the bit.
|
||||
#
|
||||
# Exit 0 only when every check passed. Stock DLL: the first check fails; the
|
||||
# 0011 DLL fails at the capability flags.
|
||||
import argparse, base64, ctypes, lzma, os, shutil, socket, sqlite3, struct, sys, tempfile, threading, time
|
||||
@@ -305,7 +318,7 @@ def check_snapshot(who, pkts, expect_seat_appearance, forbid_seat):
|
||||
check(len(server_caps) == 1 and j < server_caps[0][0] < t, "%s: the server's CAPABILITY(0xFF) sits between JOIN_GAME and TYPE_CHANGE" % who)
|
||||
if server_caps:
|
||||
proto, flags = struct.unpack_from("<HI", server_caps[0][1], 2)
|
||||
check(proto == 10 and flags == 0x37FF, "%s: server capability is protocol 10, flags 0x37FF (appearance | dialogue | setup pairs | seat plan | rules restart | seat state | lobby after match | coin toss | deck lists | profile | attack preview | tag two fields | tag partner cards), got %d / 0x%x" % (who, proto, flags))
|
||||
check(proto == 11 and flags == 0x77FF, "%s: server capability is protocol 11, flags 0x77FF (appearance | dialogue | setup pairs | seat plan | rules restart | seat state | lobby after match | coin toss | deck lists | profile | attack preview | tag two fields | tag partner cards | tag shared extra), got %d / 0x%x" % (who, proto, flags))
|
||||
for seat, expected in expect_seat_appearance.items():
|
||||
enters = [i for i, (p, d) in enumerate(pkts) if p == STOC_HS_PLAYER_ENTER and d[40] == seat]
|
||||
apps = [i for i, (p, d) in enumerate(pkts) if p == STOC_APPEARANCE and struct.unpack_from("<H", d, 0)[0] == seat]
|
||||
@@ -368,6 +381,7 @@ def main():
|
||||
tag_partner_suite(o.dll, port + 110)
|
||||
tag_across_swap_suite(o.dll, port + 120)
|
||||
tag_two_fields_suite(o.dll, port + 130)
|
||||
tag_shared_extra_suite(o.dll, port + 140)
|
||||
print()
|
||||
if failures:
|
||||
print("FAILED: %d check(s)" % len(failures))
|
||||
@@ -558,6 +572,17 @@ def make_workspace():
|
||||
db.close()
|
||||
with open(os.path.join(root, "script", "c%d.lua" % PROBE_FIELD), "w", newline="\n") as f:
|
||||
f.write(FIELD_LUA)
|
||||
# proposal 53 (TICKET-433): a Fusion per seat and a Spell that Summons one or returns it
|
||||
db = sqlite3.connect(os.path.join(root, "cards.cdb"))
|
||||
for i, code in enumerate(PROBE_SEAT_FUSIONS):
|
||||
db.execute("INSERT INTO datas VALUES(?, 3, 0, 0, 65, 2000, 2000, 6, 1, 16, 0)", (code,))
|
||||
db.execute("INSERT INTO texts VALUES(?, 'Probe Seat Fusion %d', ''" % i + ", ''" * 16 + ")", (code,))
|
||||
db.execute("INSERT INTO datas VALUES(?, 3, 0, 0, 2, 0, 0, 0, 0, 0, 0)", (PROBE_EXTRA_SPELL,))
|
||||
db.execute("INSERT INTO texts VALUES(?, 'Probe Extra Spell', ''" + ", ''" * 16 + ")", (PROBE_EXTRA_SPELL,))
|
||||
db.commit()
|
||||
db.close()
|
||||
with open(os.path.join(root, "script", "c%d.lua" % PROBE_EXTRA_SPELL), "w", newline="\n") as f:
|
||||
f.write(EXTRA_SPELL_LUA)
|
||||
return root
|
||||
|
||||
|
||||
@@ -1141,7 +1166,7 @@ def restart_room(dll_path, port, label, mode):
|
||||
pk = drain_all([h, g, w])
|
||||
check(not statuses(pk[g]) and not restarting(pk[h]), "%s: a non-host's Prepare is ignored" % label)
|
||||
for c in (h, g, w):
|
||||
c.send(CTOS_CAPABILITY, capability_bytes(2, 0x1F | FEATURE_TAG_TWO_FIELDS)) # a Tag room refuses a client without 0x1000 (proposal 45)
|
||||
c.send(CTOS_CAPABILITY, capability_bytes(2, 0x1F | FEATURE_TAG_TWO_FIELDS | FEATURE_TAG_SHARED_EXTRA)) # a Tag room refuses a client without 0x1000 (proposal 45) or 0x4000 (proposal 53)
|
||||
drain_all([h, g, w])
|
||||
h.send(CTOS_RESTART_PREPARE, prepare_bytes(rid, 30000, seats + 1, [ta, tb], tw))
|
||||
pk = drain_all([h, g, w])
|
||||
@@ -2690,7 +2715,7 @@ def tag_partner_room(dll_path, port, label, hidden):
|
||||
everyone = seated + [w]
|
||||
check([c.seat for c in everyone] == [0, 1, 2, 3, OBSERVER], "%s: four seats and a watcher (%r)" % (label, [c.seat for c in everyone]))
|
||||
cap = server_capability(seated[0].log)
|
||||
check(cap == (10, 0x37FF), "%s: the tag server's capability is protocol 10, flags 0x37FF (got %s)" % (label, cap))
|
||||
check(cap == (11, 0x77FF), "%s: the tag server's capability is protocol 11, flags 0x77FF (got %s)" % (label, cap))
|
||||
drain_all(everyone)
|
||||
for c in seated:
|
||||
c.send(CTOS_UPDATE_DECK, deck_bytes(TAG_PARTNER_DECKS[c.seat]))
|
||||
@@ -3080,7 +3105,7 @@ def tag_two_fields_room(dll_path, port, label):
|
||||
seated.append(c)
|
||||
check([c.seat for c in seated] == [0, 1, 2, 3], "%s: four seats (%r)" % (label, [c.seat for c in seated]))
|
||||
cap = server_capability(seated[0].log)
|
||||
check(cap == (10, 0x37FF), "%s: the tag server's capability is protocol 10, flags 0x37FF (got %s)" % (label, cap))
|
||||
check(cap == (11, 0x77FF), "%s: the tag server's capability is protocol 11, flags 0x77FF (got %s)" % (label, cap))
|
||||
drain_all(seated)
|
||||
old = Client("127.0.0.1", port, "tf-old")
|
||||
old.log = list(old.join())
|
||||
@@ -3090,10 +3115,10 @@ def tag_two_fields_room(dll_path, port, label):
|
||||
"%s: a joiner whose capability lacks 0x1000 gets ERROR_MSG VERERROR and is disconnected (seat %r, errors %r, closed %r)" % (label, old.seat, error_msgs(old.log), old.closed))
|
||||
new = Client("127.0.0.1", port, "tf-new")
|
||||
new.log = list(new.join())
|
||||
new.send(CTOS_CAPABILITY, capability_bytes(10, 0x37FB))
|
||||
new.send(CTOS_CAPABILITY, capability_bytes(11, 0x77FB))
|
||||
new.log += new.drain(quiet=0.4)
|
||||
check(new.seat == OBSERVER and not error_msgs(new.log) and not new.closed and stamped(new.log, STOC_CAPABILITY, OBSERVER) == [capability_bytes(10, 0x37FB)],
|
||||
"%s: a joiner with 0x1000 stays and its CAPABILITY is relayed (errors %r, closed %r)" % (label, error_msgs(new.log), new.closed))
|
||||
check(new.seat == OBSERVER and not error_msgs(new.log) and not new.closed and stamped(new.log, STOC_CAPABILITY, OBSERVER) == [capability_bytes(11, 0x77FB)],
|
||||
"%s: a joiner with 0x1000 and 0x4000 stays and its CAPABILITY is relayed (errors %r, closed %r)" % (label, error_msgs(new.log), new.closed))
|
||||
new.close()
|
||||
drain_all(seated)
|
||||
decks = {0: [PROBE_FIELD] * 40, 1: [PROBE_FIELD] * 40, 2: [PROBE_CARD] * 40, 3: [PROBE_CARD] * 40}
|
||||
@@ -3192,7 +3217,7 @@ def tag_two_fields_single(dll_path, port, label):
|
||||
h = Client("127.0.0.1", port, "tf-host")
|
||||
h.log = list(h.join())
|
||||
cap = server_capability(h.log)
|
||||
check(cap == (10, 0x37FF), "%s: the single server's capability is protocol 10, flags 0x37FF (got %s)" % (label, cap))
|
||||
check(cap == (11, 0x77FF), "%s: the single server's capability is protocol 11, flags 0x77FF (got %s)" % (label, cap))
|
||||
h.send(CTOS_CAPABILITY, capability_bytes(9, 0x27FF))
|
||||
h.log += h.drain(quiet=0.4)
|
||||
check(h.seat == 0 and not error_msgs(h.log) and not h.closed and stamped(h.log, STOC_CAPABILITY, 0) == [capability_bytes(9, 0x27FF)],
|
||||
@@ -3210,5 +3235,382 @@ def tag_two_fields_suite(dll_path, port):
|
||||
tag_two_fields_room(dll_path, port, "tag")
|
||||
tag_two_fields_single(dll_path, port + 1, "single")
|
||||
|
||||
# --- proposal 53 (TICKET-433): Tag shared Extra Deck --------------------------------------------
|
||||
# With the setup pair ygol.tag.extra=shared the server sets option 0x200 and start_duel moves the
|
||||
# waiting partner's Extra Deck into the live list; tag_swap leaves it there. Each card keeps the
|
||||
# partner who brought it, sent as QUERY_TAG_MEMBER on Extra Deck refreshes of that duel only.
|
||||
# Capability 0x4000, protocol 11. Without the pair the lists stay apart.
|
||||
FEATURE_TAG_SHARED_EXTRA = 0x4000
|
||||
QUERY_TAG_MEMBER = 0x1000000
|
||||
DUEL_TAG_SHARED_EXTRA = 0x200
|
||||
TAG_EXTRA_PAIR = "ygol.tag.extra=shared"
|
||||
PROBE_EXTRA_SPELL = PROBE_CARD + 900
|
||||
PROBE_SEAT_FUSIONS = [PROBE_CARD + 901 + seat for seat in range(4)]
|
||||
SEAT_EXTRA = {0: [PROBE_SEAT_FUSIONS[0]] * 2, 1: [PROBE_SEAT_FUSIONS[1]], 2: [PROBE_SEAT_FUSIONS[2]], 3: [PROBE_SEAT_FUSIONS[3]] * 3}
|
||||
MSG_UPDATE_DATA, MSG_UPDATE_CARD, LOCATION_EXTRA = 6, 7, 0x40
|
||||
EXTRA_SPELL_LUA = """--Probe Extra Spell (proposal 53): return your face-up Fusion Monster to the Extra Deck; with none, Special Summon 1 from it.
|
||||
local s,id,o=GetID()
|
||||
function s.initial_effect(c)
|
||||
local e1=Effect.CreateEffect(c)
|
||||
e1:SetType(EFFECT_TYPE_ACTIVATE)
|
||||
e1:SetCode(EVENT_FREE_CHAIN)
|
||||
e1:SetTarget(s.target)
|
||||
e1:SetOperation(s.activate)
|
||||
c:RegisterEffect(e1)
|
||||
end
|
||||
function s.onfield(c)
|
||||
return c:IsFaceup() and c:IsType(TYPE_FUSION)
|
||||
end
|
||||
function s.inextra(c)
|
||||
return c:IsType(TYPE_FUSION)
|
||||
end
|
||||
function s.target(e,tp,eg,ep,ev,re,r,rp,chk)
|
||||
if chk==0 then return Duel.IsExistingMatchingCard(s.onfield,tp,LOCATION_MZONE,0,1,nil) or Duel.IsExistingMatchingCard(s.inextra,tp,LOCATION_EXTRA,0,1,nil) end
|
||||
end
|
||||
function s.activate(e,tp,eg,ep,ev,re,r,rp)
|
||||
local f=Duel.GetFirstMatchingCard(s.onfield,tp,LOCATION_MZONE,0,nil)
|
||||
if f then
|
||||
Duel.SendtoDeck(f,nil,0,REASON_EFFECT)
|
||||
return
|
||||
end
|
||||
local tc=Duel.SelectMatchingCard(tp,s.inextra,tp,LOCATION_EXTRA,0,1,1,nil):GetFirst()
|
||||
if tc then Duel.SpecialSummon(tc,0,tp,tp,true,false,POS_FACEUP) end
|
||||
end
|
||||
"""
|
||||
|
||||
|
||||
def query_records(d, at):
|
||||
# (flag, code or None, value of QUERY_TAG_MEMBER or None) per record of a query buffer
|
||||
out = []
|
||||
while at + 4 <= len(d):
|
||||
(clen,) = struct.unpack_from("<i", d, at)
|
||||
if clen < 4:
|
||||
break
|
||||
if clen >= 8:
|
||||
(flag,) = struct.unpack_from("<I", d, at + 4)
|
||||
code = struct.unpack_from("<I", d, at + 8)[0] if flag & 1 and clen >= 12 else None
|
||||
member = struct.unpack_from("<I", d, at + clen - 4)[0] if flag & QUERY_TAG_MEMBER else None
|
||||
out.append((flag, code, member))
|
||||
at += clen
|
||||
return out
|
||||
|
||||
|
||||
def extra_refreshes(pkts, side):
|
||||
return [query_records(d, 3) for p, d in pkts if p == 0x01 and len(d) >= 3 and d[0] == MSG_UPDATE_DATA and d[1] == side and d[2] == LOCATION_EXTRA]
|
||||
|
||||
|
||||
def other_queries_with_bit(pkts):
|
||||
bad = 0
|
||||
for p, d in pkts:
|
||||
if p != 0x01 or len(d) < 3:
|
||||
continue
|
||||
if d[0] == MSG_UPDATE_DATA and d[2] != LOCATION_EXTRA:
|
||||
bad += sum(1 for r in query_records(d, 3) if r[0] & QUERY_TAG_MEMBER)
|
||||
elif d[0] == MSG_UPDATE_CARD:
|
||||
bad += sum(1 for r in query_records(d, 4) if r[0] & QUERY_TAG_MEMBER)
|
||||
return bad
|
||||
|
||||
|
||||
def start_extra_counts(pkts):
|
||||
# MSG_START: player, rule, i32 lp[2], u16 deck0, extra0, deck1, extra1
|
||||
return [(struct.unpack_from("<H", d, 13)[0], struct.unpack_from("<H", d, 17)[0]) for p, d in pkts if p == 0x01 and len(d) >= 19 and d[0] == MSG_START]
|
||||
|
||||
|
||||
def members_by_code(records):
|
||||
return sorted((r[1], r[2]) for r in records)
|
||||
|
||||
|
||||
def replay_duel_parts(body, flag):
|
||||
# the replay body up to the responses: (opt, start_lp, start_hand, draw_count, decks, responses)
|
||||
at = 4 + struct.unpack_from("<I", body, 0)[0] if flag & REPLAY_YGOL_SETUP_PAIRS else 0
|
||||
at += 4 * 40
|
||||
start_lp, start_hand, draw_count, opt = struct.unpack_from("<iiiI", body, at)
|
||||
at += 16
|
||||
decks = []
|
||||
for _ in range(8):
|
||||
(n,) = struct.unpack_from("<i", body, at)
|
||||
decks.append(list(struct.unpack_from("<%dI" % n, body, at + 4)))
|
||||
at += 4 + 4 * n
|
||||
responses = []
|
||||
while at < len(body):
|
||||
n = body[at]
|
||||
responses.append(body[at + 1:at + 1 + n])
|
||||
at += 1 + n
|
||||
return opt, start_lp, start_hand, draw_count, decks, responses
|
||||
|
||||
|
||||
def play_replay_back(dll, seeds, parts, pairs):
|
||||
# the library plays the recorded duel again, as a replay reader does: what start_duel made, then the Summons
|
||||
opt, start_lp, start_hand, draw_count, decks, responses = parts
|
||||
h = ctypes.c_ssize_t
|
||||
dll.create_duel_v2.restype = h
|
||||
dll.create_duel_v2.argtypes = [ctypes.POINTER(ctypes.c_uint32)]
|
||||
dll.set_player_info.argtypes = [h, ctypes.c_int32, ctypes.c_int32, ctypes.c_int32, ctypes.c_int32]
|
||||
dll.set_registry_value.argtypes = [h, ctypes.c_char_p, ctypes.c_char_p]
|
||||
dll.preload_script.argtypes = [h, ctypes.c_char_p]
|
||||
dll.new_card.argtypes = [h, ctypes.c_uint32, ctypes.c_uint8, ctypes.c_uint8, ctypes.c_uint8, ctypes.c_uint8, ctypes.c_uint8]
|
||||
dll.new_tag_card.argtypes = [h, ctypes.c_uint32, ctypes.c_uint8, ctypes.c_uint8]
|
||||
dll.start_duel.argtypes = [h, ctypes.c_uint32]
|
||||
dll.process.restype = ctypes.c_uint32
|
||||
dll.process.argtypes = [h]
|
||||
dll.get_message.argtypes = [h, ctypes.c_char_p]
|
||||
dll.set_responseb.argtypes = [h, ctypes.c_char_p]
|
||||
dll.query_field_count.argtypes = [h, ctypes.c_uint8, ctypes.c_uint8]
|
||||
dll.query_field_card.argtypes = [h, ctypes.c_uint8, ctypes.c_uint8, ctypes.c_uint32, ctypes.c_char_p, ctypes.c_int32]
|
||||
dll.ygol_query_tag_cards.argtypes = [h, ctypes.c_uint8, ctypes.c_char_p]
|
||||
dll.end_duel.argtypes = [h]
|
||||
d = dll.create_duel_v2((ctypes.c_uint32 * 8)(*seeds))
|
||||
for pair in pairs:
|
||||
k, v = pair.split("=", 1)
|
||||
dll.set_registry_value(d, k.encode(), v.encode())
|
||||
dll.set_player_info(d, 0, start_lp, start_hand, draw_count)
|
||||
dll.set_player_info(d, 1, start_lp, start_hand, draw_count)
|
||||
dll.preload_script(d, b"./script/init.lua")
|
||||
for i, codes in enumerate(decks):
|
||||
team, kind = i // 4, i % 4
|
||||
for code in codes:
|
||||
location = LOCATION_EXTRA if kind % 2 else 0x01
|
||||
if kind < 2:
|
||||
dll.new_card(d, code, team, team, location, 0, 0x08)
|
||||
else:
|
||||
dll.new_tag_card(d, code, team, location)
|
||||
dll.start_duel(d, opt)
|
||||
buf = ctypes.create_string_buffer(0x40000)
|
||||
out = {"counts": (dll.query_field_count(d, 0, LOCATION_EXTRA), dll.query_field_count(d, 1, LOCATION_EXTRA))}
|
||||
|
||||
def extra(team):
|
||||
n = dll.query_field_card(d, team, LOCATION_EXTRA, 0x1 | QUERY_TAG_MEMBER, buf, 0)
|
||||
return members_by_code(query_records(buf.raw[:n], 0))
|
||||
|
||||
def waiting_extra(team):
|
||||
dll.ygol_query_tag_cards(d, team, buf)
|
||||
return buf.raw[2]
|
||||
|
||||
out["opening"] = (extra(0), extra(1))
|
||||
out["waiting"] = (waiting_extra(0), waiting_extra(1))
|
||||
stream = b""
|
||||
left = list(responses)
|
||||
for _ in range(100000):
|
||||
r = dll.process(d)
|
||||
n = r & 0x0FFFFFFF
|
||||
if n:
|
||||
got = dll.get_message(d, buf)
|
||||
stream += buf.raw[:got]
|
||||
if r & 0x20000000:
|
||||
break
|
||||
if r & 0x10000000:
|
||||
if not left:
|
||||
break
|
||||
one = ctypes.create_string_buffer(left.pop(0), 256)
|
||||
dll.set_responseb(d, one)
|
||||
out["responses_left"] = len(left)
|
||||
out["summons"] = []
|
||||
at = 0
|
||||
while True:
|
||||
at = stream.find(bytes([MSG_SPSUMMONING]), at)
|
||||
if at < 0 or at + 5 > len(stream):
|
||||
break
|
||||
(code,) = struct.unpack_from("<I", stream, at + 1)
|
||||
if code in PROBE_SEAT_FUSIONS:
|
||||
out["summons"].append(code)
|
||||
at += 1
|
||||
out["end_extra"] = extra(0)
|
||||
dll.end_duel(d)
|
||||
return out
|
||||
|
||||
|
||||
def tag_shared_extra_room(dll_path, port, label, shared):
|
||||
print("== tag shared Extra Deck, %s" % label)
|
||||
F0, F1, F2, F3 = PROBE_SEAT_FUSIONS
|
||||
root = make_workspace()
|
||||
here = os.getcwd()
|
||||
os.chdir(root)
|
||||
try:
|
||||
pairs = [TAG_EXTRA_PAIR] if shared else []
|
||||
write_special(root, pairs)
|
||||
dll, thread = host_dll(dll_path, port, 2, " ".join(pairs))
|
||||
seated = []
|
||||
for i in range(4):
|
||||
c = Client("127.0.0.1", port, "se-seat%d" % i)
|
||||
c.log = list(c.join())
|
||||
seated.append(c)
|
||||
check([c.seat for c in seated] == [0, 1, 2, 3], "%s: four seats (%r)" % (label, [c.seat for c in seated]))
|
||||
cap = server_capability(seated[0].log)
|
||||
check(cap == (11, 0x77FF), "%s: the tag server's capability is protocol 11, flags 0x77FF (got %s)" % (label, cap))
|
||||
drain_all(seated)
|
||||
old = Client("127.0.0.1", port, "se-old")
|
||||
old.log = list(old.join())
|
||||
old.send(CTOS_CAPABILITY, capability_bytes(10, 0x37FF))
|
||||
old.log += old.drain(quiet=0.4)
|
||||
check(old.seat == OBSERVER and error_msgs(old.log) == [ERRMSG_VERERROR] and old.closed,
|
||||
"%s: a joiner with 0x1000 but without 0x4000 gets ERROR_MSG VERERROR and is disconnected (seat %r, errors %r, closed %r)" % (label, old.seat, error_msgs(old.log), old.closed))
|
||||
drain_all(seated)
|
||||
watcher = Client("127.0.0.1", port, "se-watch")
|
||||
watcher.log = list(watcher.join())
|
||||
drain_all(seated + [watcher])
|
||||
for c in seated:
|
||||
spell = PROBE_EXTRA_SPELL if c.seat < 2 else PROBE_KNIGHT
|
||||
c.send(CTOS_UPDATE_DECK, deck_bytes([spell] * 40 + SEAT_EXTRA[c.seat]))
|
||||
pump(seated, lambda: False, limit=0.8)
|
||||
seated[0].send(CTOS_HS_START)
|
||||
state = {"turn": 0, "acted": 0, "retries": 0, "selects": [], "summons": [], "swaps": []}
|
||||
picks = {1: F1, 5: F0} if shared else {1: F0}
|
||||
|
||||
def answer(c, payload):
|
||||
c.send(CTOS_TIME_CONFIRM)
|
||||
c.send(CTOS_RESPONSE, payload)
|
||||
|
||||
def play(until, limit):
|
||||
deadline = time.time() + limit
|
||||
while time.time() < deadline:
|
||||
watcher.log += watcher.drain(quiet=0.02, limit=0.1)
|
||||
for c in seated:
|
||||
for pid, d in c.drain(quiet=0.02, limit=0.2):
|
||||
c.log.append((pid, d))
|
||||
if pid == STOC_SELECT_TP:
|
||||
c.send(CTOS_TP_RESULT, bytes([1 if c.seat == 0 else 0])) # side A (seats 0 + 1) goes first
|
||||
continue
|
||||
if pid != 0x01 or not d:
|
||||
continue
|
||||
t = d[0]
|
||||
if t == MSG_NEW_TURN and c.seat == 0:
|
||||
state["turn"] += 1
|
||||
elif t == MSG_TAG_SWAP and c.seat == 0 and d[1] == 0:
|
||||
state["swaps"].append((state["turn"], d[3], d[4], len(c.log) - 1))
|
||||
elif t == MSG_SPSUMMONING and c.seat == 0:
|
||||
state["summons"].append((state["turn"], struct.unpack_from("<I", d, 1)[0]))
|
||||
elif t == MSG_RETRY:
|
||||
state["retries"] += 1
|
||||
elif t == MSG_SELECT_IDLECMD:
|
||||
n = 2
|
||||
for k in range(5):
|
||||
n += 1 + d[n] * 7
|
||||
activatable = d[n]
|
||||
if activatable and state["acted"] != state["turn"]:
|
||||
state["acted"] = state["turn"]
|
||||
answer(c, struct.pack("<i", 5)) # activate the first card: the Spell
|
||||
else:
|
||||
answer(c, struct.pack("<i", 7)) # to the End Phase
|
||||
elif t == MSG_SELECT_CARD:
|
||||
cards = [struct.unpack_from("<II", d, 6 + 8 * i) for i in range(d[5])]
|
||||
state["selects"].append((state["turn"], sorted((info_location(v)[2], code) for code, v in cards)))
|
||||
want = picks.get(state["turn"])
|
||||
answer(c, bytes([1, next((i for i, card in enumerate(cards) if card[0] == want), 0)]))
|
||||
elif t == MSG_SELECT_TRIBUTE:
|
||||
answer(c, bytes([1, 0]))
|
||||
elif t == MSG_SELECT_CHAIN:
|
||||
answer(c, struct.pack("<i", -1))
|
||||
elif t in (MSG_SELECT_PLACE, MSG_SELECT_DISFIELD):
|
||||
answer(c, first_free_zone(d))
|
||||
elif t == MSG_SELECT_POSITION:
|
||||
answer(c, struct.pack("<i", next(b for b in (1, 2, 4, 8) if d[6] & b)))
|
||||
elif t in (MSG_SELECT_EFFECTYN, MSG_SELECT_YESNO):
|
||||
answer(c, struct.pack("<i", 1))
|
||||
elif t in (MSG_SELECT_OPTION, MSG_SELECT_BATTLECMD):
|
||||
answer(c, struct.pack("<i", 0 if t == MSG_SELECT_OPTION else 3))
|
||||
if until():
|
||||
return True
|
||||
if any(c.closed for c in seated):
|
||||
return False
|
||||
return until()
|
||||
|
||||
last_turn = 6 if shared else 4
|
||||
ok = play(lambda: state["turn"] >= last_turn, limit=60)
|
||||
check(ok, "%s: the duel reached turn %d (turn %d)" % (label, last_turn, state["turn"]))
|
||||
check(state["retries"] == 0, "%s: no answer was refused (MSG_RETRY x%d)" % (label, state["retries"]))
|
||||
for c in seated:
|
||||
check(start_extra_counts(c.log) == [(3, 4) if shared else (2, 1)], "%s: seat %d's MSG_START gives the Extra Deck counts %s (%r)" % (label, c.seat, (3, 4) if shared else (2, 1), start_extra_counts(c.log)))
|
||||
check(other_queries_with_bit(c.log) == 0, "%s: seat %d: no other query carries QUERY_TAG_MEMBER (%d)" % (label, c.seat, other_queries_with_bit(c.log)))
|
||||
if shared:
|
||||
opening = {0: [(F0, 0), (F0, 0), (F1, 1)], 1: [(F2, 0), (F3, 1), (F3, 1), (F3, 1)]}
|
||||
for c in seated:
|
||||
own, other = c.seat // 2, 1 - c.seat // 2
|
||||
first = extra_refreshes(c.log, own)
|
||||
check(bool(first) and members_by_code(first[0]) == opening[own], "%s: seat %d's first Extra Deck refresh lists both partners' cards with the partner each came from (%r)" % (label, c.seat, members_by_code(first[0]) if first else None))
|
||||
masked = extra_refreshes(c.log, other)
|
||||
check(bool(masked) and len(masked[0]) == len(opening[other]) and all(r[0] == 0 for r in masked[0]), "%s: seat %d's copy of the other team's refresh is masked, flag 0, no value (%r)" % (label, c.seat, masked[0] if masked else None))
|
||||
cards = partner_cards(c.log, own)
|
||||
check(bool(cards) and all(g[3] == [] for g in cards) and len(cards[0][2]) == 5, "%s: seat %d's TAG_PARTNER_CARDS report an Extra count of 0, and the waiting hand stays (%r)" % (label, c.seat, [(g[3], len(g[2] or [])) for g in cards]))
|
||||
for team in (0, 1):
|
||||
first = extra_refreshes(watcher.log, team)
|
||||
check(bool(first) and members_by_code(first[0]) == opening[team], "%s: the watcher's first refresh of side %d has the values too (%r)" % (label, team, members_by_code(first[0]) if first else None))
|
||||
check(state["selects"][:1] == [(1, [(0, F0), (1, F0), (2, F1)])],
|
||||
"%s: on turn 1 seat 0 is offered both partners' Fusions, in sequences 0, 1, 2 (%r)" % (label, state["selects"][:1]))
|
||||
check(state["summons"] == [(1, F1), (5, F0)], "%s: seat 0 Summons seat 1's monster on turn 1, its own on turn 5 (%r)" % (label, state["summons"]))
|
||||
check([s[:3] for s in state["swaps"]] == [(3, 2, 0), (5, 3, 0)],
|
||||
"%s: MSG_TAG_SWAP keeps the one list: 2 cards on turn 3, 3 on turn 5 when seat 1 returned the Fusion (%r)" % (label, [s[:3] for s in state["swaps"]]))
|
||||
log = seated[0].log
|
||||
after = extra_refreshes(log[state["swaps"][1][3]:], 0) if len(state["swaps"]) > 1 else []
|
||||
check(bool(after) and members_by_code(after[0]) == [(F0, 0), (F0, 0), (F1, 1)], "%s: after the swap of turn 5 the Fusion that moved still says partner 1 (%r)" % (label, members_by_code(after[0]) if after else None))
|
||||
late = Client("127.0.0.1", port, "se-late")
|
||||
late.log = list(late.join())
|
||||
late.log += late.drain(quiet=0.6)
|
||||
snapshot = extra_refreshes(late.log, 0)
|
||||
check(bool(snapshot) and members_by_code(snapshot[0]) == [(F0, 0), (F1, 1)], "%s: a late watcher's snapshot refresh has the values (flag 0xefffff + the bit) (%r)" % (label, members_by_code(snapshot[0]) if snapshot else None))
|
||||
late.close()
|
||||
else:
|
||||
for c in seated + [watcher]:
|
||||
for team in (0, 1):
|
||||
records = [r for refresh in extra_refreshes(c.log, team) for r in refresh]
|
||||
check(bool(records) and not any(r[0] & QUERY_TAG_MEMBER for r in records), "%s: %s: no Extra Deck refresh of side %d carries the bit" % (label, c.name, team))
|
||||
cards = partner_cards(seated[0].log, 0)
|
||||
check(bool(cards) and cards[0][3] == [F1], "%s: the opening TAG_PARTNER_CARDS report the waiting partner's Extra Deck (%r)" % (label, cards[0][3] if cards else None))
|
||||
check(state["selects"][:1] == [(1, [(0, F0), (1, F0)])], "%s: on turn 1 seat 0 is offered only its own Fusions (%r)" % (label, state["selects"][:1]))
|
||||
check(state["summons"] == [(1, F0)], "%s: seat 0 Summons its own monster on turn 1 (%r)" % (label, state["summons"]))
|
||||
check([s[:3] for s in state["swaps"]] == [(3, 1, 0)], "%s: the swap of turn 3 brings seat 1's Extra Deck (%r)" % (label, [s[:3] for s in state["swaps"]]))
|
||||
marks = marks_of(seated)
|
||||
for c in seated[:2]:
|
||||
c.send(CTOS_SURRENDER)
|
||||
ok = pump(seated, lambda: all(match_overs(since(c, marks)) for c in seated), limit=10)
|
||||
check(ok, "%s: side 0 surrendered: MATCH_OVER reached everyone" % label)
|
||||
reps = replays(seated[0])
|
||||
if check(len(reps) == 1, "%s: one REPLAY arrived (%d)" % (label, len(reps))):
|
||||
flag, seeds, body = reps[0]
|
||||
parts = replay_duel_parts(body, flag)
|
||||
check(bool(parts[0] & DUEL_TAG_SHARED_EXTRA) == shared, "%s: the replay's opt %s option 0x200 (opt 0x%x)" % (label, "has" if shared else "does not have", parts[0]))
|
||||
back = play_replay_back(dll, seeds, parts, pairs)
|
||||
if shared:
|
||||
check(back["counts"] == (3, 4) and back["waiting"] == (0, 0), "%s: replay: start_duel merged: live Extra Decks 3 and 4, waiting lists 0 (%r, %r)" % (label, back["counts"], back["waiting"]))
|
||||
check(back["opening"] == ([(F0, 0), (F0, 0), (F1, 1)], [(F2, 0), (F3, 1), (F3, 1), (F3, 1)]), "%s: replay: the query gives each card its partner (%r)" % (label, back["opening"]))
|
||||
check(back["summons"] == [F1, F0], "%s: replay: the recorded answers Summon the waiting partner's monster, then seat 0's (%r)" % (label, back["summons"]))
|
||||
check(back["responses_left"] == 0 and back["end_extra"] == [(F0, 0), (F1, 1)], "%s: replay: every answer was used and the Extra Deck ends as it did live (%d left, %r)" % (label, back["responses_left"], back["end_extra"]))
|
||||
else:
|
||||
check(back["counts"] == (2, 1) and back["waiting"] == (1, 3), "%s: replay: the lists stay apart: live 2 and 1, waiting 1 and 3 (%r, %r)" % (label, back["counts"], back["waiting"]))
|
||||
check(back["summons"] == [F0] and back["responses_left"] == 0, "%s: replay: the recorded answers Summon the same monster (%r, %d left)" % (label, back["summons"], back["responses_left"]))
|
||||
for c in seated + [watcher]:
|
||||
c.close()
|
||||
stop_dll(dll, thread, label)
|
||||
finally:
|
||||
os.chdir(here)
|
||||
shutil.rmtree(root, ignore_errors=True)
|
||||
|
||||
|
||||
def tag_shared_extra_single(dll_path, port, label):
|
||||
print("== tag shared Extra Deck, %s (a Single room keeps a client without 0x4000)" % label)
|
||||
root = make_workspace()
|
||||
here = os.getcwd()
|
||||
os.chdir(root)
|
||||
try:
|
||||
write_special(root, [])
|
||||
dll, thread = host_dll(dll_path, port, 0)
|
||||
h = Client("127.0.0.1", port, "se-host")
|
||||
h.log = list(h.join())
|
||||
h.send(CTOS_CAPABILITY, capability_bytes(10, 0x37FF))
|
||||
h.log += h.drain(quiet=0.4)
|
||||
check(h.seat == 0 and not error_msgs(h.log) and not h.closed, "%s: a seat whose capability lacks 0x4000 stays (errors %r, closed %r)" % (label, error_msgs(h.log), h.closed))
|
||||
h.close()
|
||||
stop_dll(dll, thread, label)
|
||||
finally:
|
||||
os.chdir(here)
|
||||
shutil.rmtree(root, ignore_errors=True)
|
||||
|
||||
|
||||
def tag_shared_extra_suite(dll_path, port):
|
||||
print()
|
||||
print("hosting the tag shared Extra Deck rooms from %s" % dll_path)
|
||||
tag_shared_extra_room(dll_path, port, "pair present", True)
|
||||
tag_shared_extra_room(dll_path, port + 1, "pair absent", False)
|
||||
tag_shared_extra_single(dll_path, port + 2, "single")
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in new issue
Block a user