feedback5 WE: the 整备区 rules of PRTS 卫戍协议/帮助 §手牌区 (GitHub #82, second part) — a full regular hand refuses every purchase and reward pick, also one whose copy would complete a merge at once ("当常规手牌区全满无空位时,玩家将无法执行使手牌溢出的操作" — "例如招募/购入等通常情况下会增加手牌的操作"; BWIKI 盟约 says the same with no exception; the reporter checked it in the official game), and a free regular slot pulls the 临时整备区 in at once ("常规手牌区出现空位时自动移入"): PlayerState._fillHandFromTemp runs in every recompute, the temp row right to left (the order it fills, [ASSUMED]) into the hand's free slots right to left — after a sale, a deployment from the hand, a merge that consumed hand copies, an item equipped / destroyed / used, a summon stack removed with its owner. invariants.js: temp holds pieces only while the hand is full. The client's refusal path follows (gameLogic.shopBlockReason: 整备区已满 on every card — a one-line change in a file the R5 split moves). Bots: a full hand never tries a purchase, an affordable third copy of a held pair sheds the weakest hand single first (never one of this prep), resolveTemp decides temp right to left. Tests: test/match/feedback5-hand.test.js; merge / hardening / playtest6-elite-to-board / economy / prep-bench / uiFixes updated to the rule. Docs: META §1 Hand, DESIGN §6, PLAYING §3, research 00-INDEX / 01 (the old "a merge-completing purchase is allowed" corrected). Golden: 3 match scenarios moved (coop2-NORMAL-3, solo-HARD-9-boosted, coop2-ABYSS-10-boosted — bot seats that reached a full hand: the merge-completing purchase refused or a single shed first, temp pieces moving in by themselves); every battle digest unchanged
This commit is contained in:
1 parent
b1ec04b58c
commit
db1b44bb71
22 files changed
+356
-101
No files matched your search
@@ -5,6 +5,14 @@ import { ERR, PHASE } from '../../shared/constants.js';
|
||||
import { GameData } from '../../server/match/gamedata.js';
|
||||
import { DATA, makeMatch, give, giveItem, checkInvariants, chessOfTier } from './harness.js';
|
||||
|
||||
/** Fill every free hand slot with distinct plain equipment (nothing merges), so a piece put into temp stays there. */
|
||||
function fillHand(ps) {
|
||||
const plain = Object.values(DATA.items).filter((i) => i.itemType === 'EQUIP' && !i.isGolden && i.kind === 'passive').map((i) => i.itemId ?? i.id);
|
||||
let k = 0;
|
||||
for (let i = 0; i < ps.hand.length; i++) if (ps.hand[i] == null) ps.hand[i] = ps.newPiece('item', plain[k++]);
|
||||
ps.recompute();
|
||||
}
|
||||
|
||||
test('income = min(3 + r, 12) in every mode; funds are lost at prep end (band_cannot keeps them)', () => {
|
||||
for (const modeId of ['mode_single_funny', 'mode_multi_normal', 'mode_multi_abyss']) {
|
||||
const gd = new GameData(DATA, modeId);
|
||||
@@ -190,16 +198,21 @@ test('selling: +1 (normal and elite, board or hand), items return to the hand, i
|
||||
m.dispose();
|
||||
});
|
||||
|
||||
test('ready gating: temp must be empty; unready allowed until everyone is ready; actions locked while ready', () => {
|
||||
test('ready gating: temp must be empty (a freed hand slot pulls the temp piece in); unready allowed until everyone is ready; actions locked while ready', () => {
|
||||
const h = makeMatch({ mode: 'coop', humans: 2, seed: 10 }).start();
|
||||
h.toPrep(1);
|
||||
const m = h.m;
|
||||
const a = h.ps('p_0');
|
||||
fillHand(a);
|
||||
const t = give(m, a, chessOfTier(1).find((x) => m.pool.has(x)), 'temp');
|
||||
assert.ok(a.temp.includes(t), 'a full hand: it waits in temp');
|
||||
assert.equal(a.privateView().canReady, false);
|
||||
assert.deepEqual(m.handle('p_0', { t: 'g.ready', ready: true }), { error: ERR.TEMP_NOT_EMPTY });
|
||||
const free = a.hand.findIndex((x) => x == null);
|
||||
assert.deepEqual(m.handle('p_0', { t: 'g.move', uid: t.uid, to: { area: 'hand', idx: free } }), { ok: true });
|
||||
// destroying a hand item frees its slot: the temp piece moves in by itself (PRTS 卫戍协议/帮助 §手牌区, GitHub #82)
|
||||
const freed = a.hand[3];
|
||||
assert.deepEqual(m.handle('p_0', { t: 'g.destroy', uid: freed.uid }), { ok: true });
|
||||
assert.equal(a.hand[3], t);
|
||||
assert.ok(a.tempEmpty);
|
||||
assert.equal(a.privateView().canReady, true);
|
||||
assert.deepEqual(m.handle('p_0', { t: 'g.ready', ready: true }), { ok: true });
|
||||
assert.deepEqual(m.handle('p_0', { t: 'g.refresh' }), { error: ERR.WRONG_PHASE, detail: 'ready' });
|
||||
@@ -222,7 +235,9 @@ test('prep deadline (co-op): unready players are auto-readied and their temp is
|
||||
const a = h.ps('p_0');
|
||||
const id = chessOfTier(1).find((x) => m.pool.has(x));
|
||||
const left = m.pool.left(id);
|
||||
fillHand(a);
|
||||
give(m, a, id, 'temp');
|
||||
assert.ok(!a.tempEmpty, 'a full hand: it waits in temp');
|
||||
assert.ok(m.deadline > h.sched.now(), 'co-op prep is timed');
|
||||
assert.equal(Math.round((m.deadline - h.sched.now()) / 1000), m.gd.prepTime(1));
|
||||
h.sched.advance(m.deadline - h.sched.now() + 1);
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
// GitHub #82 (second part): the hand rules of PRTS 卫戍协议/帮助 §手牌区 — "手牌区域分为10个常规手牌区和5个临时手牌区。当
|
||||
// 常规手牌区全满无空位时,玩家将无法执行使手牌溢出的操作" ("例如招募/购入等通常情况下会增加手牌的操作") and "溢出单位会自动
|
||||
// 进入临时手牌区,常规手牌区出现空位时自动移入".
|
||||
// * a full regular hand refuses every purchase and reward pick — also one whose copy would complete a merge at once
|
||||
// (the reporter's first-hand check in the official game; BWIKI 盟约 "无法进行涉及到整备区的操作(购买、撤回等)")
|
||||
// * a free regular slot pulls a temp piece in at once (PlayerState._fillHandFromTemp, run by every recompute): after a
|
||||
// sale, a deployment from the hand, a merge that consumed hand copies, an item destroyed / equipped from the hand, a
|
||||
// summon stack removed with its owner. The temp row empties right → left (the order it fills) [ASSUMED]; each piece
|
||||
// takes the hand's next free slot right → left.
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { ERR } from '../../shared/constants.js';
|
||||
import { DATA, makeMatch, give, giveItem, checkInvariants, chessOfTier, legalTileFor } from './harness.js';
|
||||
|
||||
/** Plain equipment (no equip / merge side effects), all different: hand fillers that never merge with each other. */
|
||||
const PLAIN = Object.values(DATA.items)
|
||||
.filter((i) => i.itemType === 'EQUIP' && !i.isGolden && i.kind === 'passive')
|
||||
.map((i) => i.itemId ?? i.id).filter(Boolean);
|
||||
|
||||
/** Solo 标准 (untimed) PREP R1 with an empty board and hand, 100 funds, a known stage. */
|
||||
function prep(seed) {
|
||||
const h = makeMatch({ mode: 'solo', difficulty: 'NORMAL', seed }).start();
|
||||
h.toPrep(1);
|
||||
h.setStage('act2autochess_m04');
|
||||
const ps = h.ps('p_0');
|
||||
for (const p of [...ps.board.values(), ...ps.hand.filter(Boolean)]) if (p.kind === 'chess') ps.returnCopies(p);
|
||||
ps.board.clear();
|
||||
ps.hand.fill(null);
|
||||
ps.recompute();
|
||||
ps.funds = 100;
|
||||
return { h, m: h.m, ps };
|
||||
}
|
||||
|
||||
/** Fill every free hand slot with plain equipment (skipping `skip` ids). */
|
||||
function fillHand(ps, skip = []) {
|
||||
const ids = PLAIN.filter((id) => !skip.includes(id));
|
||||
let k = 0;
|
||||
while (ps.hand.some((x) => x == null)) giveItem(ps.m, ps, ids[k++]);
|
||||
}
|
||||
|
||||
const mergeable = (m) => chessOfTier(1, (c) => c.position === 'MELEE').find((id) => m.pool.has(id) && m.gd.mergeCount(id) === 3);
|
||||
|
||||
test('a full hand refuses a purchase / pick that would complete a merge (chess, item, reward); nothing is spent', () => {
|
||||
const { m, ps } = prep(8201);
|
||||
const id = mergeable(m);
|
||||
give(m, ps, id, 'hand', 0);
|
||||
give(m, ps, id, 'hand', 1);
|
||||
const twin = PLAIN[0];
|
||||
giveItem(m, ps, twin, 'hand', 2);
|
||||
fillHand(ps, [twin]);
|
||||
assert.ok(ps.completesChessMerge(id) && ps.completesItemMerge(twin));
|
||||
ps.shop.slots[0] = { kind: 'chess', id, basePrice: m.gd.chessPrice(id), frozen: false, sold: false };
|
||||
const itemSlot = ps.shop.slots.findIndex((s, i) => i > 0 && s && s.kind === 'item');
|
||||
ps.shop.slots[itemSlot] = { kind: 'item', id: twin, basePrice: 2, frozen: false, sold: false };
|
||||
const left = m.pool.left(id);
|
||||
assert.deepEqual(m.handle('p_0', { t: 'g.buy', slot: 0 }), { error: ERR.HAND_FULL }, 'the third copy of a held pair');
|
||||
assert.deepEqual(m.handle('p_0', { t: 'g.buy', slot: itemSlot }), { error: ERR.HAND_FULL }, 'an item whose twin is in the hand');
|
||||
ps.pushRewardOffer('merge', { ids: [id] });
|
||||
assert.deepEqual(m.handle('p_0', { t: 'g.reward', idx: 0 }), { error: ERR.HAND_FULL }, 'a merge-completing reward pick');
|
||||
assert.equal(ps.funds, 100, 'nothing spent');
|
||||
assert.equal(m.pool.left(id), left, 'no copy taken');
|
||||
assert.ok(!ps.shop.slots[0].sold && !ps.shop.slots[itemSlot].sold);
|
||||
assert.equal(ps.countCopies(m.gd.baseIdOf(id)), 2, 'no merge');
|
||||
// a free slot (an item destroyed) lets the purchase through: it completes the merge, the elite goes to the hand
|
||||
assert.deepEqual(m.handle('p_0', { t: 'g.destroy', uid: ps.hand[9].uid }), { ok: true });
|
||||
assert.deepEqual(m.handle('p_0', { t: 'g.buy', slot: 0 }), { ok: true });
|
||||
assert.ok(ps.hand.some((p) => p && p.id === m.gd.goldenIdOf(id)), 'the elite in the hand');
|
||||
assert.equal(ps.hand.filter(Boolean).length, 8, '10 − the destroyed item − 2 copies + the elite');
|
||||
checkInvariants(m);
|
||||
m.dispose();
|
||||
});
|
||||
|
||||
test('selling / destroying from a full hand pulls the temp pieces in, rightmost first, into the freed slot; Ready follows', () => {
|
||||
const { m, ps } = prep(8202);
|
||||
const sold = give(m, ps, chessOfTier(2).find((x) => m.pool.has(x)), 'hand', 4);
|
||||
fillHand(ps);
|
||||
const ids = chessOfTier(3).filter((x) => m.pool.has(x));
|
||||
const first = give(m, ps, ids[0], 'temp', 4); // the first overflow takes the rightmost temp slot (stow → freeSlot)
|
||||
const second = give(m, ps, ids[1], 'temp', 3);
|
||||
assert.ok(ps.temp.includes(first) && ps.temp.includes(second), 'a full hand: both wait in temp');
|
||||
assert.equal(ps.privateView().canReady, false);
|
||||
checkInvariants(m);
|
||||
assert.deepEqual(m.handle('p_0', { t: 'g.sell', uid: sold.uid }), { ok: true });
|
||||
assert.equal(ps.hand[4], first, 'the rightmost temp piece moves into the freed slot');
|
||||
assert.ok(ps.temp.includes(second) && !ps.temp.includes(first));
|
||||
assert.equal(ps._tempDue.has(first.uid), false, 'no longer due at the prep deadline');
|
||||
assert.equal(ps.privateView().canReady, false, 'one left in temp');
|
||||
checkInvariants(m);
|
||||
const item = ps.hand[7];
|
||||
assert.equal(item.kind, 'item');
|
||||
assert.deepEqual(m.handle('p_0', { t: 'g.destroy', uid: item.uid }), { ok: true });
|
||||
assert.equal(ps.hand[7], second);
|
||||
assert.ok(ps.tempEmpty);
|
||||
assert.equal(ps.privateView().canReady, true);
|
||||
assert.deepEqual(m.handle('p_0', { t: 'g.ready', ready: true }), { ok: true });
|
||||
checkInvariants(m);
|
||||
m.dispose();
|
||||
});
|
||||
|
||||
test('deploying a card from a full hand, or equipping an item from it, pulls a temp piece into the freed slot', () => {
|
||||
const { m, ps } = prep(8203);
|
||||
const id = chessOfTier(1, (c) => c.position === 'MELEE' && !m.gd.placeableTokens(c.chessId).length).find((x) => m.pool.has(x));
|
||||
const card = give(m, ps, id, 'hand', 9);
|
||||
fillHand(ps);
|
||||
const t1 = give(m, ps, chessOfTier(2).find((x) => m.pool.has(x)), 'temp', 4);
|
||||
const t2 = giveItem(m, ps, PLAIN[PLAIN.length - 1], 'temp', 3);
|
||||
const [r, c] = legalTileFor(m, ps, id);
|
||||
assert.deepEqual(m.handle('p_0', { t: 'g.move', uid: card.uid, to: { area: 'board', row: r, col: c } }), { ok: true });
|
||||
assert.equal(ps.hand[9], t1, 'the deployed card\'s slot took the temp piece');
|
||||
checkInvariants(m);
|
||||
const it = ps.hand[0];
|
||||
assert.deepEqual(m.handle('p_0', { t: 'g.equip', itemUid: it.uid, targetUid: card.uid }), { ok: true });
|
||||
assert.equal(ps.hand[0], t2, 'the equipped item\'s slot took the temp piece');
|
||||
assert.ok(ps.tempEmpty);
|
||||
checkInvariants(m);
|
||||
m.dispose();
|
||||
});
|
||||
|
||||
test('a gain that merges two hand copies: the elite takes one freed slot, the other pulls a temp piece in', () => {
|
||||
const { m, ps } = prep(8204);
|
||||
const id = mergeable(m);
|
||||
give(m, ps, id, 'hand', 0);
|
||||
give(m, ps, id, 'hand', 1);
|
||||
fillHand(ps);
|
||||
const ids = chessOfTier(3).filter((x) => m.pool.has(x));
|
||||
const t1 = give(m, ps, ids[0], 'temp', 4);
|
||||
const t2 = give(m, ps, ids[1], 'temp', 3);
|
||||
const elite = ps.acquireChess(id, { source: 'grant' });
|
||||
assert.ok(elite && m.gd.isGolden(elite.id));
|
||||
assert.equal(ps.hand[1], elite, 'the elite: the hand\'s next free slot (right → left)');
|
||||
assert.equal(ps.hand[0], t1, 'the other freed slot: the rightmost temp piece');
|
||||
assert.deepEqual(ps.temp.filter(Boolean), [t2], 'the hand is full again: the other waits');
|
||||
checkInvariants(m);
|
||||
m.dispose();
|
||||
});
|
||||
|
||||
test('selling a deployed summoner removes its summon stack from the hand: that slot pulls a temp piece in', () => {
|
||||
const { m, ps } = prep(8205);
|
||||
const owner = Object.values(DATA.chess).find((c) => c.visible && !c.isGolden && m.pool.has(c.chessId) && m.gd.placeableTokens(c.chessId).length && legalTileFor(m, ps, c.chessId));
|
||||
assert.ok(owner, 'a chess with a manually deployable summon');
|
||||
const op = give(m, ps, owner.chessId, 'board', legalTileFor(m, ps, owner.chessId));
|
||||
const stackAt = ps.hand.findIndex((p) => p && p.kind === 'token' && p.ownerUid === op.uid);
|
||||
assert.ok(stackAt >= 0, 'its summon stack joined the hand');
|
||||
fillHand(ps);
|
||||
const t = give(m, ps, chessOfTier(2).find((x) => m.pool.has(x)), 'temp', 4);
|
||||
assert.deepEqual(m.handle('p_0', { t: 'g.sell', uid: op.uid }), { ok: true });
|
||||
assert.equal(ps.hand[stackAt], t, 'the stack\'s slot took the temp piece');
|
||||
assert.ok(ps.tempEmpty);
|
||||
checkInvariants(m);
|
||||
m.dispose();
|
||||
});
|
||||
@@ -85,7 +85,10 @@ test('merge with a full hand and a full temp: the elite takes its deployed copy\
|
||||
for (let i = 0; i < 5; i++) give(m, ps, fillers[10 + i], 'temp', i);
|
||||
ps.shop.slots[0] = { kind: 'chess', id, basePrice: m.gd.chessPrice(id), frozen: false, sold: false };
|
||||
checkInvariants(m);
|
||||
assert.deepEqual(m.handle('p_0', { t: 'g.buy', slot: 0 }), { ok: true }, 'a purchase that completes a merge is allowed with a full hand');
|
||||
// a full hand refuses the purchase, also one that would complete the merge (PRTS 卫戍协议/帮助 §手牌区, GitHub #82);
|
||||
// a gain (an effect's grant) still completes it
|
||||
assert.deepEqual(m.handle('p_0', { t: 'g.buy', slot: 0 }), { error: 'HAND_FULL' }, 'a full hand refuses the merge-completing purchase');
|
||||
assert.ok(ps.acquireChess(id, { source: 'grant' }), 'the gained copy completes the merge');
|
||||
const elite = [...ps.board.values()].find((p) => p.id === m.gd.goldenIdOf(id));
|
||||
assert.ok(elite, 'the elite stands on a consumed copy\'s tile');
|
||||
assert.equal(ps.find(elite.uid).key, `${t1[0]},${t1[1]}`, 'the copy that deploys first (legalTileFor walks the top row left to right: on one row, the deploy order)');
|
||||
@@ -260,7 +263,7 @@ test('garrisonHooks widens a garrison to extra hooks ("<进入休整期时><休
|
||||
m.dispose();
|
||||
});
|
||||
|
||||
test('ctx.offerItems queues an item offer; g.reward takes the item (full hand refused unless it merges)', () => {
|
||||
test('ctx.offerItems queues an item offer; g.reward takes the item (a full hand refuses it, also when it would merge)', () => {
|
||||
const reg = builtins();
|
||||
const { m, ps } = prepSolo({ seed: 913, registry: reg });
|
||||
const ctx = makeCtx(m, ps, { kind: 'band', key: 'band:test' }, 'onLevelUp');
|
||||
@@ -269,8 +272,10 @@ test('ctx.offerItems queues an item offer; g.reward takes the item (full hand re
|
||||
const view = ps.privateView().shop.rewardOffer;
|
||||
assert.deepEqual(view.slots.map((s) => [s.kind, s.id, s.price]), [['item', 'chess_item_1_01_e_a', 0], ['item', 'chess_item_2_03_e_a', 0]]);
|
||||
const fillers = chessOfTier(1).filter((c) => m.pool.has(c));
|
||||
for (let i = 0; i < 10; i++) give(m, ps, fillers[i], 'hand', i);
|
||||
assert.equal(m.handle('p_0', { t: 'g.reward', idx: 0 }).error, 'HAND_FULL');
|
||||
for (let i = 0; i < 9; i++) give(m, ps, fillers[i], 'hand', i);
|
||||
giveItem(m, ps, 'chess_item_1_01_e_a', 'hand', 9);
|
||||
assert.equal(ps.completesItemMerge('chess_item_1_01_e_a'), true);
|
||||
assert.equal(m.handle('p_0', { t: 'g.reward', idx: 0 }).error, 'HAND_FULL', 'refused although it would merge (PRTS 卫戍协议/帮助 §手牌区)');
|
||||
ps.hand[0] && ps.returnCopies(ps.hand[0]);
|
||||
ps.hand[0] = null;
|
||||
ps.recompute();
|
||||
|
||||
+22
-10
@@ -67,7 +67,7 @@ test('3 copies (board + hand + bought) merge into 1 elite on the board copy\'s t
|
||||
m.dispose();
|
||||
});
|
||||
|
||||
test('elites never merge; 风丸 merges with 2 copies; a full hand still buys the merge-completing copy', () => {
|
||||
test('elites never merge; 风丸 merges with 2 copies; a full hand refuses the merge-completing copy too (GitHub #82)', () => {
|
||||
const { m, ps } = prep(22);
|
||||
const id = chessOfTier(2).find((x) => m.pool.has(x) && x !== 'chess_char_2_11_a');
|
||||
const golden = DATA.chess[id].goldenId;
|
||||
@@ -83,7 +83,9 @@ test('elites never merge; 风丸 merges with 2 copies; a full hand still buys th
|
||||
m.handle('p_0', { t: 'g.buy', slot: 0 });
|
||||
assert.ok(ps.hand.some((p) => p && p.id === DATA.chess.chess_char_2_11_a.goldenId), '风丸 elite after 2 copies');
|
||||
}
|
||||
// full hand + 2 copies in the hand: buying the 3rd completes the merge (net −1)
|
||||
// full hand + 2 copies in the hand: the 3rd copy is refused like any purchase (PRTS 卫戍协议/帮助 §手牌区 "当常规手牌区
|
||||
// 全满无空位时,玩家将无法执行使手牌溢出的操作" — "例如招募/购入"; GitHub #82); a sale frees a slot, then the purchase
|
||||
// completes the merge (the elite in the hand)
|
||||
for (const p of ps.hand) if (p) ps.returnCopies(p);
|
||||
ps.hand.fill(null);
|
||||
const x = chessOfTier(1).filter((c) => m.pool.has(c));
|
||||
@@ -95,15 +97,19 @@ test('elites never merge; 风丸 merges with 2 copies; a full hand still buys th
|
||||
stock(m, ps, x[20] || x[x.length - 1], 1);
|
||||
assert.deepEqual(m.handle('p_0', { t: 'g.buy', slot: 1 }), { error: ERR.HAND_FULL });
|
||||
stock(m, ps, target, 0);
|
||||
assert.deepEqual(m.handle('p_0', { t: 'g.buy', slot: 0 }), { error: ERR.HAND_FULL }, 'the merge-completing copy too');
|
||||
assert.ok(!ps.hand.some((p) => p && p.id === DATA.chess[target].goldenId));
|
||||
const filler = ps.hand.find((p) => p && p.id !== target);
|
||||
assert.deepEqual(m.handle('p_0', { t: 'g.sell', uid: filler.uid }), { ok: true });
|
||||
assert.deepEqual(m.handle('p_0', { t: 'g.buy', slot: 0 }), { ok: true });
|
||||
assert.ok(ps.hand.some((p) => p && p.id === DATA.chess[target].goldenId));
|
||||
assert.equal(ps.hand.filter(Boolean).length, 9);
|
||||
assert.equal(ps.hand.filter(Boolean).length, 8, '10 − the sold filler − 2 copies + the elite');
|
||||
assert.ok(ps.tempEmpty);
|
||||
checkInvariants(m);
|
||||
m.dispose();
|
||||
});
|
||||
|
||||
test('merge from two board copies with a full hand: the elite takes the copy that deploys first (no overflow, one tile freed)', () => {
|
||||
test('merge from two board copies with a full hand (a gained copy; a purchase is refused): the elite takes the copy that deploys first (no overflow, one tile freed)', () => {
|
||||
const { m, ps } = prep(23);
|
||||
const ids = chessOfTier(1, (c) => c.position === 'MELEE').filter((c) => m.pool.has(c));
|
||||
const id = ids[0];
|
||||
@@ -115,7 +121,8 @@ test('merge from two board copies with a full hand: the elite takes the copy tha
|
||||
for (let i = 0; ps.hand.some((p) => p == null); i++) give(m, ps, others[i]);
|
||||
stock(m, ps, id);
|
||||
assert.equal(ps.deployCount, 2);
|
||||
assert.deepEqual(m.handle('p_0', { t: 'g.buy', slot: 0 }), { ok: true });
|
||||
assert.deepEqual(m.handle('p_0', { t: 'g.buy', slot: 0 }), { error: ERR.HAND_FULL }, 'a full hand refuses the purchase (GitHub #82)');
|
||||
assert.ok(ps.acquireChess(id, { source: 'grant' }), 'a gain (an effect\'s grant) completes the merge');
|
||||
// deploy order = by column from the left (col asc, then row desc; Battle.start): (9,3) before (9,4) — [ASSUMED] the copy
|
||||
// the battle deploys first
|
||||
const elite = ps.board.get('9,3');
|
||||
@@ -134,12 +141,14 @@ test('merge whose copies are not deployed (temp) with a full hand overflows the
|
||||
const { m, ps } = prep(23);
|
||||
const ids = chessOfTier(1, (c) => c.position === 'MELEE').filter((c) => m.pool.has(c));
|
||||
const id = ids[0];
|
||||
give(m, ps, id, 'temp', 0);
|
||||
give(m, ps, id, 'temp', 1);
|
||||
const others = chessOfTier(2).filter((c) => m.pool.has(c));
|
||||
for (let i = 0; ps.hand.some((p) => p == null); i++) give(m, ps, others[i]);
|
||||
stock(m, ps, id);
|
||||
assert.deepEqual(m.handle('p_0', { t: 'g.buy', slot: 0 }), { ok: true });
|
||||
// with the hand full they wait in temp (a free hand slot would pull them in, PRTS 卫戍协议/帮助 §手牌区)
|
||||
give(m, ps, id, 'temp', 0);
|
||||
give(m, ps, id, 'temp', 1);
|
||||
assert.equal(ps.temp.filter(Boolean).length, 2);
|
||||
// a gain completes the merge (a purchase is refused with a full hand)
|
||||
assert.ok(ps.acquireChess(id, { source: 'grant' }));
|
||||
assert.ok(ps.temp.some((p) => p && p.id === DATA.chess[id].goldenId), 'elite overflowed into temp');
|
||||
assert.equal(ps.board.size, 0, 'nothing was deployed');
|
||||
assert.deepEqual(m.handle('p_0', { t: 'g.ready', ready: true }), { error: ERR.TEMP_NOT_EMPTY });
|
||||
@@ -187,11 +196,14 @@ test('equipment: max 2 (a third replaces the oldest), identical normal items mer
|
||||
assert.ok(ps.hand.some((p) => p && p.id === 'chess_item_1_02_e_b'), 'golden item in the hand');
|
||||
assert.ok(!a.items.some((x) => x.id === 'chess_item_1_02_e_a'));
|
||||
assert.equal(ps.stats.itemMerges, 1);
|
||||
// buying an item whose twin is in the hand merges immediately (and works with a full hand)
|
||||
// buying an item whose twin is in the hand merges immediately — but a full hand refuses the purchase all the same
|
||||
// (PRTS 卫戍协议/帮助 §手牌区, GitHub #82)
|
||||
const i5 = giveItem(m, ps, 'chess_item_2_03_e_a');
|
||||
const others = chessOfTier(1).filter((c) => m.pool.has(c));
|
||||
for (let i = 0; ps.hand.some((p) => p == null); i++) give(m, ps, others[i]);
|
||||
ps.shop.slots[0] = { kind: 'item', id: 'chess_item_2_03_e_a', basePrice: 2, frozen: false, sold: false };
|
||||
assert.deepEqual(m.handle('p_0', { t: 'g.buy', slot: 0 }), { error: ERR.HAND_FULL });
|
||||
assert.deepEqual(m.handle('p_0', { t: 'g.sell', uid: ps.hand.find((p) => p && p.kind === 'chess' && p !== a).uid }), { ok: true });
|
||||
assert.deepEqual(m.handle('p_0', { t: 'g.buy', slot: 0 }), { ok: true });
|
||||
assert.ok(ps.hand.some((p) => p && p.id === 'chess_item_2_03_e_b'));
|
||||
assert.ok(!ps.find(i5.uid));
|
||||
|
||||
@@ -199,7 +199,8 @@ test('equipment with the hand and temp full: the elite keeps up to its 2 equip s
|
||||
const warn = m.log.warn;
|
||||
m.log.warn = (s) => { warns.push(String(s)); };
|
||||
stock(m, ps, id);
|
||||
assert.deepEqual(m.handle('p_0', { t: 'g.buy', slot: 0 }), { ok: true }, 'a merge-completing buy needs no hand slot');
|
||||
assert.equal(m.handle('p_0', { t: 'g.buy', slot: 0 }).error, 'HAND_FULL', 'a full hand refuses the purchase, also a merge-completing one (GitHub #82)');
|
||||
assert.ok(ps.acquireChess(id, { source: 'grant' }), 'a gained copy completes the merge');
|
||||
m.log.warn = warn;
|
||||
const elite = ps.board.get(want);
|
||||
assert.ok(elite && m.gd.isGolden(elite.id), 'the elite took the first deployed copy\'s tile');
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { GEO, PHASE } from '../../shared/constants.js';
|
||||
import { makeMatch, give, giveItem, legalTileFor, chessOfTier } from './harness.js';
|
||||
import { DATA, makeMatch, give, giveItem, legalTileFor, chessOfTier } from './harness.js';
|
||||
|
||||
const MELEE = (c) => c.position === 'MELEE' && c.profession === 'TANK';
|
||||
|
||||
@@ -98,7 +98,12 @@ test("PR #129 review: moving a hand piece to another slot is a scout change (x f
|
||||
b.recompute();
|
||||
const id = chessOfTier(1, MELEE).find((x) => m.pool.has(x));
|
||||
const a = give(m, b, id, 'hand', 0);
|
||||
// a full hand (distinct plain equipment: nothing merges), so the temp piece stays in temp — a free hand slot would pull
|
||||
// it in (PRTS 卫戍协议/帮助 §手牌区 "常规手牌区出现空位时自动移入")
|
||||
const plain = Object.values(DATA.items).filter((i) => i.itemType === 'EQUIP' && !i.isGolden && i.kind === 'passive').map((i) => i.itemId ?? i.id);
|
||||
for (let i = 1; i < b.hand.length; i++) b.hand[i] = b.newPiece('item', plain[i]);
|
||||
const c = give(m, b, id, 'temp', 0); // 临时整备区: PRTS 帮助把它算进手牌区,一起侦察
|
||||
assert.ok(b.temp.includes(c));
|
||||
assert.deepEqual(m.handle('p_0', { t: 'g.watch', fieldId: 'n:p_1' }), { ok: true });
|
||||
|
||||
const first = h.lastTo('p_0', 'm.field');
|
||||
|
||||
Reference in new issue
Block a user