Expose the BGS auto-pass auction setting in the player panel
This commit is contained in:
parent
3da4d2714b
commit
7252b3ea19
22 changed files with 162 additions and 17 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import { chatSegments } from "@boardgamers/protocol/chat";
|
||||
import type { ViewerEmitter } from "@boardgamers/protocol/viewer";
|
||||
import { applyMove, chooseMove, initGame, type GameState, type Move } from "outpost-engine";
|
||||
import { currentPlayer, stripSecret } from "outpost-engine/wrapper.js";
|
||||
import { currentPlayer, playerSettings, setPlayerSettings, stripSecret } from "outpost-engine/wrapper.js";
|
||||
|
||||
export interface DevOptions {
|
||||
players?: number;
|
||||
|
|
@ -56,6 +56,7 @@ export function startDevBackend(emitter: ViewerEmitter<GameState, Move>, options
|
|||
function publish(): void {
|
||||
emitter.emit("state", stripSecret(state, human));
|
||||
emitter.emit("player", { index: human });
|
||||
emitter.emit("settings", playerSettings(state, human));
|
||||
emitter.emit("avatars", AVATARS.slice(0, playerCount));
|
||||
if (state.ended && !ended) {
|
||||
ended = true;
|
||||
|
|
@ -136,6 +137,12 @@ export function startDevBackend(emitter: ViewerEmitter<GameState, Move>, options
|
|||
publish();
|
||||
});
|
||||
|
||||
emitter.on("update:setting", ({ name, value }) => {
|
||||
if (name === "autoPassBids" && typeof value === "boolean") {
|
||||
setPlayerSettings(state, human, { ...playerSettings(state, human), [name]: value });
|
||||
emitter.emit("settings", playerSettings(state, human));
|
||||
}
|
||||
});
|
||||
emitter.on("fetchState", () => publish());
|
||||
|
||||
emitter.emit("chat:state", { canSend: true, mentions });
|
||||
|
|
|
|||
|
|
@ -320,9 +320,45 @@
|
|||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
{#if isMe && store.settings !== null}
|
||||
<label
|
||||
class="auto-pass"
|
||||
title="Automatically pass an auction when your cards and discounts cannot cover the required bid. This can reveal that your hand is too weak."
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
name="autoPassBids"
|
||||
bind:checked={() => store.autoPassBids, (value) => store.setAutoPassBids(value)}
|
||||
disabled={!store.canEditSettings}
|
||||
/>
|
||||
<span>Pass if I can't pay</span>
|
||||
</label>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.auto-pass {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 7px;
|
||||
min-height: 32px;
|
||||
font-size: 12px;
|
||||
line-height: 1.3;
|
||||
color: var(--text-mid);
|
||||
cursor: pointer;
|
||||
touch-action: manipulation;
|
||||
}
|
||||
.auto-pass input {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
margin: 0;
|
||||
flex-shrink: 0;
|
||||
accent-color: var(--gold);
|
||||
}
|
||||
.auto-pass:has(input:disabled) {
|
||||
cursor: default;
|
||||
opacity: 0.6;
|
||||
}
|
||||
.panel {
|
||||
position: relative;
|
||||
background: var(--bg-panel);
|
||||
|
|
|
|||
|
|
@ -208,6 +208,7 @@ export class ViewerStore {
|
|||
playerIndex = $state<number | undefined>(undefined);
|
||||
avatars = $state<string[]>([]);
|
||||
preferences = $state<Record<string, unknown>>({});
|
||||
settings = $state<Record<string, unknown> | null>(null);
|
||||
logLines = $state<string[]>([]);
|
||||
seenLog = $state(0);
|
||||
lastMoveAt = $state<number>(0);
|
||||
|
|
@ -251,6 +252,27 @@ export class ViewerStore {
|
|||
this.commands.openPlayer(index);
|
||||
}
|
||||
|
||||
get autoPassBids(): boolean {
|
||||
return this.settings?.autoPassBids === true;
|
||||
}
|
||||
|
||||
get canEditSettings(): boolean {
|
||||
return (
|
||||
this.settings !== null &&
|
||||
!!this.me &&
|
||||
!this.me.dropped &&
|
||||
!this.liveState?.ended &&
|
||||
!this.replay.active &&
|
||||
this.preferences.analysis !== true
|
||||
);
|
||||
}
|
||||
|
||||
setAutoPassBids(value: boolean): void {
|
||||
if (this.canEditSettings && this.commands.updateSetting("autoPassBids", value)) {
|
||||
this.settings = { ...this.settings, autoPassBids: value };
|
||||
}
|
||||
}
|
||||
|
||||
get state(): GameState | null {
|
||||
if (this.replay.active) {
|
||||
return this.replay.state;
|
||||
|
|
|
|||
|
|
@ -1177,5 +1177,7 @@
|
|||
"New factory": "New factory",
|
||||
"How to buy": "How to buy",
|
||||
"Remaining upgrades": "Remaining upgrades",
|
||||
"Remaining Kicker cards": "Remaining Kicker cards"
|
||||
"Remaining Kicker cards": "Remaining Kicker cards",
|
||||
"Pass if I can't pay": "Pas, hvis jeg ikke kan betale",
|
||||
"Automatically pass an auction when your cards and discounts cannot cover the required bid. This can reveal that your hand is too weak.": "Pas automatisk på en auktion, når dine kort og rabatter ikke kan dække det krævede bud. Det kan afsløre, at din hånd er for svag."
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1177,5 +1177,7 @@
|
|||
"New factory": "New factory",
|
||||
"How to buy": "How to buy",
|
||||
"Remaining upgrades": "Remaining upgrades",
|
||||
"Remaining Kicker cards": "Remaining Kicker cards"
|
||||
"Remaining Kicker cards": "Remaining Kicker cards",
|
||||
"Pass if I can't pay": "Passen, wenn ich nicht zahlen kann",
|
||||
"Automatically pass an auction when your cards and discounts cannot cover the required bid. This can reveal that your hand is too weak.": "Bei einer Auktion automatisch passen, wenn deine Karten und Rabatte das erforderliche Gebot nicht decken. Das kann verraten, dass deine Hand zu schwach ist."
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1177,5 +1177,7 @@
|
|||
"New factory": "New factory",
|
||||
"How to buy": "How to buy",
|
||||
"Remaining upgrades": "Remaining upgrades",
|
||||
"Remaining Kicker cards": "Remaining Kicker cards"
|
||||
"Remaining Kicker cards": "Remaining Kicker cards",
|
||||
"Pass if I can't pay": "Πάσο αν δεν μπορώ να πληρώσω",
|
||||
"Automatically pass an auction when your cards and discounts cannot cover the required bid. This can reveal that your hand is too weak.": "Αυτόματο πάσο σε δημοπρασία όταν οι κάρτες και οι εκπτώσεις σου δεν καλύπτουν την απαιτούμενη προσφορά. Αυτό μπορεί να αποκαλύψει ότι το χέρι σου είναι πολύ αδύναμο."
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1177,5 +1177,7 @@
|
|||
"New factory": "New factory",
|
||||
"How to buy": "How to buy",
|
||||
"Remaining upgrades": "Remaining upgrades",
|
||||
"Remaining Kicker cards": "Remaining Kicker cards"
|
||||
"Remaining Kicker cards": "Remaining Kicker cards",
|
||||
"Pass if I can't pay": "Pass if I can't pay",
|
||||
"Automatically pass an auction when your cards and discounts cannot cover the required bid. This can reveal that your hand is too weak.": "Automatically pass an auction when your cards and discounts cannot cover the required bid. This can reveal that your hand is too weak."
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1177,5 +1177,7 @@
|
|||
"New factory": "کارخانهٔ جدید",
|
||||
"How to buy": "روش خرید",
|
||||
"Remaining upgrades": "ارتقاهای باقیمانده",
|
||||
"Remaining Kicker cards": "کارتهای کیکر باقیمانده"
|
||||
"Remaining Kicker cards": "کارتهای کیکر باقیمانده",
|
||||
"Pass if I can't pay": "اگر توان پرداخت ندارم، انصراف بده",
|
||||
"Automatically pass an auction when your cards and discounts cannot cover the required bid. This can reveal that your hand is too weak.": "وقتی کارتها و تخفیفهایتان مبلغ پیشنهاد لازم را پوشش نمیدهند، خودکار از حراج انصراف دهید. این کار ممکن است ضعیف بودن دستتان را آشکار کند."
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1177,5 +1177,7 @@
|
|||
"New factory": "New factory",
|
||||
"How to buy": "How to buy",
|
||||
"Remaining upgrades": "Remaining upgrades",
|
||||
"Remaining Kicker cards": "Remaining Kicker cards"
|
||||
"Remaining Kicker cards": "Remaining Kicker cards",
|
||||
"Pass if I can't pay": "Passer si je ne peux pas payer",
|
||||
"Automatically pass an auction when your cards and discounts cannot cover the required bid. This can reveal that your hand is too weak.": "Passer automatiquement une enchère si vos cartes et réductions ne permettent pas de couvrir l’enchère requise. Cela peut révéler que votre main est trop faible."
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1177,5 +1177,7 @@
|
|||
"New factory": "New factory",
|
||||
"How to buy": "How to buy",
|
||||
"Remaining upgrades": "Remaining upgrades",
|
||||
"Remaining Kicker cards": "Remaining Kicker cards"
|
||||
"Remaining Kicker cards": "Remaining Kicker cards",
|
||||
"Pass if I can't pay": "भुगतान न कर सकूँ तो पास करें",
|
||||
"Automatically pass an auction when your cards and discounts cannot cover the required bid. This can reveal that your hand is too weak.": "जब आपके कार्ड और छूट आवश्यक बोली के लिए पर्याप्त न हों, तो नीलामी में अपने-आप पास करें। इससे पता चल सकता है कि आपका हाथ कमज़ोर है।"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1177,5 +1177,7 @@
|
|||
"New factory": "New factory",
|
||||
"How to buy": "How to buy",
|
||||
"Remaining upgrades": "Remaining upgrades",
|
||||
"Remaining Kicker cards": "Remaining Kicker cards"
|
||||
"Remaining Kicker cards": "Remaining Kicker cards",
|
||||
"Pass if I can't pay": "Passa se non posso pagare",
|
||||
"Automatically pass an auction when your cards and discounts cannot cover the required bid. This can reveal that your hand is too weak.": "Passa automaticamente in un’asta quando le tue carte e i tuoi sconti non coprono l’offerta richiesta. Questo può rivelare che la tua mano è troppo debole."
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1177,5 +1177,7 @@
|
|||
"New factory": "New factory",
|
||||
"How to buy": "How to buy",
|
||||
"Remaining upgrades": "Remaining upgrades",
|
||||
"Remaining Kicker cards": "Remaining Kicker cards"
|
||||
"Remaining Kicker cards": "Remaining Kicker cards",
|
||||
"Pass if I can't pay": "지불할 수 없으면 패스",
|
||||
"Automatically pass an auction when your cards and discounts cannot cover the required bid. This can reveal that your hand is too weak.": "카드와 할인으로 필요한 입찰 금액을 충당할 수 없으면 경매에서 자동으로 패스합니다. 이로 인해 패가 약하다는 사실이 드러날 수 있습니다."
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1177,5 +1177,7 @@
|
|||
"New factory": "New factory",
|
||||
"How to buy": "How to buy",
|
||||
"Remaining upgrades": "Remaining upgrades",
|
||||
"Remaining Kicker cards": "Remaining Kicker cards"
|
||||
"Remaining Kicker cards": "Remaining Kicker cards",
|
||||
"Pass if I can't pay": "Pas als ik niet kan betalen",
|
||||
"Automatically pass an auction when your cards and discounts cannot cover the required bid. This can reveal that your hand is too weak.": "Pas automatisch bij een veiling als je kaarten en kortingen het vereiste bod niet dekken. Dit kan verraden dat je hand te zwak is."
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1177,5 +1177,7 @@
|
|||
"New factory": "New factory",
|
||||
"How to buy": "How to buy",
|
||||
"Remaining upgrades": "Remaining upgrades",
|
||||
"Remaining Kicker cards": "Remaining Kicker cards"
|
||||
"Remaining Kicker cards": "Remaining Kicker cards",
|
||||
"Pass if I can't pay": "Pasuj, jeśli nie mogę zapłacić",
|
||||
"Automatically pass an auction when your cards and discounts cannot cover the required bid. This can reveal that your hand is too weak.": "Automatycznie pasuj w licytacji, gdy twoje karty i zniżki nie wystarczają na wymaganą ofertę. Może to ujawnić, że twoja ręka jest zbyt słaba."
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1177,5 +1177,7 @@
|
|||
"New factory": "New factory",
|
||||
"How to buy": "How to buy",
|
||||
"Remaining upgrades": "Remaining upgrades",
|
||||
"Remaining Kicker cards": "Remaining Kicker cards"
|
||||
"Remaining Kicker cards": "Remaining Kicker cards",
|
||||
"Pass if I can't pay": "Passar se eu não puder pagar",
|
||||
"Automatically pass an auction when your cards and discounts cannot cover the required bid. This can reveal that your hand is too weak.": "Passe automaticamente em um leilão quando suas cartas e descontos não cobrirem o lance necessário. Isso pode revelar que sua mão é fraca demais."
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1177,5 +1177,7 @@
|
|||
"New factory": "New factory",
|
||||
"How to buy": "How to buy",
|
||||
"Remaining upgrades": "Remaining upgrades",
|
||||
"Remaining Kicker cards": "Remaining Kicker cards"
|
||||
"Remaining Kicker cards": "Remaining Kicker cards",
|
||||
"Pass if I can't pay": "Pas dacă nu pot plăti",
|
||||
"Automatically pass an auction when your cards and discounts cannot cover the required bid. This can reveal that your hand is too weak.": "Pasează automat la o licitație când cărțile și reducerile tale nu acoperă oferta necesară. Asta poate dezvălui că mâna ta este prea slabă."
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1177,5 +1177,7 @@
|
|||
"New factory": "New factory",
|
||||
"How to buy": "How to buy",
|
||||
"Remaining upgrades": "Remaining upgrades",
|
||||
"Remaining Kicker cards": "Remaining Kicker cards"
|
||||
"Remaining Kicker cards": "Remaining Kicker cards",
|
||||
"Pass if I can't pay": "Пасовать, если не могу заплатить",
|
||||
"Automatically pass an auction when your cards and discounts cannot cover the required bid. This can reveal that your hand is too weak.": "Автоматически пасовать на аукционе, если ваших карт и скидок недостаточно для требуемой ставки. Это может выдать слабость вашей руки."
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1177,5 +1177,7 @@
|
|||
"New factory": "New factory",
|
||||
"How to buy": "How to buy",
|
||||
"Remaining upgrades": "Remaining upgrades",
|
||||
"Remaining Kicker cards": "Remaining Kicker cards"
|
||||
"Remaining Kicker cards": "Remaining Kicker cards",
|
||||
"Pass if I can't pay": "Bỏ lượt nếu không đủ tiền",
|
||||
"Automatically pass an auction when your cards and discounts cannot cover the required bid. This can reveal that your hand is too weak.": "Tự động bỏ lượt đấu giá khi bài và mức giảm giá của bạn không đủ cho giá thầu cần thiết. Điều này có thể tiết lộ rằng bài trên tay bạn quá yếu."
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1177,5 +1177,7 @@
|
|||
"New factory": "New factory",
|
||||
"How to buy": "How to buy",
|
||||
"Remaining upgrades": "Remaining upgrades",
|
||||
"Remaining Kicker cards": "Remaining Kicker cards"
|
||||
"Remaining Kicker cards": "Remaining Kicker cards",
|
||||
"Pass if I can't pay": "無法支付時自動放棄",
|
||||
"Automatically pass an auction when your cards and discounts cannot cover the required bid. This can reveal that your hand is too weak.": "當手牌和折扣不足以支付所需的出價時,自動放棄競標。這可能讓其他玩家知道你的手牌價值不足。"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,9 @@ registerViewer<GameState, Move>(
|
|||
store.preferences = preferences;
|
||||
sounds.onPreferences(preferences);
|
||||
},
|
||||
onSettings(settings) {
|
||||
store.settings = settings;
|
||||
},
|
||||
onLog(log) {
|
||||
store.onGamelog(log);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -33,9 +33,12 @@ try {
|
|||
await frame.evaluate(
|
||||
(state) => {
|
||||
window.moves = [];
|
||||
window.settingsChanges = [];
|
||||
window.emitter = outpost.launch("#app");
|
||||
emitter.on("move", (move) => moves.push(move));
|
||||
emitter.on("update:setting", (setting) => settingsChanges.push(setting));
|
||||
emitter.emit("player", { index: 0 });
|
||||
emitter.emit("settings", { autoPassBids: false });
|
||||
emitter.emit("preferences", { sound: false });
|
||||
emitter.emit("state", state);
|
||||
emitter.emit("chat:state", { canSend: true });
|
||||
|
|
@ -113,6 +116,9 @@ try {
|
|||
);
|
||||
assert.equal(await frame.locator(".factory-buttons").count(), 1, "disabled tap does not open a purchase");
|
||||
await pageScrollsFrom(frame.locator(".me .pcard").first(), "hand card");
|
||||
await pageScrollsFrom(frame.locator(".auto-pass"), "auto-pass label");
|
||||
await pageScrollsFrom(frame.locator(".auto-pass input"), "auto-pass checkbox");
|
||||
assert.equal(await frame.evaluate(() => settingsChanges.length), 0, "swiping does not change settings");
|
||||
await pageScrollsFrom(frame.locator(".market .ucard").first(), "market card");
|
||||
await pageScrollsFrom(frame.locator(".factory-buttons button:not(:disabled) svg").first(), "resource icon");
|
||||
await frame.evaluate(() => emitter.emit("player", { index: 1 }));
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ try {
|
|||
"player:clicked",
|
||||
"chat:read",
|
||||
"chat:send",
|
||||
"update:setting",
|
||||
]) {
|
||||
emitter.on(name, (data) => {
|
||||
structuredClone(data);
|
||||
|
|
@ -61,6 +62,41 @@ try {
|
|||
stripSecret(state, 0)
|
||||
);
|
||||
await page.waitForFunction(() => events.filter((e) => e.name === "ready").length === 1);
|
||||
const autoPass = page.locator('input[name="autoPassBids"]');
|
||||
assert.equal(await autoPass.count(), 0, "wait for the host's settings before showing the control");
|
||||
await page.evaluate(() => emitter.emit("settings", { autoPassBids: true }));
|
||||
assert.equal(await autoPass.isChecked(), true);
|
||||
await autoPass.uncheck();
|
||||
assert.deepEqual(await page.evaluate(() => events.filter((e) => e.name === "update:setting")), [
|
||||
{ name: "update:setting", data: { name: "autoPassBids", value: false } },
|
||||
]);
|
||||
await page.evaluate(
|
||||
(state) => {
|
||||
emitter.emit("settings", { autoPassBids: false });
|
||||
emitter.emit("state", { ...state, activeSeat: 1 });
|
||||
},
|
||||
stripSecret(state, 0)
|
||||
);
|
||||
assert.equal(await autoPass.isEnabled(), true, "setting remains accessible out of turn");
|
||||
await autoPass.check();
|
||||
await page.evaluate(
|
||||
(state) => {
|
||||
emitter.emit("settings", { autoPassBids: true });
|
||||
emitter.emit("state", state);
|
||||
},
|
||||
stripSecret(state, 0)
|
||||
);
|
||||
assert.equal(await autoPass.isChecked(), true, "a state refresh does not overwrite host settings");
|
||||
await page.evaluate(() => emitter.emit("settings", { autoPassBids: false }));
|
||||
assert.equal(await autoPass.isChecked(), false, "platform settings update the viewer");
|
||||
assert.equal(await page.evaluate(() => events.filter((e) => e.name === "update:setting").length), 2);
|
||||
assert.equal(await page.evaluate(() => events.filter((e) => e.name === "move").length), 0);
|
||||
await page.evaluate(() => emitter.emit("replay:start"));
|
||||
assert.equal(await autoPass.isDisabled(), true);
|
||||
await page.evaluate(() => emitter.emit("replay:end"));
|
||||
await page.evaluate(() => {
|
||||
events = events.filter((e) => e.name !== "replay:info");
|
||||
});
|
||||
assert.equal(await page.evaluate(() => outpost.diagnostics().compatible), true);
|
||||
assert.equal(
|
||||
await page
|
||||
|
|
@ -196,6 +232,7 @@ try {
|
|||
assert.match(await page.locator('[data-message-id="000000000000000000000070"]').textContent(), /Hello/);
|
||||
assert.equal(await page.evaluate(() => translationsRequested.length), 1, "showing original needs no new request");
|
||||
await page.evaluate(() => emitter.emit("preferences", { sound: false, analysis: true }));
|
||||
assert.equal(await autoPass.isDisabled(), true);
|
||||
await page.waitForFunction(() => !document.querySelector(".chat-translate")?.getBoundingClientRect().height);
|
||||
await page.screenshot({ path: "/tmp/outpost-analysis-" + width + ".png", fullPage: true });
|
||||
await page.evaluate(() => emitter.emit("preferences", { sound: false, analysis: false }));
|
||||
|
|
@ -219,8 +256,10 @@ try {
|
|||
assert.deepEqual(errors, []);
|
||||
await page.evaluate((state) => {
|
||||
emitter.emit("player", {});
|
||||
emitter.emit("settings", { autoPassBids: true });
|
||||
emitter.emit("state", state);
|
||||
}, stripSecret(state));
|
||||
assert.equal(await autoPass.count(), 0, "spectators have no personal auction setting");
|
||||
|
||||
await page.locator(".board").evaluate((el) => {
|
||||
el.style.display = "none";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue