Files
farmer/pumpkin.py
2025-11-10 03:07:40 +08:00

39 lines
749 B
Python

import utils
def grow(xl, yl, n):
def init():
for x in range(xl, xl+n):
l, r, d = yl, yl+n, 1
if x%2 == 1:
l, r, d = yl+n-1, yl-1, -1
for y in range(l, r, d):
utils.mv(x, y)
utils.soil()
def run():
check = list()
for x in range(xl, xl+n):
l, r, d = yl, yl+n, 1
if x%2 == 1:
l, r, d = yl+n-1, yl-1, -1
for y in range(l, r, d):
utils.mv(x, y)
utils.water()
utils.replant(Entities.Pumpkin)
check.append((x, y))
while len(check):
nxt = list()
for x, y in check:
utils.mv(x, y)
if not can_harvest():
nxt.append((x, y))
if get_entity_type() == Entities.Dead_Pumpkin:
plant(Entities.Pumpkin)
check = nxt
utils.mv(xl, yl)
utils.harv()
return (init, run)