async def sow(cmd): user_data = EwUser(member=cmd.message.author) # Checking availability of sow action if user_data.life_state != ewcfg.life_state_juvenile: response = "Only Juveniles of pure heart and with nothing better to do can farm." elif user_data.poi not in [ ewcfg.poi_id_jr_farms, ewcfg.poi_id_og_farms, ewcfg.poi_id_ab_farms ]: response = "The cracked, filthy concrete streets around you would be a pretty terrible place for a farm. Try again on more arable land." else: if user_data.poi == ewcfg.poi_id_jr_farms: farm_id = ewcfg.poi_id_jr_farms elif user_data.poi == ewcfg.poi_id_og_farms: farm_id = ewcfg.poi_id_og_farms else: # if it's the farm in arsonbrook farm_id = ewcfg.poi_id_ab_farms farm = EwFarm(id_server=cmd.message.server.id, id_user=cmd.message.author.id, farm=farm_id) if farm.time_lastsow > 0: response = "You’ve already sown something here. Try planting in another farming location. If you’ve planted in all three farming locations, you’re shit out of luck. Just wait, asshole." else: if cmd.tokens_count > 1: item_search = ewutils.flattenTokenListToString(cmd.tokens[1:]) else: item_search = "slimepoudrin" item_sought = ewitem.find_item( item_search=item_search, id_user=cmd.message.author.id, id_server=cmd.message.server.id if cmd.message.server is not None else None) if item_sought == None: response = "You don't have anything to plant! Try collecting a poudrin." else: slimes_onreap = ewcfg.reap_gain item_data = EwItem(id_item=item_sought.get("id_item")) if item_data.item_type == ewcfg.it_item: if item_data.item_props.get( "id_item") == ewcfg.item_id_slimepoudrin: vegetable = random.choice(ewcfg.vegetable_list) slimes_onreap *= 2 elif item_data.item_props.get( "context") == ewcfg.context_slimeoidheart: vegetable = random.choice(ewcfg.vegetable_list) slimes_onreap *= 2 slimeoid_data = EwSlimeoid( id_slimeoid=item_data.item_props.get("subcontext")) slimeoid_data.delete() else: response = "The soil has enough toxins without you burying your trash here." return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) elif item_data.item_type == ewcfg.it_food: food_id = item_data.item_props.get("id_food") vegetable = ewcfg.food_map.get(food_id) if ewcfg.vendor_farm not in vegetable.vendors: response = "It sure would be nice if {}s grew on trees, but alas they do not. Idiot.".format( item_sought.get("name")) return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) else: response = "The soil has enough toxins without you burying your trash here." return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) # Sowing response = "You sow a {} into the fertile soil beneath you. It will grow in about 3 hours.".format( item_sought.get("name")) farm.time_lastsow = int(time.time() / 60) # Grow time is stored in minutes. farm.time_lastphase = int(time.time()) farm.slimes_onreap = slimes_onreap farm.crop = vegetable.id_food farm.phase = ewcfg.farm_phase_sow farm.action_required = ewcfg.farm_action_none ewitem.item_delete( id_item=item_sought.get('id_item')) # Remove Poudrins farm.persist() await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def sow(cmd): user_data = EwUser(member = cmd.message.author) if user_data.life_state == ewcfg.life_state_shambler: response = "You lack the higher brain functions required to {}.".format(cmd.tokens[0]) return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) # check if the user has a farming tool equipped weapon_item = EwItem(id_item=user_data.weapon) weapon = ewcfg.weapon_map.get(weapon_item.item_props.get("weapon_type")) has_tool = False if weapon is not None: if ewcfg.weapon_class_farming in weapon.classes: has_tool = True # Checking availability of sow action if user_data.life_state != ewcfg.life_state_juvenile and not has_tool: response = "Only Juveniles of pure heart and with nothing better to do can farm." elif cmd.message.channel.name not in [ewcfg.channel_jr_farms, ewcfg.channel_og_farms, ewcfg.channel_ab_farms]: response = "The cracked, filthy concrete streets around you would be a pretty terrible place for a farm. Try again on more arable land." else: poi = ewcfg.id_to_poi.get(user_data.poi) district_data = EwDistrict(district = poi.id_poi, id_server = user_data.id_server) if district_data.is_degraded(): response = "{} has been degraded by shamblers. You can't {} here anymore.".format(poi.str_name, cmd.tokens[0]) return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) if user_data.poi == ewcfg.poi_id_jr_farms: farm_id = ewcfg.poi_id_jr_farms elif user_data.poi == ewcfg.poi_id_og_farms: farm_id = ewcfg.poi_id_og_farms else: # if it's the farm in arsonbrook farm_id = ewcfg.poi_id_ab_farms farm = EwFarm( id_server = cmd.guild.id, id_user = cmd.message.author.id, farm = farm_id ) if farm.time_lastsow > 0: response = "You’ve already sown something here. Try planting in another farming location. If you’ve planted in all three farming locations, you’re shit out of luck. Just wait, asshole." else: it_type_filter = None # gangsters can only plant poudrins if cmd.tokens_count > 1 and user_data.life_state == ewcfg.life_state_juvenile: item_search = ewutils.flattenTokenListToString(cmd.tokens[1:]) # if the item selected was a vegetable, use a food only filter in find_item for v in ewcfg.vegetable_list: if item_search in v.id_food or item_search in v.str_name: it_type_filter = ewcfg.it_food break else: item_search = "slimepoudrin" item_sought = ewitem.find_item(item_search = item_search, id_user = cmd.message.author.id, id_server = cmd.guild.id if cmd.guild is not None else None, item_type_filter = it_type_filter) if item_sought == None: response = "You don't have anything to plant! Try collecting a poudrin." else: slimes_onreap = ewcfg.reap_gain item_data = EwItem(id_item = item_sought.get("id_item")) if item_data.item_type == ewcfg.it_item: if item_data.item_props.get("id_item") == ewcfg.item_id_slimepoudrin: vegetable = random.choice(ewcfg.vegetable_list) slimes_onreap *= 2 elif item_data.item_props.get("context") == ewcfg.context_slimeoidheart: vegetable = random.choice(ewcfg.vegetable_list) slimes_onreap *= 2 slimeoid_data = EwSlimeoid(id_slimeoid = item_data.item_props.get("subcontext")) slimeoid_data.delete() else: response = "The soil has enough toxins without you burying your trash here." return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) elif item_data.item_type == ewcfg.it_food: food_id = item_data.item_props.get("id_food") vegetable = ewcfg.food_map.get(food_id) if ewcfg.vendor_farm not in vegetable.vendors: response = "It sure would be nice if {}s grew on trees, but alas they do not. Idiot.".format(item_sought.get("name")) return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) elif user_data.life_state != ewcfg.life_state_juvenile: response = "You lack the knowledge required to grow {}.".format(item_sought.get("name")) return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) else: response = "The soil has enough toxins without you burying your trash here." return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) mutations = user_data.get_mutations() growth_time = ewcfg.crops_time_to_grow if user_data.life_state == ewcfg.life_state_juvenile: growth_time /= 2 if ewcfg.mutation_id_greenfingers in mutations: growth_time /= 1.5 hours = int(growth_time / 60) minutes = int(growth_time % 60) str_growth_time = "{} hour{}{}".format(hours, "s" if hours > 1 else "", " and {} minutes".format(minutes) if minutes > 0 else "") # Sowing response = "You sow a {} into the fertile soil beneath you. It will grow in about {}.".format(item_sought.get("name"), str_growth_time) farm.time_lastsow = int(time.time() / 60) # Grow time is stored in minutes. farm.time_lastphase = int(time.time()) farm.slimes_onreap = slimes_onreap farm.crop = vegetable.id_food farm.phase = ewcfg.farm_phase_sow farm.action_required = ewcfg.farm_action_none farm.sow_life_state = user_data.life_state ewitem.item_delete(id_item = item_sought.get('id_item')) # Remove Poudrins farm.persist() await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))