Skip to content

Commit e5dfb5f

Browse files
authored
Include combustion products in recipe graph analysis (#2553)
Closes #2525. Also adds the `ignite` capability to the `lens` entity, to make it possible to combust things in classic mode.
1 parent e237038 commit e5dfb5f

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

data/entities.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,8 +546,12 @@
546546
attr: entity
547547
char: 'O'
548548
description:
549-
- A polished, rounded piece of glass, capable of focusing rays of light.
549+
- |
550+
A polished, rounded piece of glass, capable of focusing rays of light.
551+
- |
552+
Focusing the sun's rays can set things on fire via `ignite : Dir -> Cmd Unit`.
550553
properties: [pickable]
554+
capabilities: [ignite]
551555
- name: LaTeX
552556
display:
553557
attr: flower

src/swarm-scenario/Swarm/Game/Recipe/Graph.hs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,19 @@ recipeLevels emap recipeList start = levs
127127
levs = reverse $ go [start] start
128128
where
129129
isKnown known (i, _o) = null $ i Set.\\ known
130+
130131
lookupYield e = case view entityYields e of
131132
Nothing -> e
132133
Just yn -> fromMaybe e (E.lookupEntityName yn emap)
133134
yielded = Set.map lookupYield
134-
nextLevel known = Set.unions $ yielded known : map snd (filter (isKnown known) m)
135+
136+
lookupCombust e = case view E.entityCombustion e of
137+
Just (E.Combustibility _ _ _ (Just productName)) ->
138+
fromMaybe e (E.lookupEntityName productName emap)
139+
_ -> e
140+
combusted = Set.map lookupCombust
141+
142+
nextLevel known = Set.unions $ yielded known : combusted known : map snd (filter (isKnown known) m)
135143
go ls known =
136144
let n = nextLevel known Set.\\ known
137145
in if null n

test/integration/TestRecipeCoverage.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ nonCoveredList :: [EntityName]
5252
nonCoveredList =
5353
map
5454
T.toCaseFold
55-
[ "ash"
56-
, "blueprint"
55+
[ "blueprint"
5756
, "decoder ring"
5857
, "linotype"
5958
, "tape drive"

0 commit comments

Comments
 (0)