async def craps(cmd): time_now = int(time.time()) global last_crapsed_times last_used = last_crapsed_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." else: last_crapsed_times[cmd.message.author.id] = time_now value = None winnings = 0 if cmd.tokens_count > 1: value = ewutils.getIntToken(tokens = cmd.tokens, allow_all = True) if value != None: user_data = EwUser(member = cmd.message.author) if value == -1: value = user_data.slimecredit elif value > user_data.slimecredit: response = "You don't have that much SlimeCoin to bet with." else: roll1 = random.randint(1,6) roll2 = random.randint(1,6) emotes_dice = [ ewcfg.emote_dice1, ewcfg.emote_dice2, ewcfg.emote_dice3, ewcfg.emote_dice4, ewcfg.emote_dice5, ewcfg.emote_dice6 ] response = " {} {}".format(emotes_dice[roll1 - 1], emotes_dice[roll2 - 1]) if (roll1 + roll2) == 7: winnings = 5 * value response += "\n\n**You rolled a 7! It's your lucky day. You won {:,} SlimeCoin.**".format(winnings) else: response += "\n\nYou didn't roll 7. You lost your SlimeCoins." # 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.send_message(cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def donate(cmd): time_now = int(time.time()) if cmd.message.channel.name != ewcfg.channel_slimecorphq: # Only allowed in SlimeCorp HQ. response = "You must go to SlimeCorp HQ to donate slime." await cmd.client.send_message(cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) return user_data = EwUser(member = cmd.message.author) value = None if cmd.tokens_count > 1: value = ewutils.getIntToken(tokens = cmd.tokens, allow_all = True) if value != None: if value < 0: value = user_data.slimes if value <= 0: value = None if value != None and value < ewcfg.slimecoin_exchangerate: response = "You must volunteer to donate at least %d slime to receive compensation." % ewcfg.slimecoin_exchangerate elif value != None: # Amount of slime invested. cost_total = int(value) coin_total = int(value / ewcfg.slimecoin_exchangerate) if user_data.slimes < cost_total: response = "Acid-green flashes of light and bloodcurdling screams emanate from small window of SlimeCorp HQ. Unfortunately, you did not survive the procedure. Your body is dumped down a disposal chute to the sewers." user_data.die(cause = ewcfg.cause_donation) user_data.persist() # Assign the corpse role to the player. He dead. await ewrolemgr.updateRoles(client = cmd.client, member = cmd.message.author) sewerchannel = ewutils.get_channel(cmd.message.server, ewcfg.channel_sewers) await cmd.client.send_message(sewerchannel, "{} ".format(ewcfg.emote_slimeskull) + ewutils.formatMessage(cmd.message.author, "You have died in a medical mishap. {}".format(ewcfg.emote_slimeskull))) else: # Do the transfer if the player can afford it. user_data.change_slimes(n = -cost_total, source = ewcfg.source_spending) user_data.change_slimecredit(n = coin_total, coinsource = ewcfg.coinsource_donation) user_data.time_lastinvest = time_now # Persist changes user_data.persist() response = "You stumble out of a Slimecorp HQ vault room in a stupor. You don't remember what happened in there, but your body hurts and you've got {slimecoin:,} shiny new SlimeCoin in your pocket.".format(slimecoin = coin_total) else: response = ewcfg.str_exchange_specify.format(currency = "slime", action = "donate") # Send the response to the player. await cmd.client.send_message(cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
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 pachinko(cmd): resp = await ewcmd.start(cmd = cmd) time_now = int(time.time()) global last_pachinkoed_times last_used = last_pachinkoed_times.get(cmd.message.author.id) if last_used == None: last_used = 0 response = "" if last_used + 10 > 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." else: last_pachinkoed_times[cmd.message.author.id] = time_now value = ewcfg.slimes_perpachinko user_data = EwUser(member = cmd.message.author) if value > user_data.slimecredit: response = "You don't have enough SlimeCoin to play." else: await cmd.client.edit_message(resp, ewutils.formatMessage(cmd.message.author, "You insert {:,} SlimeCoin. Balls begin to drop!".format(ewcfg.slimes_perpachinko))) await asyncio.sleep(3) ball_count = 10 response = "" winballs = 0 # Drop ball_count balls while ball_count > 0: ball_count -= 1 roll = random.randint(1, 5) response += "\n*plink*" # Add a varying number of plinks to make it feel more random. plinks = random.randint(1, 4) while plinks > 0: plinks -= 1 response += " *plink*" response += " PLUNK" # 1/5 chance to win. if roll == 5: response += " ... **ding!**" winballs += 1 await cmd.client.edit_message(resp, ewutils.formatMessage(cmd.message.author, response)) await asyncio.sleep(1) winnings = int(winballs * ewcfg.slimes_perpachinko / 2) # Significant time has passed since the user issued this command. We can't trust that their data hasn't changed. user_data = EwUser(member = cmd.message.author) # add winnings/subtract losses user_data.change_slimecredit(n = winnings - value, coinsource = ewcfg.coinsource_casino) user_data.persist() if winnings > 0: response += "\n\n**You won {:,} SlimeCoin!**".format(winnings) else: response += "\n\nYou lost your SlimeCoin." # Allow the player to pachinko again now that we're done. last_pachinkoed_times[cmd.message.author.id] = 0 # Send the response to the player. 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 slots(cmd): resp = await ewcmd.start(cmd = cmd) time_now = int(time.time()) global last_slotsed_times last_used = last_slotsed_times.get(cmd.message.author.id) if last_used == None: last_used = 0 if last_used + 30 > time_now: # Rate limit slot machine action. 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." else: value = ewcfg.slimes_perslot last_slotsed_times[cmd.message.author.id] = time_now user_data = EwUser(member = cmd.message.author) if value > user_data.slimecredit: response = "You don't have enough SlimeCoin." else: # Add some suspense... await cmd.client.edit_message(resp, ewutils.formatMessage(cmd.message.author, "You insert {:,} SlimeCoin and pull the handle...".format(ewcfg.slimes_perslot))) await asyncio.sleep(3) slots = [ ewcfg.emote_tacobell, ewcfg.emote_pizzahut, ewcfg.emote_kfc, ewcfg.emote_moon, ewcfg.emote_111, ewcfg.emote_copkiller, ewcfg.emote_rowdyfucker, ewcfg.emote_theeye ] slots_len = len(slots) # Roll those tumblers! spins = 3 while spins > 0: await cmd.client.edit_message(resp, ewutils.formatMessage(cmd.message.author, "{} {} {}".format( slots[random.randrange(0, slots_len)], slots[random.randrange(0, slots_len)], slots[random.randrange(0, slots_len)] ))) await asyncio.sleep(1) spins -= 1 # Determine the final state. roll1 = slots[random.randrange(0, slots_len)] roll2 = slots[random.randrange(0, slots_len)] roll3 = slots[random.randrange(0, slots_len)] response = "{} {} {}".format(roll1, roll2, roll3) winnings = 0 # Determine winnings. if roll1 == ewcfg.emote_tacobell and roll2 == ewcfg.emote_tacobell and roll3 == ewcfg.emote_tacobell: winnings = 5 * value response += "\n\n**¡Ándale! ¡Arriba! The machine spits out {:,} SlimeCoin.**".format(winnings) elif roll1 == ewcfg.emote_pizzahut and roll2 == ewcfg.emote_pizzahut and roll3 == ewcfg.emote_pizzahut: winnings = 5 * value response += "\n\n**Oven-fired goodness! The machine spits out {:,} SlimeCoin.**".format(winnings) elif roll1 == ewcfg.emote_kfc and roll2 == ewcfg.emote_kfc and roll3 == ewcfg.emote_kfc: winnings = 5 * value response += "\n\n**The Colonel's dead eyes unnerve you deeply. The machine spits out {:,} SlimeCoin.**".format(winnings) elif (roll1 == ewcfg.emote_tacobell or roll1 == ewcfg.emote_kfc or roll1 == ewcfg.emote_pizzahut) and (roll2 == ewcfg.emote_tacobell or roll2 == ewcfg.emote_kfc or roll2 == ewcfg.emote_pizzahut) and (roll3 == ewcfg.emote_tacobell or roll3 == ewcfg.emote_kfc or roll3 == ewcfg.emote_pizzahut): winnings = value response += "\n\n**You dine on fast food. The machine spits out {:,} SlimeCoin.**".format(winnings) elif roll1 == ewcfg.emote_moon and roll2 == ewcfg.emote_moon and roll3 == ewcfg.emote_moon: winnings = 5 * value response += "\n\n**Tonight seems like a good night for VIOLENCE. The machine spits out {:,} SlimeCoin.**".format(winnings) elif roll1 == ewcfg.emote_111 and roll2 == ewcfg.emote_111 and roll3 == ewcfg.emote_111: winnings = 1111 response += "\n\n**111111111111111111111111111111111111111111111111**\n\n**The machine spits out {:,} SlimeCoin.**".format(winnings) elif roll1 == ewcfg.emote_copkiller and roll2 == ewcfg.emote_copkiller and roll3 == ewcfg.emote_copkiller: winnings = 40 * value response += "\n\n**How handsome!! The machine spits out {:,} SlimeCoin.**".format(winnings) elif roll1 == ewcfg.emote_rowdyfucker and roll2 == ewcfg.emote_rowdyfucker and roll3 == ewcfg.emote_rowdyfucker: winnings = 40 * value response += "\n\n**So powerful!! The machine spits out {:,} SlimeCoin.**".format(winnings) elif roll1 == ewcfg.emote_theeye and roll2 == ewcfg.emote_theeye and roll3 == ewcfg.emote_theeye: winnings = 350 * value response += "\n\n**JACKPOT!! The machine spews forth {:,} SlimeCoin!**".format(winnings) else: response += "\n\n*Nothing happens...*" # Significant time has passed since the user issued this command. We can't trust that their data hasn't changed. user_data = EwUser(member = cmd.message.author) # add winnings/subtract losses user_data.change_slimecredit(n = winnings - value, coinsource = ewcfg.coinsource_casino) user_data.persist() last_slotsed_times[cmd.message.author.id] = 0 # Send the response to the player. await cmd.client.edit_message(resp, ewutils.formatMessage(cmd.message.author, response))
async def attack(cmd): time_now = int(time.time()) response = "" deathreport = "" coinbounty = 0 user_data = EwUser(member=cmd.message.author) slimeoid = EwSlimeoid(member=cmd.message.author) weapon = ewcfg.weapon_map.get(user_data.weapon) if ewmap.channel_name_is_poi(cmd.message.channel.name) == False: response = "You can't commit violence from here." elif ewmap.poi_is_pvp(user_data.poi) == False: response = "You must go elsewhere to commit gang violence." elif cmd.mentions_count > 1: response = "One shot at a time!" elif cmd.mentions_count <= 0: response = "Your bloodlust is appreciated, but ENDLESS WAR didn't understand that name." elif user_data.hunger >= ewutils.hunger_max_bylevel(user_data.slimelevel): response = "You are too exhausted for gang violence right now. Go get some grub!" elif cmd.mentions_count == 1: # Get shooting player's info if user_data.slimelevel <= 0: user_data.slimelevel = 1 user_data.persist() # Get target's info. member = cmd.mentions[0] shootee_data = EwUser(member=member) shootee_slimeoid = EwSlimeoid(member=member) miss = False crit = False strikes = 0 slimes_spent = int(ewutils.slime_bylevel(user_data.slimelevel) / 20) slimes_damage = int( (slimes_spent * 4) * (100 + (user_data.weaponskill * 10)) / 100.0) if weapon is None: slimes_damage /= 2 # penalty for not using a weapon, otherwise fists would be on par with other weapons slimes_dropped = shootee_data.totaldamage + shootee_data.slimes #fumble_chance = (random.randrange(10) - 4) #if fumble_chance > user_data.weaponskill: #miss = True user_iskillers = user_data.life_state == ewcfg.life_state_enlisted and user_data.faction == ewcfg.faction_killers user_isrowdys = user_data.life_state == ewcfg.life_state_enlisted and user_data.faction == ewcfg.faction_rowdys if shootee_data.life_state == ewcfg.life_state_kingpin: # Disallow killing generals. response = "He is hiding in his ivory tower and playing video games like a retard." elif (slimes_spent > user_data.slimes): # Not enough slime to shoot. response = "You don't have enough slime to attack. ({:,}/{:,})".format( user_data.slimes, slimes_spent) elif (time_now - user_data.time_lastkill) < ewcfg.cd_kill: # disallow kill if the player has killed recently response = "Take a moment to appreciate your last slaughter." elif shootee_data.poi != user_data.poi: response = "You can't reach them from where you are." elif ewmap.poi_is_pvp(shootee_data.poi) == False: response = "{} is not mired in the ENDLESS WAR right now.".format( member.display_name) elif user_iskillers == False and user_isrowdys == False: # Only killers, rowdys, the cop killer, and rowdy f****r can shoot people. if user_data.life_state == ewcfg.life_state_juvenile: response = "Juveniles lack the moral fiber necessary for violence." else: response = "You lack the moral fiber necessary for violence." elif (time_now - shootee_data.time_lastrevive) < ewcfg.invuln_onrevive: # User is currently invulnerable. response = "{} has died too recently and is immune.".format( member.display_name) elif shootee_data.life_state == ewcfg.life_state_corpse and user_data.ghostbust == True: # Attack a ghostly target was_busted = False #hunger drain user_data.hunger += ewcfg.hunger_pershot * ewutils.hunger_cost_mod( user_data.slimelevel) # Weaponized flavor text. randombodypart = ewcfg.hitzone_list[random.randrange( len(ewcfg.hitzone_list))] # Weapon-specific adjustments if weapon != None and weapon.fn_effect != None: # Build effect container ctn = EwEffectContainer(miss=miss, crit=crit, slimes_damage=slimes_damage, slimes_spent=slimes_spent, user_data=user_data, shootee_data=shootee_data) # Make adjustments weapon.fn_effect(ctn) # Apply effects for non-reference values miss = ctn.miss crit = ctn.crit slimes_damage = ctn.slimes_damage slimes_spent = ctn.slimes_spent strikes = ctn.strikes # user_data and shootee_data should be passed by reference, so there's no need to assign them back from the effect container. if miss: slimes_damage = 0 # Remove !revive invulnerability. user_data.time_lastrevive = 0 # Spend slimes, to a minimum of zero user_data.change_slimes( n=(-user_data.slimes if slimes_spent >= user_data.slimes else -slimes_spent), source=ewcfg.source_spending) # Damage stats ewstats.track_maximum(user=user_data, metric=ewcfg.stat_max_hitdealt, value=slimes_damage) ewstats.change_stat(user=user_data, metric=ewcfg.stat_lifetime_damagedealt, n=slimes_damage) # Remove repeat killing protection if. if user_data.id_killer == shootee_data.id_user: user_data.id_killer = "" if slimes_damage >= -shootee_data.slimes: was_busted = True if was_busted: # Move around slime as a result of the shot. user_data.change_slimes(n=ewutils.slime_bylevel( shootee_data.slimelevel), source=ewcfg.source_busting) coinbounty = int(shootee_data.bounty / ewcfg.slimecoin_exchangerate) user_data.change_slimecredit( n=coinbounty, coinsource=ewcfg.coinsource_bounty) ewstats.track_maximum(user=user_data, metric=ewcfg.stat_biggest_bust_level, value=shootee_data.slimelevel) # Player was busted. shootee_data.die(cause=ewcfg.cause_busted) response = "{name_target}\'s ghost has been **BUSTED**!!".format( name_target=member.display_name) deathreport = "Your ghost has been busted by {}. {}".format( cmd.message.author.display_name, ewcfg.emote_bustin) deathreport = "{} ".format( ewcfg.emote_bustin) + ewutils.formatMessage( member, deathreport) if coinbounty > 0: response += "\n\n SlimeCorp transfers {} SlimeCoin to {}\'s account.".format( str(coinbounty), cmd.message.author.display_name) #adjust busts ewstats.increment_stat(user=user_data, metric=ewcfg.stat_ghostbusts) else: # A non-lethal blow! shootee_data.change_slimes(n=slimes_damage, source=ewcfg.source_busting) damage = str(slimes_damage) if weapon != None: if miss: response = "{}".format( weapon.str_miss.format( name_player=cmd.message.author.display_name, name_target=member.display_name + "\'s ghost")) else: response = weapon.str_damage.format( name_player=cmd.message.author.display_name, name_target=member.display_name + "\'s ghost", hitzone=randombodypart, strikes=strikes) if crit: response += " {}".format( weapon.str_crit.format( name_player=cmd.message.author. display_name, name_target=member.display_name + "\'s ghost")) response += " {target_name} loses {damage} antislime!".format( target_name=(member.display_name + "\'s ghost"), damage=damage) else: if miss: response = "{}\'s ghost is unharmed.".format( member.display_name) else: response = "{target_name} is hit!! {target_name} loses {damage} antislime!".format( target_name=(member.display_name + "\'s ghost"), damage=damage) # Persist every users' data. user_data.persist() shootee_data.persist() await ewrolemgr.updateRoles(client=cmd.client, member=cmd.message.server.get_member( shootee_data.id_user)) elif shootee_data.life_state == ewcfg.life_state_corpse and shootee_data.busted == True: # Target is already dead and not a ghost. response = "{} is already dead.".format(member.display_name) elif shootee_data.life_state == ewcfg.life_state_corpse and user_data.ghostbust == False: # Target is a ghost but user is not able to bust response = "You don't know how to fight a ghost." else: # Slimes from this shot might be awarded to the boss. role_boss = (ewcfg.role_copkiller if user_iskillers else ewcfg.role_rowdyfucker) boss_slimes = 0 user_inital_level = user_data.slimelevel was_juvenile = False was_killed = False was_shot = False if (shootee_data.life_state == ewcfg.life_state_enlisted) or ( shootee_data.life_state == ewcfg.life_state_juvenile): # User can be shot. if shootee_data.life_state == ewcfg.life_state_juvenile: was_juvenile = True was_shot = True if was_shot: #hunger drain user_data.hunger += ewcfg.hunger_pershot * ewutils.hunger_cost_mod( user_data.slimelevel) # Weaponized flavor text. randombodypart = ewcfg.hitzone_list[random.randrange( len(ewcfg.hitzone_list))] # Weapon-specific adjustments if weapon != None and weapon.fn_effect != None: # Build effect container ctn = EwEffectContainer(miss=miss, crit=crit, slimes_damage=slimes_damage, slimes_spent=slimes_spent, user_data=user_data, shootee_data=shootee_data) # Make adjustments weapon.fn_effect(ctn) # Apply effects for non-reference values miss = ctn.miss crit = ctn.crit slimes_damage = ctn.slimes_damage slimes_spent = ctn.slimes_spent strikes = ctn.strikes # user_data and shootee_data should be passed by reference, so there's no need to assign them back from the effect container. if miss: slimes_damage = 0 # Remove !revive invulnerability. user_data.time_lastrevive = 0 # Spend slimes, to a minimum of zero user_data.change_slimes( n=(-user_data.slimes if slimes_spent >= user_data.slimes else -slimes_spent), source=ewcfg.source_spending) # Damage stats ewstats.track_maximum(user=user_data, metric=ewcfg.stat_max_hitdealt, value=slimes_damage) ewstats.change_stat(user=user_data, metric=ewcfg.stat_lifetime_damagedealt, n=slimes_damage) # Remove repeat killing protection if. if user_data.id_killer == shootee_data.id_user: user_data.id_killer = "" if slimes_damage >= shootee_data.slimes: was_killed = True if was_killed: #adjust statistics ewstats.increment_stat(user=user_data, metric=ewcfg.stat_kills) ewstats.track_maximum(user=user_data, metric=ewcfg.stat_biggest_kill, value=int(slimes_dropped)) if user_data.slimelevel > shootee_data.slimelevel: ewstats.increment_stat( user=user_data, metric=ewcfg.stat_lifetime_ganks) elif user_data.slimelevel < shootee_data.slimelevel: ewstats.increment_stat( user=user_data, metric=ewcfg.stat_lifetime_takedowns) # Collect bounty coinbounty = int( shootee_data.bounty / ewcfg.slimecoin_exchangerate) # 100 slime per coin # Move around slime as a result of the shot. if shootee_data.slimes >= 0: if was_juvenile: user_data.change_slimes( n=slimes_dropped, source=ewcfg.source_killing) else: user_data.change_slimecredit( n=coinbounty, coinsource=ewcfg.coinsource_bounty) user_data.change_slimes( n=slimes_dropped / 2, source=ewcfg.source_killing) boss_slimes += int(slimes_dropped / 2) # Steal items ewitem.item_loot(member=member, id_user_target=cmd.message.author.id) #add bounty user_data.add_bounty(n=(shootee_data.bounty / 2) + (slimes_dropped / 4)) # Give a bonus to the player's weapon skill for killing a stronger player. if shootee_data.slimelevel >= user_data.slimelevel: user_data.add_weaponskill(n=1) # Player was killed. shootee_data.id_killer = user_data.id_user shootee_data.die(cause=ewcfg.cause_killing) shootee_data.change_slimes( n=-slimes_dropped / 10, source=ewcfg.source_ghostification) kill_descriptor = "beaten to death" if weapon != None: response = weapon.str_damage.format( name_player=cmd.message.author.display_name, name_target=member.display_name, hitzone=randombodypart, strikes=strikes) kill_descriptor = weapon.str_killdescriptor if crit: response += " {}".format( weapon.str_crit.format( name_player=cmd.message.author. display_name, name_target=member.display_name)) response += "\n\n{}".format( weapon.str_kill.format( name_player=cmd.message.author.display_name, name_target=member.display_name, emote_skull=ewcfg.emote_slimeskull)) shootee_data.trauma = weapon.id_weapon if slimeoid.level == ewcfg.slimeoid_state_active: brain = ewcfg.brain_map.get(slimeoid.ai) response += "\n\n{}" + brain.str_kill.format( slimeoid_name=shootee_slimeoid.name) if shootee_slimeoid.level == ewcfg.slimeoid_state_active: brain = ewcfg.brain_map.get(shootee_slimeoid.ai) response += "\n\n{}" + brain.str_death.format( slimeoid_name=shootee_slimeoid.name) else: response = "{name_target} is hit!!\n\n{name_target} has died.".format( name_target=member.display_name) shootee_data.trauma = "" if slimeoid.life_state == ewcfg.slimeoid_state_active: brain = ewcfg.brain_map.get(slimeoid.ai) response += "\n\n" + brain.str_kill.format( slimeoid_name=shootee_slimeoid.name) if shootee_slimeoid.life_state == ewcfg.slimeoid_state_active: brain = ewcfg.brain_map.get(shootee_slimeoid.ai) response += "\n\n" + brain.str_death.format( slimeoid_name=shootee_slimeoid.name) 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 coinbounty > 0: response += "\n\n SlimeCorp transfers {} SlimeCoin to {}\'s account.".format( str(coinbounty), cmd.message.author.display_name) else: # A non-lethal blow! shootee_data.change_slimes(n=-slimes_damage, source=ewcfg.source_damage) damage = str(slimes_damage) if weapon != None: if miss: response = "{}".format( weapon.str_miss.format( name_player=cmd.message.author. display_name, name_target=member.display_name)) else: response = weapon.str_damage.format( name_player=cmd.message.author.display_name, name_target=member.display_name, hitzone=randombodypart, strikes=strikes) if crit: response += " {}".format( weapon.str_crit.format( name_player=cmd.message.author. display_name, name_target=member.display_name)) response += " {target_name} loses {damage} slime!".format( target_name=member.display_name, damage=damage) else: # unarmed attacks have no miss or crit chance response = "{target_name} is hit!! {target_name} loses {damage} slime!".format( target_name=member.display_name, damage=damage) else: response = 'You are unable to attack {}.'.format( member.display_name) # Add level up text to response if appropriate if user_inital_level < user_data.slimelevel: response += "\n\n{} has been empowered by slime and is now a level {} slimeboi!".format( cmd.message.author.display_name, user_data.slimelevel) # # Give slimes to the boss if possible. # boss_member = None # if boss_slimes > 0: # for member_search in cmd.message.server.members: # if role_boss in ewutils.getRoleMap(member_search.roles): # boss_member = member_search # break # if boss_member != None: # boss_data = EwUser(member = boss_member) # boss_data.change_slimes(n = boss_slimes) # boss_data.persist() kingpin = ewutils.find_kingpin(id_server=cmd.message.server.id, kingpin_role=role_boss) if kingpin: kingpin.change_slimes(n=boss_slimes) kingpin.persist() # Persist every users' data. user_data.persist() shootee_data.persist() # Assign the corpse role to the newly dead player. if was_killed: await ewrolemgr.updateRoles(client=cmd.client, member=member) # Send the response to the player. await cmd.client.send_message( cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) if deathreport != "": sewerchannel = ewutils.get_channel(cmd.message.server, ewcfg.channel_sewers) await cmd.client.send_message(sewerchannel, deathreport)
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) 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.slimecredit / 10) player_data.change_slimecredit(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 # Give player some initial slimes. player_data.slimelevel = 0 player_data.change_slimes(n = ewcfg.slimes_onrevive) # Set time of last revive. This used to provied spawn protection, but currently isn't used. player_data.time_lastrevive = time_now # Set life state. This is what determines whether the player is actually alive. player_data.life_state = ewcfg.life_state_juvenile # Get the player out of the sewers. Will be endless-war eventually. player_data.poi = ewcfg.poi_id_downtown player_data.persist() market_data.persist() # Give some slimes to every living player (currently online) for member in cmd.message.server.members: if member.id != cmd.message.author.id and member.id != cmd.client.user.id: member_data = EwUser(member = member) if member_data.life_state != ewcfg.life_state_corpse and member_data.life_state != ewcfg.life_state_grandfoe: member_data.change_slimes(n = ewcfg.slimes_onrevive_everyone) member_data.persist() await ewrolemgr.updateRoles(client = cmd.client, member = cmd.message.author) response = '{slime4} A geyser of fresh slime erupts, showering Rowdy, Killer, and Juvenile alike. {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 ) downtownchannel = ewutils.get_channel(cmd.message.server, ewcfg.channel_downtown) reunite = ewutils.formatMessage(cmd.message.author, reunite) await cmd.client.send_message(downtownchannel, reunite) # Send the response to the player. await cmd.client.send_message(cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def xfer(cmd): time_now = int(time.time()) if cmd.message.channel.name != ewcfg.channel_stockexchange: # Only allowed in the stock exchange. response = ewcfg.str_exchange_channelreq.format(currency="SlimeCoin", action="transfer") await cmd.client.send_message( cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) return if cmd.mentions_count != 1: # Must have exactly one target to send to. response = "Mention the player you want to send SlimeCoin to." await cmd.client.send_message( cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) return member = cmd.mentions[0] target_data = EwUser(member=member) if target_data.life_state == ewcfg.life_state_kingpin: # Disallow transfers to RF and CK kingpins. response = "You can't transfer SlimeCoin to a known criminal warlord." await cmd.client.send_message( cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) return user_data = EwUser(member=cmd.message.author) market_data = EwMarket(id_server=cmd.message.author.server.id) # Parse the slime value to send. value = None if cmd.tokens_count > 1: value = ewutils.getIntToken(tokens=cmd.tokens, allow_all=True) if value != None: if value < 0: value = user_data.slimes if value <= 0: value = None if value != None: # Cost including the 5% transfer fee. cost_total = int(value * 1.05) if user_data.slimecredit < cost_total: response = "You don't have enough SlimeCoin. ({:,}/{:,})".format( user_data.slimecredit, cost_total) else: # Do the transfer if the player can afford it. target_data.change_slimecredit( n=value, coinsource=ewcfg.coinsource_transfer) user_data.change_slimecredit(n=-cost_total, coinsource=ewcfg.coinsource_transfer) user_data.time_lastinvest = time_now # Persist changes response = "You transfer {slime:,} SlimeCoin to {target_name}. Your slimebroker takes his nominal fee of {fee:,} SlimeCoin.".format( slime=value, target_name=member.display_name, fee=(cost_total - value)) user_data.persist() target_data.persist() else: response = ewcfg.str_exchange_specify.format(currency="SlimeCoin", action="transfer") # Send the response to the player. await cmd.client.send_message( cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def order(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="order") else: 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 food = ewcfg.food_map.get(value.lower() if value != None else value) if food != None and food.vendor == ewcfg.vendor_vendingmachine: togo = True member = None if not togo: # cant order togo for someone else, you can just give it to them in person if cmd.mentions_count == 1: member = cmd.mentions[0] if member.id == cmd.message.author.id: member = None member_data = EwUser(member=member) if food == None or food.vendor not in poi.vendors: response = "Check the {} for a list of items you can {}.".format( ewcfg.cmd_menu, ewcfg.cmd_order) elif member is not None and member_data.poi != user_data.poi: response = "The delivery service has become unavailable due to unforeseen circumstances." else: market_data = EwMarket(id_server=cmd.message.server.id) target_data = None if member != None: target_data = EwUser(member=member) value = food.price if not togo else food.price * ewcfg.togo_price_increase # Kingpins eat free. if user_data.life_state == ewcfg.life_state_kingpin or user_data.life_state == ewcfg.life_state_grandfoe: value = 0 if value > user_data.slimecredit: # Not enough money. response = "A {food} is {cost:,} SlimeCoin (and you only have {credits:,}).".format( food=food.str_name, cost=value, credits=user_data.slimecredit) else: user_data.change_slimecredit( n=-value, coinsource=ewcfg.coinsource_spending) if not togo: if target_data != None: target_data.hunger -= food.recover_hunger if target_data.hunger < 0: target_data.hunger = 0 target_data.inebriation += food.inebriation if target_data.inebriation > ewcfg.inebriation_max: target_data.inebriation = ewcfg.inebriation_max if food.id_food == "coleslaw": target_data.ghostbust = True else: user_data.hunger -= food.recover_hunger if user_data.hunger < 0: user_data.hunger = 0 user_data.inebriation += food.inebriation if user_data.inebriation > ewcfg.inebriation_max: user_data.inebriation = ewcfg.inebriation_max if food.id_food == "coleslaw": user_data.ghostbust = True else: # if it's togo inv = ewitem.inventory(id_user=cmd.message.author.id, id_server=cmd.message.server.id) food_in_inv = 0 for item in inv: if item.get('item_type') == ewcfg.it_food: food_in_inv += 1 if food_in_inv >= math.ceil( user_data.slimelevel / ewcfg.max_food_in_inv_mod): # 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 cmd.client.send_message( cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) item_props = { 'food_name': food.str_name, 'food_desc': food.str_desc, 'recover_hunger': food.recover_hunger, 'price': food.price, 'inebriation': food.inebriation, 'vendor': food.vendor, 'str_eat': food.str_eat, 'time_expir': time.time() + (food.time_expir if food.time_expir is not None else ewcfg.std_food_expir) } ewitem.item_create(item_type=ewcfg.it_food, id_user=cmd.message.author.id, id_server=cmd.message.server.id, item_props=item_props) response = "You slam {cost:,} SlimeCoin down at the {vendor} for a {food}{togo}{sharetext}{flavor}".format( cost=value, vendor=food.vendor, food=food.str_name, togo=" to go" if togo else "", sharetext=(". " if member == None else " and give it to {}.\n\n{}".format( member.display_name, ewutils.formatMessage(member, ""))), flavor=food.str_eat if not togo else "") if member == None and user_data.hunger <= 0 and not togo: response += "\n\nYou're stuffed!" user_data.persist() market_data.persist() if target_data != None: target_data.persist() # Send the response to the player. await cmd.client.send_message( cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))