@terrafirmagreg-team/recipe 1.2.41 → 1.2.43

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.
Files changed (47) hide show
  1. package/package.json +4 -4
  2. package/src/components/cards/calc-add-item.tsx +55 -0
  3. package/src/components/cards/card/index.tsx +2 -0
  4. package/src/components/cards/card/text.tsx +20 -4
  5. package/src/components/views/browser/card-grid.tsx +11 -23
  6. package/src/components/views/browser/frame.tsx +8 -33
  7. package/src/components/views/browser/item-view/index.tsx +8 -10
  8. package/src/components/views/browser/settings.tsx +6 -0
  9. package/src/components/views/browser/type-tabs.tsx +5 -0
  10. package/src/components/views/browser/type-view.tsx +9 -47
  11. package/src/components/views/calc/calculator/index.tsx +4 -0
  12. package/src/components/views/calc/flow/index.tsx +42 -1
  13. package/src/components/views/calc/flow/picker-dialogs.tsx +15 -8
  14. package/src/components/views/calc/flow/toolbar.tsx +2 -0
  15. package/src/components/views/calc/flow/view-menu.tsx +13 -0
  16. package/src/components/views/calc/member-picker.tsx +7 -2
  17. package/src/components/views/calc/node-card/actions.tsx +1 -1
  18. package/src/components/views/calc/node-card/badges.tsx +1 -1
  19. package/src/components/views/calc/node-card/far.tsx +1 -1
  20. package/src/components/views/calc/node-card/full.tsx +34 -5
  21. package/src/components/views/calc/node-card/menu.tsx +32 -0
  22. package/src/components/views/calc/recipe-picker/body.tsx +10 -36
  23. package/src/hooks/calc/flow/use-layout.ts +1 -1
  24. package/src/hooks/calc/flow/use-pickers.ts +14 -10
  25. package/src/hooks/calc/use-actions.ts +54 -31
  26. package/src/hooks/calc/use-recipe-ids.ts +33 -0
  27. package/src/hooks/use-card-grid.ts +14 -0
  28. package/src/lib/alloy/parse.ts +6 -3
  29. package/src/lib/browser/card-dim.test.ts +39 -0
  30. package/src/lib/browser/card-dim.ts +38 -0
  31. package/src/lib/browser/lookup.ts +3 -2
  32. package/src/lib/browser/row-match.test.ts +34 -0
  33. package/src/lib/browser/row-match.ts +8 -0
  34. package/src/lib/calc/flow.ts +3 -1
  35. package/src/lib/calc/member.test.ts +178 -0
  36. package/src/lib/calc/member.ts +90 -0
  37. package/src/lib/calc/scheme.test.ts +213 -0
  38. package/src/lib/calc/scheme.ts +8 -3
  39. package/src/lib/calc/tree/index.ts +5 -1
  40. package/src/lib/calc/tree/recipe.test.ts +88 -0
  41. package/src/lib/calc/tree/recipe.ts +19 -3
  42. package/src/lib/calc/wire.test.ts +70 -0
  43. package/src/lib/calc/wire.ts +6 -2
  44. package/src/lib/cards/model.test.ts +61 -1
  45. package/src/lib/cards/model.ts +9 -2
  46. package/src/types/calc-flow-props.ts +2 -0
  47. package/styles/calc.css +4 -0
@@ -0,0 +1,213 @@
1
+ import assert from 'node:assert/strict';
2
+ import { test } from 'node:test';
3
+ import { buildScheme, type SchemeContext } from './scheme';
4
+ import { memberTarget } from './member';
5
+ import type { CalcCard, CalcRecipe } from '@terrafirmagreg-team/recipe/types/calc';
6
+
7
+ const RODS = [
8
+ 'gtceu:amethyst_rod',
9
+ 'gtceu:opal_rod',
10
+ 'gtceu:ruby_rod',
11
+ ];
12
+ const TAG = 'tfg:precision_fabricator_holder_rods';
13
+
14
+ const RECIPE: CalcRecipe = {
15
+ recipeId: 'gtceu:high_temperature_precision_fabricator/x',
16
+ category: 'gtceu:high_temperature_precision_fabricator',
17
+ inputs: [
18
+ { id: 'tfg:ingot', kind: 'item', amount: 1, catalyst: false },
19
+ {
20
+ id: TAG,
21
+ kind: 'item',
22
+ amount: 1,
23
+ catalyst: false,
24
+ tagId: TAG,
25
+ },
26
+ ],
27
+ outputs: [{ id: 'tfg:tipped_ingot', kind: 'item', amount: 1 }],
28
+ };
29
+
30
+ const CARD: CalcCard = {
31
+ id: 'c1',
32
+ materialId: 'tfg:tipped_ingot',
33
+ kind: 'item',
34
+ recipeId: RECIPE.recipeId,
35
+ crafts: 1,
36
+ };
37
+
38
+ function ctx(tagSelections: Record<string, string>): SchemeContext {
39
+ return {
40
+ recipeMap: new Map([[RECIPE.recipeId, RECIPE]]),
41
+ getRecipesForItem: () => [],
42
+ tagMembers: (tagId) =>
43
+ tagId === TAG || tagId === `#${TAG}`
44
+ ? { members: RODS, kind: 'item' }
45
+ : undefined,
46
+ tagSelections,
47
+ recipesResolved: () => true,
48
+ deadIds: new Set(),
49
+ };
50
+ }
51
+
52
+ function tagInput(tagSelections: Record<string, string>) {
53
+ const { nodes } = buildScheme({ cards: [CARD], wires: [], ctx: ctx(tagSelections) });
54
+ const node = nodes[0];
55
+ return node?.inputs[1];
56
+ }
57
+
58
+ test('tag input resolves to first member and keeps members for picking', () => {
59
+ const input = tagInput({});
60
+ assert.equal(input?.id, 'gtceu:amethyst_rod');
61
+ assert.equal(input?.tagId, TAG);
62
+ assert.deepEqual(input?.members, RODS);
63
+ });
64
+
65
+ test('tag input honors member selection for its tagId', () => {
66
+ const input = tagInput({ [TAG]: 'gtceu:ruby_rod' });
67
+ assert.equal(input?.id, 'gtceu:ruby_rod');
68
+ });
69
+
70
+ test('tag input honors selection written under the #-prefixed card tagId', () => {
71
+ const input = tagInput({ [`#${TAG}`]: 'gtceu:opal_rod' });
72
+ assert.equal(input?.id, 'gtceu:opal_rod');
73
+ });
74
+
75
+ test('stale selection not in members falls back to first member', () => {
76
+ const input = tagInput({ [TAG]: 'gtceu:removed_rod' });
77
+ assert.equal(input?.id, 'gtceu:amethyst_rod');
78
+ });
79
+
80
+ const NBT_RODS = [
81
+ 'gtceu:amethyst_rod{Damage:0}',
82
+ 'gtceu:opal_rod{Damage:0}',
83
+ 'gtceu:ruby_rod{Damage:0}',
84
+ ];
85
+
86
+ function nbtCtx(tagSelections: Record<string, string>): SchemeContext {
87
+ return {
88
+ ...ctx(tagSelections),
89
+ tagMembers: (tagId) =>
90
+ tagId === TAG || tagId === `#${TAG}`
91
+ ? { members: NBT_RODS, kind: 'item' }
92
+ : undefined,
93
+ };
94
+ }
95
+
96
+ function nbtTagInput(tagSelections: Record<string, string>) {
97
+ const { nodes } = buildScheme({
98
+ cards: [CARD],
99
+ wires: [],
100
+ ctx: nbtCtx(tagSelections),
101
+ });
102
+ return nodes[0]?.inputs[1];
103
+ }
104
+
105
+ test('tag input resolves a base-id selection against NBT members', () => {
106
+ const input = nbtTagInput({ [TAG]: 'gtceu:ruby_rod' });
107
+ assert.equal(input?.id, 'gtceu:ruby_rod');
108
+ });
109
+
110
+ test('tag input normalizes an NBT selection to its base id', () => {
111
+ const input = nbtTagInput({ [TAG]: 'gtceu:opal_rod{Damage:0}' });
112
+ assert.equal(input?.id, 'gtceu:opal_rod');
113
+ });
114
+
115
+ test('memberTarget marks the picked member on a tag card', () => {
116
+ const { nodes } = buildScheme({
117
+ cards: [{ ...CARD, id: 't1', materialId: `#${TAG}`, recipeId: null }],
118
+ wires: [],
119
+ ctx: ctx({}),
120
+ });
121
+ const target = memberTarget(
122
+ { node: nodes[0]! },
123
+ { [`#${TAG}`]: 'gtceu:ruby_rod' },
124
+ );
125
+ assert.equal(target?.selected, 'gtceu:ruby_rod');
126
+ });
127
+
128
+ test('memberTarget resolves node-level tag cards', () => {
129
+ const { nodes } = buildScheme({
130
+ cards: [{ ...CARD, id: 't1', materialId: `#${TAG}`, recipeId: null }],
131
+ wires: [],
132
+ ctx: ctx({}),
133
+ });
134
+ const target = memberTarget({ node: nodes[0]! });
135
+ assert.equal(target?.tagId, `#${TAG}`);
136
+ assert.deepEqual(target?.members, RODS);
137
+ assert.equal(target?.selected, `#${TAG}`);
138
+ assert.equal(target?.kind, 'item');
139
+ });
140
+
141
+ test('memberTarget resolves a tag input on a recipe node', () => {
142
+ const { nodes } = buildScheme({ cards: [CARD], wires: [], ctx: ctx({}) });
143
+ const target = memberTarget({ node: nodes[0]!, input: 1 });
144
+ assert.equal(target?.tagId, TAG);
145
+ assert.deepEqual(target?.members, RODS);
146
+ assert.equal(target?.selected, 'gtceu:amethyst_rod');
147
+ assert.equal(target?.kind, 'item');
148
+ });
149
+
150
+ test('memberTarget is empty for plain inputs and missing slots', () => {
151
+ const { nodes } = buildScheme({ cards: [CARD], wires: [], ctx: ctx({}) });
152
+ assert.equal(memberTarget({ node: nodes[0]!, input: 0 }), undefined);
153
+ assert.equal(memberTarget({ node: nodes[0]!, input: 9 }), undefined);
154
+ });
155
+
156
+ const FLUID_RECIPE: CalcRecipe = {
157
+ recipeId: 'gtceu:distiller/distill_oil',
158
+ category: 'gtceu:distiller',
159
+ inputs: [{ id: 'gtceu:oil', kind: 'fluid', amount: 100, catalyst: false }],
160
+ outputs: [{ id: 'gtceu:sulfuric_gas', kind: 'fluid', amount: 50 }],
161
+ };
162
+
163
+ const CONSUME_RECIPE: CalcRecipe = {
164
+ recipeId: 'gtceu:mixer/mix_gas',
165
+ category: 'gtceu:mixer',
166
+ inputs: [
167
+ { id: 'gtceu:sulfuric_gas', kind: 'fluid', amount: 50, catalyst: false },
168
+ ],
169
+ outputs: [{ id: 'gtceu:mixed_gas', kind: 'fluid', amount: 60 }],
170
+ };
171
+
172
+ function fluidCtx(recipes: CalcRecipe[]): SchemeContext {
173
+ return {
174
+ recipeMap: new Map(recipes.map((r) => [r.recipeId, r])),
175
+ getRecipesForItem: () => [],
176
+ tagMembers: () => undefined,
177
+ tagSelections: {},
178
+ recipesResolved: () => true,
179
+ deadIds: new Set(),
180
+ };
181
+ }
182
+
183
+ test('fluid-only recipe produces its fluid output and feeds a consumer', () => {
184
+ const { nodes, flows } = buildScheme({
185
+ cards: [
186
+ {
187
+ id: 'src',
188
+ materialId: 'gtceu:sulfuric_gas',
189
+ kind: 'fluid',
190
+ recipeId: FLUID_RECIPE.recipeId,
191
+ crafts: 2,
192
+ },
193
+ {
194
+ id: 'dst',
195
+ materialId: 'gtceu:mixed_gas',
196
+ kind: 'fluid',
197
+ recipeId: CONSUME_RECIPE.recipeId,
198
+ crafts: 1,
199
+ },
200
+ ],
201
+ wires: [{ from: 'src', to: 'dst', input: 0 }],
202
+ ctx: fluidCtx([FLUID_RECIPE, CONSUME_RECIPE]),
203
+ });
204
+ const [src, dst] = nodes;
205
+ assert.equal(src?.produced, 100);
206
+ assert.equal(src?.outputs[0]?.id, 'gtceu:sulfuric_gas');
207
+ assert.equal(src?.outputs[0]?.kind, 'fluid');
208
+ assert.equal(src?.inputs[0]?.id, 'gtceu:oil');
209
+ assert.equal(src?.inputs[0]?.amount, 200);
210
+ assert.equal(dst?.inputs[0]?.covered, 50);
211
+ assert.deepEqual(flows, [50]);
212
+ assert.equal(src?.remaining, 50);
213
+ });
@@ -10,6 +10,7 @@ import type {
10
10
  CalcWire,
11
11
  TagResolution,
12
12
  } from '@terrafirmagreg-team/recipe/types/calc';
13
+ import { stackIdBase } from '@terrafirmagreg-team/dump/lib/dump/contract/ref';
13
14
  import { mergeAmounts } from './tree/materials';
14
15
  import { resolveWireEnds } from './wire';
15
16
 
@@ -37,13 +38,17 @@ function inputMember(
37
38
  ctx: SchemeContext,
38
39
  ): { id?: string; kind: CalcKind; members?: string[] } {
39
40
  if (!input.tagId) return { id: input.id, kind: input.kind };
40
- const picked = ctx.tagSelections[input.tagId];
41
+ const key = input.tagId.replace(/^#+/, '');
42
+ const picked = ctx.tagSelections[key] ?? ctx.tagSelections[`#${key}`];
41
43
  const resolution = ctx.tagMembers(input.tagId);
42
44
  const members = resolution?.members ?? [];
45
+ const pickedBase = picked ? stackIdBase(picked) : undefined;
43
46
  const memberId =
44
- picked && members.includes(picked) ? picked : members[0];
47
+ (pickedBase
48
+ ? members.find((m) => stackIdBase(m) === pickedBase)
49
+ : undefined) ?? members[0];
45
50
  return {
46
- id: memberId,
51
+ id: memberId ? stackIdBase(memberId) : undefined,
47
52
  kind: resolution?.kind ?? input.kind,
48
53
  members: members.length ? members : undefined,
49
54
  };
@@ -1,4 +1,8 @@
1
1
  export { mergeAmounts } from './materials';
2
- export { recipeDivisor, toCalcRecipe } from './recipe';
2
+ export {
3
+ recipeDivisor,
4
+ resolveRecipeAmount,
5
+ toCalcRecipe,
6
+ } from './recipe';
3
7
  export { decodeCalcState, encodeCalcState } from './share';
4
8
 
@@ -0,0 +1,88 @@
1
+ import assert from 'node:assert/strict';
2
+ import { test } from 'node:test';
3
+ import { resolveRecipeAmount } from './recipe';
4
+ import type { Recipe } from '@terrafirmagreg-team/recipe/lib/data/dto';
5
+
6
+ const FLUID_BODY = {
7
+ id: 'gtceu:distillery/distill_oil',
8
+ type: 'gtceu:distillery',
9
+ category: 'gtceu:distillery',
10
+ modId: 'gtceu',
11
+ slots: {},
12
+ properties: {},
13
+ inputs: [
14
+ { kind: 'fluid', id: 'gtceu:oil', count: 100 },
15
+ ],
16
+ outputs: [
17
+ { kind: 'fluid', id: 'gtceu:sulfuric_gas', count: 1000 },
18
+ { kind: 'item', id: 'gtceu:sulfur_dust', count: 1 },
19
+ ],
20
+ widgets: [],
21
+ bodyUrl: '',
22
+ extra: {},
23
+ } as Recipe;
24
+
25
+ test('fluid output amount comes from the loaded body, not the hint', async () => {
26
+ const amount = await resolveRecipeAmount(
27
+ 'gtceu:distillery/distill_oil',
28
+ 'gtceu:sulfuric_gas',
29
+ 'fluid',
30
+ async () => FLUID_BODY,
31
+ 1,
32
+ );
33
+ assert.equal(amount, 1000);
34
+ });
35
+
36
+ test('item output in a mixed recipe resolves by kind', async () => {
37
+ const amount = await resolveRecipeAmount(
38
+ 'gtceu:distillery/distill_oil',
39
+ 'gtceu:sulfur_dust',
40
+ 'item',
41
+ async () => FLUID_BODY,
42
+ 1,
43
+ );
44
+ assert.equal(amount, 1);
45
+ });
46
+
47
+ test('missing body falls back to the hint', async () => {
48
+ const amount = await resolveRecipeAmount(
49
+ 'gtceu:gone',
50
+ 'gtceu:sulfuric_gas',
51
+ 'fluid',
52
+ async () => undefined,
53
+ 1,
54
+ );
55
+ assert.equal(amount, 1);
56
+ });
57
+
58
+ test('body without the material falls back to the hint', async () => {
59
+ const amount = await resolveRecipeAmount(
60
+ 'gtceu:distillery/distill_oil',
61
+ 'minecraft:diamond',
62
+ 'item',
63
+ async () => FLUID_BODY,
64
+ 1,
65
+ );
66
+ assert.equal(amount, 1);
67
+ });
68
+
69
+ test('NBT-carrying output matches the base material id', async () => {
70
+ const body = {
71
+ ...FLUID_BODY,
72
+ outputs: [
73
+ {
74
+ kind: 'item',
75
+ id: 'gtceu:duranium_hammer{"Damage":0,"GT.Tool":{}}',
76
+ count: 1,
77
+ },
78
+ ],
79
+ } as Recipe;
80
+ const amount = await resolveRecipeAmount(
81
+ 'gtceu:shaped/hammer_duranium',
82
+ 'gtceu:duranium_hammer',
83
+ 'item',
84
+ async () => body,
85
+ 1,
86
+ );
87
+ assert.equal(amount, 1);
88
+ });
@@ -1,4 +1,5 @@
1
1
  import type { Recipe, RecipeIngredient } from '@terrafirmagreg-team/recipe/lib/data/dto';
2
+ import { stackIdBase } from '@terrafirmagreg-team/dump/lib/dump/contract/ref';
2
3
  import type {
3
4
  CalcKind,
4
5
  CalcMaterial,
@@ -46,7 +47,7 @@ function recipeTier(recipe: Recipe): number | undefined {
46
47
 
47
48
  export function toCalcRecipe(recipe: Recipe): CalcRecipe {
48
49
  const inputs: CalcRecipeInput[] = recipe.inputs.map((slot) => ({
49
- id: slot.id,
50
+ id: slot.kind === 'tag' ? slot.id : stackIdBase(slot.id),
50
51
  kind: slotKind(slot),
51
52
  amount: slot.count && slot.count > 0 ? slot.count : 1,
52
53
  catalyst: false,
@@ -56,7 +57,7 @@ export function toCalcRecipe(recipe: Recipe): CalcRecipe {
56
57
  for (const widget of recipe.widgets) {
57
58
  if (widget.type !== 'slot' || widget.role !== 'catalyst') continue;
58
59
  inputs.push({
59
- id: widget.id,
60
+ id: widget.kind === 'tag' ? widget.id : stackIdBase(widget.id),
60
61
  kind: widget.kind === 'fluid' ? 'fluid' : 'item',
61
62
  amount: 1,
62
63
  catalyst: true,
@@ -76,7 +77,7 @@ export function toCalcRecipe(recipe: Recipe): CalcRecipe {
76
77
  else merged.push({ ...input });
77
78
  }
78
79
  const outputs: CalcMaterial[] = recipe.outputs.map((slot) => ({
79
- id: slot.id,
80
+ id: slot.kind === 'tag' ? slot.id : stackIdBase(slot.id),
80
81
  kind: slotKind(slot),
81
82
  amount: slot.count && slot.count > 0 ? slot.count : 1,
82
83
  ...(slot.chance !== undefined ? { chance: slot.chance } : {}),
@@ -103,3 +104,18 @@ export function recipeDivisor(
103
104
  return amount > 0 ? amount : 1;
104
105
  }
105
106
 
107
+ export async function resolveRecipeAmount(
108
+ recipeId: string,
109
+ materialId: string,
110
+ kind: CalcKind,
111
+ load: (id: string) => Promise<Recipe | undefined>,
112
+ fallback = 1,
113
+ ): Promise<number> {
114
+ const body = await load(recipeId);
115
+ if (!body) return fallback;
116
+ const amount = toCalcRecipe(body)
117
+ .outputs.filter((out) => out.id === materialId && out.kind === kind)
118
+ .reduce((sum, out) => sum + out.amount * (out.chance ?? 1), 0);
119
+ return amount > 0 ? amount : fallback;
120
+ }
121
+
@@ -0,0 +1,70 @@
1
+ import assert from 'node:assert/strict';
2
+ import { test } from 'node:test';
3
+ import { wireEndMatches } from './wire';
4
+ import type { CalcNodeInput } from '@terrafirmagreg-team/recipe/types/calc';
5
+
6
+ const NBT = '{"Damage":0,"GT.Tool":{}}';
7
+
8
+ test('NBT input id matches a base output id', () => {
9
+ const input = {
10
+ id: `gtceu:duranium_hammer${NBT}`,
11
+ kind: 'item',
12
+ amount: 1,
13
+ catalyst: false,
14
+ } as CalcNodeInput;
15
+ assert.equal(
16
+ wireEndMatches(input, {
17
+ id: 'gtceu:duranium_hammer',
18
+ kind: 'item',
19
+ amount: 1,
20
+ }),
21
+ true,
22
+ );
23
+ });
24
+
25
+ test('tag members carrying NBT match a base output id', () => {
26
+ const input = {
27
+ id: 'gtceu:copper_hammer',
28
+ kind: 'item',
29
+ amount: 1,
30
+ catalyst: false,
31
+ tagId: '#forge:tools/hammers',
32
+ members: [
33
+ `gtceu:copper_hammer${NBT}`,
34
+ `gtceu:duranium_hammer${NBT}`,
35
+ ],
36
+ } as CalcNodeInput;
37
+ assert.equal(
38
+ wireEndMatches(input, {
39
+ id: 'gtceu:duranium_hammer',
40
+ kind: 'item',
41
+ amount: 1,
42
+ }),
43
+ true,
44
+ );
45
+ });
46
+
47
+ test('kind mismatch and unrelated ids still fail', () => {
48
+ const input = {
49
+ id: 'gtceu:duranium_hammer',
50
+ kind: 'item',
51
+ amount: 1,
52
+ catalyst: false,
53
+ } as CalcNodeInput;
54
+ assert.equal(
55
+ wireEndMatches(input, {
56
+ id: 'gtceu:duranium_hammer',
57
+ kind: 'fluid',
58
+ amount: 1,
59
+ }),
60
+ false,
61
+ );
62
+ assert.equal(
63
+ wireEndMatches(input, {
64
+ id: 'gtceu:copper_hammer',
65
+ kind: 'item',
66
+ amount: 1,
67
+ }),
68
+ false,
69
+ );
70
+ });
@@ -1,3 +1,4 @@
1
+ import { stackIdBase } from '@terrafirmagreg-team/dump/lib/dump/contract/ref';
1
2
  import type {
2
3
  CalcMaterial,
3
4
  CalcNode,
@@ -10,8 +11,11 @@ export function wireEndMatches(
10
11
  out: CalcMaterial,
11
12
  ): boolean {
12
13
  if (input.kind !== out.kind || !out.id) return false;
13
- if (input.id === out.id) return true;
14
- return !!input.tagId && !!input.members?.includes(out.id);
14
+ if (input.id && stackIdBase(input.id) === stackIdBase(out.id)) return true;
15
+ return (
16
+ !!input.tagId &&
17
+ !!input.members?.some((m) => stackIdBase(m) === stackIdBase(out.id))
18
+ );
15
19
  }
16
20
 
17
21
  export function resolveWireEnds(
@@ -1,6 +1,36 @@
1
1
  import assert from 'node:assert/strict';
2
2
  import { test } from 'node:test';
3
- import { widgetTextColor } from '@terrafirmagreg-team/recipe/lib/cards/model';
3
+ import {
4
+ countCoveredText,
5
+ slotCoveredLabel,
6
+ widgetTextColor,
7
+ } from '@terrafirmagreg-team/recipe/lib/cards/model';
8
+ import type {
9
+ RecipeSlotWidget,
10
+ RecipeTextWidget,
11
+ } from '@terrafirmagreg-team/recipe/lib/data/dto';
12
+
13
+ const slot = (over: Partial<RecipeSlotWidget>): RecipeSlotWidget => ({
14
+ type: 'slot',
15
+ x: 49,
16
+ y: 133,
17
+ w: 16,
18
+ h: 16,
19
+ role: 'renderOnly',
20
+ kind: 'item',
21
+ id: 'gtceu:bronze_block',
22
+ ...over,
23
+ });
24
+
25
+ const textWidget = (over: Partial<RecipeTextWidget>): RecipeTextWidget => ({
26
+ type: 'text',
27
+ x: 54,
28
+ y: 142,
29
+ w: 12,
30
+ h: 9,
31
+ text: '',
32
+ ...over,
33
+ });
4
34
 
5
35
  test('widgetTextColor defaults uncolored shadowed text to white', () => {
6
36
  assert.equal(widgetTextColor(undefined, true), 0xffffff);
@@ -19,3 +49,33 @@ test('widgetTextColor keeps explicit colors', () => {
19
49
  test('widgetTextColor masks color to 24 bits', () => {
20
50
  assert.equal(widgetTextColor(0x1ff0000, true), 0xff0000);
21
51
  });
52
+
53
+ test('countCoveredText suppresses a count text overlapping its slot', () => {
54
+ const slots = [slot({ count: 24 })];
55
+ assert.equal(countCoveredText(textWidget({ text: '24' }), slots), true);
56
+ assert.equal(countCoveredText(textWidget({ text: 'x2' }), slots), false);
57
+ });
58
+
59
+ test('countCoveredText suppresses a component-carried count', () => {
60
+ const slots = [slot({ count: 24 })];
61
+ const widget = textWidget({ component: { text: '24' } });
62
+ assert.equal(countCoveredText(widget, slots), true);
63
+ });
64
+
65
+ test('countCoveredText ignores component text that is not a count', () => {
66
+ const slots = [slot({ count: 24 })];
67
+ const widget = textWidget({ component: { text: 'Bronze Tank' } });
68
+ assert.equal(countCoveredText(widget, slots), false);
69
+ });
70
+
71
+ test('countCoveredText requires overlap with the counted slot', () => {
72
+ const slots = [slot({ count: 24 })];
73
+ const widget = textWidget({ x: 200, component: { text: '24' } });
74
+ assert.equal(countCoveredText(widget, slots), false);
75
+ });
76
+
77
+ test('slotCoveredLabel anchors a component-carried NC label', () => {
78
+ const target = slot({});
79
+ const widget = textWidget({ x: 50, component: { text: 'NC' } });
80
+ assert.equal(slotCoveredLabel(widget, [target]), target);
81
+ });
@@ -1,3 +1,4 @@
1
+ import { dumpTextString } from '@terrafirmagreg-team/dump/lib/dump/assets/lang/names';
1
2
  import type {
2
3
  RecipeSlotWidget,
3
4
  RecipeTextWidget,
@@ -47,6 +48,12 @@ export function cardStripGeo(
47
48
 
48
49
  const COUNT_TEXT = /^x?(\d[\d\s.,]*)?\s*(mB|k|B|L|M)?$/i;
49
50
 
51
+ export function widgetText(widget: RecipeTextWidget): string {
52
+ return widget.component
53
+ ? dumpTextString({}, widget.component) || widget.text
54
+ : widget.text;
55
+ }
56
+
50
57
  export function slotOverlay(
51
58
  widget: RecipeTextWidget,
52
59
  slots: RecipeSlotWidget[],
@@ -60,7 +67,7 @@ export function countCoveredText(
60
67
  widget: RecipeTextWidget,
61
68
  slots: RecipeSlotWidget[],
62
69
  ): boolean {
63
- const match = widget.text
70
+ const match = widgetText(widget)
64
71
  .replace(/§./g, '')
65
72
  .trim()
66
73
  .match(COUNT_TEXT);
@@ -105,7 +112,7 @@ export function slotCoveredLabel(
105
112
  widget: RecipeTextWidget,
106
113
  slots: RecipeSlotWidget[],
107
114
  ): RecipeSlotWidget | undefined {
108
- if (widget.text.replace(/§./g, '').trim() !== 'NC') return undefined;
115
+ if (widgetText(widget).replace(/§./g, '').trim() !== 'NC') return undefined;
109
116
  return slotOverlay(widget, slots);
110
117
  }
111
118
 
@@ -32,6 +32,8 @@ export type CalcFlowProps = {
32
32
  onModeChange: (mode: CalcViewMode) => void;
33
33
  farCards: CalcFarMode;
34
34
  onFarCardsChange: (mode: CalcFarMode) => void;
35
+ recipeIds: boolean;
36
+ onRecipeIdsChange: (show: boolean) => void;
35
37
  treeReady?: boolean;
36
38
  resetGen?: number;
37
39
  canvasId?: string;
package/styles/calc.css CHANGED
@@ -71,6 +71,10 @@
71
71
  transform: none;
72
72
  }
73
73
 
74
+ .calc-rail .calc-port::before {
75
+ inset: 0;
76
+ }
77
+
74
78
  .calc-port--ghost {
75
79
  opacity: 0;
76
80
  pointer-events: none;