Teach tutorial actions through the game board
This commit is contained in:
parent
ed21bfe073
commit
c226c43b76
6 changed files with 132 additions and 104 deletions
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "container-viewer",
|
||||
"version": "2.0.0",
|
||||
"version": "2.0.1",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/boardgamers/container.git",
|
||||
|
|
|
|||
|
|
@ -5,6 +5,12 @@ import { createRequire } from 'node:module';
|
|||
import { fileURLToPath } from 'node:url';
|
||||
import { chromium } from 'playwright';
|
||||
const require = createRequire(import.meta.url);
|
||||
require('../../engine/node_modules/ts-node').register({
|
||||
transpileOnly: true,
|
||||
compilerOptions: { module: 'CommonJS', moduleResolution: 'Node', target: 'ES2022', importHelpers: false },
|
||||
});
|
||||
const { lessons } = require('../src/tutorial/lessons');
|
||||
|
||||
const viewer = new URL('../', import.meta.url);
|
||||
const files = {
|
||||
'/bundle.js': fileURLToPath(new URL('dist/container-viewer.umd.min.js', viewer)),
|
||||
|
|
@ -33,14 +39,77 @@ const server = createServer(async (req, res) => {
|
|||
});
|
||||
await new Promise((resolve) => server.listen(0, '127.0.0.1', resolve));
|
||||
const origin = `http://127.0.0.1:${server.address().port}`;
|
||||
async function playOnBoard(page, move) {
|
||||
if (move.name === 'pass') return page.locator('[data-tutorial="turn"]').click();
|
||||
if (move.name === 'bid') {
|
||||
const keys = [7, 8, 9, 4, 5, 6, 1, 2, 3, 0, 'Del', 'Bid'];
|
||||
for (const digit of String(move.extraData.price))
|
||||
await page
|
||||
.locator('.calculator rect.button')
|
||||
.nth(keys.indexOf(Number(digit)))
|
||||
.click();
|
||||
await page.locator('.calculator rect.button').last().click();
|
||||
if (await page.locator('.modal.visible').isVisible())
|
||||
await page.locator('.modal.visible').getByRole('button', { name: 'Confirm', exact: true }).click();
|
||||
return;
|
||||
}
|
||||
if (move.name === 'accept') return page.locator('g.button').filter({ hasText: 'Accept Ada' }).click();
|
||||
if (move.name === 'decline') return page.locator('g.button').filter({ hasText: 'Keep for $6' }).click();
|
||||
const id = move.name === 'produce' ? move.extraData.piece.id : move.data?.piece?.id ?? move.extraData?.id;
|
||||
const pieces = page.locator('.piece.canDrag');
|
||||
const index = await pieces.evaluateAll(
|
||||
(els, { id, sail, factory }) =>
|
||||
els.findLastIndex((el) =>
|
||||
sail
|
||||
? el.__vue__.pieceType === 'ship' && el.__vue__.owner === 0
|
||||
: factory
|
||||
? el.__vue__.pieceType === 'factory' && el.__vue__.color === factory
|
||||
: el.__vue__.pieceId === id
|
||||
),
|
||||
{ id, sail: move.name === 'sail', factory: move.name === 'buyFactory' ? move.data : undefined }
|
||||
);
|
||||
assert.ok(index >= 0, 'piece available for ' + move.name);
|
||||
await pieces.nth(index).click();
|
||||
const zones = page.locator('.placeholder.canClick');
|
||||
const type = {
|
||||
produce: 'factoryStore',
|
||||
buyFromFactory: 'warehouseStore',
|
||||
buyFactory: 'factory',
|
||||
buyWarehouse: 'warehouse',
|
||||
sail: move.data === 'sea' ? 'openSea' : 'islandHarbor',
|
||||
}[move.name];
|
||||
const zone = await zones.evaluateAll(
|
||||
(els, { type, price }) =>
|
||||
els.findIndex(
|
||||
(el) => el.__vue__.data.type === type && (price === undefined || el.__vue__.data.price === price)
|
||||
),
|
||||
{ type, price: move.extraData?.price }
|
||||
);
|
||||
assert.ok(zone >= 0, 'destination available for ' + move.name + ' ' + type);
|
||||
const bounds = await zones.nth(zone).boundingBox();
|
||||
await zones
|
||||
.nth(zone)
|
||||
.click({
|
||||
position: {
|
||||
x: bounds.width * (type === 'factory' || type === 'warehouse' ? 0.4 : 0.15),
|
||||
y: bounds.height * 0.4,
|
||||
},
|
||||
});
|
||||
if (await page.locator('.modal.visible').isVisible())
|
||||
await page.locator('.modal.visible').getByRole('button', { name: 'Confirm', exact: true }).click();
|
||||
}
|
||||
|
||||
const browser = await chromium.launch({ executablePath: process.env.CHROMIUM_EXECUTABLE });
|
||||
try {
|
||||
for (const width of [1400, 390]) {
|
||||
for (const width of process.env.WIDTH ? [Number(process.env.WIDTH)] : [1400, 390]) {
|
||||
const context = await browser.newContext({ viewport: { width, height: 950 }, reducedMotion: 'reduce' });
|
||||
const page = await context.newPage();
|
||||
const errors = [];
|
||||
page.on('pageerror', (error) => errors.push(error.message));
|
||||
for (const chapter of ['supply-chain', 'buildings', 'selling', 'bidding', 'keep-cargo', 'scoring']) {
|
||||
for (const lesson of lessons.filter((l) => !process.env.CHAPTER || l.id === process.env.CHAPTER)) {
|
||||
const chapter = lesson.id;
|
||||
let state = lesson.initialState();
|
||||
console.log(`START ${chapter} ${width}`);
|
||||
await page.goto(`${origin}/?chapter=${chapter}`);
|
||||
const guide = page.locator('.bgs-tutorial-guide');
|
||||
await guide.waitFor();
|
||||
|
|
@ -49,10 +118,7 @@ try {
|
|||
if (heading === 'Chapter complete') break;
|
||||
const next = guide.getByRole('button', { name: 'Continue', exact: true });
|
||||
if (await next.isEnabled()) await next.click();
|
||||
else if (await page.locator('.tutorial-bid').count()) {
|
||||
await page.locator('.tutorial-bid input').fill(heading.includes('add $2') ? '2' : '8');
|
||||
await page.locator('.tutorial-bid button').click();
|
||||
} else if (heading.includes('What does keeping') || heading.includes('What does selling')) {
|
||||
else if (heading.includes('What does keeping') || heading.includes('What does selling')) {
|
||||
assert.equal(
|
||||
await guide.getByRole('button', { name: 'Show area', exact: true }).isVisible(),
|
||||
false
|
||||
|
|
@ -81,7 +147,25 @@ try {
|
|||
.locator('.tutorial-actions')
|
||||
.getByRole('button', { name: 'dark green', exact: true })
|
||||
.click();
|
||||
else await page.locator('.tutorial-actions button').first().click();
|
||||
else {
|
||||
const stepId = await page.locator('.container-tutorial').getAttribute('data-step');
|
||||
let action = lesson.choices(state, stepId)[0]?.action;
|
||||
if (chapter === 'bidding' && ['bid', 'raise'].includes(stepId))
|
||||
action = {
|
||||
kind: 'move',
|
||||
move: { name: 'bid', data: true, extraData: { price: stepId === 'bid' ? 8 : 2 } },
|
||||
};
|
||||
assert.ok(action, `action for ${chapter}/${stepId}`);
|
||||
if (action.kind === 'move') {
|
||||
assert.equal(
|
||||
await page.locator('.tutorial-actions button:visible').count(),
|
||||
0,
|
||||
'no ready-made game actions'
|
||||
);
|
||||
await playOnBoard(page, action.move);
|
||||
} else await page.locator('.tutorial-actions button').first().click();
|
||||
state = lesson.move(state, action);
|
||||
}
|
||||
await page.waitForFunction(
|
||||
(previous) => document.querySelector('.bgs-tutorial-heading strong')?.textContent !== previous,
|
||||
heading
|
||||
|
|
@ -112,16 +196,14 @@ try {
|
|||
const embeddedGuide = embedded.locator('.bgs-tutorial-guide');
|
||||
await embeddedGuide.getByRole('button', { name: 'Back to start', exact: true }).click();
|
||||
await embeddedGuide.getByRole('button', { name: 'Continue', exact: true }).click();
|
||||
await embedded.locator('.tutorial-bid input').fill('8');
|
||||
await embedded.locator('.tutorial-bid button').click();
|
||||
await playOnBoard(embedded, { name: 'bid', extraData: { price: 8 } });
|
||||
await embedded
|
||||
.locator('.tutorial-actions')
|
||||
.getByRole('button', { name: 'Reveal the bids', exact: true })
|
||||
.click();
|
||||
await embedded.locator('.tutorial-bid input').fill('2');
|
||||
await embedded.locator('.tutorial-bid button').click();
|
||||
await playOnBoard(embedded, { name: 'bid', extraData: { price: 2 } });
|
||||
await embeddedGuide.getByText('5/7 · Reveal the additional bids', { exact: true }).waitFor();
|
||||
console.log(`Sandboxed auction ${width}px: additional bid submitted`);
|
||||
console.log(`Sandboxed native auction ${width}px passed`);
|
||||
await page.goto(`${origin}/?chapter=selling`);
|
||||
await page.evaluate(() => {
|
||||
window.container.launch('#app');
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
@click="ui.selected = null"
|
||||
@keydown.esc="ui.selected = null"
|
||||
id="scene"
|
||||
data-tutorial="game-board"
|
||||
viewBox="0 0 1250 650"
|
||||
height="650"
|
||||
>
|
||||
|
|
@ -25,7 +26,7 @@
|
|||
<rect width="100%" height="100" x="0" y="0" fill="#c6c6b8" />
|
||||
<rect width="390" height="220" x="860" y="430" fill="#c6c6b8" />
|
||||
|
||||
<PassButton transform="translate(1105, 5)" :enabled="canPass()" @click="pass()" />
|
||||
<PassButton data-tutorial="turn" transform="translate(1105, 5)" :enabled="canPass()" @click="pass()" />
|
||||
<UndoButton transform="translate(1105, 36)" :enabled="canUndo()" @click="undo()" />
|
||||
<LogButton transform="translate(1105, 67)" @click="showLog()" />
|
||||
<SoundButton transform="translate(1200, 15)" :isOn="preferences.sound" @click="toggleSound()" />
|
||||
|
|
@ -216,7 +217,7 @@
|
|||
stroke-width="2px"
|
||||
rx="2px"
|
||||
/>
|
||||
<Calculator transform="translate(140, 430)" @bid="bid($event)" />
|
||||
<Calculator data-tutorial="bid" transform="translate(140, 430)" @bid="bid($event)" />
|
||||
</template>
|
||||
</template>
|
||||
|
||||
|
|
|
|||
|
|
@ -167,7 +167,14 @@ function actionStep(
|
|||
title,
|
||||
text,
|
||||
hint,
|
||||
target: 'lesson-actions',
|
||||
target:
|
||||
allowed === isWatch
|
||||
? 'lesson-actions'
|
||||
: ['bid', 'raise'].includes(id)
|
||||
? 'bid'
|
||||
: id === 'finish'
|
||||
? 'turn'
|
||||
: 'game-board',
|
||||
complete,
|
||||
validateMove: (_state, action) =>
|
||||
allowed(action) ? undefined : 'Follow the action described in this step, or use Replay step.',
|
||||
|
|
@ -217,7 +224,7 @@ const supply: Lesson = {
|
|||
actionStep(
|
||||
'produce',
|
||||
'Produce and set a price',
|
||||
'Your orange factory can produce one orange container. Produce it and offer it for $2. Production costs $1, paid to the player before you, and uses your first action.',
|
||||
'Your orange factory can produce one orange container. Click an orange container in the supply, then your factory-sales square marked 2. Production costs $1, paid to the player before you, and uses your first action.',
|
||||
(action) =>
|
||||
action.kind === 'move' &&
|
||||
action.move.name === MoveName.Produce &&
|
||||
|
|
@ -228,7 +235,7 @@ const supply: Lesson = {
|
|||
actionStep(
|
||||
'buy',
|
||||
'Buy for your warehouse',
|
||||
'Use your second action to buy Ada’s white container for $2. Offer it from your warehouse for $4. The house-shaped row holds warehouse buildings. The squares below it hold containers for sale: their numbers are prices, not extra storage spaces. Your one warehouse holds one container.',
|
||||
'Click Ada’s white container in her factory sales, then your warehouse-sales square marked 4. You pay her $2 and offer it for $4. The house-shaped row holds warehouse buildings. The squares below it hold containers for sale: their numbers are prices, not extra storage spaces. Your one warehouse holds one container.',
|
||||
(action) =>
|
||||
action.kind === 'move' &&
|
||||
action.move.name === MoveName.BuyFromFactory &&
|
||||
|
|
@ -239,7 +246,7 @@ const supply: Lesson = {
|
|||
actionStep(
|
||||
'finish',
|
||||
'Finish your turn',
|
||||
'Both actions are spent. In the normal game, Done confirms your purchases and prices. Until then, Undo can revise your turn. In a lesson, use the replay control to start this step again.',
|
||||
'Both actions are spent. In the normal game, Pass in the top-right corner confirms your purchases and prices. Until then, Undo can revise your turn. In a lesson, use the replay control to start this step again.',
|
||||
isMove(MoveName.Pass),
|
||||
(state) => state.game.currentPlayers[0] === 1
|
||||
),
|
||||
|
|
@ -291,14 +298,14 @@ const buildings: Lesson = {
|
|||
actionStep(
|
||||
'warehouse',
|
||||
'Buy room for another container',
|
||||
'Your warehouse is full with one brown container. Each warehouse holds one container. Buy a second warehouse for $4 to increase capacity to two. Buying a building uses one action.',
|
||||
'Your warehouse is full with one brown container. Each warehouse holds one container. Click a warehouse in the supply, then your empty house-shaped building slot to buy it for $4 and increase capacity to two. Buying a building uses one action.',
|
||||
isMove(MoveName.BuyWarehouse),
|
||||
(state) => state.game.players[0].warehouses.length === 2
|
||||
),
|
||||
actionStep(
|
||||
'stock',
|
||||
'Use the new storage space',
|
||||
'Buy Ada’s white container for $2 and offer it for $3. You can now keep both the brown and white containers for visiting ships to buy. Buying a warehouse does not produce or include any containers.',
|
||||
'Click Ada’s white container in her factory sales, then your warehouse-sales square marked 3. You pay $2 and offer it for $3. You can now keep both the brown and white containers for visiting ships to buy. Buying a warehouse does not produce or include any containers.',
|
||||
(action) =>
|
||||
action.kind === 'move' &&
|
||||
action.move.name === MoveName.BuyFromFactory &&
|
||||
|
|
@ -309,14 +316,14 @@ const buildings: Lesson = {
|
|||
actionStep(
|
||||
'finish',
|
||||
'Confirm these two actions',
|
||||
'You bought a warehouse, then stock for it. Choose Done. Ada and Leo will pass so you can try expanding your factory next.',
|
||||
'You bought a warehouse, then stock for it. Choose Pass in the top-right corner. Ada and Leo will pass so you can try expanding your factory next.',
|
||||
isMove(MoveName.Pass),
|
||||
(state) => state.game.currentPlayers[0] === 0 && state.game.players[0].actions === 2
|
||||
),
|
||||
actionStep(
|
||||
'factory',
|
||||
'Buy a second factory for $6',
|
||||
'Your orange factory makes orange containers. Buy a white factory to produce a second colour. You may own only one factory of each colour. Each factory also adds two spaces to your factory sales stock.',
|
||||
'Your orange factory makes orange containers. Click a white factory in the supply, then your empty circular factory slot to buy it. You may own only one factory of each colour. Each factory also adds two spaces to your factory sales stock.',
|
||||
(action) =>
|
||||
action.kind === 'move' && action.move.name === MoveName.BuyFactory && action.move.data === Color.White,
|
||||
(state) => state.game.players[0].factories.length === 2
|
||||
|
|
@ -324,7 +331,7 @@ const buildings: Lesson = {
|
|||
actionStep(
|
||||
'orange',
|
||||
'Produce with both factories',
|
||||
'One production action can make one container per factory. Pay $1 for the entire action, even when using several factories. Start with orange and offer it for $2.',
|
||||
'One production action can make one container per factory. Pay $1 for the entire action, even when using several factories. Click an orange container in the supply, then your factory-sales square marked 2.',
|
||||
(action) =>
|
||||
action.kind === 'move' &&
|
||||
action.move.name === MoveName.Produce &&
|
||||
|
|
@ -335,7 +342,7 @@ const buildings: Lesson = {
|
|||
actionStep(
|
||||
'white',
|
||||
'Add white in the same action',
|
||||
'Now produce white and offer it for $3. This is still the same production action, with no extra $1 payment. More factories produce more stock; more warehouses let you buy and resell more stock from other players.',
|
||||
'Click a white container in the supply, then your factory-sales square marked 3. This is still the same production action, with no extra $1 payment. More factories produce more stock; more warehouses let you buy and resell more stock from other players.',
|
||||
(action) =>
|
||||
action.kind === 'move' &&
|
||||
action.move.name === MoveName.Produce &&
|
||||
|
|
@ -403,14 +410,14 @@ const selling: Lesson = {
|
|||
actionStep(
|
||||
'sea',
|
||||
'Harbour → open sea',
|
||||
'Sail into open sea. Moving directly from one harbour to another is not allowed. This uses one of your two actions.',
|
||||
'Click your blue ship, then the open sea in the centre of the board. Moving directly from one harbour to another is not allowed. This uses one of your two actions.',
|
||||
isMove(MoveName.Sail),
|
||||
(state) => state.game.players[0].ship.shipPosition === ShipPosition.OpenSea
|
||||
),
|
||||
actionStep(
|
||||
'island',
|
||||
'Open sea → island',
|
||||
'Sail to the island to start the auction. An island auction ends your turn even if it was your first action. The seller does not submit a bid.',
|
||||
'Click your blue ship, then the island harbour on the right to start the auction. Confirm the sailing move. An island auction ends your turn even if it was your first action. The seller does not submit a bid.',
|
||||
(action) =>
|
||||
action.kind === 'move' &&
|
||||
action.move.name === MoveName.Sail &&
|
||||
|
|
@ -458,7 +465,7 @@ const bidding: Lesson = {
|
|||
actionStep(
|
||||
'bid',
|
||||
'Submit a sealed bid of $8',
|
||||
'Enter 8 and choose Bid. Your offer is hidden from Leo until he has also bid. You only pay if Ada ultimately sells the cargo to you. You cannot bid more cash than you hold.',
|
||||
'Use the board’s calculator: press 8, then Bid. Your offer is hidden from Leo until he has also bid. You only pay if Ada ultimately sells the cargo to you. You cannot bid more cash than you hold.',
|
||||
(action) =>
|
||||
action.kind === 'move' && action.move.name === MoveName.Bid && action.move.extraData.price === 8,
|
||||
(state) => state.game.players[0].bid === 8
|
||||
|
|
@ -473,7 +480,7 @@ const bidding: Lesson = {
|
|||
actionStep(
|
||||
'raise',
|
||||
'A tie: add $2',
|
||||
'You and Leo both offered $8. Only the tied highest bidders bid again. Enter 2 as your additional bid: your new total will be $10, not $2. You may add $0, but cannot lower your first bid.',
|
||||
'You and Leo both offered $8. Only the tied highest bidders bid again. Use the board’s calculator to bid 2 more, then confirm the $10 total. Your new total is $10, not $2. You may add $0, but cannot lower your first bid.',
|
||||
(action) =>
|
||||
action.kind === 'move' && action.move.name === MoveName.Bid && action.move.extraData.price === 2,
|
||||
(state) => state.game.players[0].additionalBid === 2
|
||||
|
|
@ -526,7 +533,7 @@ const keeping: Lesson = {
|
|||
actionStep(
|
||||
'island',
|
||||
'Offer your shipment',
|
||||
'Sail to the island. Ada and Leo will bid for the entire cargo, just as in the previous auction.',
|
||||
'Click your blue ship, then the island harbour on the right and confirm the sailing move. Ada and Leo will bid for the entire cargo, just as in the previous auction.',
|
||||
(action) =>
|
||||
action.kind === 'move' &&
|
||||
action.move.name === MoveName.Sail &&
|
||||
|
|
@ -624,7 +631,7 @@ const scoring: Lesson = {
|
|||
actionStep(
|
||||
'finish',
|
||||
'Finish the game and count',
|
||||
'The three dark-green containers contribute $0. White earns $20, orange $10, tan $6 and brown $4: $40 from the island. Add $20 cash, $2 for your warehouse container and $3 for the container on your ship; subtract $11 for your loan. Factory stock and buildings score nothing. Choose Done to see the final result.',
|
||||
'The three dark-green containers contribute $0. White earns $20, orange $10, tan $6 and brown $4: $40 from the island. Add $20 cash, $2 for your warehouse container and $3 for the container on your ship; subtract $11 for your loan. Factory stock and buildings score nothing. Choose Pass in the top-right corner to see the final result.',
|
||||
isMove(MoveName.Pass),
|
||||
(state) => ended(state.game)
|
||||
),
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import { createTutorial, TutorialMount, TutorialSnapshot } from '@boardgamers/pr
|
|||
import { mountTutorialGuide } from '@boardgamers/protocol/tutorial/dom';
|
||||
import { GameState, Move, stripSecret } from 'container-engine';
|
||||
import { Phase } from 'container-engine/src/gamestate';
|
||||
import { MoveName } from 'container-engine/src/move';
|
||||
import { EventEmitter } from 'events';
|
||||
import Vue from 'vue';
|
||||
import Game from '../components/Game.vue';
|
||||
|
|
@ -261,63 +260,21 @@ export const mountTutorial: TutorialMount = async (target, { chapter, onProgress
|
|||
let controlStep = -1;
|
||||
function renderControls(snapshot: TutorialSnapshot<LessonState>) {
|
||||
const step = lesson.steps[snapshot.step]?.id ?? '';
|
||||
// Preserve the typed bid and focus when validation reports an error.
|
||||
target.dataset.step = step;
|
||||
if (controlStep !== snapshot.step) {
|
||||
controls.replaceChildren();
|
||||
controlStep = snapshot.step;
|
||||
if (lesson.id === 'bidding' && (step === 'bid' || step === 'raise')) {
|
||||
const form = element('div', 'tutorial-bid');
|
||||
form.setAttribute('role', 'group');
|
||||
form.setAttribute('aria-label', step === 'raise' ? 'Additional bid' : 'Your sealed bid');
|
||||
const label = element('label', '', step === 'raise' ? 'Additional bid' : 'Your sealed bid');
|
||||
const input = element('input');
|
||||
input.type = 'number';
|
||||
input.inputMode = 'numeric';
|
||||
input.min = '0';
|
||||
input.step = '1';
|
||||
input.required = true;
|
||||
input.max = String(snapshot.state.game.players[0].money - snapshot.state.game.players[0].bid);
|
||||
input.value = '';
|
||||
input.id = 'tutorial-bid-amount';
|
||||
label.htmlFor = input.id;
|
||||
const submit = element('button', '', step === 'raise' ? 'Add to my bid' : 'Bid');
|
||||
submit.type = 'button';
|
||||
const total = element('span', 'tutorial-muted');
|
||||
const update = () => {
|
||||
total.textContent =
|
||||
step === 'raise'
|
||||
? `Total: $8 + $${Number(input.value) || 0} = $${8 + (Number(input.value) || 0)}`
|
||||
: '';
|
||||
};
|
||||
input.addEventListener('input', update);
|
||||
update();
|
||||
form.append(label, input, submit, total);
|
||||
const sendBid = () => {
|
||||
if (!input.reportValidity()) return;
|
||||
void play({
|
||||
kind: 'move',
|
||||
move: { name: MoveName.Bid, data: true, extraData: { price: Number(input.value) } },
|
||||
});
|
||||
};
|
||||
submit.addEventListener('click', sendBid);
|
||||
input.addEventListener('keydown', (event) => {
|
||||
if (event.key === 'Enter') {
|
||||
event.preventDefault();
|
||||
sendBid();
|
||||
}
|
||||
for (const choice of lesson
|
||||
.choices(snapshot.state, step)
|
||||
.filter((choice) => choice.action.kind !== 'move')) {
|
||||
const button = element('button');
|
||||
button.type = 'button';
|
||||
if (choice.color) button.append(swatch(choice.color));
|
||||
button.append(document.createTextNode(choice.label));
|
||||
button.addEventListener('click', () => {
|
||||
void play(choice.action);
|
||||
});
|
||||
controls.append(form);
|
||||
} else {
|
||||
for (const choice of lesson.choices(snapshot.state, step)) {
|
||||
const button = element('button');
|
||||
button.type = 'button';
|
||||
if (choice.color) button.append(swatch(choice.color));
|
||||
button.append(document.createTextNode(choice.label));
|
||||
button.addEventListener('click', () => {
|
||||
void play(choice.action);
|
||||
});
|
||||
controls.append(button);
|
||||
}
|
||||
controls.append(button);
|
||||
}
|
||||
}
|
||||
controls.querySelectorAll<HTMLInputElement | HTMLButtonElement>('input, button').forEach((control) => {
|
||||
|
|
|
|||
|
|
@ -137,25 +137,6 @@
|
|||
.tutorial-actions button:hover {
|
||||
background: #32778b;
|
||||
}
|
||||
.tutorial-bid {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
.tutorial-bid label {
|
||||
font-weight: 650;
|
||||
}
|
||||
.tutorial-bid input {
|
||||
font: inherit;
|
||||
background: white;
|
||||
color: #203a45;
|
||||
border: 1px solid #8aadb4;
|
||||
border-radius: 5px;
|
||||
width: 90px;
|
||||
min-height: 42px;
|
||||
padding: 7px;
|
||||
}
|
||||
.tutorial-summary {
|
||||
border-left: 1px solid #8aadb4;
|
||||
padding-left: 24px;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue