From 2e2d9c400335b677297a68883b94bb98526b45ac Mon Sep 17 00:00:00 2001 From: sanine Date: Mon, 6 Nov 2023 02:35:05 -0600 Subject: implement cell flag setting --- src/world/cell.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/world/cell.js') 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: {}, }))) ); } -- cgit v1.2.1