diff options
author | sanine <sanine.not@pm.me> | 2023-11-11 15:04:36 -0600 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2023-11-11 15:04:36 -0600 |
commit | f7b0ed22b2fd0ddafc4a84dde1ad8e3208144844 (patch) | |
tree | e290cda13f58eb9a2e3cf2e5e7b05748a0c8e982 /src/world/lattice.js | |
parent | c2466a35fb1edce6088b72df17444631f7034e07 (diff) |
gol changes make sound
Diffstat (limited to 'src/world/lattice.js')
-rw-r--r-- | src/world/lattice.js | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/world/lattice.js b/src/world/lattice.js index 243a47d..066a5ca 100644 --- a/src/world/lattice.js +++ b/src/world/lattice.js @@ -28,18 +28,19 @@ export function lattice_valid(lattice, proposal) { // apply a set of proposals, returning the new lattice export function lattice_apply(lattice, proposals) { - return proposals.reduce( + const result = proposals.reduce( (acc, prop) => { const change = (prop.world_updates || []).reduce( (acc_, update) => { const cell = acc_[update.y][update.x]; if (update.to) { cell.type = update.to; } if (update.flags) { - cell.flags = cell.flags || {} - // this is very side-effect-y but i couldn't think of a nicer compatible way of doing it 😔 - for (let k of Object.keys(update.flags)) { - cell.flags[k] = update.flags[k]; - } + cell.flags = { ...(cell.flags || {}), ...update.flags }; + //cell.flags = cell.flags || {} + //// this is very side-effect-y but i couldn't think of a nicer compatible way of doing it 😔 + //for (let k of Object.keys(update.flags)) { + // cell.flags[k] = update.flags[k]; + //} } return acc_ }, @@ -47,6 +48,7 @@ export function lattice_apply(lattice, proposals) { ); return change; }, - [...lattice].map(row => row.map(cell => ({ ...cell, flags: {}, }))) + [...lattice] ); + return result; } |