@openbooknetwork/hesap 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/client.css +165 -0
- package/src/families/counters/add-figures.js +85 -0
- package/src/families/counters/add-goals.js +82 -0
- package/src/families/counters/add-model.js +82 -0
- package/src/families/counters/add.js +442 -0
- package/src/families/counters/add.mjs +102 -0
- package/src/families/counters/bonds.js +5 -5
- package/src/families/counters/client.css +37 -0
- package/src/families/counters/client.js +2 -1
- package/src/families/counters/count.js +4 -5
- package/src/families/counters/counter.js +14 -0
- package/src/families/counters/goals.js +1 -9
- package/src/families/counters/i18n/en.yaml +89 -45
- package/src/families/counters/i18n/tr.yaml +56 -12
- package/src/families/counters/index.mjs +5 -3
- package/src/families/counters/match-model.js +10 -1
- package/src/families/counters/match.js +31 -11
- package/src/families/counters/match.mjs +7 -1
- package/src/families/line/client.css +118 -0
- package/src/families/line/client.js +12 -0
- package/src/families/line/figures.js +143 -0
- package/src/families/line/goals.js +168 -0
- package/src/families/line/i18n/en.yaml +61 -0
- package/src/families/line/i18n/tr.yaml +61 -0
- package/src/families/line/index.mjs +227 -0
- package/src/families/line/lens.js +49 -0
- package/src/families/line/line.js +624 -0
- package/src/families/line/model.js +219 -0
- package/src/families.mjs +2 -1
- package/src/i18n/en.yaml +158 -46
- package/src/i18n/tr.yaml +124 -12
- package/src/kit/i18n/en.yaml +8 -1
- package/src/kit/i18n/tr.yaml +7 -0
- package/src/kit/kit.css +9 -0
- package/src/kit/panel.js +2 -0
- package/src/kit/random.js +9 -0
- package/src/kit/written.js +70 -0
- package/src/node.mjs +3 -1
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
// a closed box, takes counters out of a tray, steps a marker through rows of ten, fills a bus and climbs a staircase.
|
|
3
3
|
import { modeOf, sizeOf, counts, contextOf, measuresOf, SEATS, STEPS, SIDES } from './count-model.js';
|
|
4
4
|
import { COUNT_GOALS, APPLES, LOOSE, countStart } from './count-goals.js';
|
|
5
|
-
import { another } from './goals.js';
|
|
6
5
|
import { counter, show, put, R } from './counter.js';
|
|
7
6
|
import { arrange } from './places.js';
|
|
8
7
|
import { place, rows, boxRow, pile, basket, bus, stairs, sides } from './count-figures.js';
|
|
@@ -10,11 +9,11 @@ import { carry, press } from './move.js';
|
|
|
10
9
|
import { driver } from './driver.js';
|
|
11
10
|
import { svg as el, svgPoint } from '../../kit/dom.js';
|
|
12
11
|
import { nudge } from '../../kit/drag.js';
|
|
13
|
-
import { stepper, chip, button, row } from '../../kit/panel.js';
|
|
12
|
+
import { stepper, chip, button, row, check } from '../../kit/panel.js';
|
|
14
13
|
import { goalRow } from '../../kit/goal.js';
|
|
15
14
|
import { live } from '../../kit/text.js';
|
|
16
15
|
import { numbers } from '../../kit/format.js';
|
|
17
|
-
import { dice, fresh } from '../../kit/random.js';
|
|
16
|
+
import { dice, fresh, another } from '../../kit/random.js';
|
|
18
17
|
|
|
19
18
|
const MAX = 1.7; // A figure grows to at most this scale on a wide stage.
|
|
20
19
|
const PAD = 14; // The figure keeps this far from the stage's edges, in pixels.
|
|
@@ -301,7 +300,7 @@ export default function count({ host, stage, panel, T, lang, moving, motion: fx
|
|
|
301
300
|
const g = COUNT_GOALS[c.goal];
|
|
302
301
|
goal.say(T(`goal-${c.goal}`, g.words(c, target, { int })));
|
|
303
302
|
const r = g.holds({ ...cs, basket: s.lists.basket.length, beside: s.lists.beside.length, left: s.here.filter(Boolean).length }, spec, c, target);
|
|
304
|
-
const first = goal.show(r.done, r.note ? T(`note-${c.goal}-${r.note}
|
|
303
|
+
const first = goal.show(r.done, r.note ? T(`note-${c.goal}-${r.note}`, g.words(c, target, { int })) : undefined);
|
|
305
304
|
if (first && moving()) go.cheer([...nodes.values()].map(n => n.pop));
|
|
306
305
|
}
|
|
307
306
|
|
|
@@ -312,7 +311,7 @@ export default function count({ host, stage, panel, T, lang, moving, motion: fx
|
|
|
312
311
|
if (c) {
|
|
313
312
|
goal = goalRow({ T, motion: moving() ? fx : null, hint: on => on ? T(`hint-${c.goal}`, COUNT_GOALS[c.goal].words(c, target, { int })) : null,
|
|
314
313
|
another: () => { begin(); goal.reset(); build(); if (!geo) refresh(); } });
|
|
315
|
-
ctls.push(
|
|
314
|
+
ctls.push(check({ T, press: () => { if (!cs.checked) { cs.checked = true; judge(); } } }));
|
|
316
315
|
} else {
|
|
317
316
|
const step = (id, key, ctl, value, set) => stepper({ id, label: T(key), min: ctl.lo, max: ctl.hi, value, write: int, change: v => { set(v); changed(); } });
|
|
318
317
|
if (spec.boxCtl) ctls.push(step('box', 'ctl-box', spec.boxCtl, s.box, v => { s.box = v; }));
|
|
@@ -36,6 +36,20 @@ const OBJECTS = {
|
|
|
36
36
|
|
|
37
37
|
function glyph(kind, r) {
|
|
38
38
|
if (OBJECTS[kind]) return OBJECTS[kind](r);
|
|
39
|
+
// A grown seedling with two large leaves, and a small sprout with two small ones, so the two groups of the seed
|
|
40
|
+
// tray differ by size and shape.
|
|
41
|
+
if (kind === 'seedling') return [el('path', { class: 'counters-plant-stem', d: `M 0 ${r * 0.95} L 0 ${-r * 0.35}` }),
|
|
42
|
+
el('ellipse', { class: 'counters-body', cx: -r * 0.45, cy: -r * 0.45, rx: r * 0.55, ry: r * 0.3, transform: `rotate(-30 ${-r * 0.45} ${-r * 0.45})` }),
|
|
43
|
+
el('ellipse', { class: 'counters-body', cx: r * 0.45, cy: -r * 0.6, rx: r * 0.55, ry: r * 0.3, transform: `rotate(30 ${r * 0.45} ${-r * 0.6})` })];
|
|
44
|
+
if (kind === 'sprout') return [el('path', { class: 'counters-plant-stem', d: `M 0 ${r * 0.95} L 0 ${r * 0.3}` }),
|
|
45
|
+
el('ellipse', { class: 'counters-body', cx: -r * 0.25, cy: r * 0.2, rx: r * 0.27, ry: r * 0.15, transform: `rotate(-30 ${-r * 0.25} ${r * 0.2})` }),
|
|
46
|
+
el('ellipse', { class: 'counters-body', cx: r * 0.25, cy: r * 0.12, rx: r * 0.27, ry: r * 0.15, transform: `rotate(30 ${r * 0.25} ${r * 0.12})` })];
|
|
47
|
+
// A jar of jam with its lid. The lid takes the colour of the crate the jar was sold into.
|
|
48
|
+
if (kind === 'jar') return [el('rect', { class: 'counters-jar-glass', x: -r * 0.78, y: -r * 0.72, width: r * 1.56, height: r * 1.72, rx: r * 0.32 }),
|
|
49
|
+
el('rect', { class: 'counters-jam', x: -r * 0.62, y: -r * 0.36, width: r * 1.24, height: r * 1.2, rx: r * 0.22 }),
|
|
50
|
+
el('rect', { class: 'counters-jar-lid', x: -r * 0.86, y: -r * 1.08, width: r * 1.72, height: r * 0.46, rx: r * 0.12 })];
|
|
51
|
+
// A square counter tells the second group of counters/add from the round first group by its shape.
|
|
52
|
+
if (kind === 'square') return [el('rect', { class: 'counters-body', x: -r * 0.9, y: -r * 0.9, width: r * 1.8, height: r * 1.8, rx: r * 0.22 }), el('rect', { class: 'counters-ring', x: -r * 0.52, y: -r * 0.52, width: r * 1.04, height: r * 1.04, rx: r * 0.1 })];
|
|
39
53
|
if (kind === 'bead') return [el('circle', { class: 'counters-body', r }), el('circle', { class: 'counters-shine', r: r * 0.32, cx: -r * 0.35, cy: -r * 0.35 })];
|
|
40
54
|
if (kind === 'car') {
|
|
41
55
|
const w = r * 1.5, l = r * 2.5;
|
|
@@ -42,7 +42,7 @@ export const GOALS = {
|
|
|
42
42
|
looks: ['diagram'],
|
|
43
43
|
problem(c) {
|
|
44
44
|
if (!range(c.whole) || c.whole[0] < 2 || c.whole[1] > PILE) return `whole is ${JSON.stringify(c.whole)}, write the range of the whole as [low, high] from 2 to ${PILE}, such as [5, 20]`;
|
|
45
|
-
if (c.part !== undefined && !range(c.part)) return 'part is not a range, write the part
|
|
45
|
+
if (c.part !== undefined && !range(c.part)) return 'part is not a range, write the known part as [low, high], or leave it out for 1 to one less than the whole';
|
|
46
46
|
return null;
|
|
47
47
|
},
|
|
48
48
|
draw(c, spec, dice) {
|
|
@@ -65,11 +65,3 @@ export const GOALS = {
|
|
|
65
65
|
// The reader's state as a challenge opens: no blue counters checked, an empty tray and the cup down.
|
|
66
66
|
export const challengeStart = () => ({ blue: 0, checked: false, tray: 0, lifted: false });
|
|
67
67
|
|
|
68
|
-
// another draws a target that differs from the last one, so Another one always changes the figure.
|
|
69
|
-
export function another(goal, c, spec, dice, last) {
|
|
70
|
-
for (let i = 0; i < 40; i++) {
|
|
71
|
-
const t = goal.draw(c, spec, dice);
|
|
72
|
-
if (!last || JSON.stringify(t) !== JSON.stringify(last)) return t;
|
|
73
|
-
}
|
|
74
|
-
return goal.draw(c, spec, dice);
|
|
75
|
-
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
counters_lead: "Tap
|
|
1
|
+
counters_lead: "Tap or drag the counters and watch the numbers change."
|
|
2
2
|
counters_whole: Whole
|
|
3
3
|
counters_first: First part
|
|
4
4
|
counters_second: Second part
|
|
5
5
|
counters_empty: Empty cells
|
|
6
|
-
counters_added:
|
|
6
|
+
counters_added: Added
|
|
7
7
|
counters_found: Splits found
|
|
8
8
|
counters_ways: Splits in all
|
|
9
9
|
counters_hands-first: Left hand
|
|
@@ -12,11 +12,11 @@ counters_hands-whole: Beads
|
|
|
12
12
|
counters_one-first: Counters
|
|
13
13
|
counters_one-found: Pairs found
|
|
14
14
|
counters_one-ways: Pairs in all
|
|
15
|
-
counters_two-first:
|
|
16
|
-
counters_two-second:
|
|
17
|
-
counters_cup-first:
|
|
18
|
-
counters_cup-second:
|
|
19
|
-
counters_cup-added:
|
|
15
|
+
counters_two-first: First part
|
|
16
|
+
counters_two-second: Second part
|
|
17
|
+
counters_cup-first: Known part
|
|
18
|
+
counters_cup-second: Missing part
|
|
19
|
+
counters_cup-added: Added
|
|
20
20
|
counters_pins-first: Standing
|
|
21
21
|
counters_pins-empty: Knocked down
|
|
22
22
|
counters_cars-first: Parked
|
|
@@ -27,8 +27,7 @@ counters_fill: Fill the second frame
|
|
|
27
27
|
counters_unfill: Empty the second frame
|
|
28
28
|
counters_lift: Lift the cup
|
|
29
29
|
counters_lower: Put the cup back
|
|
30
|
-
|
|
31
|
-
counters_blue: Blue counters
|
|
30
|
+
counters_blue: Second part
|
|
32
31
|
counters_tray: Tray
|
|
33
32
|
counters_pile: Pile
|
|
34
33
|
counters_cup: Cup
|
|
@@ -41,15 +40,15 @@ counters_free: Free
|
|
|
41
40
|
counters_pair: "{a} and {b}"
|
|
42
41
|
counters_list-splits: "Splits of {x}"
|
|
43
42
|
counters_list-pairs: "Pairs that make {x}"
|
|
44
|
-
counters_goal-make-whole: "
|
|
45
|
-
counters_goal-make-whole-two: "
|
|
46
|
-
counters_goal-hidden-part: "The whole is {whole}
|
|
47
|
-
counters_note-short:
|
|
48
|
-
counters_note-over:
|
|
49
|
-
counters_note-more:
|
|
50
|
-
counters_note-fewer:
|
|
51
|
-
counters_hint-make-whole: "Count on from {part} to {whole}
|
|
52
|
-
counters_hint-hidden-part: "Count on from {part} to {whole}
|
|
43
|
+
counters_goal-make-whole: "Set the second part so that it makes {whole} with the first part, {part}, then press Check."
|
|
44
|
+
counters_goal-make-whole-two: "Set the second part so that it makes {whole} with the first part, {part}, then press Check."
|
|
45
|
+
counters_goal-hidden-part: "The whole is {whole} and the known part is {part}. Put the missing part in the tray, then lift the cup."
|
|
46
|
+
counters_note-short: "There are still empty cells, so add more counters to the second part."
|
|
47
|
+
counters_note-over: "There are more counters than cells, so take some counters out of the second part."
|
|
48
|
+
counters_note-more: "There are more counters in the tray than under the cup, so put some back on the pile."
|
|
49
|
+
counters_note-fewer: "There are fewer counters in the tray than under the cup, so put more in the tray."
|
|
50
|
+
counters_hint-make-whole: "Count on from {part} to {whole} and keep track of how many numbers you say. That is how many counters the second part needs."
|
|
51
|
+
counters_hint-hidden-part: "Count on from {part} to {whole} and keep track of how many numbers you say. That is how many counters are under the cup, so put that many in the tray."
|
|
53
52
|
counters_total: How many
|
|
54
53
|
counters_tag-count: Last number said
|
|
55
54
|
counters_take-count: Left
|
|
@@ -70,18 +69,18 @@ counters_kind-person: Person
|
|
|
70
69
|
counters_gap: Empty place
|
|
71
70
|
counters_basket: Basket
|
|
72
71
|
counters_stop-sign: Bus
|
|
73
|
-
counters_goal-fill-basket: "Put
|
|
74
|
-
counters_goal-count-on: "The box holds {box}. Put counters
|
|
75
|
-
counters_goal-count-back: "Take counters away until {target}
|
|
76
|
-
counters_note-fill-basket-more:
|
|
77
|
-
counters_note-fill-basket-fewer:
|
|
78
|
-
counters_note-count-on-more: The box and the counters
|
|
79
|
-
counters_note-count-on-fewer: The box and the counters
|
|
80
|
-
counters_note-count-back-more:
|
|
81
|
-
counters_note-count-back-fewer:
|
|
82
|
-
counters_hint-fill-basket: "
|
|
83
|
-
counters_hint-count-on: "Start
|
|
84
|
-
counters_hint-count-back: "Start
|
|
72
|
+
counters_goal-fill-basket: "Put apples in the basket until it holds {target}, then press Check."
|
|
73
|
+
counters_goal-count-on: "The box holds {box}. Put counters in the dashed space until there are {target} altogether, then press Check."
|
|
74
|
+
counters_goal-count-back: "Take counters away until the number left is {target}, then press Check."
|
|
75
|
+
counters_note-fill-basket-more: "There are more than {target} apples in the basket, so take some out."
|
|
76
|
+
counters_note-fill-basket-fewer: "There are fewer than {target} apples in the basket, so put more in."
|
|
77
|
+
counters_note-count-on-more: "The box and the counters you put out come to more than {target}, so take some counters away."
|
|
78
|
+
counters_note-count-on-fewer: "The box and the counters you put out come to fewer than {target}, so put out more counters."
|
|
79
|
+
counters_note-count-back-more: "The number left is greater than {target}, so take more counters away."
|
|
80
|
+
counters_note-count-back-fewer: "The number left is less than {target}, so put some counters back."
|
|
81
|
+
counters_hint-fill-basket: "Count each apple as you put it in, and stop when you get to {target}."
|
|
82
|
+
counters_hint-count-on: "Start at {box}. Say the next number each time you put out a counter, and stop when you get to {target}."
|
|
83
|
+
counters_hint-count-back: "Start at {start}. Count back one number each time you take a counter away, and stop when you get to {target}."
|
|
85
84
|
counters_roll: Roll the ball
|
|
86
85
|
counters_set-up: Set up the pins
|
|
87
86
|
counters_ctl-top: Top row
|
|
@@ -124,31 +123,76 @@ counters_greatest: greatest
|
|
|
124
123
|
counters_show-rows: Show the rows
|
|
125
124
|
counters_order-top: First number
|
|
126
125
|
counters_order-bottom: Second number
|
|
127
|
-
counters_order-top-rows: "
|
|
128
|
-
counters_order-top-last: "
|
|
129
|
-
counters_order-bottom-rows: "
|
|
130
|
-
counters_order-bottom-last: "
|
|
126
|
+
counters_order-top-rows: "Full rows of the first"
|
|
127
|
+
counters_order-top-last: "Last row of the first"
|
|
128
|
+
counters_order-bottom-rows: "Full rows of the second"
|
|
129
|
+
counters_order-bottom-last: "Last row of the second"
|
|
131
130
|
counters_reading-equal: "{a} is equal to {b}"
|
|
132
131
|
counters_verdict-true: "true"
|
|
133
132
|
counters_verdict-false: "false"
|
|
134
133
|
counters_sign: Sign
|
|
135
134
|
counters_match-reading: In words
|
|
136
|
-
counters_match-verdict:
|
|
135
|
+
counters_match-verdict: True or false
|
|
137
136
|
counters_match-scoreboard-top: Home
|
|
138
137
|
counters_match-scoreboard-bottom: Away
|
|
139
138
|
counters_score-top: Home goal
|
|
140
139
|
counters_score-bottom: Away goal
|
|
141
140
|
counters_new-match: New match
|
|
142
|
-
counters_goal-same-rows: "
|
|
143
|
-
counters_note-same-rows-top: Some counters
|
|
144
|
-
counters_note-same-rows-bottom: Some counters
|
|
145
|
-
counters_hint-same-rows: "
|
|
146
|
-
counters_goal-one-less: "Give the top row one counter
|
|
147
|
-
counters_note-one-less-over: The top row has too many counters.
|
|
148
|
-
counters_note-one-less-short: The top row has too few counters.
|
|
149
|
-
counters_hint-one-less: "Pair the rows.
|
|
150
|
-
counters_goal-right-sign: "Put the sign
|
|
141
|
+
counters_goal-same-rows: "Give the top row as many counters as the bottom row, then press Check."
|
|
142
|
+
counters_note-same-rows-top: "Some counters in the top row have no partner, so take some away from the top row."
|
|
143
|
+
counters_note-same-rows-bottom: "Some counters in the bottom row have no partner, so add counters to the top row."
|
|
144
|
+
counters_hint-same-rows: "Pair up the counters in the two rows. Then add counters to the top row or take some away until every counter has a partner."
|
|
145
|
+
counters_goal-one-less: "Give the top row one fewer counter than the bottom row, then press Check."
|
|
146
|
+
counters_note-one-less-over: "The top row has too many counters, so take some away."
|
|
147
|
+
counters_note-one-less-short: "The top row has too few counters, so add some."
|
|
148
|
+
counters_hint-one-less: "Pair up the counters in the two rows. Then change the top row until just one counter in the bottom row has no partner."
|
|
149
|
+
counters_goal-right-sign: "Put the sign that makes the number sentence true between the two rows, then press Check."
|
|
151
150
|
counters_note-right-sign-more: The top row has more counters than this sign says.
|
|
152
151
|
counters_note-right-sign-fewer: The top row has fewer counters than this sign says.
|
|
153
|
-
counters_hint-right-sign: "
|
|
152
|
+
counters_hint-right-sign: "Pair up the counters in the two rows. The row with counters left over has more, and the open side of the sign faces that row. If no counters are left over, the sign is =."
|
|
154
153
|
counters_new-numbers: New numbers
|
|
154
|
+
counters_add-first: First number
|
|
155
|
+
counters_add-second: Second number
|
|
156
|
+
counters_add-waiting: Still to join
|
|
157
|
+
counters_add-sum: Sum
|
|
158
|
+
counters_add-dice-sum: Counters in the frames
|
|
159
|
+
counters_add-roll: Roll
|
|
160
|
+
counters_add-die: "Die showing {x}"
|
|
161
|
+
counters_add-counter-waiting: "Counter waiting to join"
|
|
162
|
+
counters_add-counter-joined: "Counter that has joined"
|
|
163
|
+
counters_add-take-second: Taken away
|
|
164
|
+
counters_add-left: Left
|
|
165
|
+
counters_add-take-counter: Counter
|
|
166
|
+
counters_add-take-ring: "Empty ring where a counter was taken away"
|
|
167
|
+
counters_add-shelf-first: Morning
|
|
168
|
+
counters_add-shelf-second: Afternoon
|
|
169
|
+
counters_add-shelf-sum: Sold
|
|
170
|
+
counters_add-shelf-written: Jars sold
|
|
171
|
+
counters_add-shelf-written-left: Jars left
|
|
172
|
+
counters_add-shelf-reading: Jars sold in words
|
|
173
|
+
counters_add-shelf-reading-left: Jars left in words
|
|
174
|
+
counters_add-shelf-crate: Sold in the
|
|
175
|
+
counters_add-shelf-jar: Jar on the shelf
|
|
176
|
+
counters_add-sold-jar: "Jar {x} in the crate"
|
|
177
|
+
counters_add-to-ten: Makes ten
|
|
178
|
+
counters_add-rest: The rest
|
|
179
|
+
counters_add-seedling: Seedling
|
|
180
|
+
counters_add-sprout: Sprout
|
|
181
|
+
counters_add-seed-waiting: Seed in the packet
|
|
182
|
+
counters_add-seed-joined: Sprout in the tray
|
|
183
|
+
counters_goal-find-sum: "Set the sum of {a} and {b} on the Sum stepper, then press Check."
|
|
184
|
+
counters_goal-find-sum-done: "A group of {a} and a group of {b} make {sum} altogether."
|
|
185
|
+
counters_note-find-sum-less: "The sum is less than {n}."
|
|
186
|
+
counters_note-find-sum-greater: "The sum is greater than {n}."
|
|
187
|
+
counters_hint-find-sum: "Picture {a} counters in the frames and {b} more counters joining them. Start at {a} and count on one number for each counter that joins."
|
|
188
|
+
counters_goal-steps-to-ten: "Split the {second} in {calc} into the part that makes ten with {first} and the rest, then press Check."
|
|
189
|
+
counters_goal-steps-to-ten-done: "{line}. The two steps are {toTen} and {rest}."
|
|
190
|
+
counters_note-steps-to-ten-past: "{step} goes past 10."
|
|
191
|
+
counters_note-steps-to-ten-short: "{step} does not reach 10."
|
|
192
|
+
counters_note-steps-to-ten-more: "{x} and {y} make more than {second}, so make the rest smaller."
|
|
193
|
+
counters_note-steps-to-ten-less: "{x} and {y} make less than {second}, so make the rest greater."
|
|
194
|
+
counters_hint-steps-to-ten-plus: "First work out how many {first} needs to make 10, and set that. Then set what is left of the {second}."
|
|
195
|
+
counters_hint-steps-to-ten-minus: "First work out how many to take away to bring {first} down to 10, and set that. Then set what is left of the {second}."
|
|
196
|
+
counters_add-take-to-ten: Down to ten
|
|
197
|
+
counters_goal-steps-to-ten-minus: "Split the {second} in {calc} into the part that takes {first} down to ten and the rest, then press Check."
|
|
198
|
+
counters_add-shelf-left: Left
|
|
@@ -14,8 +14,8 @@ counters_one-found: Bulunan ikililer
|
|
|
14
14
|
counters_one-ways: Tüm ikililer
|
|
15
15
|
counters_two-first: Kırmızı
|
|
16
16
|
counters_two-second: Mavi
|
|
17
|
-
counters_cup-first:
|
|
18
|
-
counters_cup-second:
|
|
17
|
+
counters_cup-first: Bilinen parça
|
|
18
|
+
counters_cup-second: Bilinmeyen parça
|
|
19
19
|
counters_cup-added: Eklenen mavi
|
|
20
20
|
counters_pins-first: Ayakta
|
|
21
21
|
counters_pins-empty: Devrilen
|
|
@@ -27,7 +27,6 @@ counters_fill: İkinci çerçeveyi doldur
|
|
|
27
27
|
counters_unfill: İkinci çerçeveyi boşalt
|
|
28
28
|
counters_lift: Bardağı kaldır
|
|
29
29
|
counters_lower: Bardağı geri koy
|
|
30
|
-
counters_check: Kontrol et
|
|
31
30
|
counters_blue: Mavi sayaçlar
|
|
32
31
|
counters_tray: Tepsi
|
|
33
32
|
counters_pile: Yığın
|
|
@@ -43,7 +42,7 @@ counters_list-splits: "{x} sayısının ayrımları"
|
|
|
43
42
|
counters_list-pairs: "{x} yapan ikililer"
|
|
44
43
|
counters_goal-make-whole: "Kırmızı tepside {part} sayaç var. Çerçeve {whole} sayaç tutacak biçimde mavi sayaçları ayarlayın, sonra Kontrol et düğmesine basın."
|
|
45
44
|
counters_goal-make-whole-two: "Kırmızı tepside {part} sayaç var. İki çerçeve {whole} sayaç tutacak biçimde mavi sayaçları ayarlayın, sonra Kontrol et düğmesine basın."
|
|
46
|
-
counters_goal-hidden-part: "Bütün {whole},
|
|
45
|
+
counters_goal-hidden-part: "Bütün {whole}, bilinen parça {part}. Bardağın altındaki parçayı tepside kurun, sonra bardağı kaldırın."
|
|
47
46
|
counters_note-short: Bazı hücreler hâlâ boş.
|
|
48
47
|
counters_note-over: Bazı sayaçlara hücre kalmadı.
|
|
49
48
|
counters_note-more: Tepside bardaktakinden çok sayaç var.
|
|
@@ -87,8 +86,8 @@ counters_set-up: Lobutları diz
|
|
|
87
86
|
counters_ctl-top: Üst sıra
|
|
88
87
|
counters_ctl-bottom: Alt sıra
|
|
89
88
|
counters_ctl-spread: Aralık
|
|
90
|
-
counters_match-unpaired:
|
|
91
|
-
counters_match-pairs:
|
|
89
|
+
counters_match-unpaired: Eşleşmeyen
|
|
90
|
+
counters_match-pairs: Eşleşenler
|
|
92
91
|
counters_word-same: Aynı
|
|
93
92
|
counters_tag-more: daha çok
|
|
94
93
|
counters_tag-fewer: daha az
|
|
@@ -133,22 +132,67 @@ counters_verdict-true: "doğru"
|
|
|
133
132
|
counters_verdict-false: "yanlış"
|
|
134
133
|
counters_sign: İşaret
|
|
135
134
|
counters_match-reading: Sözle
|
|
136
|
-
counters_match-verdict:
|
|
135
|
+
counters_match-verdict: İfade
|
|
137
136
|
counters_match-scoreboard-top: Ev sahibi
|
|
138
137
|
counters_match-scoreboard-bottom: Deplasman
|
|
139
138
|
counters_score-top: Ev sahibi golü
|
|
140
139
|
counters_score-bottom: Deplasman golü
|
|
141
140
|
counters_new-match: Yeni maç
|
|
142
141
|
counters_goal-same-rows: "Üst sırayı alt sırayla aynı yapın, sonra Kontrol et düğmesine basın."
|
|
143
|
-
counters_note-same-rows-top: Üst sıradaki bazı
|
|
144
|
-
counters_note-same-rows-bottom: Alt sıradaki bazı
|
|
142
|
+
counters_note-same-rows-top: Üst sıradaki bazı sayaçlar eşleşmedi.
|
|
143
|
+
counters_note-same-rows-bottom: Alt sıradaki bazı sayaçlar eşleşmedi.
|
|
145
144
|
counters_hint-same-rows: "Her üst sayaçtan bir alt sayaca çizgi çizin. Çizgisiz kalan sayaçlar neyi değiştireceğinizi gösterir."
|
|
146
145
|
counters_goal-one-less: "Üst sıraya alt sıradan bir sayaç az verin, sonra Kontrol et düğmesine basın."
|
|
147
146
|
counters_note-one-less-over: Üst sırada fazla sayaç var.
|
|
148
147
|
counters_note-one-less-short: Üst sırada eksik sayaç var.
|
|
149
|
-
counters_hint-one-less: "Sıraları eşleştirin. Bir sayaç az olunca alt sıranın bir sayacı
|
|
150
|
-
counters_goal-right-sign: "İki sıranın arasına
|
|
148
|
+
counters_hint-one-less: "Sıraları eşleştirin. Bir sayaç az olunca alt sıranın bir sayacı eşleşmeden kalır."
|
|
149
|
+
counters_goal-right-sign: "İki sıranın arasına ifadeyi doğru yapan işareti koyun, sonra Kontrol et düğmesine basın."
|
|
151
150
|
counters_note-right-sign-more: Üst sırada bu işaretin söylediğinden çok sayaç var.
|
|
152
151
|
counters_note-right-sign-fewer: Üst sırada bu işaretin söylediğinden az sayaç var.
|
|
153
|
-
counters_hint-right-sign: "Her üst sayaçtan bir alt sayaca çizgi çizin.
|
|
152
|
+
counters_hint-right-sign: "Her üst sayaçtan bir alt sayaca çizgi çizin. Eşleşmeyen sayacı kalan sırada daha çok sayaç vardır ve işaretin açık yanı ona bakar. Hiç sayaç kalmazsa işaret = olur."
|
|
154
153
|
counters_new-numbers: Yeni sayılar
|
|
154
|
+
counters_add-first: Birinci sayı
|
|
155
|
+
counters_add-second: İkinci sayı
|
|
156
|
+
counters_add-waiting: Bekleyen
|
|
157
|
+
counters_add-sum: Toplam
|
|
158
|
+
counters_add-dice-sum: Çerçevelerdeki sayaçlar
|
|
159
|
+
counters_add-roll: Zar at
|
|
160
|
+
counters_add-die: "{x} gösteren zar"
|
|
161
|
+
counters_add-counter-waiting: Bekleyen sayaç
|
|
162
|
+
counters_add-counter-joined: Bir araya getirilen sayaç
|
|
163
|
+
counters_add-take-second: Çıkan
|
|
164
|
+
counters_add-left: Fark
|
|
165
|
+
counters_add-take-counter: Sayaç
|
|
166
|
+
counters_add-take-ring: Çıkan sayacın halkası
|
|
167
|
+
counters_add-shelf-first: Sabah
|
|
168
|
+
counters_add-shelf-second: Öğleden sonra
|
|
169
|
+
counters_add-shelf-sum: Satılan
|
|
170
|
+
counters_add-shelf-written: Satılan kavanozlar
|
|
171
|
+
counters_add-shelf-written-left: Kalan kavanozlar
|
|
172
|
+
counters_add-shelf-reading: Satılan kavanozlar sözle
|
|
173
|
+
counters_add-shelf-reading-left: Kalan kavanozlar sözle
|
|
174
|
+
counters_add-shelf-crate: Satış kasası
|
|
175
|
+
counters_add-shelf-jar: Raftaki kavanoz
|
|
176
|
+
counters_add-sold-jar: "Kasadaki kavanoz, {x}"
|
|
177
|
+
counters_add-to-ten: 10'a tamamlayan
|
|
178
|
+
counters_add-rest: Diğer parça
|
|
179
|
+
counters_add-seedling: Fide
|
|
180
|
+
counters_add-sprout: Filiz
|
|
181
|
+
counters_add-seed-waiting: Paketteki tohum
|
|
182
|
+
counters_add-seed-joined: Viyoldeki filiz
|
|
183
|
+
counters_goal-find-sum: "{a} ile {b} sayısının toplamını Toplam düğmeleriyle ayarlayın, sonra Kontrol et düğmesine basın."
|
|
184
|
+
counters_goal-find-sum-done: "{a} sayaçlık bir grup ile {b} sayaçlık bir grup bir araya gelince {sum} eder."
|
|
185
|
+
counters_note-find-sum-less: "Toplam {n} sayısından küçük."
|
|
186
|
+
counters_note-find-sum-greater: "Toplam {n} sayısından büyük."
|
|
187
|
+
counters_hint-find-sum: "Çerçevelerde {a} kırmızı sayaç ve onlarla bir araya gelen {b} mavi sayaç düşünün. {a} sayısından başlayıp her mavi sayaç için bir sayı ileri sayın."
|
|
188
|
+
counters_goal-steps-to-ten: "{calc} için 10'a tamamlayan ve Diğer parça düğmelerini ayarlayın, sonra Kontrol et düğmesine basın."
|
|
189
|
+
counters_goal-steps-to-ten-done: "{line}; {toTen} ve {rest}."
|
|
190
|
+
counters_note-steps-to-ten-past: "{step}, 10'u geçiyor."
|
|
191
|
+
counters_note-steps-to-ten-short: "{step}, 10'a varmıyor."
|
|
192
|
+
counters_note-steps-to-ten-more: "10'a tamamlayan ve Diğer parça, {second} sayısından çok ediyor."
|
|
193
|
+
counters_note-steps-to-ten-less: "10'a tamamlayan ve Diğer parça, {second} sayısından az ediyor."
|
|
194
|
+
counters_hint-steps-to-ten-plus: "10'a tamamlayan, {first} ile 10 eden sayıdır. Diğer parça, {second} sayısından geriye kalandır."
|
|
195
|
+
counters_hint-steps-to-ten-minus: "Ona kadar, {first} sayısının dolu onluğundan sonraki sayaçların sayısıdır. Diğer parça, {second} sayısından geriye kalandır."
|
|
196
|
+
counters_add-take-to-ten: Ona kadar
|
|
197
|
+
counters_goal-steps-to-ten-minus: "{calc} için Ona kadar ve Diğer parça düğmelerini ayarlayın, sonra Kontrol et düğmesine basın."
|
|
198
|
+
counters_add-shelf-left: Kalan
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
// The Node half of the counters family. The bonds scene moves counters between parts and fills ten frames, the
|
|
2
|
-
// count scene counts objects one by one,
|
|
3
|
-
// scene and
|
|
2
|
+
// count scene counts objects one by one, the match scene pairs two rows, the order scene compares numbers, and the
|
|
3
|
+
// add scene joins two groups and writes their sum. It checks a page's fields against its scene and says what each
|
|
4
|
+
// link shows when the page opens.
|
|
4
5
|
import { schema } from '@openbooknetwork/kitap';
|
|
5
6
|
import { LOOKS, modeOf, capOf, opening, counts, measuresOf } from './model.js';
|
|
6
7
|
import { GOALS, challengeStart } from './goals.js';
|
|
7
8
|
import count from './count.mjs';
|
|
8
9
|
import match from './match.mjs';
|
|
9
10
|
import order from './order.mjs';
|
|
11
|
+
import add from './add.mjs';
|
|
10
12
|
import { numbers } from '../../kit/format.js';
|
|
11
13
|
import { list, challenge, drawn, value } from '../../node.mjs';
|
|
12
14
|
|
|
@@ -96,7 +98,7 @@ function startBonds(spec, lang, id) {
|
|
|
96
98
|
|
|
97
99
|
// Each scene checks its own fields, so the family's schema lets every field through to the scene.
|
|
98
100
|
const Fields = z.object({}).passthrough();
|
|
99
|
-
const SCENES = { bonds: { read: readBonds, start: startBonds }, count, match, order };
|
|
101
|
+
const SCENES = { bonds: { read: readBonds, start: startBonds }, count, match, order, add };
|
|
100
102
|
const read = ({ scene, ...fields }, info, ctx) => SCENES[scene].read(fields, info, ctx);
|
|
101
103
|
const start = (spec, lang, id) => SCENES[spec.scene].start(spec, lang, id);
|
|
102
104
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// What a match page holds and what it counts: two rows of objects and the pairs between them. The build and the
|
|
2
2
|
// browser both use this file, so a page's text and its live values agree.
|
|
3
3
|
import { isTile, signShown, readingKey, verdictKey } from './reading.js';
|
|
4
|
+
import { MINUS } from '../../kit/written.js';
|
|
4
5
|
|
|
5
6
|
// A page draws its rows as counters, as cups on a tray above saucers on a table, as the players and the chairs of
|
|
6
7
|
// a game of musical chairs, or as the two scores of a scoreboard with a ball for each goal.
|
|
@@ -74,7 +75,7 @@ export const tagKey = w => w.n == null ? `tag-${w.word}` : `tag-${w.word}-n`;
|
|
|
74
75
|
// The measures a page can read out and link in its text. The words of the tags are linked and take no readout.
|
|
75
76
|
export function measuresOf(spec) {
|
|
76
77
|
if (spec.challenge) return [];
|
|
77
|
-
const signed = [...(spec.sign ? ['reading'] : []), ...(isTile(spec) ? ['verdict'] : [])];
|
|
78
|
+
const signed = [...(spec.sign ? ['reading'] : []), ...(isTile(spec) ? ['verdict'] : []), ...(spec.written ? ['written', 'reading'] : [])];
|
|
78
79
|
if (spec.look === 'chairs' || spec.look === 'scoreboard') return ['top', 'bottom', ...signed];
|
|
79
80
|
return ['unpaired', 'pairs', 'top', 'bottom', ...signed, ...(spec.tap ? ['counted'] : []), ...(spec.trace ? ['added', 'taken'] : [])];
|
|
80
81
|
}
|
|
@@ -82,3 +83,11 @@ export const wordsLinked = spec => spec.word === true ? ['top-word', 'bottom-wor
|
|
|
82
83
|
// The strings of the line of words and of the mark of a page with a sign, as the page stands.
|
|
83
84
|
export const readingOf = (spec, s) => readingKey(s.top, s.bottom, signShown(spec, s));
|
|
84
85
|
export const verdictOf = (spec, s) => verdictKey(s.top, s.bottom, signShown(spec, s));
|
|
86
|
+
|
|
87
|
+
// differenceOf gives the written line of the difference of the rows: the greater row's number minus the less row's,
|
|
88
|
+
// with its answer once one row has every counter paired, when the counters left over take their rings. greater
|
|
89
|
+
// names the row whose number comes first, the top row when the rows are equal.
|
|
90
|
+
export function differenceOf(spec, s) {
|
|
91
|
+
const greater = s.bottom > s.top ? 'bottom' : 'top', less = greater === 'top' ? 'bottom' : 'top';
|
|
92
|
+
return { line: { a: s[greater], sign: MINUS, b: s[less], open: !lone(spec, s).ringed }, greater, less };
|
|
93
|
+
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
// The match scene: two rows of objects paired one to one. The reader draws a line between a counter of each row,
|
|
2
2
|
// seats a cup on a saucer, steps a row or stops the music of a game of chairs, and the counters left without a
|
|
3
3
|
// partner take a ring.
|
|
4
|
-
import { ROWS, GOALS_MAX, idOf, roomOf, opening, linesOf, resize, step, lone, won, counts, same, wordsOf, tagKey, measuresOf, wordsLinked, readingOf, verdictOf } from './match-model.js';
|
|
4
|
+
import { ROWS, GOALS_MAX, idOf, roomOf, opening, linesOf, resize, step, lone, won, counts, same, wordsOf, tagKey, measuresOf, wordsLinked, readingOf, verdictOf, differenceOf } from './match-model.js';
|
|
5
|
+
import { writtenLine, words, reading } from '../../kit/written.js';
|
|
5
6
|
import { signTile, verdictMark, isTile, nextSign, signShown, signOf } from './reading.js';
|
|
6
7
|
import { counter, show, put, R, HIT } from './counter.js';
|
|
7
8
|
import { rowsOf, cupsOf, scoreOf, BALL, GAP, CLOSE, WIDE } from './match-figures.js';
|
|
8
9
|
import { MATCH_GOALS } from './match-goals.js';
|
|
9
|
-
import { another } from './goals.js';
|
|
10
10
|
import { carry, press } from './move.js';
|
|
11
11
|
import { driver } from './driver.js';
|
|
12
12
|
import { svg as el, svgPoint } from '../../kit/dom.js';
|
|
13
|
-
import { stepper, slider, chip, button, row as line } from '../../kit/panel.js';
|
|
13
|
+
import { stepper, slider, chip, button, row as line, check } from '../../kit/panel.js';
|
|
14
14
|
import { goalRow } from '../../kit/goal.js';
|
|
15
|
-
import { dice, fresh } from '../../kit/random.js';
|
|
15
|
+
import { dice, fresh, another } from '../../kit/random.js';
|
|
16
16
|
import { live } from '../../kit/text.js';
|
|
17
17
|
import { numbers } from '../../kit/format.js';
|
|
18
18
|
|
|
@@ -39,7 +39,9 @@ export default function match({ host, stage, panel, T, lang, moving, motion: fx
|
|
|
39
39
|
const tile = signTile(), told = verdictMark(), cards = ROWS.map((r, k) => el('rect', { class: `counters-line-card counters-${k ? 'b' : 'a'}`, x: (k ? 132 : 22) - 23, y: -25, width: 46, height: 50, rx: 8, display: 'none' })), nums = Object.fromEntries(ROWS.map((r, k) => [r, el('text', { class: `counters-line-num counters-${k ? 'b' : 'a'}`, 'data-ref': r, x: k ? 132 : 22 })]));
|
|
40
40
|
const signed = el('g', { display: 'none' }, [...cards, nums.top, el('g', { transform: 'translate(77 0)' }, [tile.el]), nums.bottom, el('g', { transform: 'translate(170 0)' }, [told.el])]);
|
|
41
41
|
press(tile.el, () => { if (!spec || !isTile(spec)) return; s.sign = nextSign(s.sign); if (cs) cs.checked = false; changed(); });
|
|
42
|
-
|
|
42
|
+
// The written line of the difference of the rows, which stands where the line of a sign page stands.
|
|
43
|
+
const written = writtenLine();
|
|
44
|
+
const svg = el('svg', { class: 'counters-svg' }, [back, voids, wires, rings, lower, upper, tags.top.g, tags.bottom.g, rubber, word, signed, written.el]);
|
|
43
45
|
stage.appendChild(svg);
|
|
44
46
|
// spec is the page. s holds the counters of each row, the lines the reader drew and how far the Spacing slider
|
|
45
47
|
// stands, from 0 to 1. geo holds the places of the figure, nodes the drawn object of each id, pick the counter a
|
|
@@ -57,7 +59,7 @@ export default function match({ host, stage, panel, T, lang, moving, motion: fx
|
|
|
57
59
|
|
|
58
60
|
const partner = id => { const k = rowOf(id) === 'top' ? 0 : 1, l = linesOf(spec, s).find(l => l[k] === at(id)); return l ? idOf(ROWS[1 - k], l[1 - k]) : null; };
|
|
59
61
|
const layout = () => scores() ? scoreOf(GOALS_MAX, [T('match-scoreboard-top'), T('match-scoreboard-bottom')]) : cups() ? cupsOf(roomOf(spec, 'top'), roomOf(spec, 'bottom'))
|
|
60
|
-
: rowsOf({ top: roomOf(spec, 'top'), bottom: roomOf(spec, 'bottom'), ...gaps(), tag: tagRoom(), names: spec.trail ? NAMES : 0, line: spec.sign ? SIGNED : undefined });
|
|
62
|
+
: rowsOf({ top: roomOf(spec, 'top'), bottom: roomOf(spec, 'bottom'), ...gaps(), tag: tagRoom(), names: spec.trail ? NAMES : 0, line: spec.sign || spec.written ? SIGNED : undefined });
|
|
61
63
|
// The Spacing slider sets the gap of its row up to twice the gap, and a challenge draws one row wide and one close.
|
|
62
64
|
function gaps() {
|
|
63
65
|
if (spec.spread) return { gap: { [spec.spread]: GAP * (1 + s.spread) }, widest: { [spec.spread]: 2 * GAP } };
|
|
@@ -96,6 +98,7 @@ export default function match({ host, stage, panel, T, lang, moving, motion: fx
|
|
|
96
98
|
back.replaceChildren(...drawn.nodes, ...names);
|
|
97
99
|
signed.setAttribute('display', geo.line && spec.sign ? 'inline' : 'none');
|
|
98
100
|
if (geo.line) signed.setAttribute('transform', `translate(${geo.line.x} ${geo.line.y})`);
|
|
101
|
+
if (geo.line && spec.written) written.at(geo.w / 2, geo.line.y); else written.set(null);
|
|
99
102
|
tile.open(isTile(spec), T('sign')); told.show(isTile(spec) && !cs);
|
|
100
103
|
for (const card of cards) card.setAttribute('display', spec.hidden ? 'inline' : 'none');
|
|
101
104
|
for (const n of nodes.values()) n.tween?.pause();
|
|
@@ -245,6 +248,7 @@ export default function match({ host, stage, panel, T, lang, moving, motion: fx
|
|
|
245
248
|
const p = to.get(idOf('top', t)), q = to.get(idOf('bottom', b));
|
|
246
249
|
return el('line', { class: 'counters-wire', 'data-ref': 'pairs', x1: p.x, y1: p.y, x2: q.x, y2: q.y });
|
|
247
250
|
})));
|
|
251
|
+
lightPairs();
|
|
248
252
|
const l = lone(spec, s), ids = l.ringed ? ROWS.flatMap(r => l[r].map(i => idOf(r, i))) : [];
|
|
249
253
|
rings.replaceChildren(...ids.map(id => {
|
|
250
254
|
const p = to.get(id), r = cups() ? (rowOf(id) === 'top' ? R + 9 : 1.5 * SAUCER + 6) : chairs() ? R + 8 : R + 3.5;
|
|
@@ -284,6 +288,11 @@ export default function match({ host, stage, panel, T, lang, moving, motion: fx
|
|
|
284
288
|
}
|
|
285
289
|
for (const [k, b] of goals.entries()) b.disabled = s[ROWS[k]] >= GOALS_MAX;
|
|
286
290
|
}
|
|
291
|
+
if (spec.written) {
|
|
292
|
+
// The greater row's number comes first, in its row's colour, and the counters left over are the answer.
|
|
293
|
+
const d = differenceOf(spec, s), cls = r => `counters-${r === 'top' ? 'a' : 'b'}`;
|
|
294
|
+
if (written.set({ ...d.line, refs: { a: d.greater, b: d.less, c: 'unpaired' }, cls: { a: cls(d.greater), b: cls(d.less) } }, int) && anim) go.flash(written.el);
|
|
295
|
+
}
|
|
287
296
|
// A challenge that writes the numbers of its rows once it is reached uses the tags for them.
|
|
288
297
|
const ws = ends() ? Object.fromEntries(ROWS.map(r => [r, null])) : spec.word === true ? wordsOf(spec, s) : null;
|
|
289
298
|
for (const r of ROWS) {
|
|
@@ -312,7 +321,8 @@ export default function match({ host, stage, panel, T, lang, moving, motion: fx
|
|
|
312
321
|
// tags.
|
|
313
322
|
function refresh() {
|
|
314
323
|
const st = counts(spec, s), ids = measuresOf(spec), ws = wordsLinked(spec).length ? wordsOf(spec, s) : null;
|
|
315
|
-
const said = { reading: () => T(readingOf(spec, s), { a: int(s.top), b: int(s.bottom) }),
|
|
324
|
+
const said = { reading: () => spec.written ? reading(differenceOf(spec, s).line, int, T) : T(readingOf(spec, s), { a: int(s.top), b: int(s.bottom) }),
|
|
325
|
+
written: () => words(differenceOf(spec, s).line, int), verdict: () => T(verdictOf(spec, s)) }, value = id => said[id]?.() ?? int(st[id]);
|
|
316
326
|
for (const k of chips) if (k.set(value(k.id)) && moving()) go.flash(k.el);
|
|
317
327
|
judge();
|
|
318
328
|
live(host, { value: id => ids.includes(id) ? value(id) : wordsLinked(spec).includes(id) ? T(tagKey(ws[id.split('-')[0]]), { n: int(ws[id.split('-')[0]].n ?? 0) }) : null });
|
|
@@ -342,20 +352,29 @@ export default function match({ host, stage, panel, T, lang, moving, motion: fx
|
|
|
342
352
|
goals = scores() ? ROWS.map(r => button({ label: T(`score-${r}`), act: `score-${r}`, press: () => { if (s[r] < GOALS_MAX) { s = resize(s, r, s[r] + 1); changed(); } } })) : [];
|
|
343
353
|
if (scores()) ctls.push(...goals, button({ label: T('new-match'), act: 'new-match', press: () => { s = { ...opening(spec), spread: 0 }; changed(); } }));
|
|
344
354
|
// The line of words takes a line of the panel to itself, so the panel keeps its height as the words change.
|
|
345
|
-
chips = spec.readout.map(id => chip({ id, label: T(`match-${spec.trail ? 'trail' : spec.look}-${id}`) ?? T(`match-${id}`), cls:
|
|
346
|
-
for (const k of chips) if (k.id
|
|
355
|
+
chips = spec.readout.map(id => chip({ id, label: T(`match-${spec.trail ? 'trail' : spec.look}-${id}`) ?? T(`match-${id}`) ?? T(id), cls: ['reading', 'written'].includes(id) ? 'counters-chip-wide' : '' }));
|
|
356
|
+
for (const k of chips) if (!['reading', 'written'].includes(k.id)) k.width(k.id === 'verdict' ? 5 : 2);
|
|
347
357
|
// A challenge has its line with Another one and a hint, and a Check button beside its controls.
|
|
348
358
|
goal = null;
|
|
349
359
|
if (cs) {
|
|
350
360
|
const name = base.challenge.goal;
|
|
351
361
|
goal = goalRow({ T, motion: moving() ? fx : null, hint: on => on ? T(`hint-${name}`) : null, another: () => { deal(); drawPanel(); build(); if (!geo) refresh(); } });
|
|
352
|
-
ctls.push(
|
|
362
|
+
ctls.push(check({ T, press: () => { if (!cs.checked) { cs.checked = true; render('move'); if (!geo) refresh(); } } }));
|
|
353
363
|
}
|
|
354
364
|
panel.replaceChildren(...[goal?.el, ctls.length ? line('ctls', ctls) : null, chips.length ? line('out', chips) : null].filter(Boolean));
|
|
355
365
|
}
|
|
356
366
|
|
|
367
|
+
// pairsLit says the reader points at the link pairs, which lights each pair line and the counters at its ends.
|
|
368
|
+
let pairsLit = false;
|
|
369
|
+
function lightPairs() {
|
|
370
|
+
const paired = new Set(linesOf(spec, s).flatMap(([t, b]) => [idOf('top', t), idOf('bottom', b)]));
|
|
371
|
+
for (const [id, n] of nodes) n.g.classList.toggle('counters-paired-lit', pairsLit && paired.has(id));
|
|
372
|
+
for (const w of wires.children) w.classList.toggle('counters-hot', pairsLit);
|
|
373
|
+
}
|
|
357
374
|
function point(id, on) {
|
|
358
375
|
if (!spec) return;
|
|
376
|
+
written.light(id, on, ['written', 'reading']);
|
|
377
|
+
if (id === 'pairs') { pairsLit = on; lightPairs(); }
|
|
359
378
|
for (const part of svg.querySelectorAll(`[data-ref="${id}"]`)) part.classList.toggle('counters-hot', on);
|
|
360
379
|
for (const part of panel.querySelectorAll('[data-ref]')) part.classList.toggle('hot', on && part.dataset.ref === id);
|
|
361
380
|
}
|
|
@@ -363,7 +382,7 @@ export default function match({ host, stage, panel, T, lang, moving, motion: fx
|
|
|
363
382
|
|
|
364
383
|
return {
|
|
365
384
|
show(page) {
|
|
366
|
-
stop(); base = page; target = null; deal();
|
|
385
|
+
stop(); pairsLit = false; base = page; target = null; deal();
|
|
367
386
|
drawPanel(); build();
|
|
368
387
|
if (!geo) refresh();
|
|
369
388
|
},
|
|
@@ -372,6 +391,7 @@ export default function match({ host, stage, panel, T, lang, moving, motion: fx
|
|
|
372
391
|
for (const g of [back, voids, wires, rings, lower, upper]) g.replaceChildren();
|
|
373
392
|
for (const g of [word, tags.top.g, tags.bottom.g, signed]) g.setAttribute('display', 'none');
|
|
374
393
|
for (const r of ROWS) nums[r].textContent = '';
|
|
394
|
+
written.set(null);
|
|
375
395
|
},
|
|
376
396
|
point,
|
|
377
397
|
lang() { if (!spec) return; const was = goal; drawPanel(); goal?.keep(was); build(); if (!geo) refresh(); },
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// The Node half of the match scene: two rows of objects paired one to one. It checks a page's fields and says what
|
|
2
2
|
// each link shows when the page opens.
|
|
3
3
|
import { schema } from '@openbooknetwork/kitap';
|
|
4
|
-
import { MATCH_LOOKS, ROWS, ROW_MAX, SPREAD_MAX, PLAYERS, GOALS_MAX, roomOf, opening, counts, wordsOf, tagKey, measuresOf, wordsLinked, readingOf, verdictOf } from './match-model.js';
|
|
4
|
+
import { MATCH_LOOKS, ROWS, ROW_MAX, SPREAD_MAX, PLAYERS, GOALS_MAX, roomOf, opening, counts, wordsOf, tagKey, measuresOf, wordsLinked, readingOf, verdictOf, differenceOf } from './match-model.js';
|
|
5
|
+
import { words, reading } from '../../kit/written.js';
|
|
5
6
|
import { SIGN_FIELD } from './reading.js';
|
|
6
7
|
import { MATCH_GOALS, matchStart } from './match-goals.js';
|
|
7
8
|
import { numbers } from '../../kit/format.js';
|
|
@@ -26,6 +27,8 @@ const Fields = z.object({
|
|
|
26
27
|
trail: z.boolean().default(false), // The bottom row holds the top row as it was one step ago.
|
|
27
28
|
// A line of the two numbers with a sign between them: a tile that opens on this sign, or a sign that follows.
|
|
28
29
|
sign: z.enum(SIGN_FIELD).optional(),
|
|
30
|
+
// The written line of the difference of the rows under them, such as 11 − 7 = 4.
|
|
31
|
+
written: z.literal('difference').optional(),
|
|
29
32
|
// A challenge names a goal of match-goals.js and the ranges it draws its rows from.
|
|
30
33
|
challenge: z.object({ goal: z.string(), top: Range.optional(), bottom: Range.optional(), rows: Range.optional(), apart: Range.optional() }).strict().optional(),
|
|
31
34
|
readout: z.array(z.string()).default([]),
|
|
@@ -43,6 +46,7 @@ function read(fields, { at }, ctx) {
|
|
|
43
46
|
else if (lo < 0 || hi > ROW_MAX) fail(`${name} reaches ${v.ctl ? `[${lo}, ${hi}]` : v.n}, a row holds from 0 to ${ROW_MAX} objects`);
|
|
44
47
|
}
|
|
45
48
|
if (pg.sign && !['rows', 'scoreboard'].includes(pg.look)) fail('sign stands between the numbers of two rows or two scores, write look: rows or look: scoreboard');
|
|
49
|
+
if (pg.written && (pg.look !== 'rows' || pg.sign || pg.trail)) fail('written writes the difference of two rows of counters, write look: rows and leave sign and trail out');
|
|
46
50
|
if (pg.look === 'scoreboard') {
|
|
47
51
|
for (const f of ['pair', 'word', 'tap', 'trace', 'trail', 'spread']) if (pg[f]) fail(`${f} belongs to look: rows, the buttons add the goals of the scoreboard`);
|
|
48
52
|
if (top.ctl || bottom.ctl || [top.n, bottom.n].some(n => n > GOALS_MAX)) fail(`top and bottom are the scores of the home team and the away team, write each as a number from 0 to ${GOALS_MAX}`);
|
|
@@ -88,6 +92,8 @@ function start(spec, lang, id) {
|
|
|
88
92
|
if (wordsLinked(spec).includes(id)) { const w = wordsOf(spec, s)[id.split('-')[0]]; return string(lang, `counters_${tagKey(w)}`, { n: numbers(lang).int(w.n) }); }
|
|
89
93
|
if (!measuresOf(spec).includes(id)) return null;
|
|
90
94
|
const int = numbers(lang).int;
|
|
95
|
+
if (id === 'written') return words(differenceOf(spec, s).line, int);
|
|
96
|
+
if (id === 'reading' && spec.written) return reading(differenceOf(spec, s).line, int, (key, vars) => string(lang, `hesap_${key}`, vars));
|
|
91
97
|
if (id === 'reading') return string(lang, `counters_${readingOf(spec, s)}`, { a: int(s.top), b: int(s.bottom) });
|
|
92
98
|
if (id === 'verdict') return string(lang, `counters_${verdictOf(spec, s)}`);
|
|
93
99
|
return int(counts(spec, s)[id]);
|