Ceremonial PR: fix map gen #39
| @@ -89,6 +89,72 @@ class Knife { | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   showDebug(merged: Record<number, number>) { | ||||
|     if (true) { | ||||
|       let out = ""; | ||||
|       let errors: string[] = []; | ||||
|       const size = this.#regions.size; | ||||
|       for (let y = 0; y < size.h; y++) { | ||||
|         for (let x = 0; x < size.w; x++) { | ||||
|           const loc = new Point(x, y); | ||||
|           out += (() => { | ||||
|             if (this.#sealedWalls.get(loc)) { | ||||
|               return "█"; | ||||
|             } | ||||
|             if (this.#map.get(loc).architecture == Architecture.Wall) { | ||||
|               return "#"; | ||||
|             } | ||||
|             let r = this.#regions.get(loc); | ||||
|             if(typeof r === "number") { | ||||
|               const resolved = merged[r]; | ||||
|               if (typeof resolved === "number") { | ||||
|                 r = resolved; | ||||
|               } else { | ||||
|                 errors.push(`${loc} is region ${r}, not found in merged`) | ||||
|               } | ||||
|               // 0...9 and lowercase | ||||
|               if (r < 36) { | ||||
|                 return r.toString(36) | ||||
|               } | ||||
|               // uppercase | ||||
|               r -= 26; | ||||
|               if (r < 36) { | ||||
|                 return r.toString(36).toUpperCase() | ||||
|               } | ||||
|               // Greek lowercase | ||||
|               r -= 36; | ||||
|               if (r < 25) { | ||||
|                 return String.fromCodePoint(r + 0x3b1); | ||||
|               } | ||||
|               // Greek uppercase (there is a hole at 0x3a2) | ||||
|               r -= 25; | ||||
|               if (r < 17) { | ||||
|                 return String.fromCodePoint(r + 0x391); | ||||
|               } | ||||
|               r -= 17; | ||||
|               if (r < 7) { | ||||
|                 return String.fromCodePoint(r + 0x3a3); | ||||
|               } | ||||
|               // Hebrew | ||||
|               r -= 7 | ||||
|               if (r < 27) { | ||||
|                 return String.fromCodePoint(r+0x5d0); | ||||
|               } | ||||
|               // give up | ||||
|               return "?" | ||||
|             } | ||||
|             return ".";  // room without region | ||||
|           })(); | ||||
|         } | ||||
|         out += "\n"; | ||||
|       } | ||||
|       console.log(out); | ||||
|       if (errors.length > 0) { | ||||
|         console.log(`uh-oh: \n\t${errors.join("\n\t")}`); | ||||
|       } | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  | ||||
| export function generateMap(): LoadedNewMap { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user