From 8dce1626771aba9a0cc7f9c56cef6fb5695eaa60 Mon Sep 17 00:00:00 2001 From: cha0s Date: Mon, 10 May 2021 02:52:45 -0500 Subject: [PATCH] refactor: prepare grass --- packages/farm/src/resources/decorators/room.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/farm/src/resources/decorators/room.js b/packages/farm/src/resources/decorators/room.js index 31f37d4..45768dd 100644 --- a/packages/farm/src/resources/decorators/room.js +++ b/packages/farm/src/resources/decorators/room.js @@ -7,6 +7,7 @@ import { import Renderable from './room/renderable'; const DIRT = 6; +const GRASS = [1, 2, 3, 4, 10, 11, 12]; const TILLED = 7; export default (Room) => class FarmableRoom extends Room { @@ -92,7 +93,10 @@ export default (Room) => class FarmableRoom extends Room { mayPrepareSoilAt(target) { const [tiles] = this.tiles; - return DIRT === tiles.tileAt(target); + return ( + DIRT === tiles.tileAt(target) + || -1 !== GRASS.indexOf(tiles.tileAt(target)) + ); } maySowAt(center) { @@ -117,7 +121,7 @@ export default (Room) => class FarmableRoom extends Room { prepareSoilAt(target) { if ('client' !== process.env.SIDE) { const [tiles] = this.tiles; - tiles.setTileAt(target, TILLED); + tiles.setTileAt(target, DIRT === tiles.tileAt(target) ? TILLED : DIRT); this.adjustWaterAt(target, 0); } }