diff --git a/convex/maps.ts b/convex/maps.ts index 7a07263..e0907af 100644 --- a/convex/maps.ts +++ b/convex/maps.ts @@ -22,23 +22,34 @@ const LEVELS = [ ["Z", " "], ], }, + { + grid: [ + [" ", " "], + ["R", " "], + ["Z", "Z"], + ["Z", "Z"], + ], + }, ]; export const seedMaps = internalMutation({ handler: async (ctx) => { - const firstMap = await ctx.db.query("maps").first(); - - if (firstMap) { - return; - } + const maps = await ctx.db.query("maps").collect(); await Promise.all( - LEVELS.map((map, idx) => - ctx.db.insert("maps", { - level: idx + 1, - grid: map.grid, - }), - ), + LEVELS.map((map, idx) => { + const existingMap = maps.find((it) => it.level === idx + 1); + if (existingMap) { + ctx.db.patch(existingMap._id, { + grid: map.grid, + }); + } else { + ctx.db.insert("maps", { + level: idx + 1, + grid: map.grid, + }); + } + }), ); }, }); diff --git a/models/index.ts b/models/index.ts index 9befe30..49c36c3 100644 --- a/models/index.ts +++ b/models/index.ts @@ -57,6 +57,7 @@ The 2d Grid is made up of characters, where each character has a meaning. - often it's good to wall off between the zombies and players if possible, this will slow the zombies down. - You should never put a player directly next to a zombie. - You should try to put blocks directly next to players +- If the player is behind a choke point, blocking the path to the player is the best option. # Output Format