async def crystalize_negapoudrin(cmd): user_data = EwUser(member=cmd.message.author) response = "" if user_data.life_state != ewcfg.life_state_corpse: response = "What the f**k do you think you're doing, you corporeal bitch?" elif user_data.slimes >= ewcfg.slimes_to_crystalize_negapoudrin: response = "Crystalizing a negapoudrin requires a lot of negaslime, and you're not quite there yet." else: negapoudrin_data = next(i for i in static_items.item_list if i.id_item == ewcfg.item_id_negapoudrin) bknd_item.item_create(item_type=ewcfg.it_item, id_user=user_data.id_user, id_server=cmd.guild.id, item_props={ 'id_item': negapoudrin_data.id_item, 'item_name': negapoudrin_data.str_name, 'item_desc': negapoudrin_data.str_desc, }) user_data.change_slimes(n=-ewcfg.slimes_to_crystalize_negapoudrin, source=ewcfg.source_spending) user_data.persist() response = "The cathedral's bells toll in the distance, and a rumbling {} can be heard echoing from deep within the sewers. A negapoudrin has formed.".format( ewcfg.cmd_boo) return await fe_utils.send_message( cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
async def rattle(cmd): user_data = EwUser(member=cmd.message.author) if user_data.race == ewcfg.race_skeleton: time_now = int(time.time()) # generate bone item when off cooldown if (time_now > user_data.time_racialability or ewutils.DEBUG_OPTIONS['no_race_cooldown'] == True ) and random.randrange( 10) == 0: #pass cooldown check when debug racecooldown is on bone_item = next(i for i in static_items.item_list if i.context == "player_bone") bknd_item.item_create(item_type=ewcfg.it_item, id_user=user_data.poi, id_server=cmd.guild.id, item_props={ 'id_item': bone_item.id_item, 'context': bone_item.context, 'item_name': bone_item.str_name, 'item_desc': bone_item.str_desc, }) user_data.time_racialability = time_now + ewcfg.cd_drop_bone user_data.persist() # spook mentioned player if cmd.mentions_count == 1: responses = [ ", sending a shiver down their spine.", ", who clearly does not appreciate it.", ". They almost faint in shock.", ", scaring them so bad they pee themselves a little.", ". **NYEEEH!**", ", trying to appeal to the bones deep within them.", " a little bit too hard. Oof ouch owie.", " so viciously they actually get offended.", " in an attempt to socialize, but they don't think you should.", ] response = "You rattle your bones at {}{}".format( cmd.mentions[0].display_name, random.choice(responses)) # rattle alone else: response = "You rattle your bones." else: response = "You people are not allowed to do that." return await fe_utils.send_response(response, cmd)
async def create(cmd): # if not cmd.message.author.guild_permissions.administrator: if EwUser( member=cmd.message.author ).life_state != ewcfg.life_state_kingpin and not cmd.message.author.guild_permissions.administrator: response = 'Lowly Non-Kingpins cannot hope to create items with their bare hands.' return await fe_utils.send_message( cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) if len(cmd.tokens) not in [4, 5, 6]: response = 'Usage: !create "<item_name>" "<item_desc>" <recipient> <rarity(optional)>, <context>(optional)' return await fe_utils.send_message( cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) item_name = cmd.tokens[1] item_desc = cmd.tokens[2] rarity = cmd.tokens[4] if len( cmd.tokens) >= 5 and ewutils.flattenTokenListToString( cmd.tokens[4]) in ['princeps', 'plebeian', 'patrician' ] else 'princeps' context = cmd.tokens[5] if len(cmd.tokens) >= 6 else '' if cmd.mentions[0]: recipient = cmd.mentions[0] else: response = 'You need to specify a recipient. Usage: !create "<item_name>" "<item_desc>" <recipient>' return await fe_utils.send_message( cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) item_props = { "cosmetic_name": item_name, "cosmetic_desc": item_desc, "adorned": "false", "rarity": rarity, "context": context } new_item_id = bknd_item.item_create(id_server=cmd.guild.id, id_user=recipient.id, item_type=ewcfg.it_cosmetic, item_props=item_props) itm_utils.soulbind(new_item_id) response = 'Item "{}" successfully created.'.format(item_name) return await fe_utils.send_message( cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
async def reap(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 fe_utils.send_message( cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) forcereap = False if cmd.tokens[0] == ewcfg.cmd_reap_alt: if cmd.message.author.guild_permissions.administrator: forcereap = True else: return response = "" levelup_response = "" mutations = user_data.get_mutations() cosmetic_abilites = itm_utils.get_cosmetic_abilities( id_user=cmd.message.author.id, id_server=cmd.guild.id) poi = poi_static.id_to_poi.get(user_data.poi) # check if the user has a farming tool equipped weapon_item = EwItem(id_item=user_data.weapon) weapon = static_weapons.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 reap 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 cmd.message.channel.name not in [ ewcfg.channel_jr_farms, ewcfg.channel_og_farms, ewcfg.channel_ab_farms ]: response = "Do you remember planting anything here in this barren wasteland? No, you don’t. Idiot." else: poi = poi_static.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 fe_utils.send_message( cmd.client, cmd.message.channel, fe_utils.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 missed a step, you haven’t planted anything here yet." else: cur_time_min = time.time() / 60 time_grown = cur_time_min - farm.time_lastsow if farm.phase != ewcfg.farm_phase_reap and not forcereap: response = "Patience is a virtue and you are morally bankrupt. Just wait, asshole." else: # Reaping if (time_grown > ewcfg.crops_time_to_grow * 16) and not forcereap: # about 2 days response = "You eagerly cultivate your crop, but what’s this? It’s dead and wilted! It seems as though you’ve let it lay fallow for far too long. Pay better attention to your farm next time. You gain no slime." farm.time_lastsow = 0 # 0 means no seeds are currently planted farm.persist() else: user_initial_level = user_data.slimelevel slime_gain = farm.slimes_onreap controlling_faction = poi_utils.get_subzone_controlling_faction( user_data.poi, user_data.id_server) if controlling_faction != "" and controlling_faction == user_data.faction: slime_gain *= 2 if has_tool and weapon.id_weapon == ewcfg.weapon_id_hoe: slime_gain *= 1.5 if ewcfg.mutation_id_greenfingers in mutations: slime_gain *= 1.2 if user_data.poi == ewcfg.poi_id_jr_farms: slime_gain = int(slime_gain / 4) # trauma = se_static.trauma_map.get(user_data.trauma) # if trauma != None and trauma.trauma_class == ewcfg.trauma_class_slimegain: # slime_gain *= (1 - 0.5 * user_data.degradation / 100) slime_gain = max(0, round(slime_gain)) response = "You reap what you’ve sown. Your investment has yielded {:,} slime, ".format( slime_gain) # Determine if an item is found. unearthed_item = False unearthed_item_amount = 0 unearthed_item_chance = 50 / ewcfg.unearthed_item_rarity # 1 in 30 chance if ewcfg.mutation_id_lucky in mutations: unearthed_item_chance *= 1.33 # 1 in 22.5 chance if ewcfg.cosmeticAbility_id_lucky in cosmetic_abilites: unearthed_item_chance *= 1.33 # 1 in ~17 chance with both if has_tool and weapon.id_weapon == ewcfg.weapon_id_shovel: # 1 in 6 chance unearthed_item_chance *= 5 if random.random() < unearthed_item_chance: unearthed_item = True unearthed_item_amount = 1 if random.randint( 1, 3) != 1 else 2 # 33% chance of extra drop if unearthed_item == True: # If there are multiple possible products, randomly select one. item = random.choice(vendors.mine_results) item_props = itm_utils.gen_item_props(item) if item is not None: for creation in range(unearthed_item_amount): bknd_item.item_create( item_type=item.item_type, id_user=cmd.message.author.id, id_server=cmd.guild.id, item_props=item_props) if unearthed_item_amount == 1: response += "a {}, ".format(item.str_name) elif unearthed_item_amount == 2: response += "two {}s, ".format(item.str_name) # Determine what crop is grown. vegetable = static_food.food_map.get(farm.crop) if vegetable is None: vegetable = random.choice(static_food.vegetable_list) item_props = itm_utils.gen_item_props(vegetable) # Create and give a bushel of whatever crop was grown, unless it's a metal crop. if item_props.get('id_food') in [ ewcfg.item_id_metallicaps, ewcfg.item_id_steelbeans, ewcfg.item_id_aushucks ]: metallic_crop_ammount = 1 if random.randrange(10) == 0: metallic_crop_ammount = 5 if random.randrange( 2) == 0 else 6 if has_tool and weapon.id_weapon == ewcfg.weapon_id_pitchfork: metallic_crop_ammount *= 2 for vcreate in range(metallic_crop_ammount): bknd_item.item_create( id_user=cmd.message.author.id, id_server=cmd.guild.id, item_type=vegetable.item_type, item_props=item_props) if metallic_crop_ammount == 1: response += "and a single {}!".format( vegetable.str_name) else: response += "and a bushel or two of {}!".format( vegetable.str_name) # if random.randrange(10) == 0: # for vcreate in range(6): # bknd_item.item_create( # id_user=cmd.message.author.id, # id_server=cmd.guild.id, # item_type=vegetable.item_type, # item_props=item_props # ) # # response += "and a bushel of {}!".format(vegetable.str_name) # else: # response += "and a bushel of... hey, what the hell! You didn't reap anything! Must've been some odd seeds..." else: unearthed_vegetable_amount = 3 if has_tool and weapon.id_weapon == ewcfg.weapon_id_pitchfork: unearthed_vegetable_amount *= 2 for vcreate in range(unearthed_vegetable_amount): bknd_item.item_create( id_user=cmd.message.author.id, id_server=cmd.guild.id, item_type=vegetable.item_type, item_props=item_props) response += "and a bushel of {}!".format( vegetable.str_name) levelup_response = user_data.change_slimes( n=slime_gain, source=ewcfg.source_farming) was_levelup = True if user_initial_level < user_data.slimelevel else False # Tell the player their slime level increased. if was_levelup: response += "\n\n" + levelup_response user_data.hunger += ewcfg.hunger_perfarm user_data.persist() farm.time_lastsow = 0 # 0 means no seeds are currently planted farm.persist() # gangsters don't need their roles updated if user_data.life_state == ewcfg.life_state_juvenile: await ewrolemgr.updateRoles(client=cmd.client, member=cmd.message.author) await fe_utils.send_message( cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
async def award_fish(fisher, cmd, user_data): response = "" actual_fisherman = None actual_fisherman_data = user_data if fisher.inhabitant_id: actual_fisherman = user_data.get_possession()[1] actual_fisherman_data = EwUser(id_user=actual_fisherman, id_server=cmd.guild.id) if fisher.current_fish in ["item", "seaitem"]: slimesea_inventory = bknd_item.inventory(id_server=cmd.guild.id, id_user=ewcfg.poi_id_slimesea) if (fisher.pier.pier_type != ewcfg.fish_slime_saltwater or len(slimesea_inventory) == 0 or random.random() < 0.2) and fisher.current_fish == "item": item = random.choice(vendors.mine_results) unearthed_item_amount = (random.randrange(5) + 8 ) # anywhere from 8-12 drops item_props = itm_utils.gen_item_props(item) # Ensure item limits are enforced, including food since this isn't the fish section if bknd_item.check_inv_capacity(user_data=actual_fisherman_data, item_type=item.item_type): for creation in range(unearthed_item_amount): bknd_item.item_create(item_type=item.item_type, id_user=actual_fisherman or cmd.message.author.id, id_server=cmd.guild.id, item_props=item_props) response = "You reel in {} {}s! ".format( unearthed_item_amount, item.str_name) else: response = "You woulda reeled in some {}s, but your back gave out under the weight of the rest of your {}s.".format( item.str_name, item.item_type) else: item = random.choice(slimesea_inventory) if bknd_item.give_item(id_item=item.get('id_item'), member=cmd.message.author): response = "You reel in a {}!".format(item.get('name')) else: response = "You woulda reeled in a {}, but your back gave out under the weight of the rest of your {}s.".format( item.str_name, item.item_type) fisher.stop() user_data.persist() else: user_initial_level = user_data.slimelevel gang_bonus = False has_fishingrod = False if user_data.weapon >= 0: weapon_item = EwItem(id_item=user_data.weapon) weapon = static_weapons.weapon_map.get( weapon_item.item_props.get("weapon_type")) if weapon.id_weapon == "fishingrod": has_fishingrod = True value = 0 # Rewards from the fish's size slime_gain = ewcfg.fish_gain * static_fish.size_to_reward[ fisher.current_size] value += 10 * static_fish.size_to_reward[fisher.current_size] # Rewards from the fish's rarity value += 10 * static_fish.rarity_to_reward[static_fish.fish_map[ fisher.current_fish].rarity] if user_data.life_state == 2: if fisher.current_fish in static_fish.day_fish and user_data.faction == ewcfg.faction_rowdys: gang_bonus = True slime_gain = slime_gain * 1.5 value += 20 if fisher.current_fish in static_fish.night_fish and user_data.faction == ewcfg.faction_killers: gang_bonus = True slime_gain = slime_gain * 1.5 value += 20 # Disabled while I try out the new mastery fishing #if has_fishingrod == True: # slime_gain = slime_gain * 2 # trauma = se_static.trauma_map.get(user_data.trauma) # if trauma != None and trauma.trauma_class == ewcfg.trauma_class_slimegain: # slime_gain *= (1 - 0.5 * user_data.degradation / 100) if fisher.pier.pier_type == ewcfg.fish_slime_void: slime_gain = slime_gain * 1.5 value += 30 if fisher.current_fish == "plebefish": slime_gain = ewcfg.fish_gain * .5 value = 10 controlling_faction = poi_utils.get_subzone_controlling_faction( user_data.poi, user_data.id_server) if controlling_faction != "" and controlling_faction == user_data.faction: slime_gain *= 2 if user_data.poi == ewcfg.poi_id_juviesrow_pier: slime_gain = int(slime_gain / 4) #trauma = se_static.trauma_map.get(user_data.trauma) #if trauma != None and trauma.trauma_class == ewcfg.trauma_class_slimegain and False: #slime_gain *= (1 - 0.5 * user_data.degradation / 100) slime_gain = max(0, round(slime_gain)) bknd_item.item_create( id_user=actual_fisherman or cmd.message.author.id, id_server=cmd.guild.id, item_type=ewcfg.it_food, item_props={ 'id_food': static_fish.fish_map[fisher.current_fish].id_fish, 'food_name': static_fish.fish_map[fisher.current_fish].str_name, 'food_desc': "{}\nIt's {} inches long.".format( static_fish.fish_map[fisher.current_fish].str_desc, fisher.length), 'recover_hunger': 20, 'str_eat': ewcfg.str_eat_raw_material.format( static_fish.fish_map[fisher.current_fish].str_name), 'rarity': static_fish.fish_map[fisher.current_fish].rarity, 'size': fisher.current_size, 'time_expir': time.time() + ewcfg.std_food_expir, 'time_fridged': 0, 'acquisition': ewcfg.acquisition_fishing, 'value': value, 'noslime': 'false', 'length': fisher.length }) if fisher.inhabitant_id: server = cmd.guild inhabitant_member = server.get_member(fisher.inhabitant_id) inhabitant_name = inhabitant_member.display_name inhabitant_data = EwUser(id_user=fisher.inhabitant_id, id_server=user_data.id_server) inhabitee_name = server.get_member(actual_fisherman).display_name slime_gain = int(0.25 * slime_gain) response = "The two of you together manage to reel in a {fish}! {flavor} {ghost} haunts {slime:,} slime away from the fish before placing it on {fleshling}'s hands." \ .format( fish=static_fish.fish_map[fisher.current_fish].str_name, flavor=static_fish.fish_map[fisher.current_fish].str_desc, ghost=inhabitant_name, fleshling=inhabitee_name, slime=slime_gain, ) inhabitant_data.change_slimes(n=-slime_gain) inhabitant_data.persist() fisher.stop() else: response = "You reel in a {fish}! {flavor} You grab hold and wring {slime:,} slime from it. " \ .format(fish=static_fish.fish_map[fisher.current_fish].str_name, flavor=static_fish.fish_map[fisher.current_fish].str_desc, slime=slime_gain) if gang_bonus == True: if user_data.faction == ewcfg.faction_rowdys: response += "The Rowdy-pride this fish is showing gave you more slime than usual. " elif user_data.faction == ewcfg.faction_killers: response += "The Killer-pride this fish is showing gave you more slime than usual. " levelup_response = user_data.change_slimes( n=slime_gain, source=ewcfg.source_fishing) was_levelup = True if user_initial_level < user_data.slimelevel else False # Tell the player their slime level increased. if was_levelup: response += levelup_response fisher.stop() user_data.persist() return response
async def debug_create_random_fish(cmd): if ewutils.DEBUG or cmd.message.author.guild_permissions.administrator: pass else: return fish = random.choice(static_fish.fish_names) size_number = random.randint(0, 100) if size_number >= 0 and size_number < 6: # 5% size = ewcfg.fish_size_miniscule elif size_number >= 6 and size_number < 11: # 5% size = ewcfg.fish_size_small elif size_number >= 11 and size_number < 31: # 20% size = ewcfg.fish_size_average elif size_number >= 31 and size_number < 71: # 40% size = ewcfg.fish_size_big elif size_number >= 71 and size_number < 91: # 20 size = ewcfg.fish_size_huge else: # 10% size = ewcfg.fish_size_colossal value = 0 if size == ewcfg.fish_size_miniscule: value += 10 elif size == ewcfg.fish_size_small: value += 20 elif size == ewcfg.fish_size_average: value += 30 elif size == ewcfg.fish_size_big: value += 40 elif size == ewcfg.fish_size_huge: value += 50 else: value += 60 if static_fish.fish_map[fish].rarity == ewcfg.fish_rarity_common: value += 10 if static_fish.fish_map[fish].rarity == ewcfg.fish_rarity_uncommon: value += 20 if static_fish.fish_map[fish].rarity == ewcfg.fish_rarity_rare: value += 30 if static_fish.fish_map[fish].rarity == ewcfg.fish_rarity_promo: value += 40 bknd_item.item_create( id_user=cmd.message.author.id, id_server=cmd.guild.id, item_type=ewcfg.it_food, item_props={ 'id_food': static_fish.fish_map[fish].id_fish, 'food_name': static_fish.fish_map[fish].str_name, 'food_desc': static_fish.fish_map[fish].str_desc, 'recover_hunger': 20, 'str_eat': ewcfg.str_eat_raw_material.format(static_fish.fish_map[fish].str_name), 'rarity': static_fish.fish_map[fish].rarity, 'size': size, 'time_expir': time.time() + ewcfg.std_food_expir, 'time_fridged': 0, 'acquisition': ewcfg.acquisition_fishing, 'value': value } )
async def barter_all(cmd): user_data = EwUser(member=cmd.message.author) mutations = user_data.get_mutations() # if non-zone channel, break if ewutils.channel_name_is_poi(cmd.message.channel.name) == False: return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "You must {} in a zone's channel.".format(cmd.tokens[0]))) # if not in speakeasy, break if cmd.message.channel.name != ewcfg.channel_speakeasy: if user_data.poi in poi_static.piers: response = 'You ask a nearby fisherman if he wants to trade you anything for this fish you just caught. He tells you to f**k off, but also helpfully informs you that there’s an old sea captain that frequents the Speakeasy that might be able to help you. What an inexplicably helpful/grouchy fisherman!' else: response = 'What random passerby is going to give two shits about your fish? You’ll have to consult a fellow fisherman… perhaps you’ll find some on a pier?' return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) # if corpse, break if user_data.life_state == ewcfg.life_state_corpse: response = 'Captain Albert Alexander hits the table with his glass and shouts "Nay laddy, you can fool me once but not twice! I dont do deals with spirits, get out of my sight!"' return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) food_items = bknd_item.inventory(id_user=user_data.id_user, id_server=user_data.id_server, item_type_filter=ewcfg.it_food) offer_items = [] # list of items to create when offer goes through offer_slime = 0 # slime to give player when offer goes through fish_ids_to_remove = [] # list of fish to delete when offer goes through # check if food item is a fish and add to offer if it is for item in food_items: fish = EwItem(id_item=item.get('id_item')) # if item is a fish, add to offer if fish.item_props.get('acquisition') == ewcfg.acquisition_fishing: fish_ids_to_remove.append(fish.id_item) value = int(fish.item_props['value']) # Random choice between 0, 1, and 2 offer_decision = random.randint(0, 2) if (offer_decision != 2 or ewcfg.mutation_id_davyjoneskeister in mutations) and fish.item_props.get('noslime') != "true" and ewcfg.mutation_id_onemansjunk not in mutations: # If Captain Albert Alexander wants to offer you slime for your fish. 66% chance. max_value = value * 6000 # 600,000 slime for a colossal promo fish, 120,000 for a miniscule common fish. min_value = max_value / 5 # 120,000 slime for a colossal promo fish, 24,000 for a miniscule common fish. slime_gain = round(random.triangular(min_value, max_value, min_value * 2)) offer_slime += slime_gain else: # If Captain Albert Alexander wants to offer you an item for your fish. 33% chance. Once there are more unique items, we'll make this 50%. potential_items = [] # Filters out all non-generic items without the current fish as an ingredient. for result in vendors.appraise_results: if result.ingredients == fish.item_props.get('id_item') or result.ingredients == "generic" and result.acquisition == ewcfg.acquisition_bartering: # Generic means that it can be made with any fish. potential_items.append(result) else: pass # Filters out items of greater value than your fish. for value_filter in potential_items: if value < value_filter.context: potential_items.remove(value_filter) else: pass offer_items.append(random.choice(potential_items)) # if player had some fish to offer if offer_slime > 0 or len(offer_items) > 0: response = "You approach a man of particularly swashbuckling appearance, adorned in an old sea captain's uniform and bicorne cap, and surrounded by empty glass steins. You ask him if he is Captain Albert Alexander and he replies that he hasn’t heard that name in a long time. You drop all of your fish at his feet." items_desc = "" if len(offer_items) > 0: if len(offer_items) > 4: items_desc = "a handful items" elif len(offer_items) > 1: items_desc = "a few items" else: items_desc = "a {}".format(offer_items[0].str_name) offer_desc = "{}{}{}".format((str(offer_slime) + " slime") if (offer_slime > 0) else "", " and " if (offer_slime > 0 and len(items_desc) > 0) else "", items_desc if (len(items_desc) > 0) else "") response += ' \n"Hm, alright… for your fish... I’ll trade you {}!"'.format(offer_desc) await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) response = "" if offer_slime > 0: slime_gain = offer_slime user_initial_level = user_data.slimelevel levelup_response = user_data.change_slimes(n=slime_gain, source=ewcfg.source_fishing) was_levelup = True if user_initial_level < user_data.slimelevel else False # Tell the player their slime level increased. if was_levelup: response += levelup_response response += "\n\n" if len(offer_items): for item in offer_items: item_props = itm_utils.gen_item_props(item) bknd_item.item_create( item_type=item.item_type, id_user=cmd.message.author.id, id_server=cmd.guild.id, item_props=item_props ) for id in fish_ids_to_remove: bknd_item.item_delete(id_item=id) user_data.persist() response += '"Pleasure doing business with you, laddy!"' # player has no fish else: response = "You need some fish to barter with Captain Albert Alexander. Get out there and do some fishing!" await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
async def barter(cmd): user_data = EwUser(member=cmd.message.author) mutations = user_data.get_mutations() if ewutils.channel_name_is_poi(cmd.message.channel.name) == False: return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "You must {} in a zone's channel.".format(cmd.tokens[0]))) market_data = EwMarket(id_server=user_data.id_server) item_search = ewutils.flattenTokenListToString(cmd.tokens[1:]) item_sought = bknd_item.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) # Checking availability of appraisal # if market_data.clock < 8 or market_data.clock > 17: # response = "You ask the bartender if he knows someone who would want to trade you something for your recently caught fish. Apparently, at night, an old commodore by the name of Captain Albert Alexander comes to drown his sorrows at this very tavern. You guess you’ll just have to sit here and wait for him, then." if cmd.message.channel.name != ewcfg.channel_speakeasy: if user_data.poi in poi_static.piers: response = 'You ask a nearby fisherman if he wants to trade you anything for this fish you just caught. He tells you to f**k off, but also helpfully informs you that there’s an old sea captain that frequents the Speakeasy that might be able to help you. What an inexplicably helpful/grouchy fisherman!' else: response = 'What random passerby is going to give two shits about your fish? You’ll have to consult a fellow fisherman… perhaps you’ll find some on a pier?' return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) if user_data.life_state == ewcfg.life_state_corpse: response = 'Captain Albert Alexander hits the table with his glass and shouts "Nay laddy, you can fool me once but not twice! I dont do deals with spirits, get out of my sight!"' return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) elif item_sought: name = item_sought.get('name') fish = EwItem(id_item=item_sought.get('id_item')) id_fish = fish.id_item # str_fish = fish.item_props.get('str_name') item_props = fish.item_props acquisition = item_props.get('acquisition') response = "You approach a man of particularly swashbuckling appearance, adorned in an old sea captain's uniform and bicorne cap, and surrounded by empty glass steins. You ask him if he is Captain Albert Alexander and he replies that he hasn’t heard that name in a long time. You submit your {} for bartering".format(name) if acquisition != ewcfg.acquisition_fishing: response += '. \n"Have you lost yer mind, laddy? That’s not a fish!! Just what’re you trying to pull??"' else: value = int(item_props['value']) items = [] # Filters out all non-generic items without the current fish as an ingredient. for result in vendors.appraise_results: if result.ingredients == fish.item_props.get('id_item') or result.ingredients == "generic" and result.acquisition == ewcfg.acquisition_bartering: # Generic means that it can be made with any fish. items.append(result) else: pass # Filters out items of greater value than your fish. for value_filter in items: if value < value_filter.context: items.remove(value_filter) else: pass else: offer = EwOffer( id_server=cmd.guild.id, id_user=cmd.message.author.id, offer_give=id_fish ) cur_time_min = time.time() / 60 time_offered = cur_time_min - offer.time_sinceoffer if offer.time_sinceoffer > 0 and time_offered < ewcfg.fish_offer_timeout: offer_receive = str(offer.offer_receive) if offer_receive.isdigit() == True and ewcfg.mutation_id_onemansjunk in mutations: item = random.choice(items) if hasattr(item, 'id_item'): offer.offer_receive = item.id_item if hasattr(item, 'id_food'): offer.offer_receive = item.id_food if hasattr(item, 'id_cosmetic'): offer.offer_receive = item.id_cosmetic response = '\n"Well, back again I see! That fish certainly looked better the last time I saw it. Best I’ll do is trade ya a {} for your {}."'.format(item.str_name, name) elif offer_receive.isdigit() == True: slime_gain = int(offer.offer_receive) response = '\n"Well, back again I see! My offer still stands, I’ll trade ya {} slime for your {}"'.format(slime_gain, name) elif ewcfg.mutation_id_davyjoneskeister in mutations and item_props.get('noslime') != "true": max_value = value * 6000 # 600,000 slime for a colossal promo fish, 120,000 for a miniscule common fish. min_value = max_value / 10 # 60,000 slime for a colossal promo fish, 12,000 for a miniscule common fish. slime_gain = round(random.triangular(min_value, max_value, min_value * 2)) offer.offer_receive = slime_gain offer.persist() response = '\n"You know what, laddy? I like the cut of your jib. I\'ll change my offer. How about {} slime for your {}?"'.format(slime_gain, name) else: for result in vendors.appraise_results: if hasattr(result, 'id_item'): if result.id_item != offer.offer_receive: pass else: item = result if hasattr(result, 'id_food'): if result.id_food != offer.offer_receive: pass else: item = result if hasattr(result, 'id_cosmetic'): if result.id_cosmetic != offer.offer_receive: pass else: item = result response = '\n"Well, back again I see! My offer still stands, I’ll trade ya a {} for your {}"'.format(item.str_name, name) response += "\n**!accept** or **!refuse** Captain Albert Alexander's deal." await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) else: # Random choice between 0, 1, and 2 offer_decision = random.randint(0, 2) if (offer_decision != 2 or ewcfg.mutation_id_davyjoneskeister in mutations) and item_props.get('noslime') != "true" and ewcfg.mutation_id_onemansjunk not in mutations: # If Captain Albert Alexander wants to offer you slime for your fish. 66% chance. max_value = value * 6000 # 600,000 slime for a colossal promo fish, 120,000 for a miniscule common fish. min_value = max_value / 10 # 60,000 slime for a colossal promo fish, 12,000 for a miniscule common fish. slime_gain = round(random.triangular(min_value, max_value, min_value * 2)) offer.offer_receive = slime_gain response = '"Hm, alright… for this {}... I’ll offer you {} slime! Trust me, you’re not going to get a better deal anywhere else, laddy."'.format(name, slime_gain) else: # If Captain Albert Alexander wants to offer you an item for your fish. 33% chance. Once there are more unique items, we'll make this 50%. item = random.choice(items) if hasattr(item, 'id_item'): offer.offer_receive = item.id_item if hasattr(item, 'id_food'): offer.offer_receive = item.id_food if hasattr(item, 'id_cosmetic'): offer.offer_receive = item.id_cosmetic response = '"Hm, alright… for this {}... I’ll offer you a {}! Trust me, you’re not going to get a better deal anywhere else, laddy."'.format(name, item.str_name) offer.time_sinceoffer = int(time.time() / 60) offer.persist() response += "\n**!accept** or **!refuse** Captain Albert Alexander's deal." await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) # Wait for an answer accepted = False try: message = await cmd.client.wait_for('message', timeout=20, check=lambda message: message.author == cmd.message.author and message.content.lower() in [ewcfg.cmd_accept, ewcfg.cmd_refuse]) if message != None: if message.content.lower() == ewcfg.cmd_accept: accepted = True if message.content.lower() == ewcfg.cmd_refuse: accepted = False except: accepted = False offer = EwOffer( id_server=cmd.guild.id, id_user=cmd.message.author.id, offer_give=id_fish ) user_data = EwUser(member=cmd.message.author) fish = EwItem(id_item=id_fish) # cancel deal if fish is no longer in user's inventory if fish.id_owner != str(user_data.id_user): accepted = False # cancel deal if the user has left Vagrant's Corner if user_data.poi != ewcfg.poi_id_speakeasy: accepted = False # cancel deal if the offer has been deleted if offer.time_sinceoffer == 0: accepted = False if accepted == True: offer_receive = str(offer.offer_receive) response = "" if offer_receive.isdigit() == True: slime_gain = int(offer_receive) user_initial_level = user_data.slimelevel levelup_response = user_data.change_slimes(n=slime_gain, source=ewcfg.source_fishing) was_levelup = True if user_initial_level < user_data.slimelevel else False # Tell the player their slime level increased. if was_levelup: response += levelup_response response += "\n\n" else: item_props = itm_utils.gen_item_props(item) bknd_item.item_create( item_type=item.item_type, id_user=cmd.message.author.id, id_server=cmd.guild.id, item_props=item_props ) bknd_item.item_delete(id_item=item_sought.get('id_item')) user_data.persist() offer.deal() response += '"Pleasure doing business with you, laddy!"' else: response = '"Ah, what a shame. Maybe you’ll change your mind in the future…?"' else: if item_search: # If they didn't forget to specify an item and it just wasn't found. response = "You don't have one." else: response = "Offer Captain Albert Alexander which fish? (check **!inventory**)" await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
async def order_zine(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 fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) poi = poi_static.id_to_poi.get(user_data.poi) if not poi.write_manuscript: response = "You can't buy zines here! Try going to the cafe. If you're looking for educational books, try the colleges. If you can't read, then you might want to try the comic shop." elif len(cmd.tokens) == 1: response = "Specify a zine to purchase. Find zine IDs with !browse." elif not bknd_item.check_inv_capacity(user_data=user_data, item_type=ewcfg.it_book): response = "You can't carry any more zines." else: if cmd.tokens[1].isdigit(): id_book = int(cmd.tokens[1]) if int_is_zine(id_book, cmd.guild.id): book = EwBook(id_book=id_book) accepted = True if book.genre == 3: accepted = False response = "THIS ZINE IS PORNOGRAPHY. CONFIRM THAT YOU ARE AT LEAST 18 YEARS OLD. **!accept** or **!refuse**" await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) try: message = await cmd.client.wait_for('message', timeout=20, check=lambda message: message.author == cmd.message.author and message.content.lower() in [ewcfg.cmd_accept, ewcfg.cmd_refuse]) if message != None: if message.content.lower() == ewcfg.cmd_accept: accepted = True if message.content.lower() == ewcfg.cmd_refuse: accepted = False except: accepted = False if not accepted: response = "No p**n for you." elif accepted: if book.genre != 10 and poi.id_poi == ewcfg.poi_id_clinicofslimoplasty: response = "Specify a zine to purchase. Find zine IDs with !browse." return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) user_data = EwUser(member=cmd.message.author) #if book.genre != 10: # price = ewcfg.zine_cost #else: # price = ewcfg.zine_cost / 4 #if user_data.slimes < price: poudrins = bknd_item.find_item(item_search="slimepoudrin", id_user=cmd.message.author.id, id_server=cmd.guild.id if cmd.guild is not None else None, item_type_filter=ewcfg.it_item) if poudrins == None: response = "YOU CAN'T AFFORD IT. YOU NEED A POUDRIN." else: bknd_item.item_create( item_type=ewcfg.it_book, id_user=user_data.id_user, id_server=cmd.guild.id, item_props={ "title": book.title, "author": book.author, "date_published": book.date_published, "id_book": book.id_book, "book_desc": "A book by {}, published on {}.".format(book.author, book.date_published) }) book_sale = EwBookSale(id_book=book.id_book, member=cmd.message.author) if book.id_user != user_data.id_user: if book_sale.bought == 0: book_sale.bought = 1 book.sales += 1 book_sale.persist() book.persist() bknd_item.item_delete(id_item=poudrins.get('id_item')) #user_data.change_slimes(n=-(price), source=ewcfg.source_spending) user_data.persist() if book.genre != 10: author = EwUser(id_user=book.id_user, id_server=book.id_server) if author.id_user != user_data.id_user and bknd_item.check_inv_capacity(user_data=user_data, item_type=ewcfg.it_item): bknd_item.item_create( item_type=ewcfg.it_item, id_user=author.id_user, id_server=cmd.guild.id, item_props={ 'context': 'poudrin', 'item_name': 'Royalty Poudrin', 'item_desc': 'You received this less powerful poudrin from some fool who decided to buy your zine. !crush it for 5k slime.', 'id_item': 'royaltypoudrin' }) response = "You manage to locate {} by {} in the vast array of zines on the bookshelf, so you bring it to the counter and hand over {:,} slime to the employee. Now it's time to !read it.".format(book.title, book.author, ewcfg.zine_cost) else: response = "Specify a zine to purchase. Find zine IDs with !browse." else: response = "Specify a zine to purchase. Find zine IDs with !browse." await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
async def smelt(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 fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) # Find sought recipe. if cmd.tokens_count > 1: sought_result = ewutils.flattenTokenListToString(cmd.tokens[1:]) found_recipe = smelting.smelting_recipe_map.get(sought_result) if found_recipe != None: if 'soul' in found_recipe.products: return await smeltsoul(cmd=cmd) # Checks what ingredients are needed to smelt the recipe. necessary_ingredients = found_recipe.ingredients necessary_ingredients_list = [] owned_ingredients = [] # Seeks out the necessary ingredients in your inventory. missing_ingredients = [] for matched_item in necessary_ingredients: necessary_items = necessary_ingredients.get(matched_item) necessary_str = "{} {}".format(necessary_items, matched_item) if necessary_items > 1: necessary_str += "s" necessary_ingredients_list.append(necessary_str) sought_items = itm_utils.find_item_all(item_search=matched_item, id_user=user_data.id_user, id_server=user_data.id_server) missing_items = necessary_items - len(sought_items) if missing_items > 0: missing_str = "{} {}".format(missing_items, matched_item) if missing_items > 1: missing_str += "s" missing_ingredients.append(missing_str) else: for i in range(necessary_ingredients.get(matched_item)): sought_item = sought_items.pop() owned_ingredients.append(sought_item.get('id_item')) # If you don't have all the necessary ingredients. if len(missing_ingredients) > 0: response = "You've never done this before, have you? To smelt {}, you’ll need to combine *{}*.".format(found_recipe.str_name, ewutils.formatNiceList(names=necessary_ingredients_list, conjunction="and")) response += " You are missing *{}*.".format(ewutils.formatNiceList(names=missing_ingredients, conjunction="and")) else: # If you try to smelt a random cosmetic, use old smelting code to calculate what your result will be. if found_recipe.id_recipe == "coolcosmetic" or found_recipe.id_recipe == "toughcosmetic" or found_recipe.id_recipe == "smartcosmetic" or found_recipe.id_recipe == "beautifulcosmetic" or found_recipe.id_recipe == "cutecosmetic": if not bknd_item.check_inv_capacity(user_data=user_data, item_type=ewcfg.it_cosmetic): response = "You can't carry anymore cosmetic items." return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) patrician_rarity = 100 patrician_smelted = random.randint(1, patrician_rarity) patrician = False if patrician_smelted <= 5: patrician = True cosmetics_list = [] if found_recipe.id_recipe == "toughcosmetic": style = ewcfg.style_tough elif found_recipe.id_recipe == "smartcosmetic": style = ewcfg.style_smart elif found_recipe.id_recipe == "beautifulcosmetic": style = ewcfg.style_beautiful elif found_recipe.id_recipe == "cutecosmetic": style = ewcfg.style_cute else: style = ewcfg.style_cool for result in static_cosmetics.cosmetic_items_list: if result.style == style and result.acquisition == ewcfg.acquisition_smelting: cosmetics_list.append(result) else: pass items = [] for cosmetic in cosmetics_list: if patrician and cosmetic.rarity == ewcfg.rarity_patrician: items.append(cosmetic) elif not patrician and cosmetic.rarity == ewcfg.rarity_plebeian: items.append(cosmetic) item = items[random.randint(0, len(items) - 1)] item_props = itm_utils.gen_item_props(item) bknd_item.item_create( item_type=item.item_type, id_user=cmd.message.author.id, id_server=cmd.guild.id, item_props=item_props ) # If you're trying to smelt a specific item. else: possible_results = [] # Matches the recipe's listed products to actual items. for result in vendors.smelt_results: if hasattr(result, 'id_item'): if result.id_item not in found_recipe.products: pass else: possible_results.append(result) if hasattr(result, 'id_food'): if result.id_food not in found_recipe.products: pass else: possible_results.append(result) if hasattr(result, 'id_cosmetic'): if result.id_cosmetic not in found_recipe.products: pass else: possible_results.append(result) if hasattr(result, 'id_weapon'): if result.id_weapon not in found_recipe.products: pass else: possible_results.append(result) if hasattr(result, 'id_furniture'): if result.id_furniture not in found_recipe.products: pass else: possible_results.append(result) # If there are multiple possible products, randomly select one. item = random.choice(possible_results) if not bknd_item.check_inv_capacity(user_data=user_data, item_type=item.item_type): response = "You can't carry any more {}s.".format(item.item_type) return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) item_props = itm_utils.gen_item_props(item) newitem_id = bknd_item.item_create( item_type=item.item_type, id_user=cmd.message.author.id, id_server=cmd.guild.id, item_props=item_props ) for id_item in owned_ingredients: item_check = EwItem(id_item=id_item) if item_check.item_props.get('id_cosmetic') != 'soul': bknd_item.item_delete(id_item=id_item) else: newitem = EwItem(id_item=newitem_id) newitem.item_props['target'] = id_item newitem.persist() bknd_item.give_item(id_item=id_item, id_user='******', id_server=cmd.guild.id) name = "" if hasattr(item, 'str_name'): name = item.str_name elif hasattr(item, 'id_weapon'): name = item.id_weapon response = "You sacrifice your {} to smelt a {}!!".format(ewutils.formatNiceList(names=necessary_ingredients_list, conjunction="and"), name) user_data.persist() else: response = "There is no recipe by the name." else: response = "Please specify a desired smelt result." # Send response await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
async def mine(cmd): market_data = EwMarket(id_server=cmd.message.author.guild.id) 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 fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) mutations = user_data.get_mutations() cosmetic_abilites = itm_utils.get_cosmetic_abilities(id_user=cmd.message.author.id, id_server=cmd.guild.id) time_now = int(time.time()) poi = poi_static.id_to_poi.get(user_data.poi) response = "" # Kingpins can't mine. if user_data.life_state == ewcfg.life_state_kingpin or user_data.life_state == ewcfg.life_state_grandfoe: return # ghosts cant mine (anymore) if user_data.life_state == ewcfg.life_state_corpse: return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "You can't mine while you're dead. Try {}.".format(ewcfg.cmd_revive))) # Enlisted players only mine at certain times. if user_data.life_state == ewcfg.life_state_enlisted: if user_data.faction == ewcfg.faction_rowdys and (market_data.clock < 8 or market_data.clock > 17): return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "Rowdies only mine in the daytime. Wait for full daylight at 8am.".format(ewcfg.cmd_revive))) if user_data.faction == ewcfg.faction_killers and (market_data.clock < 20 and market_data.clock > 5): return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "Killers only mine under cover of darkness. Wait for nightfall at 8pm.".format(ewcfg.cmd_revive))) # Mine only in the mines. if cmd.message.channel.name in ewcfg.mining_channels: poi = poi_static.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 fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) if user_data.hunger >= user_data.get_hunger_max(): return await mismine(cmd, user_data, "exhaustion") # return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "You've exhausted yourself from mining. You'll need some refreshment before getting back to work.")) else: printgrid = True hunger_cost_mod = ewutils.hunger_cost_mod(user_data.slimelevel) extra = hunger_cost_mod - int(hunger_cost_mod) # extra is the fractional part of hunger_cost_mod world_events = bknd_worldevent.get_world_events(id_server=cmd.guild.id) mining_type = ewcfg.mines_mining_type_map.get(user_data.poi) for id_event in world_events: if world_events.get(id_event) == ewcfg.event_type_minecollapse: event_data = EwWorldEvent(id_event=id_event) if int(event_data.event_props.get('id_user')) == user_data.id_user and event_data.event_props.get('poi') == user_data.poi: captcha = event_data.event_props.get('captcha').lower() tokens_lower = [] for token in cmd.tokens[1:]: tokens_lower.append(token.lower()) if captcha in tokens_lower: bknd_worldevent.delete_world_event(id_event=id_event) response = "You escape from the collapsing mineshaft." return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) elif ewcfg.mutation_id_lightminer in mutations: bknd_worldevent.delete_world_event(id_event=id_event) response = "You nimbly step outside the collapse without even thinking about it." return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) else: return await mismine(cmd, user_data, ewcfg.event_type_minecollapse) if user_data.poi not in juviecmdutils.mines_map: response = "You can't mine here! Go to the mines in Juvie's Row, Toxington, or Cratersville!" return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) elif user_data.id_server not in juviecmdutils.mines_map.get(user_data.poi): init_grid(user_data.poi, user_data.id_server) printgrid = True grid_cont = juviecmdutils.mines_map.get(user_data.poi).get(user_data.id_server) grid = grid_cont.grid grid_type = ewcfg.grid_type_by_mining_type.get(mining_type) if grid_type != grid_cont.grid_type: init_grid(user_data.poi, user_data.id_server) printgrid = True grid_cont = juviecmdutils.mines_map.get(user_data.poi).get(user_data.id_server) grid = grid_cont.grid # minesweeper = True # grid_multiplier = grid_cont.cells_mined ** 0.4 # flag = False mining_yield = get_mining_yield_by_grid_type(cmd, grid_cont) if type(mining_yield) == type(""): response = mining_yield if len(response) > 0: await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) if time_now > grid_cont.time_last_posted + 10: await print_grid(cmd) return if mining_yield == 0: user_data.hunger += ewcfg.hunger_permine * int(hunger_cost_mod) user_data.persist() # response = "This vein has already been mined dry." # await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) if printgrid: return await print_grid(cmd) else: return has_pickaxe = False if user_data.weapon >= 0: weapon_item = EwItem(id_item=user_data.weapon) weapon = static_weapons.weapon_map.get(weapon_item.item_props.get("weapon_type")) if (weapon.id_weapon == ewcfg.weapon_id_pickaxe or weapon.id_weapon == ewcfg.weapon_id_diamondpickaxe) and user_data.life_state != ewcfg.life_state_juvenile: has_pickaxe = True # if user_data.sidearm >= 0: # sidearm_item = EwItem(id_item=user_data.sidearm) # sidearm = static_weapons.weapon_map.get(sidearm_item.item_props.get("weapon_type")) # if sidearm.id_weapon == ewcfg.weapon_id_pickaxe: # has_pickaxe = True # Determine if an item is found. unearthed_item = False unearthed_item_amount = (random.randrange(3) + 5) # anywhere from 5-7 drops # juvies get items 4 times as often as enlisted players unearthed_item_chance = 1 / ewcfg.unearthed_item_rarity if user_data.life_state == ewcfg.life_state_juvenile: unearthed_item_chance *= 2 if has_pickaxe == True: unearthed_item_chance *= 1.5 if ewcfg.mutation_id_lucky in mutations: unearthed_item_chance *= 1.33 if ewcfg.cosmeticAbility_id_lucky in cosmetic_abilites: unearthed_item_chance *= 1.33 # event bonus for id_event in world_events: if world_events.get(id_event) == ewcfg.event_type_slimefrenzy: event_data = EwWorldEvent(id_event=id_event) if event_data.event_props.get('poi') == user_data.poi and int(event_data.event_props.get('id_user')) == user_data.id_user: mining_yield *= 2 if world_events.get(id_event) == ewcfg.event_type_poudrinfrenzy: event_data = EwWorldEvent(id_event=id_event) if event_data.event_props.get('poi') == user_data.poi and int(event_data.event_props.get('id_user')) == user_data.id_user: unearthed_item_chance = 1 unearthed_item_amount = 1 if random.random() < 0.05: id_event = create_mining_event(cmd) event_data = EwWorldEvent(id_event=id_event) if event_data.id_event == -1: return ewutils.logMsg("Error couldn't find world event with id {}".format(id_event)) if event_data.event_type == ewcfg.event_type_slimeglob: mining_yield *= 4 bknd_worldevent.delete_world_event(id_event=id_event) if event_data.time_activate <= time.time(): event_def = poi_static.event_type_to_def.get(event_data.event_type) if event_def == None: return ewutils.logMsg("Error, couldn't find event def for event type {}".format(event_data.event_type)) str_event_start = event_def.str_event_start if event_data.event_type == ewcfg.event_type_minecollapse: str_event_start = str_event_start.format(cmd=ewcfg.cmd_mine, captcha=ewutils.text_to_regional_indicator(event_data.event_props.get('captcha'))) await fe_utils.send_response(str_event_start, cmd) event_data.time_expir = time_now + 60 event_data.persist() str_event_start = "" if str_event_start != "": response += str_event_start + "\n" if random.random() < unearthed_item_chance: unearthed_item = True if unearthed_item == True: # If there are multiple possible products, randomly select one. item = random.choice(vendors.mine_results) if bknd_item.check_inv_capacity(user_data=user_data, item_type=item.item_type): item_props = itm_utils.gen_item_props(item) for creation in range(unearthed_item_amount): bknd_item.item_create( item_type=item.item_type, id_user=cmd.message.author.id, id_server=cmd.guild.id, item_props=item_props ) if unearthed_item_amount == 1: response += "You unearthed a {}! ".format(item.str_name) else: response += "You unearthed {} {}s! ".format(unearthed_item_amount, item.str_name) ewstats.change_stat(user=user_data, metric=ewcfg.stat_lifetime_poudrins, n=unearthed_item_amount) # ewutils.logMsg('{} has found {} {}(s)!'.format(cmd.message.author.display_name, item.str_name, unearthed_item_amount)) user_initial_level = user_data.slimelevel # Add mined slime to the user. slime_bylevel = ewutils.slime_bylevel(user_data.slimelevel) # mining_yield = math.floor((slime_bylevel / 10) + 1) # alternate_yield = math.floor(200 + slime_bylevel ** (1 / math.e)) # mining_yield = min(mining_yield, alternate_yield) controlling_faction = poi_utils.get_subzone_controlling_faction(user_data.poi, user_data.id_server) if controlling_faction != "" and controlling_faction == user_data.faction: mining_yield *= 2 if has_pickaxe == True: mining_yield *= 2 if user_data.life_state == ewcfg.life_state_juvenile: mining_yield *= 2 # trauma = se_static.trauma_map.get(user_data.trauma) # if trauma != None and trauma.trauma_class == ewcfg.trauma_class_slimegain: # mining_yield *= (1 - 0.5 * user_data.degradation / 100) mining_yield = max(0, round(mining_yield)) # Fatigue the miner. user_data.hunger += ewcfg.hunger_permine * int(hunger_cost_mod) if extra > 0: # if hunger_cost_mod is not an integer # there's an x% chance that an extra stamina is deducted, where x is the fractional part of hunger_cost_mod in percent (times 100) if random.randint(1, 100) <= extra * 100: user_data.hunger += ewcfg.hunger_permine levelup_response = user_data.change_slimes(n=mining_yield, source=ewcfg.source_mining) was_levelup = True if user_initial_level < user_data.slimelevel else False # Tell the player their slime level increased and/or they unearthed an item. if was_levelup: response += levelup_response user_data.persist() if printgrid: await print_grid(cmd) # gangsters don't need their roles updated if user_data.life_state == ewcfg.life_state_juvenile: await ewrolemgr.updateRoles(client=cmd.client, member=cmd.message.author) else: return await mismine(cmd, user_data, "channel") # response = "You can't mine here! Go to the mines in Juvie's Row, Toxington, or Cratersville!" if len(response) > 0: await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
async def exalt(cmd): author = cmd.message.author user_data = EwUser(member=author) if not author.guild_permissions.administrator and user_data.life_state != ewcfg.life_state_kingpin: response = "You do not have the power within you worthy of !exalting another player." return await fe_utils.send_message( cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) if cmd.mentions_count > 0: recipient = cmd.mentions[0] else: response = 'You need to specify a recipient. Usage: !exalt @[recipient].' return await fe_utils.send_message( cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) recipient_data = EwUser(member=recipient) # DOUBLE HALLOWEEN # # # Gather the Medallion if ewcfg.dh_active: medallion_results = [] for m in cosmetics.cosmetic_items_list: if m.ingredients == 'HorsemanSoul': medallion_results.append(m) else: pass medallion = medallion_results[0] medallion_props = itm_utils.gen_item_props(medallion) medallion_id = bknd_item.item_create(item_type=medallion.item_type, id_user=recipient.id, id_server=cmd.guild.id, item_props=medallion_props) # Soulbind the medallion. A player can get at most twice, but later on a new command could be added to destroy them/trade them in. # I imagine this would be something similar to how players can destroy Australium Wrenches in TF2, which broadcasts a message to everyone in the game, or something. itm_utils.soulbind(medallion_id) response = "**{} has been gifted the Double Halloween Medallion!!**\n".format( recipient.display_name) elif ewcfg.swilldermuk_active: # SWILLDERMUK gambit = ewstats.get_stat(id_server=cmd.guild.id, id_user=recipient_data.id_user, metric=ewcfg.stat_gambit) if gambit > 0: # Give the user the Janus Mask mask_results = [] for m in cosmetics.cosmetic_items_list: if m.ingredients == 'SwilldermukFinalGambit': mask_results.append(m) else: pass mask = mask_results[0] mask_props = itm_utils.gen_item_props(mask) mask_id = bknd_item.item_create(item_type=mask.item_type, id_user=recipient.id, id_server=cmd.guild.id, item_props=mask_props) itm_utils.soulbind(mask_id) response = "In light of their supreme reign over Swilldermuk, and in honor of their pranking prowess, {} recieves the Janus Mask!".format( recipient.display_name) else: # Give the user the Sword of Seething sword_results = [] for s in static_items.item_list: if s.context == 'swordofseething': sword_results.append(s) else: pass sword = sword_results[0] sword_props = itm_utils.gen_item_props(sword) sword_id = bknd_item.item_create(item_type=sword.item_type, id_user=recipient.id, id_server=cmd.guild.id, item_props=sword_props) itm_utils.soulbind(sword_id) response = "In response to their unparalleled ability to let everything go to shit and be the laughingstock of all of NLACakaNM, {} recieves the SWORD OF SEETHING! God help us all...".format( recipient.display_name) else: response = "Exalting? Nah, not enough holiday cheer." return await fe_utils.send_message( cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
async def create(cmd): # if not cmd.message.author.guild_permissions.administrator: #if EwUser(member=cmd.message.author).life_state != ewcfg.life_state_kingpin and not cmd.message.author.guild_permissions.administrator: if not (0 < ewrolemgr.checkClearance(member=cmd.message.author) < 4) or EwUser(member=cmd.message.author ).life_state != ewcfg.life_state_kingpin: response = 'Lowly Non-Kingpins cannot hope to create items with their bare hands.' return await fe_utils.send_message( cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) if len(cmd.tokens) not in [4, 5, 6]: response = 'Usage: !create "<item_name>" "<item_desc>" <recipient> <rarity(optional)>, <context>(optional)' return await fe_utils.send_message( cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) item_name = cmd.tokens[1] item_desc = cmd.tokens[2] rarity = cmd.tokens[4] if len( cmd.tokens) >= 5 and ewutils.flattenTokenListToString( cmd.tokens[4]) in ['princeps', 'plebeian', 'patrician' ] else 'princeps' context = cmd.tokens[5] if len(cmd.tokens) >= 6 else '' if cmd.mentions[0]: recipient = cmd.mentions[0] else: response = 'You need to specify a recipient. Usage: !create "<item_name>" "<item_desc>" <recipient>' return await fe_utils.send_message( cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) # princeps stopped assigning durability and stuff for... reasons (idk!!!! something with the caching update???? As far as I can tell????) so I just assigned them here lol item_props = { "id_cosmetic": "princep", "cosmetic_name": item_name, "cosmetic_desc": item_desc, "str_onadorn": ewcfg.str_generic_onadorn, "str_unadorn": ewcfg.str_generic_unadorn, "str_onbreak": ewcfg.str_generic_onbreak, "rarity": rarity, "attack": 3, "defense": 3, "speed": 3, "ability": None, "durability": ewcfg.base_durability * 100, "size": 1, "fashion_style": ewcfg.style_cool, "freshness": 100, "adorned": "false", "context": context } new_item_id = bknd_item.item_create(id_server=cmd.guild.id, id_user=recipient.id, item_type=ewcfg.it_cosmetic, item_props=item_props) itm_utils.soulbind(new_item_id) response = 'Item "{}" successfully created.'.format(item_name) return await fe_utils.send_message( cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
async def create(cmd): """ Command that creates a princeps cosmetic item. Usable only by admins and kingpins. - !create item_name item_desc recipient style rarity context """ # Only BD admins and above can create princeps if (ewrolemgr.check_clearance(member=cmd.message.author) > 3) and (EwUser( member=cmd.message.author).life_state != ewcfg.life_state_kingpin): response = 'Lowly Non-Kingpins cannot hope to create items with their bare hands.' return await fe_utils.send_response(response, cmd) if len(cmd.tokens) not in [4, 5, 6, 7]: response = 'Usage: !create "<item_name>" "<item_desc>" <recipient> <style>(optional) <rarity(optional)>, <context>(optional).\n' return await fe_utils.send_response(response, cmd) item_name = cmd.tokens[1] item_desc = cmd.tokens[2] # recipient is the third token style = cmd.tokens[4] if len( cmd.tokens) >= 5 and ewutils.flattenTokenListToString( cmd.tokens[4]) in ewcfg.fashion_styles else ewcfg.style_cool rarity = cmd.tokens[5] if len( cmd.tokens) >= 6 and ewutils.flattenTokenListToString( cmd.tokens[5]) in ['princeps', 'plebeian', 'patrician' ] else 'princeps' context = cmd.tokens[6] if len(cmd.tokens) >= 7 else '' if cmd.mentions and cmd.mentions[0]: recipient = cmd.mentions[0] else: response = 'You need to specify a recipient. Usage: !create "<item_name>" "<item_desc>" <recipient> <style>(optional) <rarity>(optional) <context>(optional)' return await fe_utils.send_response(response, cmd) # princeps stopped assigning durability and stuff for... reasons (idk!!!! something with the caching update???? As far as I can tell????) so I just assigned them here lol item_props = { "id_cosmetic": "princep", "cosmetic_name": item_name, "cosmetic_desc": item_desc, "str_onadorn": ewcfg.str_generic_onadorn, "str_unadorn": ewcfg.str_generic_unadorn, "str_onbreak": ewcfg.str_generic_onbreak, "rarity": rarity, "attack": 3, "defense": 3, "speed": 3, "ability": None, "durability": ewcfg.base_durability * 100, "size": 1, "fashion_style": style, "freshness": 100, "adorned": "false", "context": context } new_item_id = bknd_item.item_create(id_server=cmd.guild.id, id_user=recipient.id, item_type=ewcfg.it_cosmetic, item_props=item_props) itm_utils.soulbind(new_item_id) response = 'Item "{}" successfully created.'.format(item_name) return await fe_utils.send_response(response, cmd)
async def destroy_slimeoid(cmd): user_data = EwUser(member=cmd.message.author) slimeoid_data = EwSlimeoid(member=cmd.message.author) # Check of the player is alive if user_data.life_state != ewcfg.life_state_corpse: response = "You... want to destroy your Slimeoid? That's, like, sorta illegal." # Check if the player isn't at Waffle House as a ghost elif user_data.life_state == ewcfg.life_state_corpse and cmd.message.channel.name != ewcfg.channel_wafflehouse: response = "Slimeoids don't f**k with ghosts." # Check if the player has a slimeoid elif slimeoid_data.life_state == ewcfg.slimeoid_state_none: response = "Good news! You don't have a Slimeoid. So no need to destroy one." # If all of those don't work else: # Creates each type-specific heart. Also turns the slimeoid's type into a string, for flavor text purposes. if slimeoid_data.sltype == ewcfg.sltype_lab: # Creates string "Slimeoid" slimeoid_type = "Slimeoid" # Forming slimeoids DON'T drop hearts if slimeoid_data.life_state != ewcfg.slimeoid_state_forming: # Creates the item props for the slimeoid heart item_props = { 'context': ewcfg.context_slimeoidheart, 'subcontext': slimeoid_data.id_slimeoid, 'item_name': "Heart of {}".format(slimeoid_data.name), 'item_desc': "A poudrin-like crystal. If you listen carefully you can hear something that sounds like a faint heartbeat." } # Creates the item in downtown bknd_item.item_create(id_user=ewcfg.channel_downtown, id_server=cmd.guild.id, item_type=ewcfg.it_item, item_props=item_props) else: # Creates string "Negaslimeoid" slimeoid_type = "Negaslimeoid" # Forming negaslimeoids DON'T drop cores if slimeoid_data.life_state != ewcfg.slimeoid_state_forming: # Creates the item props for the negaslimeoid core item_props = { 'context': ewcfg.context_negaslimeoidheart, 'subcontext': slimeoid_data.id_slimeoid, 'item_name': "Core of {}".format(slimeoid_data.name), 'item_desc': "A smooth, inert rock. If you listen carefully you can hear otherworldly whispering." } # Creates the item at Waffle House bknd_item.item_create(id_user=ewcfg.channel_wafflehouse, id_server=cmd.guild.id, item_type=ewcfg.it_item, item_props=item_props) cosmetics = bknd_item.inventory(id_user=cmd.message.author.id, id_server=cmd.guild.id, item_type_filter=ewcfg.it_cosmetic) # get the cosmetics worn by the slimeoid for item in cosmetics: cos = EwItem(id_item=item.get('id_item')) if cos.item_props.get('slimeoid') == 'true': cos.item_props['slimeoid'] = 'false' cos.persist() # Craft the response response = "You think upon your past and spiritually connect with {} the {}. With the Ouija® Board in front of you, you spell out the forbidden words: \n\n\"lol\" \"lmao\" \n\nYour former companion is rended across space and time. All that remains is their {}, though unobtainable by you. {}".format( slimeoid_data.name, slimeoid_type, "heart" if slimeoid_type == "Slimeoid" else "core", ewcfg.emote_slimeskull) # Kill the slimeoid and persist slimeoid_data.die() slimeoid_data.persist() user_data.active_slimeoid = -1 # Take some of the player's negaslime for destroying a slimeoid. if user_data.slimes < 0: user_data.slimes -= user_data.slimes / 10 user_data.persist() # Go to final response # Final response await send_response(response, cmd)
async def mill(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 fe_utils.send_message( cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) market_data = EwMarket(id_server=user_data.id_server) item_search = ewutils.flattenTokenListToString(cmd.tokens[1:]) item_sought = bknd_item.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=ewcfg.it_food) # Checking availability of milling if user_data.life_state != ewcfg.life_state_juvenile: response = "Only Juveniles of pure heart and with nothing better to do can mill their vegetables." elif cmd.message.channel.name not in [ ewcfg.channel_jr_farms, ewcfg.channel_og_farms, ewcfg.channel_ab_farms ]: response = "Alas, there doesn’t seem to be an official SlimeCorp milling station anywhere around here. Probably because you’re in the middle of the f*****g city. Try looking where you reaped your vegetable in the first place, dumbass." # elif user_data.slimes < ewcfg.slimes_permill: # response = "It costs {} to !mill, and you only have {}.".format(ewcfg.slimes_permill, user_data.slimes) elif item_sought: poi = poi_static.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 fe_utils.send_message( cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) items = [] vegetable = EwItem(id_item=item_sought.get('id_item')) for result in vendors.mill_results: if type(result.ingredients) == str: if vegetable.item_props.get('id_food') != result.ingredients: pass else: items.append(result) elif type(result.ingredients) == list: if vegetable.item_props.get( 'id_food') not in result.ingredients: pass else: items.append(result) if len(items) > 0: item = random.choice(items) item_props = itm_utils.gen_item_props(item) bknd_item.item_create(item_type=item.item_type, id_user=cmd.message.author.id, id_server=cmd.guild.id, item_props=item_props) response = "You walk up to the official ~~SlimeCorp~~ Garden Gankers Milling Station and shove your irradiated produce into the hand-crank. You begin slowly churning them into a glorious, pastry goo. As the goo tosses and turns inside the machine, it solidifies, and after a few moments a {} pops out!".format( item.str_name) # market_data.donated_slimes += ewcfg.slimes_permill market_data.persist() bknd_item.item_delete(id_item=item_sought.get('id_item')) # user_data.change_slimes(n = -ewcfg.slimes_permill, source = ewcfg.source_spending) # user_data.slime_donations += ewcfg.slimes_permill user_data.persist() else: response = "You can only mill fresh vegetables! SlimeCorp obviously wants you to support local farmers." else: if item_search: # if they didn't forget to specify an item and it just wasn't found response = "You don't have one." else: response = "Mill which item? (check **!inventory**)" await fe_utils.send_message( cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
async def crush(cmd): member = cmd.message.author user_data = EwUser(member=member) response = "" # if it's not overwritten crush_slimes = ewcfg.crush_slimes command = "crush" if cmd.tokens[0] == (ewcfg.cmd_prefix + 'crunch'): command = "crunch" if user_data.life_state == ewcfg.life_state_corpse: response = "Alas, your ghostly form cannot {} anything. Lame.".format(command) return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) item_search = ewutils.flattenTokenListToString(cmd.tokens[1:]) item_sought = bknd_item.find_item(item_search=item_search, id_user=user_data.id_user, id_server=user_data.id_server) if item_sought: sought_id = item_sought.get('id_item') item_data = EwItem(id_item=sought_id) response = "The item doesn't have !{} functionality".format(command) # if it's not overwritten if item_data.item_props.get("id_item") == ewcfg.item_id_slimepoudrin: # delete a slime poudrin from the player's inventory bknd_item.item_delete(id_item=sought_id) levelup_response = user_data.change_slimes(n=crush_slimes, source=ewcfg.source_crush) user_data.persist() response = "You {} the hardened slime crystal with your bare teeth.\nYou gain {} slime. Sick, dude!!".format(command, crush_slimes) if len(levelup_response) > 0: response += "\n\n" + levelup_response elif item_data.item_props.get("id_item") == ewcfg.item_id_royaltypoudrin: # delete a royalty poudrin from the player's inventory bknd_item.item_delete(id_item=sought_id) crush_slimes = 5000 levelup_response = user_data.change_slimes(n=crush_slimes, source=ewcfg.source_crush) user_data.persist() response = "You {} your hard-earned slime crystal with your bare teeth.\nYou gain {} slime. Ah, the joy of writing!".format(command, crush_slimes) if len(levelup_response) > 0: response += "\n\n" + levelup_response elif item_data.item_props.get("id_food") in static_food.vegetable_to_cosmetic_material.keys(): bknd_item.item_delete(id_item=sought_id) crop_name = item_data.item_props.get('food_name') # Turn the crop into its proper cosmetic material item. cosmetic_material_id = static_food.vegetable_to_cosmetic_material[item_data.item_props.get("id_food")] new_item = static_items.item_map.get(cosmetic_material_id) new_item_type = ewcfg.it_item if new_item != None: new_name = new_item.str_name new_item_props = itm_utils.gen_item_props(new_item) else: ewutils.logMsg("ERROR: !crunch failed to retrieve proper cosmetic material for crop {}.".format(item_data.item_props.get("id_food"))) new_name = None new_item_props = None generated_item_id = bknd_item.item_create( item_type=new_item_type, id_user=cmd.message.author.id, id_server=cmd.guild.id, item_props=new_item_props ) response = "You {} your {} in your mouth and spit it out to create some {}!!".format(command, crop_name, new_name) elif item_data.item_props.get("id_food") in static_food.candy_ids_list: bknd_item.item_delete(id_item=sought_id) item_name = item_data.item_props.get('food_name') if float(getattr(item_data, "time_expir", 0)) < time.time(): response = "The {} melts disappointingly in your hand...".format(item_name) else: gristnum = random.randrange(2) + 1 gristcount = 0 response = "You crush the {} with an iron grip. You gain {} piece(s) of Double Halloween Grist!".format(item_name, gristnum) while gristcount < gristnum: grist = static_items.item_map.get(ewcfg.item_id_doublehalloweengrist) grist_props = itm_utils.gen_item_props(grist) bknd_item.item_create( item_type=grist.item_type, id_user=cmd.message.author.id, id_server=cmd.message.guild.id, item_props=grist_props ) gristcount += 1 elif item_data.item_props.get("id_item") == ewcfg.item_id_negapoudrin: # delete a negapoudrin from the player's inventory bknd_item.item_delete(id_item=sought_id) crush_slimes = -1000000 # kill player if they have less than 1 million slime if user_data.slimes < 1000000: user_data.die(cause=ewcfg.cause_suicide) # remove 1 million slime from the player else: levelup_response = user_data.change_slimes(n = crush_slimes, source = ewcfg.source_crush) user_data.persist() response = "You {} your hard-earned slime crystal with your bare teeth.\nAs the nerve endings in your teeth explode, you realize you bit into a negapoudrin! You writhe on the ground as slime gushes from all of your orifices.".format(command) if len(levelup_response) > 0: response += "\n\n" + levelup_response else: if item_search: # if they didnt forget to specify an item and it just wasn't found response = "You don't have one." else: response = "{} which item? (check **!inventory**)".format(command) # Send the response to the player. await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
async def revive(cmd, player_auto=None): time_now = int(time.time()) response = "" if cmd.message.channel.name != ewcfg.channel_endlesswar and cmd.message.channel.name != ewcfg.channel_sewers and player_auto is None: response = "Come to me. I hunger. #{}.".format(ewcfg.channel_sewers) else: if player_auto: player_data = EwUser(id_server=cmd.guild.id, id_user=player_auto) else: player_data = EwUser(member=cmd.message.author) # time_until_revive = (player_data.time_lastdeath + 600) - time_now time_until_revive = (player_data.time_lastdeath) - time_now if time_until_revive > 0 and player_auto is None: response = "ENDLESS WAR is not ready to {} you yet ({}s).".format( cmd.tokens[0], time_until_revive) return await fe_utils.send_message( cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) slimeoid = EwSlimeoid(member=cmd.message.author) if player_data.life_state == ewcfg.life_state_corpse: market_data = EwMarket(id_server=cmd.guild.id) # Endless War collects his fee. # fee = (player_data.slimecoin / 10) # player_data.change_slimecoin(n = -fee, coinsource = ewcfg.coinsource_revival) # market_data.slimes_revivefee += fee # player_data.busted = False # Preserve negaslime if player_data.slimes < 0: # market_data.negaslime += player_data.slimes player_data.change_slimes(n=-player_data.slimes) # set to 0 # reset slimelevel to zero player_data.slimelevel = 0 # Set time of last revive. This used to provied spawn protection, but currently isn't used. player_data.time_lastrevive = time_now if False: #player_data.degradation >= 100: player_data.life_state = ewcfg.life_state_shambler player_data.change_slimes(n=0.5 * ewcfg.slimes_shambler) player_data.trauma = "" poi_death = poi_static.id_to_poi.get(player_data.poi_death) if move_utils.inaccessible(poi=poi_death, user_data=player_data): player_data.poi = ewcfg.poi_id_endlesswar else: player_data.poi = poi_death.id_poi else: # Set life state. This is what determines whether the player is actually alive. player_data.life_state = ewcfg.life_state_juvenile # Give player some initial slimes. player_data.change_slimes(n=ewcfg.slimes_onrevive) # Get the player out of the sewers. player_data.poi = ewcfg.poi_id_endlesswar # Give newly spawned juvies a foul odour player_data.applyStatus(ewcfg.status_repelled_id) # Turn player's negaslimeoid into a core if they have one if slimeoid.sltype == ewcfg.sltype_nega: # Only create a negaslimeoid core if the negaslimeoid is fully conjured if slimeoid.life_state != ewcfg.slimeoid_state_forming: # Turn negaslimeoid into a negaslimeoid core item_props = { 'context': ewcfg.context_negaslimeoidheart, 'subcontext': slimeoid.id_slimeoid, 'item_name': "Core of {}".format(slimeoid.name), 'item_desc': "A smooth, inert rock. If you listen carefully you can hear otherworldly whispering." } bknd_item.item_create(id_user=ewcfg.channel_sewers, id_server=cmd.guild.id, item_type=ewcfg.it_item, item_props=item_props) # Kill the slimeoid and set player's active_slimeoid to -1 slimeoid.die() slimeoid.persist() player_data.active_slimeoid = -1 player_data.persist() market_data.persist() # Shower every district in the city with slime from the sewers. sewer_data = EwDistrict(district=ewcfg.poi_id_thesewers, id_server=cmd.guild.id) # the amount of slime showered is divided equally amongst the districts districts_amount = len(poi_static.capturable_districts) geyser_amount = int(0.5 * sewer_data.slimes / districts_amount) # Get a list of all the districts for poi in poi_static.capturable_districts: district_data = EwDistrict(district=poi, id_server=cmd.guild.id) district_data.change_slimes(n=geyser_amount) sewer_data.change_slimes(n=-1 * geyser_amount) district_data.persist() sewer_data.persist() sewer_inv = bknd_item.inventory(id_user=sewer_data.name, id_server=sewer_data.id_server) for item in sewer_inv: district = ewcfg.poi_id_slimesea if random.random() < 0.5: district = random.choice(poi_static.capturable_districts) bknd_item.give_item(id_item=item.get("id_item"), id_user=district, id_server=sewer_data.id_server) await ewrolemgr.updateRoles(client=cmd.client, member=cmd.message.author) response = '{slime4} Geysers of fresh slime erupt from every manhole in the city, showering their surrounding districts. {slime4} {name} has been reborn in slime. {slime4}'.format( slime4=ewcfg.emote_slime4, name=cmd.message.author.display_name) else: response = 'You\'re not dead just yet.' # deathreport = "You were {} by {}. {}".format(kill_descriptor, cmd.message.author.display_name, ewcfg.emote_slimeskull) # deathreport = "{} ".format(ewcfg.emote_slimeskull) + fe_utils.formatMessage(member, deathreport) if slimeoid.life_state == ewcfg.slimeoid_state_active and slimeoid.sltype != ewcfg.sltype_nega: reunite = "" brain = sl_static.brain_map.get(slimeoid.ai) reunite += brain.str_revive.format(slimeoid_name=slimeoid.name) new_poi = poi_static.id_to_poi.get(player_data.poi) revivechannel = fe_utils.get_channel(cmd.guild, new_poi.channel) reunite = fe_utils.formatMessage(cmd.message.author, reunite) await fe_utils.send_message(cmd.client, revivechannel, reunite) # Send the response to the player. await fe_utils.send_message( cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
async def order(cmd): user_data = EwUser(member=cmd.message.author) mutations = user_data.get_mutations() if user_data.life_state == ewcfg.life_state_shambler and user_data.poi != ewcfg.poi_id_nuclear_beach_edge: response = "You lack the higher brain functions required to {}.".format(cmd.tokens[0]) return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) market_data = EwMarket(id_server=cmd.guild.id) currency_used = 'slime' current_currency_amount = user_data.slimes # poi = ewmap.fetch_poi_if_coordless(cmd.message.channel.name) poi = poi_static.id_to_poi.get(user_data.poi) if poi is None or len(poi.vendors) == 0 or ewutils.channel_name_is_poi(cmd.message.channel.name) == False: # Only allowed in the food court. response = "There’s nothing to buy here. If you want to purchase some items, go to a sub-zone with a vendor in it, like the food court, the speakeasy, or the bazaar." else: poi = poi_static.id_to_poi.get(user_data.poi) district_data = EwDistrict(district=poi.id_poi, id_server=user_data.id_server) shambler_multiplier = 1 # for speakeasy during shambler times if district_data.is_degraded(): if poi.id_poi == ewcfg.poi_id_speakeasy: shambler_multiplier = 4 else: response = "{} has been degraded by shamblers. You can't {} here anymore.".format(poi.str_name, cmd.tokens[0]) return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) # value = ewutils.flattenTokenListToString(cmd.tokens[1:2]) # if cmd.tokens_count > 1: # value = cmd.tokens[1] # value = value.lower() value = None togo = False if cmd.tokens_count > 1: for token in cmd.tokens[1:]: if token.startswith('<@') == False and token.lower() not in "togo": # togo can be spelled together or separate value = token break for token in cmd.tokens[1:]: if token.lower() in "togo": # lets people get away with just typing only to or only go (or only t etc.) but whatever togo = True break # Finds the item if it's an EwGeneralItem. if value == "mylittleponyfigurine": value = random.choice(static_items.furniture_pony) item = static_items.item_map.get(value) item_type = ewcfg.it_item if item != None: item_id = item.id_item name = item.str_name # Finds the item if it's an EwFood item. if item == None: item = static_food.food_map.get(value) item_type = ewcfg.it_food if item != None: item_id = item.id_food name = item.str_name # Finds the item if it's an EwCosmeticItem. if item == None: item = static_cosmetics.cosmetic_map.get(value) item_type = ewcfg.it_cosmetic if item != None: item_id = item.id_cosmetic name = item.str_name if item == None: item = static_items.furniture_map.get(value) item_type = ewcfg.it_furniture if item != None: item_id = item.id_furniture name = item.str_name if item_id in static_items.furniture_pony: item.vendors = [ewcfg.vendor_bazaar] if item == None: item = static_weapons.weapon_map.get(value) item_type = ewcfg.it_weapon if item != None: item_id = item.id_weapon name = item.str_weapon if item == None: item = static_relic.relic_map.get(value) item_type = ewcfg.it_relic if item != None and relic_utils.canCreateRelic(item.id_relic, cmd.guild.id): item_id = item.id_relic name = item.str_name elif item != None: item = None if item != None: item_type = item.item_type # Gets a vendor that the item is available and the player currently located in try: current_vendor = (set(item.vendors).intersection(set(poi.vendors))).pop() except: current_vendor = None # Check if the item is available in the current bazaar item rotation if current_vendor == ewcfg.vendor_bazaar: if item_id not in market_data.bazaar_wares.values(): if item_id in static_items.furniture_pony and "mylittleponyfigurine" in market_data.bazaar_wares.values(): pass else: current_vendor = None if current_vendor is None or len(current_vendor) < 1: response = "Check the {} for a list of items you can {}.".format(ewcfg.cmd_menu, ewcfg.cmd_order) else: response = "" value = item.price premium_purchase = True if item_id in ewcfg.premium_items else False if premium_purchase: togo = True # Just in case they order a premium food item, don't make them eat it right then and there. if ewcfg.cd_premium_purchase > (int(time.time()) - user_data.time_lastpremiumpurchase): response = "That item is in very limited stock! The vendor asks that you refrain from purchasing it for a day or two." return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) elif ewcfg.cd_new_player > (int(time.time()) - user_data.time_joined): response = "You've only been in the city for a few days. The vendor doesn't trust you with that item very much..." return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) stock_data = None company_data = None # factor in the current stocks for vendor in item.vendors: if vendor in ewcfg.vendor_stock_map: stock = ewcfg.vendor_stock_map.get(vendor) company_data = EwCompany(id_server=user_data.id_server, stock=stock) stock_data = EwStock(id_server=user_data.id_server, stock=stock) if stock_data is not None: value *= (stock_data.exchange_rate / ewcfg.default_stock_exchange_rate) ** 0.2 controlling_faction = poi_utils.get_subzone_controlling_faction(user_data.poi, user_data.id_server) if controlling_faction != "": # prices are halved for the controlling gang if controlling_faction == user_data.faction: value /= 2 # and 4 times as much for enemy gangsters elif user_data.faction != "": value *= 4 # raise shambled speakeasy price 4 times value *= shambler_multiplier # Raise the price for togo ordering. This gets lowered back down later if someone does togo ordering on a non-food item by mistake. if togo: value *= 1.5 if current_vendor == ewcfg.vendor_breakroom and user_data.faction == ewcfg.faction_slimecorp: value = 0 value = int(value) food_ordered = False target_data = None # Kingpins eat free. if (user_data.life_state == ewcfg.life_state_kingpin or user_data.life_state == ewcfg.life_state_grandfoe) and item_type == ewcfg.it_food: value = 0 if value > current_currency_amount: # Not enough money. response = "A {} costs {:,} {}, and you only have {:,}.".format(name, value, currency_used, current_currency_amount) else: mutations = user_data.get_mutations() if random.randrange(5) == 0 and ewcfg.mutation_id_stickyfingers in mutations: value = 0 user_data.change_crime(n=ewcfg.cr_larceny_points) inv_response = bknd_item.check_inv_capacity(user_data=user_data, item_type=item_type, return_strings=True, pronoun="You") if inv_response != "" and (item_type != ewcfg.it_food or togo): return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, inv_response)) if item_type == ewcfg.it_food: food_ordered = True target = None target_data = None if not togo: # cant order togo for someone else, you can just give it to them in person if cmd.mentions_count == 1: target = cmd.mentions[0] if target.id == cmd.message.author.id: target = None if target != None: target_data = EwUser(member=target) if target_data.life_state == ewcfg.life_state_corpse and target_data.get_possession(): response = "How are you planning to feed them while they're possessing you?" return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) elif target_data.poi != user_data.poi: response = "You can't order anything for them because they aren't here!" return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) elif item_type == ewcfg.it_weapon: if user_data.life_state == ewcfg.life_state_corpse: response = "Ghosts can't hold weapons." return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) item_props = itm_utils.gen_item_props(item) # Only food should have the value multiplied. If someone togo orders a non-food item by mistake, lower it back down. if not food_ordered and togo: value = int(value / 1.5) if currency_used == 'slime': user_data.change_slimes(n=-value, source=ewcfg.source_spending) if company_data is not None: company_data.recent_profits += value company_data.persist() if item.str_name == "arcade cabinet": item_props['furniture_desc'] = random.choice(ewcfg.cabinets_list) elif item.item_type == ewcfg.it_furniture: if "custom" in item_props.get('id_furniture'): if cmd.tokens_count < 4 or cmd.tokens[2] == "" or cmd.tokens[3] == "": response = "You need to specify the customization text before buying a custom item. Come on, isn't that self-evident? (!order [custom item] \"custom name\" \"custom description\")" return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) else: customname = cmd.tokens[2] if len(customname) > 32: response = "That name is too long. ({:,}/32)".format(len(customname)) return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) customdesc = cmd.tokens[3] if len(customdesc) > 500: response = "That description is too long. ({:,}/500)".format(len(customdesc)) return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) name = item_props['furniture_name'] = item_props['furniture_name'].format(custom=customname) item_props['furniture_desc'] = customdesc item_props['furniture_look_desc'] = item_props['furniture_look_desc'].format(custom=customname) item_props['furniture_place_desc'] = item_props['furniture_place_desc'].format(custom=customname) id_item = bknd_item.item_create( item_type=item_type, id_user=cmd.message.author.id, id_server=cmd.guild.id, stack_max=-1, stack_size=0, item_props=item_props ) if value == 0: response = "You swipe a {} from the counter at {}.".format(name, current_vendor) else: response = "You slam {:,} {} down on the counter at {} for {}.".format(value, currency_used, current_vendor, name) if food_ordered and not togo: item_data = EwItem(id_item=id_item) # Eat food on the spot! if target_data != None: target_player_data = EwPlayer(id_user=target_data.id_user) if value == 0: response = "You swipe a {} from the counter at {} and give it to {}.".format(name, current_vendor, target_player_data.display_name) else: response = "You slam {:,} slime down on the counter at {} for {} and give it to {}.".format(value, current_vendor, name, target_player_data.display_name) response += "\n\n*{}*: ".format(target_player_data.display_name) + target_data.eat(item_data) target_data.persist() else: if value == 0: response = "You swipe a {} from the counter at {} and eat it right on the spot.".format(name, current_vendor) else: response = "You slam {:,} slime down on the counter at {} for {} and eat it right on the spot.".format(value, current_vendor, name) user_player_data = EwPlayer(id_user=user_data.id_user) response += "\n\n*{}*: ".format(user_player_data.display_name) + user_data.eat(item_data) user_data.persist() if premium_purchase: user_data.time_lastpremiumpurchase = int(time.time()) user_data.persist() else: response = "Check the {} for a list of items you can {}.".format(ewcfg.cmd_menu, ewcfg.cmd_order) # Send the response to the player. await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
async def publish_manuscript(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 fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) market_data = EwMarket(id_server=user_data.id_server) poi = poi_static.id_to_poi.get(user_data.poi) if not poi.write_manuscript: response = "You'd love to work on your zine, however your current location doesn't strike you as a particularly good place to write. Try heading over the the Cafe, the Comic Shop, or one of the colleges (NLACU/NMS)." elif user_data.manuscript == -1: response = "You have yet to create a manuscript. Try !createmanuscript" else: book = EwBook(member=cmd.message.author, book_state=0) # check if zine is unreasonably short length = 0 for page in book.book_pages.keys(): length += len(book.book_pages[page]) if book.genre == -1: response = "Before you publish your zine, you must first set a genre with !setgenre. The genre choices are {}.".format(ewutils.formatNiceList(ewcfg.book_genres)) elif len(book.book_pages.keys()) < 3 or length < 10: response = "Who are you trying to fool? This zine is obviously too short!" else: accepted = False response = "Are you sure you want to publish your manuscript? This cannot be undone. **!accept** or **!refuse**" await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) try: message = await cmd.client.wait_for('message', timeout=20, check=lambda message: message.author == cmd.message.author and message.content.lower() in [ewcfg.cmd_accept, ewcfg.cmd_refuse]) if message != None: if message.content.lower() == ewcfg.cmd_accept: accepted = True if message.content.lower() == ewcfg.cmd_refuse: accepted = False except: accepted = False if not accepted: response = "The manuscript was not published." else: book.book_state = 1 book.date_published = market_data.day length = 0 for page in range(1, book.pages + 1): length += len(book.book_pages.get(page, "")) book.length = length user_data.manuscript = -1 user_data.persist() book.persist() bknd_item.item_create( item_type=ewcfg.it_book, id_user=user_data.id_user, id_server=book.id_server, item_props={ "title": book.title, "author": book.author, "date_published": book.date_published, "id_book": book.id_book, "book_desc": "A zine by {}, published on {}. It's the author's copy.".format(book.author, book.date_published) }) book_sale = EwBookSale(id_book=book.id_book, member=cmd.message.author) book_sale.bought = 1 book_sale.persist() response = "You've published your manuscript! Anybody can now buy your creation and you'll get royalties!" await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))