async def clear_mutations(cmd): user_data = EwUser(member = cmd.message.author) market_data = EwMarket(id_server = user_data.id_server) response = "" if cmd.message.channel.name != ewcfg.channel_slimeoidlab: response = "You require the advanced equipment at the Slimeoid Lab to modify your mutations." return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) if user_data.life_state == ewcfg.life_state_corpse: response = "How do you expect to mutate without exposure to slime, dumbass?" return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) mutations = user_data.get_mutations() if len(mutations) == 0: response = "You have not developed any specialized mutations yet." return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) poudrin = ewitem.find_item(item_search = "slimepoudrin", id_user = cmd.message.author.id, id_server = cmd.message.server.id if cmd.message.server is not None else None, item_type_filter = ewcfg.it_item) if poudrin == None: response = "You need a slime poudrin to replace a mutation." return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) else: ewitem.item_delete(id_item = poudrin.get('id_item')) # Remove Poudrins market_data.donated_poudrins += 1 market_data.persist() user_data.poudrin_donations += 1 user_data.persist() user_data.clear_mutations() response = "After several minutes long elevator descents, in the depths of some basement level far below the laboratory's lobby, you lay down on a reclined medical chair. A SlimeCorp employee finishes the novel length terms of service they were reciting and asks you if you have any questions. You weren’t listening so you just tell them to get on with it so you can go back to getting slime. They oblige.\nThey grab a random used syringe with just a dash of black serum still left inside it. They carefully stab you with it, injecting the mystery formula into your bloodstream. Almost immediately, normalcy returns to your inherently abnormal life… your body returns to whatever might be considered normal for your species. You hand off one of your hard-earned poudrins to the SlimeCorp employee for their troubles." return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def reroll_last_mutation(cmd): last_mutation_counter = -1 last_mutation = "" user_data = EwUser(member = cmd.message.author) market_data = EwMarket(id_server = user_data.id_server) response = "" if cmd.message.channel.name != ewcfg.channel_slimeoidlab: response = "You require the advanced equipment at the Slimeoid Lab to modify your mutations." return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) if user_data.life_state == ewcfg.life_state_corpse: response = "How do you expect to mutate without exposure to slime, dumbass?" return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) mutations = user_data.get_mutations() if len(mutations) == 0: response = "You have not developed any specialized mutations yet." return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) for id_mutation in mutations: mutation_data = EwMutation(id_server = user_data.id_server, id_user = user_data.id_user, id_mutation = id_mutation) if mutation_data.mutation_counter > last_mutation_counter: last_mutation_counter = mutation_data.mutation_counter last_mutation = id_mutation reroll_fatigue = EwStatusEffect(id_status = ewcfg.status_rerollfatigue_id, user_data = user_data) poudrins_needed = 2 ** int(reroll_fatigue.value) poudrins = ewitem.find_item_all(item_search = ewcfg.item_id_slimepoudrin, id_user = cmd.message.author.id, id_server = cmd.message.server.id if cmd.message.server is not None else None, item_type_filter = ewcfg.it_item) poudrins_have = len(poudrins) if poudrins_have < poudrins_needed: response = "You need {} slime poudrin{} to replace a mutation, but you only have {}.".format(poudrins_needed, "" if poudrins_needed == 1 else "s", poudrins_have) return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) else: for delete in range(poudrins_needed): ewitem.item_delete(id_item = poudrins.pop(0).get('id_item')) # Remove Poudrins market_data.donated_poudrins += poudrins_needed market_data.persist() user_data.poudrin_donations += poudrins_needed user_data.persist() reroll_fatigue.value = int(reroll_fatigue.value) + 1 reroll_fatigue.persist() mutation_data = EwMutation(id_server = user_data.id_server, id_user = user_data.id_user, id_mutation = last_mutation) new_mutation = random.choice(list(ewcfg.mutation_ids)) while new_mutation in mutations: new_mutation = random.choice(list(ewcfg.mutation_ids)) mutation_data.id_mutation = new_mutation mutation_data.time_lastuse = int(time.time()) mutation_data.persist() response = "After several minutes long elevator descents, in the depths of some basement level far below the laboratory's lobby, you lay down on a reclined medical chair. A SlimeCorp employee finishes the novel length terms of service they were reciting and asks you if you have any questions. You weren’t listening so you just tell them to get on with it so you can go back to getting slime. They oblige.\nThey grab a butterfly needle and carefully stab you with it, draining some strangely colored slime from your bloodstream. Almost immediately, the effects of your last mutation fade away… but, this feeling of respite is fleeting. The SlimeCorp employee writes down a few notes, files away the freshly drawn sample, and soon enough you are stabbed with syringes. This time, it’s already filled with some bizarre, multi-colored serum you’ve never seen before. The effects are instantaneous. {}\nYou hand off {} of your hard-earned poudrins to the SlimeCorp employee for their troubles.".format(ewcfg.mutations_map[new_mutation].str_acquire, poudrins_needed) return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def post_leaderboards(client = None, server = None): leaderboard_channel = ewutils.get_channel(server = server, channel_name = ewcfg.channel_leaderboard) market = EwMarket(id_server = server.id) time = "day {}".format(market.day) await ewutils.send_message(client, leaderboard_channel, "▓▓{} **STATE OF THE CITY:** {} {}▓▓".format(ewcfg.emote_theeye, time, ewcfg.emote_theeye)) kingpins = make_kingpin_board(server = server, title = ewcfg.leaderboard_kingpins) await ewutils.send_message(client, leaderboard_channel, kingpins) districts = make_district_control_board(id_server = server.id, title = ewcfg.leaderboard_districts) await ewutils.send_message(client, leaderboard_channel, districts) topslimes = make_userdata_board(server = server, category = ewcfg.col_slimes, title = ewcfg.leaderboard_slimes) await ewutils.send_message(client, leaderboard_channel, topslimes) topcoins = make_userdata_board(server = server, category = ewcfg.col_slimecoin, title = ewcfg.leaderboard_slimecoin) await ewutils.send_message(client, leaderboard_channel, topcoins) topghosts = make_userdata_board(server = server, category = ewcfg.col_slimes, title = ewcfg.leaderboard_ghosts, lowscores = True, rows = 3) await ewutils.send_message(client, leaderboard_channel, topghosts) topbounty = make_userdata_board(server = server, category = ewcfg.col_bounty, title = ewcfg.leaderboard_bounty, divide_by = ewcfg.slimecoin_exchangerate) await ewutils.send_message(client, leaderboard_channel, topbounty) topdonated = make_userdata_board(server = server, category = ewcfg.col_splattered_slimes, title = ewcfg.leaderboard_donated) await ewutils.send_message(client, leaderboard_channel, topdonated) topslimeoids = make_slimeoids_top_board(server = server) await ewutils.send_message(client, leaderboard_channel, topslimeoids) topfestivity = make_slimernalia_board(server = server, title = ewcfg.leaderboard_slimernalia) await ewutils.send_message(client, leaderboard_channel, topfestivity) topzines = make_zines_top_board(server=server) await ewutils.send_message(client, leaderboard_channel, topzines)
def check_fursuit_active(id_server): market_data = EwMarket(id_server=id_server) if (market_data.day % 31 == 0 and market_data.clock >= 20 or market_data.day % 31 == 1 and market_data.clock < 6): return True else: return False
def weather_txt(id_server): response = "" market_data = EwMarket(id_server=id_server) time_current = market_data.clock displaytime = str(time_current) ampm = '' if time_current <= 12: ampm = 'AM' if time_current > 12: displaytime = str(time_current - 12) ampm = 'PM' if time_current == 0: displaytime = 'midnight' ampm = '' if time_current == 12: displaytime = 'high noon' ampm = '' flair = '' weather_data = ewcfg.weather_map.get(market_data.weather) if weather_data != None: if time_current >= 6 and time_current <= 7: flair = weather_data.str_sunrise if time_current >= 8 and time_current <= 17: flair = weather_data.str_day if time_current >= 18 and time_current <= 19: flair = weather_data.str_sunset if time_current >= 20 or time_current <= 5: flair = weather_data.str_night response += "It is currently {}{} in NLACakaNM.{}".format( displaytime, ampm, (' ' + flair)) return response
async def negaslime(cmd): # Add persisted negative slime. market_data = EwMarket(id_server=cmd.message.server.id) negaslime = market_data.negaslime await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage( cmd.message.author, "The dead have amassed {:,} negative slime.".format(negaslime)))
async def negapool(cmd): # Add persisted negative slime. market_data = EwMarket(id_server=cmd.message.server.id) negaslime = market_data.negaslime await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage( cmd.message.author, "The dead have a total of {:,} negative slime at their disposal for summoning." .format(negaslime)))
async def spawn_enemies(id_server = None): if random.randrange(3) == 0: weathertype = ewcfg.enemy_weathertype_normal market_data = EwMarket(id_server=id_server) # If it's raining, an enemy has 1/3 chance to spawn as a bicarbonate enemy, which doesn't take rain damage if market_data.weather == ewcfg.weather_bicarbonaterain: if random.randrange(2) == 0: weathertype = ewcfg.enemy_weathertype_rainresist resp_cont = ewhunting.spawn_enemy(id_server=id_server, weather=weathertype) await resp_cont.post()
async def flutter(cmd): user_data = EwUser(member = cmd.message.author) if user_data.race == ewcfg.races["avian"]: district_data = EwDistrict(district = user_data.poi, id_server = cmd.guild.id) market_data = EwMarket(id_server=cmd.guild.id) response = "You flap your wings in an attempt to fly, but " excuses = [] if market_data.weather == ewcfg.weather_lightning: excuses.append("the current weather would make that a bit dangerous, so you decide not to.") if ewcfg.mutation_id_bigbones in user_data.get_mutations(): excuses.append("your bones are too big for you to get off the ground.") if ewcfg.mutation_id_lightasafeather in user_data.get_mutations(): excuses.append("your wings are too skinny to generate enough lift.") if 6 <= market_data.clock >= 20: excuses.append("it's not safe to fly at night, so you decide not to.") else: excuses.append("flying in plain daylight might get you shot off the sky, so you decide not to.") if user_data.slimes > 1000000: excuses.append("you have too much slime on you, so you don't even get off the ground.") else: excuses.append("you're too weak for this right now, gonna need to get more slime.") if user_data.life_state == ewcfg.life_state_corpse: excuses.append("your incorporeal wings generate no lift.") elif user_data.life_state == ewcfg.life_state_juvenile: excuses.append("you lack the moral fiber to do so.") else: if user_data.faction == ewcfg.faction_boober: excuses.append("you end up thrashing with your wings in an unorganized fashion.") if user_data.faction == ewcfg.faction_milkers: excuses.append("you end up doing rapid dabs instead.") if len(district_data.get_players_in_district()) > 1: excuses.append("it's embarassing to do so with other people around.") else: excuses.append("you can't be bothered if there's no one here to see you do it.") if user_data.hunger / user_data.get_hunger_max() < 0.5: excuses.append("you're too hungry, and end up looking for worms instead.") else: excuses.append("you're too full from your last meal for such vigorous exercise.") response += random.choice(excuses) else: response = "You people are not allowed to do that." return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def fursuit(cmd): user_data = EwUser(member=cmd.message.author) mutations = user_data.get_mutations() market_data = EwMarket(id_server=cmd.message.server.id) if ewcfg.mutation_id_organicfursuit in mutations: days_until = -market_data.day % 31 response = "With a basic hairy palm reading, you determine that you'll be particularly powerful in {} day{}.".format( days_until, "s" if days_until is not 1 else "") else: response = "You're about as hairless as an egg, my friend." await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
def get_move_speed(user_data): time_now = int(time.time()) mutations = user_data.get_mutations() market_data = EwMarket(id_server = user_data.id_server) move_speed = 1 if ewcfg.mutation_id_organicfursuit in mutations and check_fursuit_active(user_data.id_server): move_speed *= 2 if ewcfg.mutation_id_lightasafeather in mutations and market_data.weather == "windy": move_speed *= 2 if ewcfg.mutation_id_fastmetabolism in mutations and user_data.hunger / user_data.get_hunger_max() < 0.4: move_speed *= 1.33 if user_data.time_expirpvp >= time_now: move_speed = 0.5 # Reduces movement speed to half standard movement speed, even if you have mutations that speed it up. return move_speed
async def cast(cmd): time_now = round(time.time()) has_reeled = False user_data = EwUser(member = cmd.message.author) market_data = EwMarket(id_server = cmd.message.author.server.id) statuses = user_data.getStatusEffects() if cmd.message.author.id not in fishers.keys(): fishers[cmd.message.author.id] = EwFisher() fisher = fishers[cmd.message.author.id] # Ghosts cannot fish. if user_data.life_state == ewcfg.life_state_corpse: response = "You can't fish while you're dead. Try {}.".format(ewcfg.cmd_revive) # Players who are already cast a line cannot cast another one. elif fisher.fishing == True: response = "You've already cast a line." # Only fish at The Pier elif cmd.message.channel.name in [ewcfg.channel_tt_pier, ewcfg.channel_jp_pier, ewcfg.channel_cl_pier, ewcfg.channel_afb_pier, ewcfg.channel_vc_pier, ewcfg.channel_se_pier, ewcfg.channel_ferry]: if user_data.hunger >= ewutils.hunger_max_bylevel(user_data.slimelevel): response = "You're too hungry to fish right now." else: has_fishingrod = False if user_data.weapon >= 0: weapon_item = EwItem(id_item = user_data.weapon) weapon = ewcfg.weapon_map.get(weapon_item.item_props.get("weapon_type")) if weapon.id_weapon == "fishingrod": has_fishingrod = True if ewcfg.status_high_id in statuses: fisher.high = True fisher.current_fish = gen_fish(market_data, cmd, has_fishingrod) fisher.fishing = True fisher.bait = False fisher.pier = user_data.poi item_search = ewutils.flattenTokenListToString(cmd.tokens[1:]) author = cmd.message.author server = cmd.message.server item_sought = ewitem.find_item(item_search = item_search, id_user = author.id, id_server = server.id) if item_sought: item = EwItem(id_item = item_sought.get('id_item')) if item.item_type == ewcfg.it_food: str_name = item.item_props['food_name'] id_food = item.item_props.get('id_food') fisher.bait = True if id_food in ewcfg.plebe_bait: fisher.current_fish = "plebefish" elif id_food == "doublestuffedcrust": if random.randrange(5) == 3: fisher.current_fish = "doublestuffedflounder" elif id_food in ["chickenbucket", "familymeal"]: if random.randrange(5) == 3: fisher.current_fish = "seacolonel" elif id_food in ["steakvolcanoquesomachorito", "nachosupreme"]: if random.randrange(5) == 3: fisher.current_fish = "marlinsupreme" elif id_food in ["blacklimes", "blacklimesour"]: if random.randrange(2) == 1: fisher.current_fish = "blacklimesalmon" elif id_food in ["pinkrowddishes", "pinkrowdatouille"]: if random.randrange(2) == 1: fisher.current_fish = "thrash" elif id_food in ["purplekilliflowercrustpizza", "purplekilliflower"]: if random.randrange(2) == 1: fisher.current_fish = "dab" elif id_food == "kingpincrab": if random.randrange(5) == 1: fisher.current_fish = "uncookedkingpincrab" elif float(item.time_expir if item.time_expir is not None else 0) < time.time(): if random.randrange(2) == 1: fisher.current_fish = "plebefish" ewitem.item_delete(item_sought.get('id_item')) if fisher.current_fish == "item": fisher.current_size = "item" else: fisher.current_size = gen_fish_size(has_fishingrod) if fisher.bait == False: response = "You cast your fishing line into the " else: response = "You attach your {} to the hook as bait and then cast your fishing line into the ".format(str_name) if cmd.message.channel.name in [ewcfg.channel_afb_pier, ewcfg.channel_vc_pier, ewcfg.channel_se_pier, ewcfg.channel_ferry]: response += "vast Slime Sea." else: response += "glowing Slime Lake." user_data.hunger += ewcfg.hunger_perfish * ewutils.hunger_cost_mod(user_data.slimelevel) user_data.persist() await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) bite_text = gen_bite_text(fisher.current_size) # User has a 1/10 chance to get a bite fun = 100 if fisher.bait == True: # Bait attatched, user has a 1/7 chance to get a bite fun = 70 bun = 0 while not ewutils.TERMINATE: if fun <= 0: fun = 1 else: damp = random.randrange(fun) if not fisher.high: await asyncio.sleep(60) else: await asyncio.sleep(30) user_data = EwUser(member=cmd.message.author) if user_data.poi != fisher.pier: fisher.fishing = False return if user_data.life_state == ewcfg.life_state_corpse: fisher.fishing = False return if fisher.fishing == False: return if damp > 10: await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, random.choice(ewcfg.nobite_text))) fun -= 2 bun += 1 if bun >= 5: fun -= 1 if bun >= 15: fun -= 1 continue else: break fisher.bite = True await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, bite_text)) await asyncio.sleep(8) if fisher.bite != False: fisher.fishing = False fisher.bite = False fisher.current_fish = "" fisher.current_size = "" fisher.bait = False return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, "The fish got away...")) else: has_reeled = True else: response = "You can't fish here. Go to a pier." # Don't send out a response if the user actually reeled in a fish, since that gets sent by the reel command instead. if has_reeled == False: await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def embiggen(cmd): user_data = EwUser(member = cmd.message.author) market_data = EwMarket(id_server = user_data.id_server) item_search = ewutils.flattenTokenListToString(cmd.tokens[1:]) item_sought = ewitem.find_item(item_search = item_search, id_user = cmd.message.author.id, id_server = cmd.message.server.id if cmd.message.server is not None else None) if cmd.message.channel.name != ewcfg.channel_slimeoidlab: response = "How are you going to embiggen your fish on the side of the street? You’ve got to see a professional for this, man. Head to the SlimeCorp Laboratory, they’ve got dozens of modern day magic potions ‘n shit over there." elif item_sought: name = item_sought.get('name') fish = EwItem(id_item = item_sought.get('id_item')) acquisition = fish.item_props.get('acquisition') if acquisition != ewcfg.acquisition_fishing: response = "You can only embiggen fishes, dummy. Otherwise everyone would be walking around with colossal nunchucks and huge chicken buckets. Actually, that gives me an idea..." else: size = fish.item_props.get('size') poudrin_cost = 0 if size == ewcfg.fish_size_miniscule: poudrin_cost = 2 if size == ewcfg.fish_size_small: poudrin_cost = 4 if size == ewcfg.fish_size_average: poudrin_cost = 8 if size == ewcfg.fish_size_big: poudrin_cost = 16 if size == ewcfg.fish_size_huge: poudrin_cost = 32 poudrins_owned = ewitem.find_item_all(item_search = "slimepoudrin", id_user = user_data.id_user, id_server = user_data.id_server) poudrin_amount = len(poudrins_owned) if poudrin_cost == 0: response = "Your {} is already as colossal as a fish can get!".format(name) elif poudrin_amount < poudrin_cost: response = "You need {} poudrins to embiggen your {}, but you only have {}!!".format(poudrin_cost, name, poudrin_amount) else: if size == ewcfg.fish_size_miniscule: fish.item_props['size'] = ewcfg.fish_size_small if size == ewcfg.fish_size_small: fish.item_props['size'] = ewcfg.fish_size_average if size == ewcfg.fish_size_average: fish.item_props['size'] = ewcfg.fish_size_big if size == ewcfg.fish_size_big: fish.item_props['size'] = ewcfg.fish_size_huge if size == ewcfg.fish_size_huge: fish.item_props['size'] = ewcfg.fish_size_colossal fish.persist() for delete in range(poudrin_cost): poudrin = poudrins_owned.pop() ewitem.item_delete(id_item = poudrin.get("id_item")) market_data.donated_poudrins += poudrin_cost market_data.persist() user_data.poudrin_donations += poudrin_cost user_data.persist() response = "After several minutes long elevator descents, in the depths of some basement level far below the laboratory's lobby, you lay down your {} on a reclined medical chair. A SlimeCorp employee finishes the novel length terms of service they were reciting and asks you if you have any questions. You weren’t listening so you just tell them to get on with it so you can go back to haggling prices with Captain Albert Alexander. They oblige.\nThey grab a butterfly needle and carefully stab your fish with it, injecting filled with some bizarre, multi-colored serum you’ve never seen before. Sick, it’s bigger now!!".format(name) 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 = "Embiggen which fish? (check **!inventory**)" await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def order(cmd): user_data = EwUser(member=cmd.message.author) 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 ewutils.send_message( cmd.client, cmd.message.channel, ewutils.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 = ewcfg.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 = ewcfg.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( ) and poi.id_poi != ewcfg.poi_id_nuclear_beach_edge: 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 ewutils.send_message( cmd.client, cmd.message.channel, ewutils.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(ewcfg.furniture_pony) item = ewcfg.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 = ewcfg.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 = ewcfg.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 = ewcfg.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 ewcfg.furniture_pony: item.vendors = [ewcfg.vendor_bazaar] if item == None: item = ewcfg.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_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 ewcfg.furniture_pony and "mylittleponyfigurine" in market_data.bazaar_wares.values( ): pass else: current_vendor = None if current_vendor == ewcfg.vendor_downpourlaboratory: currency_used = 'brainz' current_currency_amount = user_data.gvs_currency 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 ewutils.send_message( cmd.client, cmd.message.channel, ewutils.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 ewutils.send_message( cmd.client, cmd.message.channel, ewutils.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 = ewutils.get_subzone_controlling_faction( user_data.poi, user_data.id_server) if controlling_faction != "" and poi.id_poi != ewcfg.poi_id_nuclear_beach_edge: # 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: if item_type == ewcfg.it_food: food_ordered = True food_items = ewitem.inventory( id_user=cmd.message.author.id, id_server=cmd.guild.id, item_type_filter=ewcfg.it_food) 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 ewutils.send_message( cmd.client, cmd.message.channel, ewutils.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 ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage( cmd.message.author, response)) if len(food_items) >= user_data.get_food_capacity( ) and target_data == None and togo: # user_data never got persisted so the player won't lose money unnecessarily response = "You can't carry any more food than that." return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) elif item_type == ewcfg.it_weapon: weapons_held = ewitem.inventory( id_user=user_data.id_user, id_server=cmd.guild.id, item_type_filter=ewcfg.it_weapon) has_weapon = False # Thrown weapons are stackable if ewcfg.weapon_class_thrown in item.classes: # Check the player's inventory for the weapon and add amount to stack size. Create a new item the max stack size has been reached for wep in weapons_held: weapon = EwItem(id_item=wep.get("id_item")) if weapon.item_props.get( "weapon_type" ) == item.id_weapon and weapon.stack_size < weapon.stack_max: has_weapon = True weapon.stack_size += 1 weapon.persist() if value == 0: response = "You swipe a {} from the counter at {}.".format( item.str_weapon, current_vendor) else: response = "You slam {:,} slime down on the counter at {} for {}.".format( value, current_vendor, item.str_weapon) user_data.change_slimes( n=-value, source=ewcfg.source_spending) user_data.persist() return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage( cmd.message.author, response)) if has_weapon == False: if len(weapons_held ) >= user_data.get_weapon_capacity(): response = "You can't carry any more weapons." return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage( cmd.message.author, response)) elif user_data.life_state == ewcfg.life_state_corpse: response = "Ghosts can't hold weapons." return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage( cmd.message.author, response)) item_props = ewitem.gen_item_props(item) customtext = cmd.message.content[(len(cmd.tokens[0]) + len(cmd.tokens[1]) + 2):] if item.item_type == ewcfg.it_furniture and "custom" in item_props.get( 'id_furniture'): if customtext == "": response = "You need to specify the customization text before buying a custom item. Come on, isn't that self-evident?" return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) # 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) elif currency_used == 'brainz': user_data.gvs_currency -= value 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'): item_props['furniture_name'] = item_props[ 'furniture_name'].format(custom=customtext) item_props['furniture_desc'] = item_props[ 'furniture_desc'].format(custom=customtext) item_props['furniture_look_desc'] = item_props[ 'furniture_look_desc'].format( custom=customtext) item_props['furniture_place_desc'] = item_props[ 'furniture_place_desc'].format( custom=customtext) item.str_name = item.str_name.format( custom=customtext) id_item = ewitem.item_create( item_type=item_type, id_user=cmd.message.author.id, id_server=cmd.guild.id, stack_max=20 if item_type == ewcfg.it_weapon and ewcfg.weapon_class_thrown in item.classes else -1, stack_size=1 if item_type == ewcfg.it_weapon and ewcfg.weapon_class_thrown in item.classes else 0, item_props=item_props) if value == 0: response = "You swipe a {} from the counter at {}.".format( item.str_name, current_vendor) else: response = "You slam {:,} {} down on the counter at {} for {}.".format( value, currency_used, current_vendor, item.str_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( item.str_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, item.str_name, target_player_data.display_name) response += "\n\n*{}*: ".format( target_player_data.display_name ) + target_data.eat(item_data) target_data.persist() asyncio.ensure_future( ewutils.decrease_food_multiplier( user_data.id_user)) else: if value == 0: response = "You swipe a {} from the counter at {} and eat it right on the spot.".format( item.str_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, item.str_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() asyncio.ensure_future( ewutils.decrease_food_multiplier( user_data.id_user)) 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 ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def mill(cmd): user_data = EwUser(member=cmd.message.author) market_data = EwMarket(id_server=user_data.id_server) item_search = ewutils.flattenTokenListToString(cmd.tokens[1:]) item_sought = ewitem.find_item(item_search=item_search, id_user=cmd.message.author.id, id_server=cmd.message.server.id if cmd.message.server is not None else None) # 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 user_data.poi not in [ ewcfg.poi_id_jr_farms, ewcfg.poi_id_og_farms, ewcfg.poi_id_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: items = [] vegetable = EwItem(id_item=item_sought.get('id_item')) for result in ewcfg.mill_results: if result.ingredients != vegetable.item_props.get('id_food'): pass else: items.append(result) if len(items) > 0: item = random.choice(items) item_props = ewitem.gen_item_props(item) ewitem.item_create(item_type=item.item_type, id_user=cmd.message.author.id, id_server=cmd.message.server.id, item_props=item_props) response = "You walk up to the official SlimeCorp Milling Station and shove your irradiated produce into the hand-crank. You painfully grip the needle-covered crank handle, dripping {} slime into a small compartment on the device’s side which supposedly fuels it. 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( ewcfg.slimes_permill, item.str_name) market_data.donated_slimes += ewcfg.slimes_permill market_data.persist() ewitem.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 ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def weather_tick(id_server=None): if id_server != None: try: market_data = EwMarket(id_server=id_server) if market_data.weather == ewcfg.weather_sunny: exposed_pois = [] exposed_pois.extend(ewcfg.capturable_districts) exposed_pois.extend(ewcfg.outskirts) exposed_pois = tuple(exposed_pois) users = ewutils.execute_sql_query( "SELECT id_user FROM users WHERE id_server = %s AND {poi} IN %s AND {life_state} > 0" .format(poi=ewcfg.col_poi, life_state=ewcfg.col_life_state), (id_server, exposed_pois)) for user in users: try: user_data = EwUser(id_user=user[0], id_server=id_server) if user_data.life_state == ewcfg.life_state_kingpin: continue else: mutations = user_data.get_mutations() if ewcfg.mutation_id_airlock in mutations: user_data.hunger -= min(user_data.hunger, 5) except: ewutils.logMsg( "Error occurred in weather tick for server {}". format(id_server)) if market_data.weather != ewcfg.weather_bicarbonaterain: return exposed_pois = [] exposed_pois.extend(ewcfg.capturable_districts) exposed_pois.extend(ewcfg.outskirts) exposed_pois = tuple(exposed_pois) client = ewutils.get_client() server = client.get_guild(id_server) users = ewutils.execute_sql_query( "SELECT id_user FROM users WHERE id_server = %s AND {poi} IN %s AND {life_state} > 0" .format(poi=ewcfg.col_poi, life_state=ewcfg.col_life_state), (id_server, exposed_pois)) deathreport = "" resp_cont = ewutils.EwResponseContainer(id_server=id_server) for user in users: user_data = EwUser(id_user=user[0], id_server=id_server) if user_data.life_state == ewcfg.life_state_kingpin: continue user_poi = ewcfg.id_to_poi.get(user_data.poi) player_data = EwPlayer(id_server=user_data.id_server, id_user=user_data.id_user) protected = False slimeoid_protected = False if user_data.weapon >= 0: weapon_item = EwItem(id_item=user_data.weapon) if weapon_item.item_props.get( 'weapon_type') in ewcfg.rain_protection: protected = True cosmetics = ewitem.inventory( id_user=user_data.id_user, id_server=id_server, item_type_filter=ewcfg.it_cosmetic) for cosmetic in cosmetics: cosmetic_data = EwItem(id_item=cosmetic.get('id_item')) if cosmetic_data.item_props.get( 'id_cosmetic') in ewcfg.rain_protection: if cosmetic_data.item_props.get('adorned') == 'true': protected = True elif cosmetic_data.item_props.get( 'slimeoid') == 'true': slimeoid_protected = True if not protected: if user_data.life_state == ewcfg.life_state_shambler: slime_gain = (ewcfg.slimes_shambler - user_data.slimes) / 10 slime_gain = max(0, int(slime_gain)) user_data.change_slimes(n=slime_gain, source=ewcfg.source_weather) else: if random.random() < 0.01: user_data.degradation += 1 user_data.persist() if not slimeoid_protected: slimeoid_data = EwSlimeoid(id_user=user_data.id_user, id_server=id_server) if slimeoid_data.life_state != ewcfg.slimeoid_state_active: continue slimeoid_response = "" if random.randrange(10) < slimeoid_data.level: slimeoid_response = "*{uname}*: {slname} cries out in pain, as it's hit by the bicarbonate rain.".format( uname=player_data.display_name, slname=slimeoid_data.name) else: 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." } ewitem.item_create(id_user=str(user_data.id_user), id_server=id_server, item_type=ewcfg.it_item, item_props=item_props) slimeoid_data.die() slimeoid_data.persist() slimeoid_response = "*{uname}*: {slname} lets out a final whimper as it's dissolved by the bicarbonate rain. {skull} You quickly pocket its heart.".format( uname=player_data.display_name, slname=slimeoid_data.name, skull=ewcfg.emote_slimeskull) resp_cont.add_channel_response(user_poi.channel, slimeoid_response) for poi in exposed_pois: district_data = EwDistrict(district=poi, id_server=id_server) slimes_to_erase = district_data.slimes * 0.01 * ewcfg.weather_tick_length slimes_to_erase = max(slimes_to_erase, ewcfg.weather_tick_length * 1000) slimes_to_erase = min(district_data.slimes, slimes_to_erase) #round up or down, randomly weighted remainder = slimes_to_erase - int(slimes_to_erase) if random.random() < remainder: slimes_to_erase += 1 slimes_to_erase = int(slimes_to_erase) district_data.change_slimes(n=-slimes_to_erase, source=ewcfg.source_weather) district_data.persist() enemies = ewutils.execute_sql_query( "SELECT id_enemy FROM enemies WHERE id_server = %s AND {poi} IN %s AND {life_state} = %s AND {weathertype} != %s" .format(poi=ewcfg.col_enemy_poi, life_state=ewcfg.col_enemy_life_state, weathertype=ewcfg.col_enemy_weathertype), (id_server, exposed_pois, ewcfg.enemy_lifestate_alive, ewcfg.enemy_weathertype_rainresist)) for enemy in enemies: enemy_data = EwEnemy(id_enemy=enemy[0]) enemy_poi = ewcfg.id_to_poi.get(enemy_data.poi) slimes_to_erase = enemy_data.slimes * 0.01 * ewcfg.weather_tick_length slimes_to_erase = max(slimes_to_erase, ewcfg.weather_tick_length * 1000) slimes_to_erase = min(enemy_data.slimes, slimes_to_erase) #round up or down, randomly weighted remainder = slimes_to_erase - int(slimes_to_erase) if random.random() < remainder: slimes_to_erase += 1 slimes_to_erase = int(slimes_to_erase) enemy_data.change_slimes(n=-slimes_to_erase, source=ewcfg.source_weather) enemy_data.persist() response = "{name} takes {slimeloss:,} damage from the bicarbonate rain.".format( name=enemy_data.display_name, slimeloss=slimes_to_erase) resp_cont.add_channel_response(enemy_poi.channel, response) if enemy_data.slimes <= 0: ewhunting.delete_enemy(enemy_data) deathreport = "{skull} {name} is dissolved by the bicarbonate rain. {skull}".format( skull=ewcfg.emote_slimeskull, name=enemy_data.display_name) resp_cont.add_channel_response(enemy_poi.channel, deathreport) await resp_cont.post() except: ewutils.logMsg( "Error occurred in weather tick for server {}".format( id_server))
async def barter(cmd): user_data = EwUser(member = cmd.message.author) market_data = EwMarket(id_server = user_data.id_server) item_search = ewutils.flattenTokenListToString(cmd.tokens[1:]) item_sought = ewitem.find_item(item_search = item_search, id_user = cmd.message.author.id, id_server = cmd.message.server.id if cmd.message.server is not None else None) # 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 cmd.message.channel.name in [ewcfg.channel_tt_pier, ewcfg.channel_jp_pier, ewcfg.channel_cl_pier, ewcfg.channel_afb_pier, ewcfg.channel_vc_pier, ewcfg.channel_se_pier, ewcfg.channel_ferry]: 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?' 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 ewcfg.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.message.server.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: 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) else: for result in ewcfg.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 ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) else: # Random choice between 0, 1, and 2 offer_decision = random.randint(0, 2) if offer_decision != 2: # 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 ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) # Wait for an answer accepted = False try: message = await cmd.client.wait_for_message(timeout = 20, author = cmd.message.author, check = ewutils.check_accept_or_refuse) if message != None: if message.content.lower() == "!accept": accepted = True if message.content.lower() == "!refuse": accepted = False except: accepted = False offer = EwOffer( id_server = cmd.message.server.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 != user_data.id_user: accepted = False # cancel deal if the user has left the speakeasy 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 = ewitem.gen_item_props(item) ewitem.item_create( item_type = item.item_type, id_user = cmd.message.author.id, id_server = cmd.message.server.id, item_props = item_props ) ewitem.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 ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def haunt(cmd): time_now = int(time.time()) response = "" resp_cont = ewutils.EwResponseContainer(id_server=cmd.message.server.id) if cmd.mentions_count > 1: response = "You can only spook one person at a time. Who do you think you are, the Lord of Ghosts?" elif cmd.mentions_count == 1: # Get the user and target data from the database. user_data = EwUser(member=cmd.message.author) member = cmd.mentions[0] haunted_data = EwUser(member=member) market_data = EwMarket(id_server=cmd.message.server.id) target_isshambler = haunted_data.life_state == ewcfg.life_state_shambler if user_data.life_state != ewcfg.life_state_corpse: # Only dead players can haunt. response = "You can't haunt now. Try {}.".format(ewcfg.cmd_suicide) elif haunted_data.life_state == ewcfg.life_state_kingpin: # Disallow haunting of generals. response = "He is too far from the sewers in his ivory tower, and thus cannot be haunted." elif (time_now - user_data.time_lasthaunt) < ewcfg.cd_haunt: # Disallow haunting if the user has haunted too recently. response = "You're being a little TOO spooky lately, don't you think? Try again in {} seconds.".format( int(ewcfg.cd_haunt - (time_now - user_data.time_lasthaunt))) elif ewmap.channel_name_is_poi(cmd.message.channel.name) == False: response = "You can't commit violence from here." elif time_now > haunted_data.time_expirpvp and not target_isshambler: # Require the target to be flagged for PvP response = "{} is not mired in the ENDLESS WAR right now.".format( member.display_name) elif haunted_data.life_state == ewcfg.life_state_corpse: # Dead players can't be haunted. response = "{} is already dead.".format(member.display_name) elif haunted_data.life_state == ewcfg.life_state_grandfoe: # Grand foes can't be haunted. response = "{} is invulnerable to ghosts.".format( member.display_name) elif haunted_data.life_state == ewcfg.life_state_enlisted or haunted_data.life_state == ewcfg.life_state_juvenile or haunted_data.life_state == ewcfg.life_state_shambler: # Target can be haunted by the player. haunted_slimes = int(haunted_data.slimes / ewcfg.slimes_hauntratio) # if user_data.poi == haunted_data.poi: # when haunting someone face to face, there is no cap and you get double the amount # haunted_slimes *= 2 if haunted_slimes > ewcfg.slimes_hauntmax: haunted_slimes = ewcfg.slimes_hauntmax #if -user_data.slimes < haunted_slimes: # cap on for how much you can haunt # haunted_slimes = -user_data.slimes haunted_data.change_slimes(n=-haunted_slimes, source=ewcfg.source_haunted) user_data.change_slimes(n=-haunted_slimes, source=ewcfg.source_haunter) market_data.negaslime -= haunted_slimes user_data.time_lasthaunt = time_now user_data.busted = False user_data.time_expirpvp = ewutils.calculatePvpTimer( user_data.time_expirpvp, (int(time.time()) + ewcfg.time_pvp_attack)) resp_cont.add_member_to_update(cmd.message.author) # Persist changes to the database. user_data.persist() haunted_data.persist() market_data.persist() response = "{} has been haunted by the ghost of {}! Slime has been lost!".format( member.display_name, cmd.message.author.display_name) haunted_channel = ewcfg.id_to_poi.get(haunted_data.poi).channel haunt_message = "You feel a cold shiver run down your spine" if cmd.tokens_count > 2: haunt_message_content = re.sub( "<.+>", "", cmd.message.content[(len(cmd.tokens[0])):]).strip() # Cut down really big messages so discord doesn't crash if len(haunt_message_content) > 500: haunt_message_content = haunt_message_content[:-500] haunt_message += " and faintly hear the words \"{}\"".format( haunt_message_content) haunt_message += "." haunt_message = ewutils.formatMessage(member, haunt_message) resp_cont.add_channel_response(haunted_channel, haunt_message) else: # Some condition we didn't think of. response = "You cannot haunt {}.".format(member.display_name) else: # No mentions, or mentions we didn't understand. response = "Your spookiness is appreciated, but ENDLESS WAR didn\'t understand that name." # Send the response to the player. resp_cont.add_channel_response(cmd.message.channel.name, response) await resp_cont.post()
async def haunt(cmd): time_now = int(time.time()) response = "" resp_cont = ewutils.EwResponseContainer(id_server = cmd.guild.id) if cmd.mentions_count > 1: response = "You can only spook one person at a time. Who do you think you are, the Lord of Ghosts?" else: haunted_data = None member = None if cmd.mentions_count == 0 and cmd.tokens_count > 1: server = cmd.guild member = server.get_member(ewutils.getIntToken(cmd.tokens)) haunted_data = EwUser(member = member) elif cmd.mentions_count == 1: member = cmd.mentions[0] haunted_data = EwUser(member = member) if member: # Get the user and target data from the database. user_data = EwUser(member = cmd.message.author) market_data = EwMarket(id_server = cmd.guild.id) target_mutations = haunted_data.get_mutations() target_poi = ewcfg.id_to_poi.get(haunted_data.poi) target_is_shambler = haunted_data.life_state == ewcfg.life_state_shambler target_is_inhabitted = haunted_data.id_user == user_data.get_inhabitee() if user_data.life_state != ewcfg.life_state_corpse: # Only dead players can haunt. response = "You can't haunt now. Try {}.".format(ewcfg.cmd_suicide) elif haunted_data.life_state == ewcfg.life_state_kingpin: # Disallow haunting of generals. response = "He is too far from the sewers in his ivory tower, and thus cannot be haunted." elif (time_now - user_data.time_lasthaunt) < ewcfg.cd_haunt: # Disallow haunting if the user has haunted too recently. response = "You're being a little TOO spooky lately, don't you think? Try again in {} seconds.".format(int(ewcfg.cd_haunt-(time_now-user_data.time_lasthaunt))) elif ewutils.channel_name_is_poi(cmd.message.channel.name) == False: response = "You can't commit violence from here." elif target_poi.pvp == False: #Require the target to be in a PvP area, and flagged if it's a remote haunt response = "{} is not mired in the ENDLESS WAR right now.".format(member.display_name) elif haunted_data.life_state == ewcfg.life_state_corpse: # Dead players can't be haunted. response = "{} is already dead.".format(member.display_name) elif haunted_data.life_state == ewcfg.life_state_grandfoe: # Grand foes can't be haunted. response = "{} is invulnerable to ghosts.".format(member.display_name) elif haunted_data.life_state == ewcfg.life_state_enlisted or haunted_data.life_state == ewcfg.life_state_juvenile or haunted_data.life_state == ewcfg.life_state_shambler: haunt_power_multiplier = 1 # power to the ancients ghost_age = time_now - user_data.time_lastdeath if ghost_age > 60 * 60 * 24 * 7: # dead for longer than if ghost_age > 60 * 60 * 24 * 365: # one friggin year haunt_power_multiplier *= 2.5 if ghost_age > 60 * 60 * 24 * 90: # three months haunt_power_multiplier *= 2 elif ghost_age > 60 * 60 * 24 * 30: # one month haunt_power_multiplier *= 1.5 else: # one week haunt_power_multiplier *= 1.25 # vitriol as virtue list_ids = [] for quadrant in ewcfg.quadrant_ids: quadrant_data = ewquadrants.EwQuadrant(id_server=cmd.guild.id, id_user=cmd.message.author.id, quadrant=quadrant) if quadrant_data.id_target != -1 and quadrant_data.check_if_onesided() is False: list_ids.append(quadrant_data.id_target) if quadrant_data.id_target2 != -1 and quadrant_data.check_if_onesided() is False: list_ids.append(quadrant_data.id_target2) if haunted_data.id_user in list_ids: # any mutual quadrants haunt_power_multiplier *= 1.2 if haunted_data.faction and ((not user_data.faction) or (user_data.faction != haunted_data.faction)): # opposite faction (or no faction at all) haunt_power_multiplier *= 1.2 if user_data.id_killer == haunted_data.id_user: # haunting your murderer/buster haunt_power_multiplier *= 1.2 # places of power. if haunted_data.poi in [ewcfg.poi_id_thevoid, ewcfg.poi_id_wafflehouse, ewcfg.poi_id_blackpond]: haunt_power_multiplier *= 2 elif haunted_data.poi in ewmap.get_void_connection_pois(cmd.guild.id): haunt_power_multiplier *= 1.25 # glory to the vanquished target_kills = ewstats.get_stat(user = haunted_data, metric = ewcfg.stat_kills) if target_kills > 5: haunt_power_multiplier *= 1.25 + ((target_kills - 5) / 100) # 1% per kill after 5 else: haunt_power_multiplier *= 1 + (target_kills * 5 / 100) # 5% per kill if time_now - haunted_data.time_lastkill < (60 * 15): haunt_power_multiplier *= 1.5 # wet hands # misc if ewcfg.weather_map.get(market_data.weather) == ewcfg.weather_foggy: haunt_power_multiplier *= 1.1 if not haunted_data.has_soul: haunt_power_multiplier *= 1.2 # uncomment this after moon mechanics update # if (market_data.day % 31 == 15 and market_data.clock >= 20) or (market_data.day % 31 == 16 and market_data.clock <= 6): # haunt_power_multiplier *= 2 # divide haunt power by 2 if not in same area if user_data.poi != haunted_data.poi: haunt_power_multiplier /= 2 # Double Halloween #haunt_power_multiplier *= 4 haunted_slimes = int((haunted_data.slimes / ewcfg.slimes_hauntratio) * haunt_power_multiplier) slimes_lost = int(haunted_slimes / 5) # hauntee only loses 1/5th of what the ghost gets as antislime if ewcfg.mutation_id_coleblooded in target_mutations: haunted_slimes = -10000 if user_data.slimes > haunted_slimes: haunted_slimes = user_data.slimes haunted_data.change_slimes(n = -slimes_lost, source = ewcfg.source_haunted) user_data.change_slimes(n = -haunted_slimes, source = ewcfg.source_haunter) market_data.negaslime -= haunted_slimes user_data.time_lasthaunt = time_now user_data.busted = False resp_cont.add_member_to_update(cmd.message.author) # Persist changes to the database. user_data.persist() haunted_data.persist() market_data.persist() response = "{} has been haunted by the ghost of {}! Slime has been lost! {} antislime congeals within you.".format(member.display_name, cmd.message.author.display_name, haunted_slimes) if ewcfg.mutation_id_coleblooded in target_mutations: response = "{} has been haunted by the ghost of {}! Their exorcising coleslaw blood purges {} antislime from your being! Better not do that again.".format(member.display_name, cmd.message.author.display_name, -haunted_slimes) haunted_channel = ewcfg.id_to_poi.get(haunted_data.poi).channel haunt_message = "You feel a cold shiver run down your spine" if cmd.tokens_count > 2: haunt_message_content = re.sub("<.+>" if cmd.mentions_count == 1 else "\d{17,}", "", cmd.message.content[(len(cmd.tokens[0])):]).strip() # Cut down really big messages so discord doesn't crash if len(haunt_message_content) > 500: haunt_message_content = haunt_message_content[:-500] haunt_message += " and faintly hear the words \"{}\"".format(haunt_message_content) haunt_message += ". {} slime evaporates from your body.".format(slimes_lost) if ewcfg.mutation_id_coleblooded in target_mutations: haunt_message += " The ghost that did it wails in agony as their ectoplasm boils in your coleslaw blood!" haunt_message = ewutils.formatMessage(member, haunt_message) resp_cont.add_channel_response(haunted_channel, haunt_message) else: # No mentions, or mentions we didn't understand. response = "Your spookiness is appreciated, but ENDLESS WAR didn\'t understand that name." # Send the response to the player. resp_cont.add_channel_response(cmd.message.channel.name, response) await resp_cont.post()
async def scavenge(cmd): market_data = EwMarket(id_server=cmd.message.author.server.id) user_data = EwUser(member=cmd.message.author) mutations = user_data.get_mutations() time_now = int(time.time()) response = "" time_since_last_scavenge = time_now - user_data.time_lastscavenge # Kingpins can't scavenge. if user_data.life_state == ewcfg.life_state_kingpin or user_data.life_state == ewcfg.life_state_grandfoe: return # ghosts cant scavenge if user_data.life_state == ewcfg.life_state_corpse: return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage( cmd.message.author, "What would you want to do that for? You're a ghost, you have no need for such lowly materialistic possessions like slime. You only engage in intellectual pursuits now. {} if you want to give into your base human desire to see numbers go up." .format(ewcfg.cmd_revive))) # currently not active - no cooldown if time_since_last_scavenge < ewcfg.cd_scavenge: return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, "Slow down, you filthy hyena.")) # Scavenge only in location channels if ewmap.channel_name_is_poi(cmd.message.channel.name) == True: if user_data.hunger >= user_data.get_hunger_max(): return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage( cmd.message.author, "You are too exhausted to scrounge up scraps of slime off the street! Go get some grub!" )) else: district_data = EwDistrict(district=user_data.poi, id_server=cmd.message.author.server.id) user_initial_level = user_data.slimelevel # add scavenged slime to user if ewcfg.mutation_id_trashmouth in mutations: time_since_last_scavenge *= 3 time_since_last_scavenge = min(max(1, time_since_last_scavenge), 30) scavenge_mod = 0.003 * (time_since_last_scavenge**0.9) if ewcfg.mutation_id_whitenationalist in mutations and market_data.weather == "snow": scavenge_mod *= 1.5 if ewcfg.mutation_id_webbedfeet in mutations: district_slimelevel = len(str(district_data.slimes)) scavenge_mod *= max(1, min(district_slimelevel - 3, 4)) scavenge_yield = math.floor(scavenge_mod * district_data.slimes) levelup_response = user_data.change_slimes( n=scavenge_yield, source=ewcfg.source_scavenging) district_data.change_slimes(n=-1 * scavenge_yield, source=ewcfg.source_scavenging) district_data.persist() if levelup_response != "": response += levelup_response + "\n\n" #response += "You scrape together {} slime from the streets.\n\n".format(scavenge_yield) if cmd.tokens_count > 1: item_search = ewutils.flattenTokenListToString(cmd.tokens[1:]) loot_resp = ewitem.item_lootspecific( id_server=user_data.id_server, id_user=user_data.id_user, item_search=item_search) response += loot_resp else: loot_multiplier = 1.0 + ewitem.get_inventory_size( owner=user_data.poi, id_server=user_data.id_server) loot_chance = loot_multiplier / ewcfg.scavenge_item_rarity if ewcfg.mutation_id_dumpsterdiver in mutations: loot_chance *= 10 if random.random() < loot_chance: loot_resp = ewitem.item_lootrandom( id_server=user_data.id_server, id_user=user_data.id_user) response += loot_resp # Fatigue the scavenger. 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 user_data.hunger += ewcfg.hunger_perscavenge * 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_perscavenge user_data.time_lastscavenge = time_now user_data.persist() if not response == "": await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) else: return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage( cmd.message.author, "You'll find no slime here, this place has been picked clean. Head into the city to try and scavenge some slime." ))
async def flag(cmd): market_data = EwMarket(id_server=cmd.message.author.server.id) user_data = EwUser(member=cmd.message.author) mutations = user_data.get_mutations() time_now = int(time.time()) 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 ewutils.send_message( cmd.client, cmd.message.channel, ewutils.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 ewutils.send_message( cmd.client, cmd.message.channel, ewutils.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 ewutils.send_message( cmd.client, cmd.message.channel, ewutils.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.channel_mines, ewcfg.channel_cv_mines, ewcfg.channel_tt_mines ]: if user_data.hunger >= user_data.get_hunger_max(): return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage( cmd.message.author, "You've exhausted yourself from mining. You'll need some refreshment before getting back to work." )) else: if user_data.poi not in mines_map: response = "You can't mine here! Go to the mines in Juvie's Row, Toxington, or Cratersville!" return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) elif user_data.id_server not in mines_map.get(user_data.poi): init_grid_ms(user_data.poi, user_data.id_server) grid_cont = mines_map.get(user_data.poi).get(user_data.id_server) grid = grid_cont.grid if cmd.tokens_count < 2: response = "Please specify which vein to mine." await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) return await print_grid_ms(cmd) grid_multiplier = grid_cont.cells_mined**0.4 row = -1 col = -1 for token in cmd.tokens[1:]: if row < 1 or col < 1: coords = token.lower() for char in coords: if char in ewcfg.alphabet: col = ewcfg.alphabet.index(char) coords = coords.replace(char, "") try: row = int(coords) except: row = -1 row -= 1 if row not in range(len(grid)): response = "Invalid vein." await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) return await print_grid_ms(cmd) if col not in range(len(grid[row])): response = "Invalid vein." await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) return await print_grid_ms(cmd) if grid[row][col] in [ ewcfg.cell_empty_marked, ewcfg.cell_mine_marked ]: if grid[row][col] == ewcfg.cell_empty_marked: grid[row][col] = ewcfg.cell_empty elif grid[row][col] == ewcfg.cell_mine_marked: grid[row][col] = ewcfg.cell_mine return await print_grid_ms(cmd) if grid[row][col] == ewcfg.cell_empty_open: response = "This vein has already been mined dry." await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) return await print_grid_ms(cmd) if grid[row][col] == ewcfg.cell_mine: grid[row][col] = ewcfg.cell_mine_marked return await print_grid_ms(cmd) grid[row][col] = ewcfg.cell_empty_marked return await print_grid_ms(cmd) else: response = "You can't mine here! Go to the mines in Juvie's Row, Toxington, or Cratersville!" if len(response) > 0: await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def mine(cmd): market_data = EwMarket(id_server=cmd.message.author.server.id) user_data = EwUser(member=cmd.message.author) mutations = user_data.get_mutations() time_now = int(time.time()) 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 ewutils.send_message( cmd.client, cmd.message.channel, ewutils.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 ewutils.send_message( cmd.client, cmd.message.channel, ewutils.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 ewutils.send_message( cmd.client, cmd.message.channel, ewutils.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.channel_mines, ewcfg.channel_cv_mines, ewcfg.channel_tt_mines ]: if user_data.hunger >= user_data.get_hunger_max(): return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage( cmd.message.author, "You've exhausted yourself from mining. You'll need some refreshment before getting back to work." )) else: printgrid = False 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 if user_data.poi not in mines_map: response = "You can't mine here! Go to the mines in Juvie's Row, Toxington, or Cratersville!" return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) elif user_data.id_server not in mines_map.get(user_data.poi): init_grid(user_data.poi, user_data.id_server) printgrid = True grid_cont = mines_map.get(user_data.poi).get(user_data.id_server) grid = grid_cont.grid #minesweeper = False if cmd.tokens_count < 2: response = "Please specify which vein to mine." await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) return await print_grid(cmd) else: #minesweeper = True #grid_multiplier = grid_cont.cells_mined ** 0.4 #flag = False row = -1 col = -1 for token in cmd.tokens[1:]: if token.lower() == "reset": user_data.hunger += ewcfg.hunger_perminereset * int( hunger_cost_mod) if random.random() < extra: user_data.hunger += ewcfg.hunger_perminereset user_data.persist() init_grid(user_data.poi, user_data.id_server) return await print_grid(cmd) if row < 1 or col < 1: coords = token.lower() for char in coords: if char in ewcfg.alphabet: col = ewcfg.alphabet.index(char) coords = coords.replace(char, "") try: row = int(coords) except: row = -1 row -= 1 if row not in range(len(grid)) or col not in range( len(grid[row])): response = "Invalid vein." await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) return await print_grid(cmd) mining_yield = 0 mining_accident = False slimes_pertile = ewcfg.slimes_pertile for current_row in range(max(0, row - 1), min(row + 2, len(grid))): for current_col in range( max(0, col - 1), min(col + 2, len(grid[current_row]))): symbol_prev = get_cell_symbol( grid[current_row][current_col]) slimes_fromtile = slimes_pertile if current_row == row and current_col == col: slimes_fromtile *= 2 mining_yield += max( 0, min(slimes_fromtile, grid[current_row][current_col])) grid[current_row][current_col] -= slimes_fromtile if grid[current_row][ current_col] < -60 * ewcfg.slimes_pertile: mining_accident = True if get_cell_symbol( grid[current_row][current_col]) != symbol_prev: printgrid = True if mining_accident: user_data.change_slimes(n=-(user_data.slimes * 0.5)) user_data.persist() init_grid(user_data.poi, user_data.id_server) response = "You have lost an arm and a leg in a mining accident. Tis but a scratch." await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) return await print_grid(cmd) 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 ewutils.send_message( cmd.client, cmd.message.channel, ewutils.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 = ewcfg.weapon_map.get( weapon_item.item_props.get("weapon_type")) if weapon.id_weapon == ewcfg.weapon_id_pickaxe: has_pickaxe = True # Determine if an item is found. unearthed_item = False unearthed_item_amount = 0 # 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 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(ewcfg.mine_results) item_props = ewitem.gen_item_props(item) for creation in range(unearthed_item_amount): ewitem.item_create(item_type=item.item_type, id_user=cmd.message.author.id, id_server=cmd.message.server.id, item_props=item_props) if unearthed_item_amount == 1: response = "You unearthed a {}! ".format(item.str_name) elif unearthed_item_amount == 2: response = "You unearthed two (2) {}! ".format( 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) if has_pickaxe == True: mining_yield *= 2 # 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) else: response = "You can't mine here! Go to the mines in Juvie's Row, Toxington, or Cratersville!" if len(response) > 0: await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def reel(cmd): user_data = EwUser(member = cmd.message.author) if cmd.message.author.id not in fishers.keys(): fishers[cmd.message.author.id] = EwFisher() fisher = fishers[cmd.message.author.id] poi = ewcfg.id_to_poi.get(user_data.poi) # Ghosts cannot fish. if user_data.life_state == ewcfg.life_state_corpse: response = "You can't fish while you're dead. Try {}.".format(ewcfg.cmd_revive) elif cmd.message.channel.name in [ewcfg.channel_tt_pier, ewcfg.channel_jp_pier, ewcfg.channel_cl_pier, ewcfg.channel_afb_pier, ewcfg.channel_vc_pier, ewcfg.channel_se_pier, ewcfg.channel_ferry]: # Players who haven't cast a line cannot reel. if fisher.fishing == False: response = "You haven't cast your hook yet. Try !cast." # If a fish isn't biting, then a player reels in nothing. elif fisher.bite == False and fisher.fishing == True: fisher.current_fish = "" fisher.current_size = "" fisher.fishing = False fisher.pier = "" response = "You reeled in too early! Nothing was caught." # On successful reel. else: if fisher.current_fish == "item": slimesea_inventory = ewitem.inventory(id_server = cmd.message.server.id, id_user = ewcfg.poi_id_slimesea) pier_poi = ewcfg.id_to_poi.get(fisher.pier) if pier_poi.pier_type != ewcfg.fish_slime_saltwater or len(slimesea_inventory) == 0 or random.random() < 0.5: item = random.choice(ewcfg.mine_results) unearthed_item_amount = (random.randrange(5) + 8) # anywhere from 8-12 drops item_props = ewitem.gen_item_props(item) for creation in range(unearthed_item_amount): ewitem.item_create( item_type = item.item_type, id_user = cmd.message.author.id, id_server = cmd.message.server.id, item_props = item_props ) response = "You reel in {} {}s! ".format(unearthed_item_amount, item.str_name) else: item = random.choice(slimesea_inventory) ewitem.give_item(id_item = item.get('id_item'), member = cmd.message.author) response = "You reel in a {}!".format(item.get('name')) fisher.fishing = False fisher.bite = False fisher.current_fish = "" fisher.current_size = "" fisher.pier = "" 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 = ewcfg.weapon_map.get(weapon_item.item_props.get("weapon_type")) if weapon.id_weapon == "fishingrod": has_fishingrod = True value = 0 if fisher.current_size == ewcfg.fish_size_miniscule: slime_gain = ewcfg.fish_gain * 1 value += 10 elif fisher.current_size == ewcfg.fish_size_small: slime_gain = ewcfg.fish_gain * 2 value += 20 elif fisher.current_size == ewcfg.fish_size_average: slime_gain = ewcfg.fish_gain * 3 value += 30 elif fisher.current_size == ewcfg.fish_size_big: slime_gain = ewcfg.fish_gain * 4 value += 40 elif fisher.current_size == ewcfg.fish_size_huge: slime_gain = ewcfg.fish_gain * 5 value += 50 else: slime_gain = ewcfg.fish_gain * 6 value += 60 if ewcfg.fish_map[fisher.current_fish].rarity == ewcfg.fish_rarity_common: value += 10 if ewcfg.fish_map[fisher.current_fish].rarity == ewcfg.fish_rarity_uncommon: value += 20 if ewcfg.fish_map[fisher.current_fish].rarity == ewcfg.fish_rarity_rare: value += 30 if ewcfg.fish_map[fisher.current_fish].rarity == ewcfg.fish_rarity_promo: value += 40 if user_data.life_state == 2: if ewcfg.fish_map[fisher.current_fish].catch_time == ewcfg.fish_catchtime_day and user_data.faction == ewcfg.faction_rowdys: gang_bonus = True slime_gain = slime_gain * 1.5 value += 20 if ewcfg.fish_map[fisher.current_fish].catch_time == ewcfg.fish_catchtime_night and user_data.faction == ewcfg.faction_killers: gang_bonus = True slime_gain = slime_gain * 1.5 value += 20 if has_fishingrod == True: slime_gain = slime_gain * 2 if fisher.current_fish == "plebefish": slime_gain = ewcfg.fish_gain * .5 value = 10 if poi.is_subzone: district_data = EwDistrict(district = poi.mother_district, id_server = cmd.message.server.id) else: district_data = EwDistrict(district = poi.id_poi, id_server = cmd.message.server.id) if district_data.controlling_faction != "" and district_data.controlling_faction == user_data.faction: slime_gain *= 2 ewitem.item_create( id_user = cmd.message.author.id, id_server = cmd.message.server.id, item_type = ewcfg.it_food, item_props = { 'id_food': ewcfg.fish_map[fisher.current_fish].id_fish, 'food_name': ewcfg.fish_map[fisher.current_fish].str_name, 'food_desc': ewcfg.fish_map[fisher.current_fish].str_desc, 'recover_hunger': 20, 'str_eat': ewcfg.str_eat_raw_material.format(ewcfg.fish_map[fisher.current_fish].str_name), 'rarity': ewcfg.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 } ) response = "You reel in a {fish}! {flavor} You grab hold and wring {slime} slime from it. "\ .format(fish = ewcfg.fish_map[fisher.current_fish].str_name, flavor = ewcfg.fish_map[fisher.current_fish].str_desc, slime = str(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 market_data = EwMarket(id_server=user_data.id_server) if market_data.caught_fish == ewcfg.debugfish_goal and fisher.pier in ewcfg.debugpiers: item = ewcfg.debugitem ewitem.item_create( item_type=ewcfg.it_item, id_user=user_data.id_user, id_server=user_data.id_server, item_props={ 'id_item': item.id_item, 'context': item.context, 'item_name': item.str_name, 'item_desc': item.str_desc, } ), ewutils.logMsg('Created item: {}'.format(item.id_item)) item = EwItem(id_item=item.id_item) item.persist() response += ewcfg.debugfish_response market_data.caught_fish += 1 market_data.persist() elif market_data.caught_fish < ewcfg.debugfish_goal and fisher.pier in ewcfg.debugpiers: market_data.caught_fish += 1 market_data.persist() fisher.fishing = False fisher.bite = False fisher.current_fish = "" fisher.current_size = "" fisher.pier = "" user_data.persist() else: response = "You cast your fishing rod unto a sidewalk. That is to say, you've accomplished nothing. Go to a pier if you want to fish." await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def summon_negaslimeoid(cmd): response = "" user_data = EwUser(member=cmd.message.author) if user_data.life_state != ewcfg.life_state_corpse: response = "Only the dead have the occult knowledge required to summon a cosmic horror." return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) if user_data.poi not in ewcfg.capturable_districts: response = "You can't conduct the ritual here." return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) name = None if cmd.tokens_count > 1: #value = ewutils.getIntToken(tokens = cmd.tokens, allow_all = True, negate = True) slimeoid = EwSlimeoid(member=cmd.message.author, sltype=ewcfg.sltype_nega) if slimeoid.life_state != ewcfg.slimeoid_state_none: response = "You already have an active negaslimeoid." return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) negaslimeoid_name = cmd.message.content[(len(cmd.tokens[0])):].strip() if len(negaslimeoid_name) > 32: response = "That name is too long. ({:,}/32)".format( len(negaslimeoid_name)) return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) market_data = EwMarket(id_server=cmd.message.author.server.id) if market_data.negaslime >= 0: response = "The dead haven't amassed any negaslime yet." else: max_level = min( len(str(user_data.slimes)) - 1, len(str(market_data.negaslime)) - 1) level = random.randint(1, max_level) value = 10**(level - 1) #user_data.change_slimes(n = int(value/10)) market_data.negaslime += value slimeoid.sltype = ewcfg.sltype_nega slimeoid.life_state = ewcfg.slimeoid_state_active slimeoid.level = level slimeoid.id_user = user_data.id_user slimeoid.id_server = user_data.id_server slimeoid.poi = user_data.poi slimeoid.name = negaslimeoid_name slimeoid.body = random.choice(ewcfg.body_names) slimeoid.head = random.choice(ewcfg.head_names) slimeoid.legs = random.choice(ewcfg.mobility_names) slimeoid.armor = random.choice(ewcfg.defense_names) slimeoid.weapon = random.choice(ewcfg.offense_names) slimeoid.special = random.choice(ewcfg.special_names) slimeoid.ai = random.choice(ewcfg.brain_names) for i in range(level): rand = random.randrange(3) if rand == 0: slimeoid.atk += 1 elif rand == 1: slimeoid.defense += 1 else: slimeoid.intel += 1 user_data.persist() slimeoid.persist() market_data.persist() response = "You have summoned **{}**, a {}-foot-tall Negaslimeoid.".format( slimeoid.name, slimeoid.level) desc = ewslimeoid.slimeoid_describe(slimeoid) response += desc else: response = "To summon a negaslimeoid you must first know its name." await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def appraise(cmd): user_data = EwUser(member = cmd.message.author) market_data = EwMarket(id_server = user_data.id_server) item_search = ewutils.flattenTokenListToString(cmd.tokens[1:]) item_sought = ewitem.find_item(item_search = item_search, id_user = cmd.message.author.id, id_server = cmd.message.server.id if cmd.message.server is not None else None) payment = ewitem.find_item(item_search = "manhattanproject", id_user = cmd.message.author.id, id_server = cmd.message.server.id if cmd.message.server 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 cmd.message.channel.name in [ewcfg.channel_tt_pier, ewcfg.channel_jp_pier, ewcfg.channel_cl_pier, ewcfg.channel_afb_pier, ewcfg.channel_vc_pier, ewcfg.channel_se_pier, ewcfg.channel_ferry]: response = 'You ask a nearby fisherman if he could appraise 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?' elif item_sought: name = item_sought.get('name') fish = EwItem(id_item = item_sought.get('id_item')) item_props = fish.item_props # str_fish = fish.item_props.get('str_name') # id_fish = item_props['id_food'] 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 appraisal".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??"'.format(name) else: if payment == None: response += ", but he says he won’t provide his services for free... but, if you bring him a Manhattan Project, you might be able to get an appraisal." else: item_props = fish.item_props rarity = item_props['rarity'] size = item_props['size'] value = int(item_props['value']) response += ' and offer him a Manhattan Project as payment. \n"Hm, alright, let’s see here...' if rarity == ewcfg.fish_rarity_common: response += "Ah, a {}, that’s a pretty common fish... ".format(name) if rarity == ewcfg.fish_rarity_uncommon: response += "Interesting, a {}, that’s a pretty uncommon fish you’ve got there... ".format(name) if rarity == ewcfg.fish_rarity_rare: response += "Amazing, it’s a {}! Consider yourself lucky, that’s a pretty rare fish! ".format(name) if rarity == ewcfg.fish_rarity_promo: response += "Shiver me timbers, is that a {}?? Unbelievable, that’s an extremely rare fish!! It was only ever released as a promotional item in Japan during the late ‘90s. ".format(name) if size == ewcfg.fish_size_miniscule: response += "Or, is it just a speck of dust? Seriously, that {} is downright miniscule! ".format(name) if size == ewcfg.fish_size_small: response += "Hmmm, it’s a little small, don’t you think? " if size == ewcfg.fish_size_average: response += "It’s an average size for the species. " if size == ewcfg.fish_size_big: response += "Whoa, that’s a big one, too! " if size == ewcfg.fish_size_huge: response += "Look at the size of that thing, it’s huge! " if size == ewcfg.fish_size_colossal: response += "By Neptune’s beard, what a sight to behold, this {name} is absolutely colossal!! In all my years in the Navy, I don’t think I’ve ever seen a {name} as big as yours!! ".format(name = name) response += "So, I’d say this fish " if value <= 20: response += 'is absolutely worthless."' if value <= 40 and value >= 21: response += 'isn’t worth very much."' if value <= 60 and value >= 41: response += 'is somewhat valuable."' if value <= 80 and value >= 61: response += 'is highly valuable!"' if value <= 99 and value >= 81: response += 'is worth a fortune!!"' if value >= 100: response += 'is the most magnificent specimen I’ve ever seen!"' ewitem.item_delete(id_item = payment.get('id_item')) user_data.persist() 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 = "Ask Captain Albert Alexander to appraise which fish? (check **!inventory**)" await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def menu(cmd): user_data = EwUser(member=cmd.message.author) market_data = EwMarket(id_server=cmd.message.server.id) poi = ewmap.fetch_poi_if_coordless(cmd.message.channel.name) if poi is None or len(poi.vendors) == 0: # 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: if poi.is_subzone: district_data = EwDistrict(district=poi.mother_district, id_server=cmd.message.server.id) else: district_data = EwDistrict(district=poi.id_poi, id_server=cmd.message.server.id) response = "{} Menu:\n\n".format(poi.str_name) for vendor in poi.vendors: items = [] # If the vendor is the bazaar get the current rotation of items from the market_data vendor_inv = ewcfg.vendor_inv[ vendor] if vendor != ewcfg.vendor_bazaar else market_data.bazaar_wares.values( ) for item_name in vendor_inv: item_item = ewcfg.item_map.get(item_name) food_item = ewcfg.food_map.get(item_name) cosmetic_item = ewcfg.cosmetic_map.get(item_name) furniture_item = ewcfg.furniture_map.get(item_name) weapon_item = ewcfg.weapon_map.get(item_name) # increase profits for the stock market stock_data = None if vendor in ewcfg.vendor_stock_map: stock = ewcfg.vendor_stock_map.get(vendor) stock_data = EwStock(id_server=user_data.id_server, stock=stock) value = 0 if item_item: value = item_item.price if food_item: value = food_item.price if cosmetic_item: value = cosmetic_item.price if furniture_item: value = furniture_item.price if weapon_item: value = weapon_item.price if stock_data != None: value *= (stock_data.exchange_rate / ewcfg.default_stock_exchange_rate)**0.2 if district_data.controlling_faction != "": # prices are halved for the controlling gang if district_data.controlling_faction == user_data.faction: value /= 2 # and 4 times as much for enemy gangsters elif user_data.faction != "": value *= 4 value = int(value) if value != 0: items.append('{name} ({price})'.format(name=item_name, price=value)) else: items.append(item_name) response += "**{}**: *{}*\n".format( vendor, ewutils.formatNiceList(names=items)) if user_data.has_soul == 0: if vendor == ewcfg.vendor_dojo: response += "\n\nThe Dojo master looks at your soulless form with pity." elif vendor == ewcfg.vendor_bar: response += "\n\nThe bartender, sensing your misery, asks if you're okay." elif vendor == ewcfg.vendor_diner: response += "\n\nThe cook gives you a concerned look as he throws down another helping of flapjacks." elif vendor == ewcfg.vendor_seafood: response += "\n\nThe waiter sneers at how soulless and unkempt you look. You try to ignore him." elif vendor == ewcfg.vendor_bazaar: response += "\n\nAll the shops seem so lively. You wish you had a soul so you could be like them." elif vendor == ewcfg.vendor_beachresort or vendor == ewcfg.vendor_countryclub: response += "\n\nEverything looks so fancy here, but it doesn't really appeal to you since you don't have a soul." # Send the response to the player. await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def menu(cmd): user_data = EwUser(member=cmd.message.author, data_level=2) 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 ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) market_data = EwMarket(id_server=cmd.guild.id) #poi = ewmap.fetch_poi_if_coordless(cmd.message.channel.name) poi = ewcfg.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 = ewcfg.id_to_poi.get(user_data.poi) mother_district_data = None for mother_poi in poi.mother_districts: mother_poi_data = ewcfg.id_to_poi.get(mother_poi) if mother_poi_data.is_district: # One of the mother pois was a district, get its controlling faction mother_district_data = EwDistrict( district=mother_poi, id_server=user_data.id_server) break else: # One of the mother pois was a street, get the father district of that street and its controlling faction father_poi = mother_poi_data.father_district mother_district_data = EwDistrict( district=father_poi, id_server=user_data.id_server) break district_data = EwDistrict(district=poi.id_poi, id_server=user_data.id_server) #mother_district_data = EwDistrict(district = destination_poi.id_poi, id_server = user_data.id_server) shambler_multiplier = 1 #for speakeasy during shambler times if district_data.is_degraded( ) and poi.id_poi != ewcfg.poi_id_nuclear_beach_edge: 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 ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) controlling_faction = ewutils.get_subzone_controlling_faction( user_data.poi, user_data.id_server) response = "{} Menu:\n\n".format(poi.str_name) vendors_list = poi.vendors for vendor in vendors_list: if vendor == ewcfg.vendor_secretbodega: if user_data.freshness < ewcfg.freshnesslevel_4: continue else: response += '\nThe hipster behind the counter nearly falls out of his chair after laying eyes on the sheer, unadulterated freshness before him.\n"S-Sir! Your outfit... i-it is positively ***on fleek!!*** As I see you are a fashion enthusiast like myself, let me show you the good stuff…"\n' items = [] # If the vendor is the bazaar get the current rotation of items from the market_data vendor_inv = ewcfg.vendor_inv[ vendor] if vendor != ewcfg.vendor_bazaar else market_data.bazaar_wares.values( ) for item_name in vendor_inv: item_item = ewcfg.item_map.get(item_name) food_item = ewcfg.food_map.get(item_name) cosmetic_item = ewcfg.cosmetic_map.get(item_name) furniture_item = ewcfg.furniture_map.get(item_name) weapon_item = ewcfg.weapon_map.get(item_name) # increase profits for the stock market stock_data = None if vendor in ewcfg.vendor_stock_map: stock = ewcfg.vendor_stock_map.get(vendor) stock_data = EwStock(id_server=user_data.id_server, stock=stock) value = 0 if item_item: value = item_item.price if food_item: value = food_item.price if cosmetic_item: value = cosmetic_item.price if furniture_item: value = furniture_item.price if weapon_item: value = weapon_item.price if stock_data != None: value *= (stock_data.exchange_rate / ewcfg.default_stock_exchange_rate)**0.2 #multiply by 4 is speakeasy is shambled value *= shambler_multiplier if mother_district_data != None: if mother_district_data.all_streets_taken( ) != "" and poi.id_poi != ewcfg.poi_id_nuclear_beach_edge: # prices are halved for the controlling gang if mother_district_data.all_streets_taken( ) == user_data.faction: value /= 2 # and 4 times as much for enemy gangsters elif user_data.faction != "": value *= 4 if vendor == ewcfg.vendor_breakroom and user_data.faction == ewcfg.faction_slimecorp: value = 0 value = int(value) if value != 0: items.append('{name} ({price})'.format(name=item_name, price=value)) else: items.append(item_name) response += "**{}**: *{}*\n".format( vendor, ewutils.formatNiceList(names=items)) if vendor == ewcfg.vendor_bodega: if user_data.freshness < ewcfg.freshnesslevel_1: response += "\nThe hipster behind the counter is utterly repulsed by the fashion disaster in front of him. Looks like you just aren’t fresh enough for him." if user_data.has_soul == 0: if vendor == ewcfg.vendor_dojo: response += "\n\nThe Dojo master looks at your soulless form with pity." elif vendor == ewcfg.vendor_bar: response += "\n\nThe bartender, sensing your misery, asks if you're okay." elif vendor == ewcfg.vendor_diner: response += "\n\nThe cook gives you a concerned look as he throws down another helping of flapjacks." elif vendor == ewcfg.vendor_seafood: response += "\n\nThe waiter sneers at how soulless and unkempt you look. You try to ignore him." elif vendor == ewcfg.vendor_bazaar: response += "\n\nAll the shops seem so lively. You wish you had a soul so you could be like them." elif vendor == ewcfg.vendor_beachresort or vendor == ewcfg.vendor_countryclub: response += "\n\nEverything looks so fancy here, but it doesn't really appeal to you since you don't have a soul." elif vendor == ewcfg.vendor_bodega: if user_data.freshness < ewcfg.freshnesslevel_1: response += ".. and you probably never will be." elif vendor == ewcfg.vendor_glocksburycomics: response += "\n\nThe cashier here tries to start up a conversation about life being worth living. You're having none of it." elif vendor == ewcfg.vendor_basedhardware: response += "\n\nSo many industrial metals here... You contemplate which you could use to kill yourself..." elif vendor == ewcfg.vendor_basedhardware: response += "\n\nNot even waffles could hope to make your emptiness go away." elif vendor == ewcfg.vendor_greencakecafe: response += "\n\nThe barista behind the counter pauses to look at your soulless misery for a second, but decides you're not worth it and gets back to work." elif vendor == ewcfg.vendor_slimypersuits: response += "\n\nYour mere presence in here ruins the cheery atmosphere." # Send the response to the player. await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def order(cmd): user_data = EwUser(member=cmd.message.author) market_data = EwMarket(id_server=cmd.message.server.id) poi = ewmap.fetch_poi_if_coordless(cmd.message.channel.name) if poi is None or len(poi.vendors) == 0: # 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: value = ewutils.flattenTokenListToString(cmd.tokens[1:]) #if cmd.tokens_count > 1: # value = cmd.tokens[1] # value = value.lower() # Finds the item if it's an EwGeneralItem. item = ewcfg.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 = ewcfg.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 = ewcfg.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 = ewcfg.furniture_map.get(value) item_type = ewcfg.it_furniture if item != None: item_id = item.id_furniture name = item.str_name if item == None: item = ewcfg.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_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(): 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 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 if poi.is_subzone: district_data = EwDistrict(district=poi.mother_district, id_server=cmd.message.server.id) else: district_data = EwDistrict(district=poi.id_poi, id_server=cmd.message.server.id) if district_data.controlling_faction != "": # prices are halved for the controlling gang if district_data.controlling_faction == user_data.faction: value /= 2 # and 4 times as much for enemy gangsters elif user_data.faction != "": value *= 4 value = int(value) # 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 # Yo, Slimernalia! if item_type == ewcfg.it_food: value = 0 if value > user_data.slimes: # Not enough money. response = "A {} costs {:,} slime, and you only have {:,}.".format( name, value, user_data.slimes) else: if item_type == ewcfg.it_food: food_items = ewitem.inventory( id_user=cmd.message.author.id, id_server=cmd.message.server.id, item_type_filter=ewcfg.it_food) if len(food_items) >= user_data.get_food_capacity(): # user_data never got persisted so the player won't lose money unnecessarily response = "You can't carry any more food than that." return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) elif item_type == ewcfg.it_weapon: weapons_held = ewitem.inventory( id_user=user_data.id_user, id_server=cmd.message.server.id, item_type_filter=ewcfg.it_weapon) has_weapon = False # Thrown weapons are stackable if ewcfg.weapon_class_thrown in item.classes: # Check the player's inventory for the weapon and add amount to stack size. Create a new item the max stack size has been reached for wep in weapons_held: weapon = EwItem(id_item=wep.get("id_item")) if weapon.item_props.get( "weapon_type" ) == item.id_weapon and weapon.stack_size < weapon.stack_max: has_weapon = True weapon.stack_size += 1 weapon.persist() response = "You slam {:,} slime down on the counter at {} for {}.".format( value, current_vendor, item.str_weapon) user_data.change_slimes( n=-value, source=ewcfg.source_spending) user_data.persist() return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage( cmd.message.author, response)) if has_weapon == False: if len(weapons_held ) >= user_data.get_weapon_capacity(): response = "You can't carry any more weapons." return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage( cmd.message.author, response)) elif user_data.life_state == ewcfg.life_state_corpse: response = "Ghosts can't hold weapons." return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage( cmd.message.author, response)) user_data.change_slimes(n=-value, source=ewcfg.source_spending) if company_data is not None: company_data.recent_profits += value company_data.persist() item_props = ewitem.gen_item_props(item) if item.str_name == "arcade cabinet": item_props['furniture_desc'] = random.choice( ewcfg.cabinets_list) ewitem.item_create( item_type=item_type, id_user=cmd.message.author.id, id_server=cmd.message.server.id, stack_max=20 if item_type == ewcfg.it_weapon and ewcfg.weapon_class_thrown in item.classes else -1, stack_size=1 if item_type == ewcfg.it_weapon and ewcfg.weapon_class_thrown in item.classes else 0, item_props=item_props) response = "You slam {:,} slime down on the counter at {} for {}.".format( value, current_vendor, item.str_name) 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 ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def revive(cmd): time_now = int(time.time()) response = "" if cmd.message.channel.name != ewcfg.channel_endlesswar and cmd.message.channel.name != ewcfg.channel_sewers: response = "Come to me. I hunger. #{}.".format(ewcfg.channel_sewers) else: player_data = EwUser(member=cmd.message.author) time_until_revive = (player_data.time_lastdeath + player_data.degradation) - time_now if time_until_revive > 0: response = "ENDLESS WAR is not ready to {} you yet ({}s).".format( cmd.tokens[0], time_until_revive) return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.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.message.server.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 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 = ewcfg.id_to_poi.get(player_data.poi_death) if ewmap.inaccessible(poi=poi_death, user_data=player_data): player_data.poi = ewcfg.poi_id_downtown 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_downtown 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.message.server.id) # the amount of slime showered is divided equally amongst the districts districts_amount = len(ewcfg.capturable_districts) geyser_amount = int(0.5 * sewer_data.slimes / districts_amount) # Get a list of all the districts for poi in ewcfg.capturable_districts: district_data = EwDistrict(district=poi, id_server=cmd.message.server.id) district_data.change_slimes(n=geyser_amount) sewer_data.change_slimes(n=-1 * geyser_amount) district_data.persist() sewer_data.persist() sewer_inv = ewitem.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(ewcfg.capturable_districts) ewitem.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) + ewutils.formatMessage(member, deathreport) if slimeoid.life_state == ewcfg.slimeoid_state_active: reunite = "" brain = ewcfg.brain_map.get(slimeoid.ai) reunite += brain.str_revive.format(slimeoid_name=slimeoid.name) new_poi = ewcfg.id_to_poi.get(player_data.poi) revivechannel = ewutils.get_channel(cmd.message.server, new_poi.channel) reunite = ewutils.formatMessage(cmd.message.author, reunite) await ewutils.send_message(cmd.client, revivechannel, reunite) # Send the response to the player. await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
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 ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) market_data = EwMarket(id_server = user_data.id_server) item_search = ewutils.flattenTokenListToString(cmd.tokens[1:]) item_sought = ewitem.find_item(item_search = item_search, id_user = cmd.message.author.id, id_server = cmd.guild.id if cmd.guild is not None else None, item_type_filter=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 = ewcfg.id_to_poi.get(user_data.poi) district_data = EwDistrict(district = poi.id_poi, id_server = user_data.id_server) if district_data.is_degraded(): response = "{} has been degraded by shamblers. You can't {} here anymore.".format(poi.str_name, cmd.tokens[0]) return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) items = [] vegetable = EwItem(id_item = item_sought.get('id_item')) for result in ewcfg.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 = ewitem.gen_item_props(item) ewitem.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() ewitem.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 ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))