if self.growing and self.growtimeremaining == 0: # check for grow complete self.growing = False self.to_harvest = True chance = random.randint(0, 100) if chance <= farmlib.rules["DESTROY_CHANCE"]: farmtile["object"] = None farmtile["water"] = 0 return True return False # not updated def onplant(self): """onplant :return: """ self.start_grow() def start_grow(self): """Start seed growing""" self.growing = True self.growstarttime = int(time.time()) self.growendtime = self.growstarttime + self.growtime # load objects from json file objects = DictMapper() objects.load(os.path.join("data", "objects.json"))
from __future__ import absolute_import import os import pygame from farmlib.dictmapper import DictMapper from farmlib.pluginsystem import base_plugin_system as PluginSystem # SETTINGS rules = DictMapper() rules.load(os.path.join("data", "rules.json")) images = DictMapper() images.load(os.path.join("data", "images.json")) __VERSION__ = rules["VERSION"] # init plugin system pygame.font.init() pygame.mixer.init() filename = os.path.join("data", "sounds", "click.wav") if os.path.isfile(filename): clickfilename = filename elif os.path.isfile(os.path.join('..', filename)): clickfilename = os.path.join('..', filename) else: # handle error in a way that doesn't make sphinx crash print("ERROR: No such file: '{}'".format(filename))