refactor: prepare grass

This commit is contained in:
cha0s 2021-05-10 02:52:45 -05:00
parent d6846f294a
commit 8dce162677

View File

@ -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);
}
}