Skip to content

Commit

Permalink
Code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Tengs Penkwe committed Feb 25, 2024
1 parent c22cc12 commit 603ab62
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
3 changes: 1 addition & 2 deletions src/Util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ export function openImage(imagePath: string) {
throw new Error(`Unsupported platform: ${platform()}`);
}

exec(command, (error, stdout, ) => {
exec(command, (error, stdout) => {
if (error) {
logger.error(`Error opening image: ${error.message}`);
return;
}
logger.info(`Image opened: ${stdout}`);
});
}

26 changes: 14 additions & 12 deletions src/backend/Farm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ export class Farm {
this.Width = props.Width as number;
this.Polyculture = props.Polyculture as boolean;
this.MaxWaterUsage = props.MaxWaterUsage as number;
if (props.Season !== "Spring" && props.Season !== "Summer" && props.Season !== "Fall" && props.Season !== "Winter" && props.Season !== "All") {
throw new Error("Season must be one of Spring, Summer, Fall, Winter, or All");
}
this.Season = props.Season as "Spring" | "Summer" | "Fall" | "Winter" | "All";
this.Crops = Array.from({length: this.Height}, () => Array(this.Width).fill(null));
}
Expand Down Expand Up @@ -248,25 +251,25 @@ export class Farm {

private getSeasonalBackground(season: string, srcDir: string): string {
const seasonMap: {[key: string]: string} = {
"Spring": "spring.png",
"Summer": "summer.png",
"Fall": "fall.png",
"Winter": "winter.png"
Spring: "spring.png",
Summer: "summer.png",
Fall: "fall.png",
Winter: "winter.png",
};
return path.join(srcDir, seasonMap[season]);
}

private getSeasonalIcon(season: string, srcDir: string): MergeImageSrc {
const iconMap: {[key: string]: string} = {
"Spring": "flower.png",
"Summer": "sun.png",
"Fall": "leaf.png",
"Winter": "snowman.png"
Spring: "flower.png",
Summer: "sun.png",
Fall: "leaf.png",
Winter: "snowman.png",
};
return {
src: path.join(srcDir, iconMap[season]),
x: 300,
y: 50
x: 300,
y: 50,
};
}

Expand All @@ -278,15 +281,14 @@ export class Farm {
tiles.push({
src: backgroundSrc,
x: x,
y: y
y: y,
});
}
}
return tiles;
}

public getDisplayFarmOutputConfig(srcDir: string) {

const dim = this.getDisplayFarmDimensions();
const backgroundSrc = this.getSeasonalBackground(this.Season, srcDir);
const backgroundTiles = this.tileBackgroundImage(backgroundSrc, dim);
Expand Down

0 comments on commit 603ab62

Please sign in to comment.