mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-22 10:37:14 +00:00
fixed
This commit is contained in:
@@ -1,13 +1,10 @@
|
||||
import { z } from "zod";
|
||||
import rawTerritoryPatterns from "../../resources/territory_patterns.json";
|
||||
|
||||
const PatternSchema = z.object({
|
||||
patternBase64: z.string().optional(),
|
||||
});
|
||||
|
||||
const TerritoryPatternsSchema = z.object({
|
||||
patterns: z.record(PatternSchema),
|
||||
});
|
||||
export const TerritoryPatternsSchema = z.record(
|
||||
z.string(),
|
||||
z.string().base64(),
|
||||
);
|
||||
|
||||
export const territoryPatterns =
|
||||
TerritoryPatternsSchema.parse(rawTerritoryPatterns);
|
||||
|
||||
@@ -82,7 +82,7 @@ export class territoryPatternsModal extends LitElement {
|
||||
class="flex flex-wrap gap-4 p-2"
|
||||
style="justify-content: center; align-items: flex-start;"
|
||||
>
|
||||
${Object.entries(territoryPatterns.patterns).map(([key, pattern]) => {
|
||||
${Object.entries(territoryPatterns ?? {}).map(([key, pattern]) => {
|
||||
const isLocked = this.isPatternLocked(key);
|
||||
const reason = this.lockedReasons[key] || "Locked";
|
||||
|
||||
@@ -114,7 +114,7 @@ export class territoryPatternsModal extends LitElement {
|
||||
"
|
||||
>
|
||||
${(() => {
|
||||
const decoder = new PatternDecoder(pattern.patternBase64!);
|
||||
const decoder = new PatternDecoder(pattern);
|
||||
const cellCountX = decoder.getTileWidth();
|
||||
const cellCountY = decoder.getTileHeight();
|
||||
const cellSize = Math.floor(
|
||||
@@ -186,12 +186,12 @@ export class territoryPatternsModal extends LitElement {
|
||||
private updatePreview() {
|
||||
if (!this.previewButton || !this.selectedPattern) return;
|
||||
|
||||
const pattern = territoryPatterns.patterns[this.selectedPattern];
|
||||
const pattern = territoryPatterns[this.selectedPattern];
|
||||
if (!pattern) return;
|
||||
|
||||
const fixedHeight = 48;
|
||||
const fixedWidth = 48;
|
||||
const decoder = new PatternDecoder(pattern.patternBase64!);
|
||||
const decoder = new PatternDecoder(pattern);
|
||||
const cellCountX = decoder.getTileWidth();
|
||||
const cellCountY = decoder.getTileHeight();
|
||||
|
||||
|
||||
@@ -299,9 +299,9 @@ export class TerritoryLayer implements Layer {
|
||||
const x = this.game.x(tile);
|
||||
const y = this.game.y(tile);
|
||||
const baseColor = this.theme.territoryColor(owner);
|
||||
const patternConfig = territoryPatterns.patterns[patternName];
|
||||
const patternBase64 = territoryPatterns[patternName];
|
||||
|
||||
const decoder = new PatternDecoder(patternConfig.patternBase64 ?? "");
|
||||
const decoder = new PatternDecoder(patternBase64 ?? "");
|
||||
const bit = decoder.isSet(x, y) ? 1 : 0;
|
||||
const colorToUse = bit ? baseColor.darken(0.2) : baseColor;
|
||||
this.paintCell(x, y, colorToUse, 150);
|
||||
|
||||
Reference in New Issue
Block a user