async def shares(cmd): user_data = EwUser(member=cmd.message.author) stock = "" response = "" if cmd.tokens_count > 0: stock = ewutils.flattenTokenListToString(cmd.tokens[1:]) if stock in ewcfg.stocks: response = get_user_shares_str(id_server=user_data.id_server, id_user=user_data.id_user, stock=stock) elif stock == "": for stock in ewcfg.stocks: response += "\n" response += get_user_shares_str(id_server=user_data.id_server, id_user=user_data.id_user, stock=stock) else: response = "That's not a valid stock name, please use a proper one, you c**t: {}".format( ewutils.formatNiceList(ewcfg.stocks)) # Send the response to the player. await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
def format_tutorial_response(scene): response = scene.text if scene.dungeon_state: response += "\n\nWhat do you do?\n\n**>options: " options = [] for path in scene.options.keys(): options.append("{}{}".format(ewcfg.cmd_prefix, path)) response += ewutils.formatNiceList(names=options, conjunction="or") response += "**" return response
async def equip(cmd): response = "" user_data = EwUser(member=cmd.message.author) if cmd.message.channel.name != ewcfg.channel_dojo: response = "You must go to the #{} to change your equipment.".format( ewcfg.channel_dojo) elif user_data.life_state == ewcfg.life_state_corpse: response = "Ghosts can't equip weapons." elif user_data.life_state == ewcfg.life_state_juvenile: response = "Juvies can't equip weapons." else: value = None if cmd.tokens_count > 1: value = cmd.tokens[1] value = value.lower() weapon = ewcfg.weapon_map.get(value) if weapon != None: response = weapon.str_equip try: conn_info = ewutils.databaseConnect() conn = conn_info.get('conn') cursor = conn.cursor() user_skills = ewutils.weaponskills_get( member=cmd.message.author) user_data.weapon = weapon.id_weapon weaponskillinfo = user_skills.get(weapon.id_weapon) if weaponskillinfo == None: user_data.weaponskill = 0 user_data.weaponname = "" else: user_data.weaponskill = weaponskillinfo.get('skill') user_data.weaponname = weaponskillinfo.get('name') user_data.persist() conn.commit() finally: cursor.close() ewutils.databaseClose(conn_info) else: response = "Choose your weapon: {}".format( ewutils.formatNiceList(names=ewcfg.weapon_names, conjunction="or")) # Send the response to the player. await cmd.client.send_message( cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def equip(cmd): resp = await ewcmd.start(cmd) response = "" if cmd.message.channel.name != ewcfg.channel_dojo: response = "You must go to the #{} to change your equipment.".format( ewcfg.channel_dojo) else: value = None if cmd.tokens_count > 1: value = cmd.tokens[1] weapon = ewcfg.weapon_map.get(value) if weapon != None: response = weapon.str_equip try: conn = ewutils.databaseConnect() cursor = conn.cursor() user_data = EwUser(member=cmd.message.author, conn=conn, cursor=cursor) user_skills = ewutils.weaponskills_get( member=cmd.message.author, conn=conn, cursor=cursor) user_data.weapon = weapon.id_weapon weaponskillinfo = user_skills.get(weapon.id_weapon) if weaponskillinfo == None: user_data.weaponskill = 0 user_data.weaponname = "" else: user_data.weaponskill = weaponskillinfo.get('skill') user_data.weaponname = weaponskillinfo.get('name') user_data.persist(conn=conn, cursor=cursor) conn.commit() finally: cursor.close() conn.close() else: response = "Choose your weapon: {}".format( ewutils.formatNiceList(names=ewcfg.weapon_names, conjunction="or")) # Send the response to the player. await cmd.client.edit_message( resp, ewutils.formatMessage(cmd.message.author, response))
async def menu(cmd): if cmd.message.channel.name != ewcfg.channel_foodcourt: # Only allowed in the food court. response = ewcfg.str_food_channelreq.format(action="see the menu") else: response = "NLACakaNM Food Court Menu:\n\n" for vendor in ewcfg.food_vendor_inv: response += "**{}**: *{}*\n".format( vendor, ewutils.formatNiceList(names=ewcfg.food_vendor_inv[vendor])) # Send the response to the player. await cmd.client.send_message( cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def stocks(cmd): user_data = EwUser(member=cmd.message.author) if user_data.poi != ewcfg.poi_id_stockexchange: # Only allowed in the stock exchange. response = "You must go to the Slime Stock Exchange to check the currently available stocks." return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) else: response = "Here are the currently available stocks: {}".format( ewutils.formatNiceList(ewcfg.stocks)) # 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) poi = ewcfg.id_to_poi.get(user_data.poi) if poi == None or len(poi.vendors) == 0: # Only allowed in the food court. response = ewcfg.str_food_channelreq.format(action="see the menu") else: response = "{} Menu:\n\n".format(poi.str_name) for vendor in poi.vendors: response += "**{}**: *{}*\n".format( vendor, ewutils.formatNiceList(names=ewcfg.food_vendor_inv[vendor])) # Send the response to the player. await cmd.client.send_message( cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def rate(cmd): user_data = EwUser(member=cmd.message.author) response = "" if user_data.poi != ewcfg.poi_id_stockexchange: # Only allowed in the stock exchange. response = "You must go to the Slime Stock Exchange to check the current stock exchange rates ." return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) else: stock = "" if cmd.tokens_count > 0: stock = ewutils.flattenTokenListToString(cmd.tokens[1:]) if stock in ewcfg.stocks: stock = EwStock(id_server=cmd.message.server.id, stock=stock) response = "The current value of {stock} stocks is {cred:,} SlimeCoin per 1000 Shares.".format( stock=ewcfg.stock_names.get(stock.id_stock), cred=stock.exchange_rate) elif stock == "": for stock in ewcfg.stocks: stock = EwStock(id_server=cmd.message.server.id, stock=stock) response += "\nThe current value of {stock} stocks is {cred:,} SlimeCoin per 1000 Shares.".format( stock=ewcfg.stock_names.get(stock.id_stock), cred=stock.exchange_rate) else: response = "That's not a valid stock name, please use a proper one, you c**t: {}".format( ewutils.formatNiceList(ewcfg.stocks)) # Send the response to the player. await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def data(cmd): response = "" user_data = None member = None resp_cont = ewutils.EwResponseContainer(id_server=cmd.message.server.id) if len(cmd.tokens) > 1 and cmd.mentions_count == 0: user_data = EwUser(member=cmd.message.author) soughtenemy = " ".join(cmd.tokens[1:]).lower() enemy = find_enemy(soughtenemy, user_data) if enemy != None: if enemy.attacktype != ewcfg.enemy_attacktype_unarmed: response = "{} is a level {} enemy. They have {} slime, and attack with their {}.".format( enemy.display_name, enemy.level, enemy.slimes, enemy.attacktype) else: response = "{} is a level {} enemy. They have {} slime.".format( enemy.display_name, enemy.level, enemy.slimes) else: response = "ENDLESS WAR didn't understand that name." resp_cont.add_channel_response(cmd.message.channel.name, response) elif cmd.mentions_count == 0: user_data = EwUser(member=cmd.message.author) slimeoid = EwSlimeoid(member=cmd.message.author) mutations = user_data.get_mutations() cosmetics = ewitem.inventory(id_user=cmd.message.author.id, id_server=cmd.message.server.id, item_type_filter=ewcfg.it_cosmetic) adorned_cosmetics = [] for cosmetic in cosmetics: cos = EwItem(id_item=cosmetic.get('id_item')) if cos.item_props['adorned'] == 'true': hue = ewcfg.hue_map.get(cos.item_props.get('hue')) adorned_cosmetics.append((hue.str_name + " " if hue != None else "") + cosmetic.get('name')) poi = ewcfg.id_to_poi.get(user_data.poi) if poi != None: response = "You find yourself {} {}. ".format( poi.str_in, poi.str_name) # return my data if user_data.life_state == ewcfg.life_state_corpse: response += "You are a level {} deadboi.".format( user_data.slimelevel) else: response += "You are a level {} slimeboi.".format( user_data.slimelevel) coinbounty = int(user_data.bounty / ewcfg.slimecoin_exchangerate) weapon_item = EwItem(id_item=user_data.weapon) weapon = ewcfg.weapon_map.get( weapon_item.item_props.get("weapon_type")) if weapon != None: response += " {} {}{}.".format( ewcfg.str_weapon_married_self if user_data.weaponmarried == True else ewcfg.str_weapon_wielding_self, ("" if len(weapon_item.item_props.get("weapon_name")) == 0 else "{}, ".format(weapon_item.item_props.get("weapon_name"))), weapon.str_weapon) if user_data.weaponskill >= 5: response += " {}".format( weapon.str_weaponmaster_self.format( rank=(user_data.weaponskill - 4))) trauma = ewcfg.weapon_map.get(user_data.trauma) # if trauma is not gathered from weapon_map, get it from attack_type_map if trauma == None: trauma = ewcfg.attack_type_map.get(user_data.trauma) if trauma != None: response += " {}".format(trauma.str_trauma_self) response_block = "" for mutation in mutations: mutation_flavor = ewcfg.mutations_map[mutation] response_block += "{} ".format(mutation_flavor.str_describe_self) if len(response_block) > 0: response += "\n\n" + response_block resp_cont.add_channel_response(cmd.message.channel.name, response) response = "" response_block = "" user_kills = ewstats.get_stat(user=user_data, metric=ewcfg.stat_kills) enemy_kills = ewstats.get_stat(user=user_data, metric=ewcfg.stat_pve_kills) if user_kills > 0 and enemy_kills > 0: response_block += "You have {:,} confirmed kills, and {:,} confirmed hunts. ".format( user_kills, enemy_kills) elif user_kills > 0: response_block += "You have {:,} confirmed kills. ".format( user_kills) elif enemy_kills > 0: response_block += "You have {:,} confirmed hunts. ".format( enemy_kills) if coinbounty != 0: response_block += "SlimeCorp offers a bounty of {:,} SlimeCoin for your death. ".format( coinbounty) if len(adorned_cosmetics) > 0: response_block += "You have a {} adorned. ".format( ewutils.formatNiceList(adorned_cosmetics, 'and')) if user_data.hunger > 0: response_block += "You are {}% hungry. ".format( round(user_data.hunger * 100.0 / user_data.get_hunger_max(), 1)) if user_data.busted and user_data.life_state == ewcfg.life_state_corpse: response_block += "You are busted and therefore cannot leave the sewers until your next !haunt. " statuses = user_data.getStatusEffects() for status in statuses: status_effect = EwStatusEffect(id_status=status, user_data=user_data) if status_effect.time_expire > time.time( ) or status_effect.time_expire == -1: status_flavor = ewcfg.status_effects_def_map.get(status) if status_flavor is not None: response_block += status_flavor.str_describe_self + " " if (slimeoid.life_state == ewcfg.slimeoid_state_active) and ( user_data.life_state != ewcfg.life_state_corpse): response_block += "You are accompanied by {}, a {}-foot-tall Slimeoid. ".format( slimeoid.name, str(slimeoid.level)) if len(response_block) > 0: response += "\n" + response_block response += "\n\nhttps://ew.krakissi.net/stats/player.html?pl={}".format( user_data.id_user) resp_cont.add_channel_response(cmd.message.channel.name, response) else: member = cmd.mentions[0] resp_cont = gen_data_text(id_user=member.id, id_server=member.server.id, display_name=member.display_name, channel_name=cmd.message.channel.name) # Send the response to the player. resp_cont.format_channel_response(cmd.message.channel.name, cmd.message.author) await resp_cont.post() await ewrolemgr.updateRoles(client=cmd.client, member=cmd.message.author) if member != None: await ewrolemgr.updateRoles(client=cmd.client, member=member)
def gen_data_text(id_user=None, id_server=None, display_name=None, channel_name=None): resp_cont = ewutils.EwResponseContainer(id_server=id_server) response = "" user_data = EwUser(id_user=id_user, id_server=id_server) slimeoid = EwSlimeoid(id_user=id_user, id_server=id_server) mutations = user_data.get_mutations() cosmetics = ewitem.inventory(id_user=user_data.id_user, id_server=user_data.id_server, item_type_filter=ewcfg.it_cosmetic) adorned_cosmetics = [] for cosmetic in cosmetics: cos = EwItem(id_item=cosmetic.get('id_item')) if cos.item_props['adorned'] == 'true': hue = ewcfg.hue_map.get(cos.item_props.get('hue')) adorned_cosmetics.append((hue.str_name + " " if hue != None else "") + cosmetic.get('name')) if user_data.life_state == ewcfg.life_state_grandfoe: poi = ewcfg.id_to_poi.get(user_data.poi) if poi != None: response = "{} is {} {}.".format(display_name, poi.str_in, poi.str_name) else: response = "You can't discern anything useful about {}.".format( display_name) resp_cont.add_channel_response(channel_name, response) else: # return somebody's score if user_data.life_state == ewcfg.life_state_corpse: response = "{} is a level {} deadboi.".format( display_name, user_data.slimelevel) else: response = "{} is a level {} slimeboi.".format( display_name, user_data.slimelevel) coinbounty = int(user_data.bounty / ewcfg.slimecoin_exchangerate) weapon_item = EwItem(id_item=user_data.weapon) weapon = ewcfg.weapon_map.get( weapon_item.item_props.get("weapon_type")) if weapon != None: response += " {} {}{}.".format( ewcfg.str_weapon_married if user_data.weaponmarried == True else ewcfg.str_weapon_wielding, ("" if len(weapon_item.item_props.get("weapon_name")) == 0 else "{}, ".format(weapon_item.item_props.get("weapon_name"))), weapon.str_weapon) if user_data.weaponskill >= 5: response += " {}".format( weapon.str_weaponmaster.format( rank=(user_data.weaponskill - 4))) trauma = ewcfg.weapon_map.get(user_data.trauma) # if trauma is not gathered from weapon_map, get it from attack_type_map if trauma == None: trauma = ewcfg.attack_type_map.get(user_data.trauma) if trauma != None: response += " {}".format(trauma.str_trauma) response_block = "" for mutation in mutations: mutation_flavor = ewcfg.mutations_map[mutation] response_block += "{} ".format(mutation_flavor.str_describe_other) if len(response_block) > 0: response += "\n\n" + response_block resp_cont.add_channel_response(channel_name, response) response = "" response_block = "" user_kills = ewstats.get_stat(user=user_data, metric=ewcfg.stat_kills) enemy_kills = ewstats.get_stat(user=user_data, metric=ewcfg.stat_pve_kills) if user_kills > 0 and enemy_kills > 0: response_block += "They have {:,} confirmed kills, and {:,} confirmed hunts. ".format( user_kills, enemy_kills) elif user_kills > 0: response_block += "They have {:,} confirmed kills. ".format( user_kills) elif enemy_kills > 0: response_block += "They have {:,} confirmed hunts. ".format( enemy_kills) if coinbounty != 0: response_block += "SlimeCorp offers a bounty of {:,} SlimeCoin for their death. ".format( coinbounty) if len(adorned_cosmetics) > 0: response_block += "They have a {} adorned. ".format( ewutils.formatNiceList(adorned_cosmetics, 'and')) statuses = user_data.getStatusEffects() for status in statuses: status_effect = EwStatusEffect(id_status=status, user_data=user_data) if status_effect.time_expire > time.time( ) or status_effect.time_expire == -1: status_flavor = ewcfg.status_effects_def_map.get(status) if status_flavor is not None: response_block += status_flavor.str_describe + " " if (slimeoid.life_state == ewcfg.slimeoid_state_active) and ( user_data.life_state != ewcfg.life_state_corpse): response_block += "They are accompanied by {}, a {}-foot-tall Slimeoid.".format( slimeoid.name, str(slimeoid.level)) if len(response_block) > 0: response += "\n" + response_block response += "\n\nhttps://ew.krakissi.net/stats/player.html?pl={}".format( id_user) resp_cont.add_channel_response(channel_name, response) return resp_cont
async def baccarat(cmd): resp = await ewcmd.start(cmd = cmd) time_now = int(time.time()) bet = "" all_bets = ["player", "dealer", "tie"] img_base = "https://ew.krakissi.net/img/cas/sb/" response = "" rank = "" suit = "" str_ranksuit = " the **{} of {}**. " global last_rouletted_times last_used = last_rouletted_times.get(cmd.message.author.id) if last_used == None: last_used = 0 if last_used + 2 > time_now: response = "**ENOUGH**" elif cmd.message.channel.name != ewcfg.channel_casino: # Only allowed in the slime casino. response = "You must go to the Casino to gamble your SlimeCoin." await cmd.client.edit_message(resp, ewutils.formatMessage(cmd.message.author, response)) await asyncio.sleep(1) else: last_rouletted_times[cmd.message.author.id] = time_now value = None if cmd.tokens_count > 1: value = ewutils.getIntToken(tokens = cmd.tokens[:2], allow_all = True) bet = ewutils.flattenTokenListToString(tokens = cmd.tokens[2:]) if value != None: user_data = EwUser(member = cmd.message.author) if value == -1: value = user_data.slimecredit if value > user_data.slimecredit or value == 0: response = "You don't have enough SlimeCoin." await cmd.client.edit_message(resp, ewutils.formatMessage(cmd.message.author, response)) await asyncio.sleep(1) elif len(bet) == 0: response = "You must specify what hand you are betting on. Options are {}.".format(ewutils.formatNiceList(names = all_bets), img_base) await cmd.client.edit_message(resp, ewutils.formatMessage(cmd.message.author, response)) await asyncio.sleep(1) elif bet not in all_bets: response = "The dealer didn't understand your wager. Options are {}.".format(ewutils.formatNiceList(names = all_bets), img_base) await cmd.client.edit_message(resp, ewutils.formatMessage(cmd.message.author, response)) await asyncio.sleep(1) else: resp_d = await ewcmd.start(cmd = cmd) resp_f = await ewcmd.start(cmd = cmd) response = "You bet {} SlimeCoin on {}. The dealer shuffles the deck, then begins to deal.".format(str(value),str(bet)) await cmd.client.edit_message(resp, ewutils.formatMessage(cmd.message.author, response)) await asyncio.sleep(1) response += "\nThe dealer deals you your first card..." await cmd.client.edit_message(resp, ewutils.formatMessage(cmd.message.author, response)) await asyncio.sleep(3) winnings = 0 end = False phit = False d = 0 p = 0 drawp1 = str(random.randint(1,52)) if drawp1 in ["1", "14", "27", "40"]: p += 1 if drawp1 in ["2", "15", "28", "41"]: p += 2 if drawp1 in ["3", "16", "29", "42"]: p += 3 if drawp1 in ["4", "17", "30", "43"]: p += 4 if drawp1 in ["5", "18", "31", "44"]: p += 5 if drawp1 in ["6", "19", "32", "45"]: p += 6 if drawp1 in ["7", "20", "33", "46"]: p += 7 if drawp1 in ["8", "21", "34", "47"]: p += 8 if drawp1 in ["9", "22", "35", "48"]: p += 9 if drawp1 in ["10","11","12","13","23","24","25","26","36","37","38","39","49","50","51","52"]: p += 0 lastcard = drawp1 if lastcard in ["1", "14", "27", "40"]: rank = "Ace" if lastcard in ["2", "15", "28", "41"]: rank = "Two" if lastcard in ["3", "16", "29", "42"]: rank = "Three" if lastcard in ["4", "17", "30", "43"]: rank = "Four" if lastcard in ["5", "18", "31", "44"]: rank = "Five" if lastcard in ["6", "19", "32", "45"]: rank = "Six" if lastcard in ["7", "20", "33", "46"]: rank = "Seven" if lastcard in ["8", "21", "34", "47"]: rank = "Eight" if lastcard in ["9", "22", "35", "48"]: rank = "Nine" if lastcard in ["10", "23", "36", "49"]: rank = "Ten" if lastcard in ["11", "24", "37", "50"]: rank = "Jack" if lastcard in ["12", "25", "38", "51"]: rank = "Queen" if lastcard in ["13", "26", "39", "52"]: rank = "King" if lastcard in ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13"]: suit = "Hearts" if lastcard in ["14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26"]: suit = "Slugs" if lastcard in ["27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39"]: suit = "Hats" if lastcard in ["40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52"]: suit = "Shields" if p > 9: p -= 10 if d > 9: d -= 10 response += str_ranksuit.format(rank, suit) response += img_base + lastcard + ".png" await cmd.client.edit_message(resp, ewutils.formatMessage(cmd.message.author, response)) await asyncio.sleep(1) response += "\nThe dealer deals you your second card..." await cmd.client.edit_message(resp, ewutils.formatMessage(cmd.message.author, response)) await asyncio.sleep(3) while True: drawp2 = str(random.randint(1,52)) if drawp2 != drawp1: break if drawp2 in ["1", "14", "27", "40"]: p += 1 if drawp2 in ["2", "15", "28", "41"]: p += 2 if drawp2 in ["3", "16", "29", "42"]: p += 3 if drawp2 in ["4", "17", "30", "43"]: p += 4 if drawp2 in ["5", "18", "31", "44"]: p += 5 if drawp2 in ["6", "19", "32", "45"]: p += 6 if drawp2 in ["7", "20", "33", "46"]: p += 7 if drawp2 in ["8", "21", "34", "47"]: p += 8 if drawp2 in ["9", "22", "35", "48"]: p += 9 if drawp2 in ["10","11","12","13","23","24","25","26","36","37","38","39","49","50","51","52"]: p += 0 lastcard = drawp2 if lastcard in ["1", "14", "27", "40"]: rank = "Ace" if lastcard in ["2", "15", "28", "41"]: rank = "Two" if lastcard in ["3", "16", "29", "42"]: rank = "Three" if lastcard in ["4", "17", "30", "43"]: rank = "Four" if lastcard in ["5", "18", "31", "44"]: rank = "Five" if lastcard in ["6", "19", "32", "45"]: rank = "Six" if lastcard in ["7", "20", "33", "46"]: rank = "Seven" if lastcard in ["8", "21", "34", "47"]: rank = "Eight" if lastcard in ["9", "22", "35", "48"]: rank = "Nine" if lastcard in ["10", "23", "36", "49"]: rank = "Ten" if lastcard in ["11", "24", "37", "50"]: rank = "Jack" if lastcard in ["12", "25", "38", "51"]: rank = "Queen" if lastcard in ["13", "26", "39", "52"]: rank = "King" if lastcard in ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13"]: suit = "Hearts" if lastcard in ["14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26"]: suit = "Slugs" if lastcard in ["27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39"]: suit = "Hats" if lastcard in ["40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52"]: suit = "Shields" if p > 9: p -= 10 if d > 9: d -= 10 response += str_ranksuit.format(rank, suit) response += img_base + lastcard + ".png" await cmd.client.edit_message(resp, ewutils.formatMessage(cmd.message.author, response)) await asyncio.sleep(1) responsesave = response response = "\nThe dealer deals the house its first card..." await cmd.client.edit_message(resp_d, ewutils.formatMessage(cmd.message.author, response)) await asyncio.sleep(3) while True: drawd1 = str(random.randint(1,52)) if drawd1 != drawp1 and drawd1 != drawp2: break if drawd1 in ["1", "14", "27", "40"]: d += 1 if drawd1 in ["2", "15", "28", "41"]: d += 2 if drawd1 in ["3", "16", "29", "42"]: d += 3 if drawd1 in ["4", "17", "30", "43"]: d += 4 if drawd1 in ["5", "18", "31", "44"]: d += 5 if drawd1 in ["6", "19", "32", "45"]: d += 6 if drawd1 in ["7", "20", "33", "46"]: d += 7 if drawd1 in ["8", "21", "34", "47"]: d += 8 if drawd1 in ["9", "22", "35", "48"]: d += 9 if drawd1 in ["10","11","12","13","23","24","25","26","36","37","38","39","49","50","51","52"]: d += 0 lastcard = drawd1 if lastcard in ["1", "14", "27", "40"]: rank = "Ace" if lastcard in ["2", "15", "28", "41"]: rank = "Two" if lastcard in ["3", "16", "29", "42"]: rank = "Three" if lastcard in ["4", "17", "30", "43"]: rank = "Four" if lastcard in ["5", "18", "31", "44"]: rank = "Five" if lastcard in ["6", "19", "32", "45"]: rank = "Six" if lastcard in ["7", "20", "33", "46"]: rank = "Seven" if lastcard in ["8", "21", "34", "47"]: rank = "Eight" if lastcard in ["9", "22", "35", "48"]: rank = "Nine" if lastcard in ["10", "23", "36", "49"]: rank = "Ten" if lastcard in ["11", "24", "37", "50"]: rank = "Jack" if lastcard in ["12", "25", "38", "51"]: rank = "Queen" if lastcard in ["13", "26", "39", "52"]: rank = "King" if lastcard in ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13"]: suit = "Hearts" if lastcard in ["14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26"]: suit = "Slugs" if lastcard in ["27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39"]: suit = "Hats" if lastcard in ["40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52"]: suit = "Shields" if p > 9: p -= 10 if d > 9: d -= 10 response += str_ranksuit.format(rank, suit) response += img_base + lastcard + ".png" await cmd.client.edit_message(resp_d, ewutils.formatMessage(cmd.message.author, response)) await asyncio.sleep(1) response += "\nThe dealer deals the house its second card..." await cmd.client.edit_message(resp_d, ewutils.formatMessage(cmd.message.author, response)) await asyncio.sleep(3) while True: drawd2 = str(random.randint(1,52)) if drawd2 != drawp1 and drawd2 != drawp2 and drawd2 != drawd1: break if drawd2 in ["1", "14", "27", "40"]: d += 1 if drawd2 in ["2", "15", "28", "41"]: d += 2 if drawd2 in ["3", "16", "29", "42"]: d += 3 if drawd2 in ["4", "17", "30", "43"]: d += 4 if drawd2 in ["5", "18", "31", "44"]: d += 5 if drawd2 in ["6", "19", "32", "45"]: d += 6 if drawd2 in ["7", "20", "33", "46"]: d += 7 if drawd2 in ["8", "21", "34", "47"]: d += 8 if drawd2 in ["9", "22", "35", "48"]: d += 9 if drawd2 in ["10","11","12","13","23","24","25","26","36","37","38","39","49","50","51","52"]: d += 0 lastcard = drawd2 if lastcard in ["1", "14", "27", "40"]: rank = "Ace" if lastcard in ["2", "15", "28", "41"]: rank = "Two" if lastcard in ["3", "16", "29", "42"]: rank = "Three" if lastcard in ["4", "17", "30", "43"]: rank = "Four" if lastcard in ["5", "18", "31", "44"]: rank = "Five" if lastcard in ["6", "19", "32", "45"]: rank = "Six" if lastcard in ["7", "20", "33", "46"]: rank = "Seven" if lastcard in ["8", "21", "34", "47"]: rank = "Eight" if lastcard in ["9", "22", "35", "48"]: rank = "Nine" if lastcard in ["10", "23", "36", "49"]: rank = "Ten" if lastcard in ["11", "24", "37", "50"]: rank = "Jack" if lastcard in ["12", "25", "38", "51"]: rank = "Queen" if lastcard in ["13", "26", "39", "52"]: rank = "King" if lastcard in ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13"]: suit = "Hearts" if lastcard in ["14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26"]: suit = "Slugs" if lastcard in ["27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39"]: suit = "Hats" if lastcard in ["40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52"]: suit = "Shields" if p > 9: p -= 10 if d > 9: d -= 10 response += str_ranksuit.format(rank, suit) response += img_base + lastcard + ".png" await cmd.client.edit_message(resp_d, ewutils.formatMessage(cmd.message.author, response)) await asyncio.sleep(1) responsesave_d = response if d in [8, 9] or p in [8, 9]: end = True drawp3 = "" if (p <= 5) and (end != True): response = responsesave response += "\nThe dealer deals you another card..." await cmd.client.edit_message(resp, ewutils.formatMessage(cmd.message.author, response)) await asyncio.sleep(3) phit = True while True: drawp3 = str(random.randint(1,52)) if drawp3 != drawp1 and drawp3 != drawp2 and drawp3 != drawd1 and drawp3 != drawd2: break if drawp3 in ["1", "14", "27", "40"]: p += 1 if drawp3 in ["2", "15", "28", "41"]: p += 2 if drawp3 in ["3", "16", "29", "42"]: p += 3 if drawp3 in ["4", "17", "30", "43"]: p += 4 if drawp3 in ["5", "18", "31", "44"]: p += 5 if drawp3 in ["6", "19", "32", "45"]: p += 6 if drawp3 in ["7", "20", "33", "46"]: p += 7 if drawp3 in ["8", "21", "34", "47"]: p += 8 if drawp3 in ["9", "22", "35", "48"]: p += 9 if drawp3 in ["10","11","12","13","23","24","25","26","36","37","38","39","49","50","51","52"]: p += 0 lastcard = drawp3 if lastcard in ["1", "14", "27", "40"]: rank = "Ace" if lastcard in ["2", "15", "28", "41"]: rank = "Two" if lastcard in ["3", "16", "29", "42"]: rank = "Three" if lastcard in ["4", "17", "30", "43"]: rank = "Four" if lastcard in ["5", "18", "31", "44"]: rank = "Five" if lastcard in ["6", "19", "32", "45"]: rank = "Six" if lastcard in ["7", "20", "33", "46"]: rank = "Seven" if lastcard in ["8", "21", "34", "47"]: rank = "Eight" if lastcard in ["9", "22", "35", "48"]: rank = "Nine" if lastcard in ["10", "23", "36", "49"]: rank = "Ten" if lastcard in ["11", "24", "37", "50"]: rank = "Jack" if lastcard in ["12", "25", "38", "51"]: rank = "Queen" if lastcard in ["13", "26", "39", "52"]: rank = "King" if lastcard in ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13"]: suit = "Hearts" if lastcard in ["14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26"]: suit = "Slugs" if lastcard in ["27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39"]: suit = "Hats" if lastcard in ["40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52"]: suit = "Shields" if p > 9: p -= 10 if d > 9: d -= 10 response += str_ranksuit.format(rank, suit) response += img_base + lastcard + ".png" await cmd.client.edit_message(resp, ewutils.formatMessage(cmd.message.author, response)) await asyncio.sleep(1) if ((phit != True and d <= 5) or (phit == True and ((d <= 2) or (d == 3 and drawp3 not in ["8", "21", "34", "47"]) or (d == 4 and drawp3 in ["2", "15", "28", "41", "3", "16", "29", "42", "4", "17", "30", "43", "5", "18", "31", "44", "6", "19", "32", "45", "7", "20", "33", "46"]) or (d == 5 and drawp3 in ["4", "17", "30", "43", "5", "18", "31", "44", "6", "19", "32", "45", "7", "20", "33", "46"]) or (d == 6 and drawp3 in ["6", "19", "32", "45", "7", "20", "33", "46"])))) and (d != 7) and (end != True): response = responsesave_d response += "\nThe dealer deals the house another card..." await cmd.client.edit_message(resp_d, ewutils.formatMessage(cmd.message.author, response)) await asyncio.sleep(3) while True: drawd3 = str(random.randint(1,52)) if drawd3 != drawp1 and drawd3 != drawp2 and drawd3 != drawd1 and drawd3 != drawd2 and drawd3 != drawp3: break if drawd3 in ["1", "14", "27", "40"]: d += 1 if drawd3 in ["2", "15", "28", "41"]: d += 2 if drawd3 in ["3", "16", "29", "42"]: d += 3 if drawd3 in ["4", "17", "30", "43"]: d += 4 if drawd3 in ["5", "18", "31", "44"]: d += 5 if drawd3 in ["6", "19", "32", "45"]: d += 6 if drawd3 in ["7", "20", "33", "46"]: d += 7 if drawd3 in ["8", "21", "34", "47"]: d += 8 if drawd3 in ["9", "22", "35", "48"]: d += 9 if drawd3 in ["10","11","12","13","23","24","25","26","36","37","38","39","49","50","51","52"]: d += 0 lastcard = drawd3 if lastcard in ["1", "14", "27", "40"]: rank = "Ace" if lastcard in ["2", "15", "28", "41"]: rank = "Two" if lastcard in ["3", "16", "29", "42"]: rank = "Three" if lastcard in ["4", "17", "30", "43"]: rank = "Four" if lastcard in ["5", "18", "31", "44"]: rank = "Five" if lastcard in ["6", "19", "32", "45"]: rank = "Six" if lastcard in ["7", "20", "33", "46"]: rank = "Seven" if lastcard in ["8", "21", "34", "47"]: rank = "Eight" if lastcard in ["9", "22", "35", "48"]: rank = "Nine" if lastcard in ["10", "23", "36", "49"]: rank = "Ten" if lastcard in ["11", "24", "37", "50"]: rank = "Jack" if lastcard in ["12", "25", "38", "51"]: rank = "Queen" if lastcard in ["13", "26", "39", "52"]: rank = "King" if lastcard in ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13"]: suit = "Hearts" if lastcard in ["14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26"]: suit = "Slugs" if lastcard in ["27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39"]: suit = "Hats" if lastcard in ["40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52"]: suit = "Shields" if p > 9: p -= 10 if d > 9: d -= 10 response += str_ranksuit.format(rank, suit) response += img_base + lastcard + ".png" await cmd.client.edit_message(resp_d, ewutils.formatMessage(cmd.message.author, response)) await asyncio.sleep(2) if p > 9: p -= 10 if d > 9: d -= 10 if p > d: response = "\n\nPlayer hand beats the dealer hand {} to {}.".format(str(p), str(d)) result = "player" odds = 2 elif d > p: response = "\n\nDealer hand beats the player hand {} to {}.".format(str(d), str(p)) result = "dealer" odds = 2 else: # p == d (peed lol) response = "\n\nPlayer hand and dealer hand tied at {}.".format(str(p)) result = "tie" odds = 8 if bet == result: winnings = (odds * value) response += "\n\n**You won {:,} SlimeCoin!**".format(winnings) else: response += "\n\n*You lost your bet.*" # add winnings/subtract losses user_data = EwUser(member = cmd.message.author) user_data.change_slimecredit(n = winnings - value, coinsource = ewcfg.coinsource_casino) user_data.persist() await cmd.client.edit_message(resp_f, ewutils.formatMessage(cmd.message.author, response)) else: response = "Specify how much SlimeCoin you will wager." await cmd.client.edit_message(resp, ewutils.formatMessage(cmd.message.author, response))
async def roulette(cmd): resp = await ewcmd.start(cmd = cmd) time_now = int(time.time()) bet = "" all_bets = ["0", "00", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "1strow", "2ndrow", "3rdrow", "1st12", "2nd12", "3rd12", "1to18", "19to36", "even", "odd", "pink", "purple", "green"] img_base = "https://ew.krakissi.net/img/cas/sr/" global last_rouletted_times last_used = last_rouletted_times.get(cmd.message.author.id) if last_used == None: last_used = 0 if last_used + 5 > time_now: response = "**ENOUGH**" elif cmd.message.channel.name != ewcfg.channel_casino: # Only allowed in the slime casino. response = "You must go to the #{} to gamble your SlimeCoin.".format(ewcfg.channel_casino) else: last_rouletted_times[cmd.message.author.id] = time_now value = None if cmd.tokens_count > 1: value = ewutils.getIntToken(tokens = cmd.tokens[:2], allow_all = True) bet = ewutils.flattenTokenListToString(tokens = cmd.tokens[2:]) if value != None: user_data = EwUser(member = cmd.message.author) if value == -1: value = user_data.slimecredit if value > user_data.slimecredit or value == 0: response = "You don't have enough SlimeCoin." elif len(bet) == 0: response = "You need to say what you're betting on. Options are: {}\n{}board.png".format(ewutils.formatNiceList(names = all_bets), img_base) elif bet not in all_bets: response = "The dealer didn't understand your wager. Options are: {}\n{}board.png".format(ewutils.formatNiceList(names = all_bets), img_base) else: await cmd.client.edit_message(resp, ewutils.formatMessage( cmd.message.author, img_base + "sr.gif" )) await asyncio.sleep(5) roll = str(random.randint(1, 38)) if roll == "37": roll = "0" if roll == "38": roll = "00" odd = ["1", "3", "5", "7", "9", "11", "13", "15", "17", "19", "21", "23", "25", "27", "29", "31", "33", "35"] even = ["2", "4", "6", "8", "10", "12", "14", "16", "18", "20", "22", "24", "26", "28", "30", "32", "34", "36"] firstrow = ["1", "4", "7", "10", "13", "16", "19", "22", "25", "28", "31", "34"] secondrow = ["2", "5", "8", "11", "14", "17", "20", "23", "26", "29", "32", "35"] thirdrow = ["3", "6", "9", "12", "15", "18", "21", "24", "27", "30", "33", "36"] firsttwelve = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"] secondtwelve = ["13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24"] thirdtwelve = ["25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36"] onetoeighteen = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18"] nineteentothirtysix = ["19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36"] pink = ["2", "4", "6", "8", "10", "11", "13", "15", "17", "20", "22", "24", "26", "28", "29", "31", "33", "35"] purple = ["1", "3", "5", "7", "9", "12", "14", "16", "18", "19", "21", "23", "25", "27", "30", "32", "34", "36"] green = ["0", "00"] if roll == bet: winnings = (value * 36) elif bet == "1strow" and roll in firstrow: winnings = (value * 3) elif bet == "2ndrow" and roll in secondrow: winnings = (value * 3) elif bet == "3rdrow" and roll in thirdrow: winnings = (value * 3) elif bet == "1st12" and roll in firsttwelve: winnings = (value * 3) elif bet == "2nd12" and roll in secondtwelve: winnings = (value * 3) elif bet == "3rd12" and roll in thirdtwelve: winnings = (value * 3) elif bet == "1to18" and roll in onetoeighteen: winnings = (value * 2) elif bet == "19to36" and roll in nineteentothirtysix: winnings = (value * 2) elif bet == "odd" and roll in odd: winnings = (value * 2) elif bet == "even" and roll in even: winnings = (value * 2) elif bet == "pink" and roll in pink: winnings = (value * 2) elif bet == "purple" and roll in purple: winnings = (value * 2) elif bet == "green" and roll in green: winnings = (value * 18) else: winnings = 0 response = "The ball landed on {}!\n".format(roll) if winnings > 0: response += " You won {} SlimeCoin!".format(winnings) else: response += " You lost your bet..." # Assemble image file name. response += "\n\n{}{}.gif".format(img_base, roll) # add winnings/subtract losses user_data.change_slimecredit(n = winnings - value, coinsource = ewcfg.coinsource_casino) user_data.persist() else: response = "Specify how much SlimeCoin you will wager." # Send the response to the player. await cmd.client.edit_message(resp, ewutils.formatMessage(cmd.message.author, response))
async def advertise(cmd): time_now = int(time.time()) user_data = EwUser(member = cmd.message.author) if cmd.message.channel.name != ewcfg.channel_slimecorphq: response = "To buy ad space, you'll need to go SlimeCorp HQ." return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) cost = ewcfg.slimecoin_toadvertise if user_data.slimecoin < cost: response = "Your don't have enough slimecoin to advertise. ({:,}/{:,})".format(user_data.slimecoin, cost) return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) ads = get_ads(cmd.message.server.id) if len(ads) >= ewcfg.max_concurrent_ads: first_ad = EwAd(id_ad = ads[0]) first_expire = first_ad.time_expir secs_to_expire = int(first_expire - time_now) mins_to_expire = int(secs_to_expire / 60) hours_to_expire = int(mins_to_expire / 60) days_to_expire = int(hours_to_expire / 24) expire_list = [] if hours_to_expire > 0: expire_list.append("{} days".format(days_to_expire)) if hours_to_expire > 0: expire_list.append("{} hours".format(hours_to_expire % 24)) if mins_to_expire > 0: expire_list.append("{} minutes".format(mins_to_expire % 60)) else: expire_list.append("{} seconds".format(secs_to_expire % 60)) time_to_expire = ewutils.formatNiceList(names = expire_list, conjunction = "and") response = "Sorry, but all of our ad space is currently in use. The next vacancy will be in {}.".format(time_to_expire) return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) if cmd.tokens_count < 2: response = "Please specify the content of your ad." return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) content = cmd.message.content[len(cmd.tokens[0]):].strip() if len(content) > ewcfg.max_length_ads: response = "Your ad is too long, we can't fit that on a billboard. ({:,}/{:,})".format(len(content), ewcfg.max_length_ads) return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) sponsor_disclaimer = "Paid for by {}".format(cmd.message.author.display_name) response = "This is what your ad is going to look like." await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) response = "{}\n\n*{}*".format(content, sponsor_disclaimer) await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) response = "It will cost {:,} slimecoin to stay up for 4 weeks. Is this fine? {} or {}".format(cost, ewcfg.cmd_confirm, ewcfg.cmd_cancel) await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) accepted = False try: msg = await cmd.client.wait_for_message(timeout = 30, author = cmd.message.author, check = ewutils.check_confirm_or_cancel) if msg != None: if msg.content.lower() == ewcfg.cmd_confirm: accepted = True except: accepted = False if accepted: create_ad( id_server = cmd.message.server.id, id_sponsor = cmd.message.author.id, content = content, time_expir = time_now + ewcfg.uptime_ads, ) user_data.change_slimecoin(n = -cost, coinsource = ewcfg.coinsource_spending) user_data.persist() response = "Your ad will be put up immediately. Thank you for your business." return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) else: response = "Good luck raising awareness by word of mouth." return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def publish_manuscript(cmd = None, dm = False): user_data = EwUser(member=cmd.message.author) market_data = EwMarket(id_server = user_data.id_server) if not dm: poi = ewcfg.chname_to_poi.get(cmd.message.channel.name) else: poi = ewcfg.id_to_poi.get(user_data.poi) if not poi.write_manuscript and not dm: response = "You'd love to work on your zine, however your current location doesn't strike you as a particularly good place to write. Try heading over the the Cafe, the Comic Shop, or one of the colleges (NLACU/NMS)." elif poi not in ewcfg.zine_mother_districts and dm: response = "You'd love to work on your zine, however your current location doesn't strike you as a particularly good place to write. Try heading over the the Cafe, the Comic Shop, or one of the colleges (NLACU/NMS). Keep in mind, once you're there you can work on your manuscript in DMs." elif user_data.manuscript == -1: response = "You have yet to create a manuscript. Try !createmanuscript" else: book = EwBook(member=cmd.message.author, book_state=0) # check if zine is unreasonably short length = 0 for page in book.book_pages.keys(): length += len(book.book_pages[page]) if book.genre == -1: response = "Before you publish your zine, you must first set a genre with !setgenre. The genre choices are {}.".format(ewutils.formatNiceList(ewcfg.book_genres)) elif len(book.book_pages.keys()) < 3 or length < 10: response = "Who are you trying to fool? This zine is obviously too short!" else: accepted = False response = "Are you sure you want to publish your manuscript? This cannot be undone. **!accept** or **!refuse**" await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) try: message = await cmd.client.wait_for_message(timeout=20, author=cmd.message.author, check=check) if message != None: if message.content.lower() == "!accept": accepted = True if message.content.lower() == "!refuse": accepted = False except: accepted = False if not accepted: response = "The manuscript was not published." else: book.book_state = 1 book.date_published = market_data.day length = 0 for page in range(1, book.pages+1): length += len(book.book_pages.get(page, "")) book.length = length user_data.manuscript = -1 user_data.persist() book.persist() ewitem.item_create( item_type=ewcfg.it_book, id_user=user_data.id_user, id_server=book.id_server, item_props={ "title": book.title, "author": book.author, "date_published": book.date_published, "id_book": book.id_book, "book_desc": "A zine by {}, published on {}. It's the author's copy.".format(book.author, book.date_published) }) book_sale = EwBookSale(id_book=book.id_book, member=cmd.message.author) book_sale.bought = 1 book_sale.persist() response = "You've published your manuscript! Anybody can now buy your creation and you'll get royalties!" await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def withdraw(cmd): user_data = EwUser(member=cmd.message.author) time_now = round(time.time()) market_data = EwMarket(id_server=cmd.message.author.server.id) if market_data.clock < 6 or market_data.clock >= 20: response = ewcfg.str_exchange_closed return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) if user_data.poi != ewcfg.poi_id_stockexchange: # Only allowed in the stock exchange. response = ewcfg.str_exchange_channelreq.format(currency="SlimeCoin", action="withdraw") 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: # Disallow withdraws from ghosts. response = "Your slimebroker can't confirm your identity while you're dead." return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) else: value = None stock = None if cmd.tokens_count > 1: value = ewutils.getIntToken(cmd.tokens[1:], allow_all=True) for token in cmd.tokens[1:]: if token.lower() in ewcfg.stocks: stock = token.lower() break if stock != None: stock = EwStock(id_server=cmd.message.server.id, stock=stock) total_shares = getUserTotalShares(id_server=user_data.id_server, stock=stock.id_stock, id_user=user_data.id_user) if value != None: if value < 0: value = total_shares if value <= 0: value = None if value != None: if value <= total_shares: exchange_rate = (stock.exchange_rate / 1000.0) shares = value slimecoin = round(value * exchange_rate) if user_data.time_lastinvest + ewcfg.cd_invest > time_now: # Limit frequency of withdrawals response = ewcfg.str_exchange_busy.format( action="withdraw") else: user_data.change_slimecoin( n=slimecoin, coinsource=ewcfg.coinsource_withdraw) total_shares -= shares user_data.time_lastinvest = time_now stock.total_shares -= shares response = "You exchange {shares:,} shares in {stock} for {coins:,} SlimeCoin.".format( coins=slimecoin, shares=shares, stock=ewcfg.stock_names.get(stock.id_stock)) user_data.persist() stock.timestamp = round(time.time()) stock.persist() updateUserTotalShares(id_server=user_data.id_server, stock=stock.id_stock, id_user=user_data.id_user, shares=total_shares) else: response = "You don't have that many shares in {stock} to exchange.".format( stock=ewcfg.stock_names.get(stock.id_stock)) else: response = ewcfg.str_exchange_specify.format( currency="SlimeCoin", action="withdraw") else: response = "That's not a valid stock name, please use a proper one, you c**t: {}".format( ewutils.formatNiceList(names=ewcfg.stocks)) await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def smelt(cmd): user_data = EwUser(member = cmd.message.author) if user_data.life_state == ewcfg.life_state_shambler: response = "You lack the higher brain functions required to {}.".format(cmd.tokens[0]) return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) # Find sought recipe. if cmd.tokens_count > 1: sought_result = ewutils.flattenTokenListToString(cmd.tokens[1:]) found_recipe = ewcfg.smelting_recipe_map.get(sought_result) if found_recipe != None: if 'soul' in found_recipe.products: return await smeltsoul(cmd=cmd) # Checks what ingredients are needed to smelt the recipe. necessary_ingredients = found_recipe.ingredients necessary_ingredients_list = [] owned_ingredients = [] # Seeks out the necessary ingredients in your inventory. missing_ingredients = [] for matched_item in necessary_ingredients: necessary_items = necessary_ingredients.get(matched_item) necessary_str = "{} {}".format(necessary_items, matched_item) if necessary_items > 1: necessary_str += "s" necessary_ingredients_list.append(necessary_str) sought_items = ewitem.find_item_all(item_search = matched_item, id_user = user_data.id_user, id_server = user_data.id_server) missing_items = necessary_items - len(sought_items) if missing_items > 0: missing_str = "{} {}".format(missing_items, matched_item) if missing_items > 1: missing_str += "s" missing_ingredients.append(missing_str) else: for i in range(necessary_ingredients.get(matched_item)): sought_item = sought_items.pop() owned_ingredients.append(sought_item.get('id_item')) # If you don't have all the necessary ingredients. if len(missing_ingredients) > 0: response = "You’ve never done this before, have you? To smelt {}, you’ll need to combine *{}*.".format(found_recipe.str_name, ewutils.formatNiceList(names = necessary_ingredients_list, conjunction = "and")) response += " You are missing *{}*.".format(ewutils.formatNiceList(names = missing_ingredients, conjunction = "and")) else: # If you try to smelt a random cosmetic, use old smelting code to calculate what your result will be. if found_recipe.id_recipe == "cosmetic": patrician_rarity = 20 patrician_smelted = random.randint(1, patrician_rarity) patrician = False if patrician_smelted == 1: patrician = True cosmetics_list = [] for result in ewcfg.cosmetic_items_list: if result.acquisition == ewcfg.acquisition_smelting: cosmetics_list.append(result) else: pass items = [] for cosmetic in cosmetics_list: if patrician and cosmetic.rarity == ewcfg.rarity_patrician: items.append(cosmetic) elif not patrician and cosmetic.rarity == ewcfg.rarity_plebeian: items.append(cosmetic) item = items[random.randint(0, len(items) - 1)] ewitem.item_create( item_type = ewcfg.it_cosmetic, id_user = cmd.message.author.id, id_server = cmd.message.server.id, item_props = { 'id_cosmetic': item.id_cosmetic, 'cosmetic_name': item.str_name, 'cosmetic_desc': item.str_desc, 'rarity': item.rarity, 'adorned': 'false' } ) # If you're trying to smelt a specific item. else: possible_results = [] # Matches the recipe's listed products to actual items. for result in ewcfg.smelt_results: if hasattr(result, 'id_item'): if result.id_item not in found_recipe.products: pass else: possible_results.append(result) if hasattr(result, 'id_food'): if result.id_food not in found_recipe.products: pass else: possible_results.append(result) if hasattr(result, 'id_cosmetic'): if result.id_cosmetic not in found_recipe.products: pass else: possible_results.append(result) if hasattr(result, 'id_weapon'): if result.id_weapon not in found_recipe.products: pass else: possible_results.append(result) if hasattr(result, 'id_furniture'): if result.id_furniture not in found_recipe.products: pass else: possible_results.append(result) # If there are multiple possible products, randomly select one. item = random.choice(possible_results) item_props = ewitem.gen_item_props(item) newitem_id = ewitem.item_create( item_type = item.item_type, id_user = cmd.message.author.id, id_server = cmd.message.server.id, item_props = item_props ) for id_item in owned_ingredients: item_check = ewitem.EwItem(id_item=id_item) if item_check.item_props.get('id_cosmetic') != 'soul': ewitem.item_delete(id_item = id_item) else: newitem = ewitem.EwItem(id_item=newitem_id) newitem.item_props['target'] = id_item newitem.persist() ewitem.give_item(id_item=id_item, id_user='******', id_server=cmd.message.server.id) name = "" if hasattr(item, 'str_name'): name = item.str_name elif hasattr(item, 'id_weapon'): name = item.id_weapon response = "You sacrifice your {} to smelt a {}!!".format(ewutils.formatNiceList(names = necessary_ingredients_list, conjunction = "and"), name) user_data.persist() else: response = "There is no recipe by the name." else: response = "Please specify a desired smelt result." # Send response await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def set_length(cmd = None, dm = False): user_data = EwUser(member=cmd.message.author) if not dm: poi = ewcfg.chname_to_poi.get(cmd.message.channel.name) else: poi = ewcfg.id_to_poi.get(user_data.poi) if not poi.write_manuscript and not dm: response = "You'd love to work on your zine, however your current location doesn't strike you as a particularly good place to write. Try heading over the the Cafe, the Comic Shop, or one of the colleges (NLACU/NMS)." elif poi not in ewcfg.zine_mother_districts and dm: response = "You'd love to work on your zine, however your current location doesn't strike you as a particularly good place to write. Try heading over the the Cafe, the Comic Shop, or one of the colleges (NLACU/NMS). Keep in mind, once you're there you can work on your manuscript in DMs." elif user_data.hunger >= user_data.get_hunger_max() and user_data.life_state != ewcfg.life_state_corpse: response = "You are just too hungry to alter the length of your masterpiece!" elif user_data.manuscript == -1: response = "You have yet to create a manuscript. Try !createmanuscript" elif len(cmd.tokens) == 1: response = "Specify how many pages you want it to be ({} and {} pages).".format(ewcfg.minimum_pages, ewcfg.maximum_pages) else: length = cmd.tokens[1] if not length.isdigit(): response = "Your manuscript can be between {} and {} pages".format(ewcfg.minimum_pages, ewcfg.maximum_pages) else: book = EwBook(member = cmd.message.author, book_state = 0) length = int(length) if book.pages == length: response = "Your manuscript is already {} pages long.".format(length) elif length > ewcfg.maximum_pages or length < ewcfg.minimum_pages: response = "Your manuscript can be between {} and {} pages".format(ewcfg.minimum_pages, ewcfg.maximum_pages) else: pages_with_content = [] for page in book.book_pages.keys(): if book.book_pages.get(page) is not None: if page > length: pages_with_content.append(page) accepted = True if len(pages_with_content) != 0: accepted = False page_list = ewutils.formatNiceList(pages_with_content) response = "There is writing on these pages: {}. If you change the number of pages to {}, you will cut these pages out. Will you still do it? **!accept** or **!refuse**".format(page_list, length) await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) try: message = await cmd.client.wait_for_message(timeout=20, author=cmd.message.author, check=check) if message != None: if message.content.lower() == "!accept": accepted = True if message.content.lower() == "!refuse": accepted = False except: accepted = False if not accepted: response = "The pages remain unchanged." else: if length > book.pages: response = "You haphazardly slap on a few extra pages at the end of your manuscript so you can write more bullshit." else: response = "You violently tear some pages out of your manuscript." book.pages = length if len(pages_with_content) != 0: for page in pages_with_content: del book.book_pages[page] book.persist() await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def invest(cmd): user_data = EwUser(member=cmd.message.author) time_now = round(time.time()) market_data = EwMarket(id_server=cmd.message.author.server.id) if user_data.poi != ewcfg.poi_id_stockexchange: # Only allowed in the stock exchange. response = ewcfg.str_exchange_channelreq.format(currency="SlimeCoin", action="invest") return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) if market_data.clock < 6 or market_data.clock >= 20: response = ewcfg.str_exchange_closed return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) if user_data.time_lastinvest + ewcfg.cd_invest > time_now: # Limit frequency of investments. response = ewcfg.str_exchange_busy.format(action="invest") 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: # Disallow invests from ghosts. response = "Your slimebroker can't confirm your identity while you're dead." return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) if user_data.life_state == ewcfg.life_state_kingpin: # Disallow investments by RF and CK kingpins. response = "You need that money to buy more videogames." return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) else: value = None stock = None if cmd.tokens_count > 1: value = ewutils.getIntToken(cmd.tokens, allow_all=True) for token in cmd.tokens[1:]: if token.lower() in ewcfg.stocks: stock = token.lower() break if value != None: if value < 0: value = user_data.slimecoin if value <= 0: value = None if value != None: if stock != None: stock = EwStock(id_server=cmd.message.server.id, stock=stock) # basic exchange rate / 1000 = 1 share exchange_rate = (stock.exchange_rate / 1000.0) cost_total = round(value * 1.05) # gets the highest value possible where the player can still pay the fee if value == user_data.slimecoin: while cost_total > user_data.slimecoin: value -= cost_total - value cost_total = round(value * 1.05) # The user can only buy a whole number of shares, so adjust their cost based on the actual number of shares purchased. net_shares = round(value / exchange_rate) if user_data.slimecoin < cost_total: response = "You don't have enough SlimeCoin. ({:,}/{:,})".format( user_data.slimecoin, cost_total) elif value > user_data.slimecoin: response = "You don't have that much SlimeCoin to invest." elif net_shares == 0: response = "You don't have enough SlimeCoin to buy a share in {stock}".format( stock=ewcfg.stock_names.get(stock.id_stock)) else: user_data.change_slimecoin( n=-cost_total, coinsource=ewcfg.coinsource_invest) shares = getUserTotalShares(id_server=user_data.id_server, stock=stock.id_stock, id_user=user_data.id_user) shares += net_shares updateUserTotalShares(id_server=user_data.id_server, stock=stock.id_stock, id_user=user_data.id_user, shares=shares) user_data.time_lastinvest = time_now stock.total_shares += net_shares response = "You invest {coin:,} SlimeCoin and receive {shares:,} shares in {stock}. Your slimebroker takes his nominal fee of {fee:,} SlimeCoin.".format( coin=value, shares=net_shares, stock=ewcfg.stock_names.get(stock.id_stock), fee=(cost_total - value)) user_data.persist() stock.timestamp = round(time.time()) stock.persist() else: response = "That's not a valid stock name, please use a proper one, you c**t: {}".format( ewutils.formatNiceList(names=ewcfg.stocks)) else: response = ewcfg.str_exchange_specify.format(currency="SlimeCoin", action="invest") # Send the response to the player. await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def find_recipes_by_item(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)) used_recipe = None # if the player specifies an item name if cmd.tokens_count > 1: sought_item = ewutils.flattenTokenListToString(cmd.tokens[1:]) # Allow for the use of recipe aliases found_recipe = ewcfg.smelting_recipe_map.get(sought_item) if found_recipe != None: used_recipe = found_recipe.id_recipe # item_sought_in_inventory = ewitem.find_item(item_search=sought_item, id_user=cmd.message.author.id, id_server=cmd.guild.id if cmd.guild is not None else None) makes_sought_item = [] uses_sought_item = [] # if the item name is an item in the player's inventory, we're assuming that the player is looking up information about this item specifically. # if item_sought_in_inventory is not None: # sought_item = item_sought_in_inventory.id_item # print(item_sought_in_inventory['item_def']) # man i could NOT get this to work . maybe another day # finds the recipes in questions that applys for name in ewcfg.recipe_names: # find recipes that this item is used as an ingredient in if ewcfg.smelting_recipe_map[name].ingredients.get( sought_item) is not None: uses_sought_item.append(name) # find recipes used to create this item elif sought_item in ewcfg.smelting_recipe_map[name].products: makes_sought_item.append(ewcfg.smelting_recipe_map[name]) # finds recipes based on possible recipe aliases elif used_recipe in ewcfg.smelting_recipe_map[name].products: makes_sought_item.append(ewcfg.smelting_recipe_map[name]) # zero matches in either of the above: if len(makes_sought_item) < 1 and len(uses_sought_item) < 1: response = "No recipes found for *{}*.".format(sought_item) #adds the recipe list to a response else: response = "\n" number_recipe = 1 list_length = len(makes_sought_item) for item in makes_sought_item: if (item.id_recipe == "toughcosmetic" and ewcfg.cosmetic_map[sought_item].style is not ewcfg.style_tough or item.id_recipe == "smartcosmetic" and ewcfg.cosmetic_map[sought_item].style is not ewcfg.style_smart or item.id_recipe == "beautifulcosmetic" and ewcfg.cosmetic_map[sought_item].style is not ewcfg.style_beautiful or item.id_recipe == "cutecosmetic" and ewcfg.cosmetic_map[sought_item].style is not ewcfg.style_cute or item.id_recipe == "coolcosmetic" and ewcfg.cosmetic_map[sought_item].style is not ewcfg.style_cool): list_length -= 1 continue else: # formats items in form "# item" (like "1 poudrin" or whatever) ingredients_list = [] ingredient_strings = [] for ingredient in item.ingredients: ingredient_strings.append("{} {}".format( item.ingredients.get(ingredient), ingredient)) if number_recipe == 1: response += "To smelt this item, you'll need *{}*. ({})\n".format( ewutils.formatNiceList(names=ingredient_strings, conjunction="and"), item.id_recipe) else: response += "Alternatively, to smelt this item, you'll need *{}*. ({})\n".format( ewutils.formatNiceList(names=ingredient_strings, conjunction="and"), item.id_recipe) number_recipe += 1 if len(uses_sought_item) > 0: response += "This item can be used to smelt *{}*.".format( ewutils.formatNiceList(names=uses_sought_item, conjunction="and")) # if the player doesnt specify a 2nd argument else: response = "Please specify an item you would like to look up usage for." # send response to 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=1) 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=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: poi = ewcfg.chname_to_poi.get(cmd.message.channel.name) district_data = EwDistrict(district=poi.id_poi, id_server=cmd.message.server.id) if district_data.is_degraded(): response = "{} has been degraded by shamblers. You can't {} here anymore.".format( poi.str_name, cmd.tokens[0]) return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) if 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) vendors_list = poi.vendors for vendor in vendors_list: if vendor == ewcfg.vendor_secretbodega: if user_data.freshness < 5000: 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 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 vendor == ewcfg.vendor_bodega: if user_data.freshness < 100: 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 < 100: response += ".. and you probably never will be." # 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 set_genre(cmd = None, dm = False): user_data = EwUser(member = cmd.message.author) genre = cmd.message.content[(len(cmd.tokens[0])):].strip() if not dm: poi = ewcfg.chname_to_poi.get(cmd.message.channel.name) else: poi = ewcfg.id_to_poi.get(user_data.poi) if not poi.write_manuscript and not dm: response = "You'd love to work on your zine, however your current location doesn't strike you as a particularly good place to write. Try heading over the the Cafe, the Comic Shop, or one of the colleges (NLACU/NMS)." elif poi not in ewcfg.zine_mother_districts and dm: response = "You'd love to work on your zine, however your current location doesn't strike you as a particularly good place to write. Try heading over the the Cafe, the Comic Shop, or one of the colleges (NLACU/NMS). Keep in mind, once you're there you can work on your manuscript in DMs." elif user_data.hunger >= user_data.get_hunger_max() and user_data.life_state != ewcfg.life_state_corpse: response = "You are just too hungry to alter the title of your masterpiece!" elif user_data.manuscript == -1: response = "You have yet to create a manuscript. Try !createmanuscript" elif genre not in ewcfg.book_genres: response = "Please specify the genre you want to change it to. You can choose from {}.".format(ewutils.formatNiceList(ewcfg.book_genres)) else: for i in [i for i, x in enumerate(ewcfg.book_genres) if x == genre]: id_genre = i book = EwBook(member = cmd.message.author, book_state = 0) book.genre = id_genre book.persist() response = "You scribble {} onto the back cover.".format(genre) 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))