Skip to content

Commit

Permalink
copy over known (count 0) items when salvaging (#398)
Browse files Browse the repository at this point in the history
Fixes #391.
  • Loading branch information
byorgey authored Jun 15, 2022
1 parent bda16b7 commit 7a88bc1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Swarm/Game/Step.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1294,6 +1294,11 @@ execConst c vs s k = do
`isJustOr` Fatal "While executing 'salvage': there's no such thing as a logger!?"
when (creative || inst `E.contains` logger) $ robotLog <>= target ^. robotLog

-- Immediately copy over any items the robot knows about
-- but has 0 of
let knownItems = map snd . filter ((== 0) . fst) . elems $ salvageInventory
robotInventory %= \i -> foldr (insertCount 0) i knownItems

-- Now reprogram the robot being salvaged to 'give' each
-- item in its inventory to us, one at a time, then
-- self-destruct at the end. Make it a system robot so we
Expand Down

0 comments on commit 7a88bc1

Please sign in to comment.