MCPcopy
hub / github.com/feichao93/battle-city / convertToSteels

Function convertToSteels

app/sagas/powerUpManager.ts:48–66  ·  view source on GitHub ↗
(map: MapRecord)

Source from the content-addressed store, hash-verified

46}
47
48function convertToSteels(map: MapRecord) {
49 const { eagle, steels, bricks } = map
50 const eagleSurroundingBox = {
51 x: eagle.x - 8,
52 y: eagle.y - 8,
53 width: 32 - 1,
54 height: 32 - 1,
55 }
56 const surroundingTTSet = new Set(IndexHelper.iter('steel', eagleSurroundingBox))
57 const eagleTTSet = new Set(IndexHelper.iter('steel', asRect(eagle, -0.1)))
58 const nextSteels = steels.map(
59 (set, t) => (surroundingTTSet.has(t) && !eagleTTSet.has(t) ? true : set),
60 )
61
62 const surroundBTSet = new Set(IndexHelper.iter('brick', eagleSurroundingBox))
63 const nextBricks = bricks.map((set, t) => (surroundBTSet.has(t) ? false : set))
64
65 return map.set('steels', nextSteels).set('bricks', nextBricks)
66}
67
68function* shovel() {
69 try {

Callers 1

shovelFunction · 0.85

Calls 2

asRectFunction · 0.90
iterMethod · 0.45

Tested by

no test coverage detected