summaryrefslogtreecommitdiff
path: root/src/world/cell.js
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2023-11-06 02:35:05 -0600
committersanine <sanine.not@pm.me>2023-11-06 02:35:05 -0600
commit2e2d9c400335b677297a68883b94bb98526b45ac (patch)
treea76af9947b41c79709c4f228026bd4068b274b29 /src/world/cell.js
parent41d720dbd78d91ac85239c8352cd479ec898f9e0 (diff)
implement cell flag setting
Diffstat (limited to 'src/world/cell.js')
-rw-r--r--src/world/cell.js11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/world/cell.js b/src/world/cell.js
index 5783d72..6e013c6 100644
--- a/src/world/cell.js
+++ b/src/world/cell.js
@@ -29,13 +29,20 @@ export function cells_apply(cells, proposals) {
(acc, prop) => {
const change = (prop.world_updates || []).reduce(
(acc_, update) => {
- acc_[update.y][update.x].type = update.to;
+ const cell = acc_[update.y][update.x];
+ if (update.to) { cell.type = update.to; }
+ if (update.flags) {
+ cell.flags = cell.flags || {}
+ for (let k of Object.keys(update.flags)) {
+ cell.flags[k] = update.flags[k];
+ }
+ }
return acc_
},
[...acc]
);
return change;
},
- [...cells]
+ [...cells].map(row => row.map(cell => ({ ...cell, flags: {}, })))
);
}