This commit is contained in:
Aotumuri
2025-05-22 20:15:04 +09:00
parent b145f41de1
commit 18e35400a3
4 changed files with 48 additions and 97 deletions
+4 -25
View File
@@ -48,27 +48,6 @@ export class territoryPatternsModal extends LitElement {
this.updatePreview();
});
for (const [key, p] of Object.entries(territoryPatterns.patterns)) {
if (!p.pattern && p.patternBase64) {
const bytes = Uint8Array.from(atob(p.patternBase64), (c) =>
c.charCodeAt(0),
);
const bits = Array.from(bytes).flatMap((byte) =>
[...Array(8)].map((_, i) => (byte >> (7 - i)) & 1),
);
const pattern: number[][] = [];
for (let y = 0; y < p.tileHeight; y++) {
const row: number[] = [];
for (let x = 0; x < p.tileWidth; x++) {
const index = y * p.tileWidth + x;
row.push(bits[index] ?? 0);
}
pattern.push(row);
}
p.pattern = pattern;
}
}
this.setLockedPatterns(["evan"], {
evan: "This pattern is locked because it is restricted.",
});
@@ -133,8 +112,8 @@ export class territoryPatternsModal extends LitElement {
"
>
${(() => {
const cellCountX = pattern.tileWidth;
const cellCountY = pattern.tileHeight;
const cellCountX = pattern.tileWidth ?? 1;
const cellCountY = pattern.tileHeight ?? 1;
const cellSize = Math.floor(
this.buttonWidth / Math.max(cellCountX, cellCountY),
);
@@ -200,8 +179,8 @@ export class territoryPatternsModal extends LitElement {
const fixedHeight = 48;
const fixedWidth = 48;
const cellCountX = pattern.tileWidth;
const cellCountY = pattern.tileHeight;
const cellCountX = pattern.tileWidth ?? 1;
const cellCountY = pattern.tileHeight ?? 1;
const cellSize = Math.min(
fixedHeight / cellCountY,