コード例 #1
0
ファイル: ewdistrict.py プロジェクト: Mordnilap/endless-war
async def rejuvenate(cmd):
	user_data = EwUser(member=cmd.message.author)

	if user_data.life_state == ewcfg.life_state_shambler and user_data.poi != ewcfg.poi_id_oozegardens:
		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))
	elif user_data.life_state == ewcfg.life_state_shambler and user_data.poi == ewcfg.poi_id_oozegardens:
		response = "You decide to change your ways and become one of the Garden Gankers in order to overthrow your old master."
		await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))

		await asyncio.sleep(5)

		user_data = EwUser(member=cmd.message.author)
		user_data.life_state = ewcfg.life_state_juvenile
		user_data.degradation = 0
		#user_data.gvs_currency = 0

		ewutils.moves_active[user_data.id_user] = 0

		user_data.poi = ewcfg.poi_id_og_farms
		user_data.persist()

		client = ewutils.get_client()
		server = client.get_guild(user_data.id_server)
		member = server.get_member(user_data.id_user)
		
		base_poi_channel = ewutils.get_channel(cmd.message.guild, ewcfg.channel_og_farms)

		response = "You enter into Atomic Forest inside the farms of Ooze Gardens and are sterilized of the Modelovirus. Hortisolis gives you a big hug and says he's glad you've overcome your desire for vengeance in pursuit of deposing Downpour."

		await ewrolemgr.updateRoles(client=cmd.client, member=member)
		return await ewutils.send_message(cmd.client, base_poi_channel, ewutils.formatMessage(cmd.message.author, response))

	else:
		pass
コード例 #2
0
async def smoke(cmd):
	usermodel = EwUser(member=cmd.message.author)
	#item_sought = ewitem.find_item(item_search="cigarette", id_user=cmd.message.author.id, id_server=usermodel.id_server)
	item_sought = None
	item_stash = ewitem.inventory(id_user=cmd.message.author.id, id_server=usermodel.id_server)
	for item_piece in item_stash:
		item = EwItem(id_item=item_piece.get('id_item'))
		if item_piece.get('item_type') == ewcfg.it_cosmetic and item.item_props.get('id_cosmetic') == "cigarette" and "lit" not in item.item_props.get('cosmetic_desc'):
			item_sought = item_piece

	if item_sought:
		item = EwItem(id_item=item_sought.get('id_item'))
		if item_sought.get('item_type') == ewcfg.it_cosmetic and item.item_props.get('id_cosmetic') == "cigarette":
			response = "You light a cig and bring it to your mouth. So relaxing. So *cool*. All those naysayers and PSAs in Health class can go f**k themselves."
			item.item_props['cosmetic_desc'] = "A single lit cigarette sticking out of your mouth. You huff these things down in seconds but you’re never seen without one. Everyone thinks you’re really, really cool."
			item.item_props['adorned'] = "true"
			item.persist()
			await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
			await asyncio.sleep(60)
			item = EwItem(id_item=item_sought.get('id_item'))

			response = "The cigarette fizzled out."

			item.item_props['cosmetic_desc'] = "It's a cigarette butt. What kind of hoarder holds on to these?"
			item.item_props['adorned'] = "false"
			item.item_props['id_cosmetic'] = "cigarettebutt"
			item.item_props['cosmetic_name'] = "cigarette butt"
			item.persist()
		else:
			response = "There aren't any usable cigarettes in your inventory."
	else:
		response = "There aren't any usable cigarettes in your inventory."
	return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
コード例 #3
0
async def dedorn(cmd):
	item_id = ewutils.flattenTokenListToString(cmd.tokens[1:])

	try:
		item_id_int = int(item_id)
	except:
		item_id_int = None

	if item_id != None and len(item_id) > 0:
		response = "You don't have one."

		items = ewitem.inventory(
			id_user = cmd.message.author.id,
			id_server = cmd.message.server.id,
			item_type_filter = ewcfg.it_cosmetic
		)

		item_sought = None
		for item in items:
			if item.get('id_item') == item_id_int or item_id in ewutils.flattenTokenListToString(item.get('name')):
				i = EwItem(item.get('id_item'))
				if i.item_props.get("adorned") == 'true':
					item_sought = i
					break

		if item_sought != None:
			item_sought.item_props['adorned'] = 'false'

			response = "You successfully dedorn your " + item_sought.item_props['cosmetic_name'] + "."

			item_sought.persist()

		await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
	else:
		await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, 'Dedorn which cosmetic? Check your **!inventory**.'))
コード例 #4
0
async def shamblestop(cmd):
    global sb_userid_to_player
    shamble_player = sb_userid_to_player.get(cmd.message.author.id)

    if shamble_player == None:
        response = "You have to join a game using {} first.".format(
            ewcfg.cmd_shambleball)
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

    if not ewutils.channel_name_is_poi(cmd.message.channel.name):
        response = "You have to go into the city to play Shambleball."
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

    global sb_games
    game_data = sb_games.get(shamble_player.id_game)

    poi_data = ewcfg.chname_to_poi.get(cmd.message.channel.name)

    if poi_data.id_poi != game_data.poi:
        game_poi = ewcfg.id_to_poi.get(game_data.poi)
        response = "Your Shambleball game is happening in the #{} channel.".format(
            game_poi.channel)
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

    shamble_player.velocity = [0, 0]
コード例 #5
0
async def capture_progress(cmd):
    user_data = EwUser(member=cmd.message.author)
    response = ""

    poi = ewcfg.id_to_poi.get(user_data.poi)
    response += "**{}**: ".format(poi.str_name)

    if not user_data.poi in ewcfg.capturable_districts:
        response += "This zone cannot be captured."
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

    district_data = EwDistrict(id_server=user_data.id_server,
                               district=user_data.poi)

    if district_data.controlling_faction != "":
        response += "{} control this district. ".format(
            district_data.controlling_faction.capitalize())
    elif district_data.capturing_faction != "":
        response += "{} are capturing this district. ".format(
            district_data.capturing_faction.capitalize())
    else:
        response += "Nobody has staked a claim to this district yet. ".format(
            district_data.controlling_faction.capitalize())

    response += "Current capture progress: {:.3g}%".format(
        100 * district_data.capture_points / district_data.max_capture_points)
    return await ewutils.send_message(
        cmd.client, cmd.message.channel,
        ewutils.formatMessage(cmd.message.author, response))
コード例 #6
0
async def crush(cmd):
    member = cmd.message.author
    user_data = EwUser(member=member)
    response = ""

    poudrin = ewitem.find_item(item_search="slimepoudrin",
                               id_user=cmd.message.author.id,
                               id_server=cmd.message.server.id
                               if cmd.message.server is not None else None)

    if user_data.life_state == ewcfg.life_state_corpse:
        response = "Alas, you try to shatter the hardened slime crystal, but your ghostly form cannot firmly grasp it."
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

    if poudrin is None:
        response = "You need a slime poudrin."
    else:
        # delete a slime poudrin from the player's inventory
        ewitem.item_delete(id_item=poudrin.get('id_item'))

        user_data.slimes += ewcfg.crush_slimes
        user_data.persist()

        response = "You crush the hardened slime crystal with your bare hands.\nYou gain 10,000 slime. Sick, dude!!"

    # Send the response to the player.
    await ewutils.send_message(
        cmd.client, cmd.message.channel,
        ewutils.formatMessage(cmd.message.author, response))
コード例 #7
0
ファイル: ewitem.py プロジェクト: lateralyst/endless-war
async def item_use(cmd):
    item_search = ewutils.flattenTokenListToString(cmd.tokens[1:])
    author = cmd.message.author
    server = cmd.message.server

    item_sought = find_item(item_search=item_search,
                            id_user=author.id,
                            id_server=server.id)

    if item_sought:
        item = EwItem(id_item=item_sought.get('id_item'))

        response = "The item doesn't have !use functionality"  # if it's not overwritten

        user_data = EwUser(member=author)

        if item.item_type == ewcfg.it_food:
            response = user_data.eat(item)
            user_data.persist()

        await cmd.client.send_message(
            cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

    else:
        if item_search:  # if they didnt forget to specify an item and it just wasn't found
            response = "You don't have one."
        else:
            response = "Use which item? (check **!inventory**)"

        await cmd.client.send_message(
            cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))
コード例 #8
0
ファイル: ewdistrict.py プロジェクト: Mordnilap/endless-war
async def shamble(cmd):

	user_data = EwUser(member = cmd.message.author)

	if user_data.life_state != ewcfg.life_state_shambler and user_data.poi != ewcfg.poi_id_assaultflatsbeach:
		response = "You have too many higher brain functions left to {}.".format(cmd.tokens[0])
		return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
	elif user_data.life_state in [ewcfg.life_state_juvenile, ewcfg.life_state_enlisted] and user_data.poi == ewcfg.poi_id_assaultflatsbeach:
		response = "You feel an overwhelming sympathy for the plight of the Shamblers and decide to join their ranks."
		await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))

		await asyncio.sleep(5)
		
		user_data = EwUser(member=cmd.message.author)
		user_data.life_state = ewcfg.life_state_shambler
		user_data.degradation = 100

		ewutils.moves_active[user_data.id_user] = 0

		user_data.poi = ewcfg.poi_id_nuclear_beach_edge
		user_data.persist()
		
		member = cmd.message.author
		
		base_poi_channel = ewutils.get_channel(cmd.message.guild, 'nuclear-beach-edge')

		response = 'You arrive inside the facility and are injected with a unique strain of the Modelovirus. Not long after, a voice on the intercom chimes in.\n**"Welcome, {}. Welcome to Downpour Laboratories. It\'s safer here. Please treat all machines and facilities with respect, they are precious to our cause."**'.format(member.display_name)

		await ewrolemgr.updateRoles(client=cmd.client, member=member)
		return await ewutils.send_message(cmd.client, base_poi_channel, ewutils.formatMessage(cmd.message.author, response))
	
	else:
		pass
コード例 #9
0
async def renounce(cmd):
    user_data = EwUser(member=cmd.message.author)

    if user_data.life_state == ewcfg.life_state_corpse:
        response = "You're dead, bitch."
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

    elif user_data.life_state != ewcfg.life_state_enlisted:
        response = "What exactly are you renouncing? Your lackadaisical, idyllic life free of vice and violence? You aren't actually currently enlisted in any gang, retard."

    elif user_data.poi not in [
            ewcfg.poi_id_rowdyroughhouse, ewcfg.poi_id_copkilltown
    ]:
        response = "To turn in your badge, you must return to your soon-to-be former gang base."

    else:
        renounce_fee = int(user_data.slimes) / 2
        user_data.change_slimes(n=-renounce_fee)
        faction = user_data.faction
        user_data.life_state = ewcfg.life_state_juvenile
        user_data.weapon = -1
        user_data.persist()
        response = "You are no longer enlisted in the {}, but you are not free of association with them. Your former teammates immediately begin to beat the shit out of you, knocking {} slime out of you before you're able to get away.".format(
            faction, renounce_fee)
        await ewrolemgr.updateRoles(client=cmd.client,
                                    member=cmd.message.author)

    await ewutils.send_message(
        cmd.client, cmd.message.channel,
        ewutils.formatMessage(cmd.message.author, response))
コード例 #10
0
async def check_schedule(cmd):
    if ewutils.channel_name_is_poi(cmd.message.channel.name) == False:
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(
                cmd.message.author,
                "You must {} in a zone's channel.".format(cmd.tokens[0])))
    user_data = EwUser(member=cmd.message.author)
    poi = ewcfg.id_to_poi.get(user_data.poi)
    response = ""

    if poi.is_transport_stop:
        response = "The following public transit lines stop here:"
        for line in poi.transport_lines:
            line_data = ewcfg.id_to_transport_line.get(line)
            response += "\n-" + line_data.str_name
    elif poi.is_transport:
        transport_data = EwTransport(id_server=user_data.id_server,
                                     poi=poi.id_poi)
        transport_line = ewcfg.id_to_transport_line.get(
            transport_data.current_line)
        response = "This {} is following {}.".format(
            transport_data.transport_type,
            transport_line.str_name.replace("The", "the"))
    else:
        response = "There is no schedule to check here."

    return await ewutils.send_message(
        cmd.client, cmd.message.channel,
        ewutils.formatMessage(cmd.message.author, response))
コード例 #11
0
ファイル: ewdistrict.py プロジェクト: Mordnilap/endless-war
async def capture_progress(cmd):
	user_data = EwUser(member = cmd.message.author)
	response = ""

	poi = ewcfg.id_to_poi.get(user_data.poi)
	response += "**{}**: ".format(poi.str_name)

	if not user_data.poi in ewcfg.capturable_districts:
		response += "This zone cannot be captured."
		return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))

	district_data = EwDistrict(id_server=user_data.id_server, district=user_data.poi)

	if district_data.controlling_faction != "":
		response += "{} control this district. ".format(district_data.controlling_faction.capitalize())
	elif district_data.capturing_faction != "" and district_data.cap_side != district_data.capturing_faction:
		response += "{} are de-capturing this district. ".format(district_data.capturing_faction.capitalize())
	elif district_data.capturing_faction != "":
		response += "{} are capturing this district. ".format(district_data.capturing_faction.capitalize())
	else:
		response += "Nobody has staked a claim to this district yet."

	response += "\n\n**Current influence: {:,}**\nMinimum influence: {:,}\nMaximum influence: {:,}\nPercentage to maximum influence: {:,}%".format(abs(district_data.capture_points), int(ewcfg.min_influence[district_data.property_class]), int(ewcfg.limit_influence[district_data.property_class]), round((abs(district_data.capture_points) * 100/(ewcfg.limit_influence[district_data.property_class])), 1))


	#if district_data.time_unlock > 0:


		#response += "\nThis district cannot be captured currently. It will unlock in {}.".format(ewutils.formatNiceTime(seconds = district_data.time_unlock, round_to_minutes = True))
	return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
コード例 #12
0
async def reroll_last_mutation(cmd):
	last_mutation_counter = -1
	last_mutation = ""
	user_data = EwUser(member = cmd.message.author)
	market_data = EwMarket(id_server = user_data.id_server)
	response = ""

	if cmd.message.channel.name != ewcfg.channel_slimeoidlab:
		response = "You require the advanced equipment at the Slimeoid Lab to modify your mutations."
		return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))

	if user_data.life_state == ewcfg.life_state_corpse:
		response = "How do you expect to mutate without exposure to slime, dumbass?"
		return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))


	mutations = user_data.get_mutations()
	if len(mutations) == 0:
		response = "You have not developed any specialized mutations yet."
		return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))

	for id_mutation in mutations:
		mutation_data = EwMutation(id_server = user_data.id_server, id_user = user_data.id_user, id_mutation = id_mutation)
		if mutation_data.mutation_counter > last_mutation_counter:
			last_mutation_counter = mutation_data.mutation_counter
			last_mutation = id_mutation

	reroll_fatigue = EwStatusEffect(id_status = ewcfg.status_rerollfatigue_id, user_data = user_data)

	poudrins_needed = 2 ** int(reroll_fatigue.value)

	poudrins = ewitem.find_item_all(item_search = ewcfg.item_id_slimepoudrin, id_user = cmd.message.author.id, id_server = cmd.message.server.id if cmd.message.server is not None else None, item_type_filter = ewcfg.it_item)

	poudrins_have = len(poudrins)

	if poudrins_have < poudrins_needed:
		response = "You need {} slime poudrin{} to replace a mutation, but you only have {}.".format(poudrins_needed, "" if poudrins_needed == 1 else "s", poudrins_have)

		return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
	else:
		for delete in range(poudrins_needed):
			ewitem.item_delete(id_item = poudrins.pop(0).get('id_item'))  # Remove Poudrins
		market_data.donated_poudrins += poudrins_needed
		market_data.persist()
		user_data.poudrin_donations += poudrins_needed
		user_data.persist()
		reroll_fatigue.value = int(reroll_fatigue.value) + 1
		reroll_fatigue.persist()

	mutation_data = EwMutation(id_server = user_data.id_server, id_user = user_data.id_user, id_mutation = last_mutation)
	new_mutation = random.choice(list(ewcfg.mutation_ids))
	while new_mutation in mutations:
		new_mutation = random.choice(list(ewcfg.mutation_ids))

	mutation_data.id_mutation = new_mutation
	mutation_data.time_lastuse = int(time.time())
	mutation_data.persist()

	response = "After several minutes long elevator descents, in the depths of some basement level far below the laboratory's lobby, you lay down on a reclined medical chair. A SlimeCorp employee finishes the novel length terms of service they were reciting and asks you if you have any questions. You weren’t listening so you just tell them to get on with it so you can go back to getting slime. They oblige.\nThey grab a butterfly needle and carefully stab you with it, draining some strangely colored slime from your bloodstream. Almost immediately, the effects of your last mutation fade away… but, this feeling of respite is fleeting. The SlimeCorp employee writes down a few notes, files away the freshly drawn sample, and soon enough you are stabbed with syringes. This time, it’s already filled with some bizarre, multi-colored serum you’ve never seen before. The effects are instantaneous. {}\nYou hand off {} of your hard-earned poudrins to the SlimeCorp employee for their troubles.".format(ewcfg.mutations_map[new_mutation].str_acquire, poudrins_needed)
	return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
コード例 #13
0
async def clear_mutations(cmd):
	user_data = EwUser(member = cmd.message.author)
	market_data = EwMarket(id_server = user_data.id_server)
	response = ""
	if cmd.message.channel.name != ewcfg.channel_slimeoidlab:
		response = "You require the advanced equipment at the Slimeoid Lab to modify your mutations."
		return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))

	if user_data.life_state == ewcfg.life_state_corpse:
		response = "How do you expect to mutate without exposure to slime, dumbass?"
		return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))


	mutations = user_data.get_mutations()
	if len(mutations) == 0:
		response = "You have not developed any specialized mutations yet."
		return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))

	poudrin = ewitem.find_item(item_search = "slimepoudrin", id_user = cmd.message.author.id, id_server = cmd.message.server.id if cmd.message.server is not None else None, item_type_filter = ewcfg.it_item)

	if poudrin == None:
		response = "You need a slime poudrin to replace a mutation."
		return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
	else:
		ewitem.item_delete(id_item = poudrin.get('id_item'))  # Remove Poudrins
		market_data.donated_poudrins += 1
		market_data.persist()
		user_data.poudrin_donations += 1
		user_data.persist()

	user_data.clear_mutations()
	response = "After several minutes long elevator descents, in the depths of some basement level far below the laboratory's lobby, you lay down on a reclined medical chair. A SlimeCorp employee finishes the novel length terms of service they were reciting and asks you if you have any questions. You weren’t listening so you just tell them to get on with it so you can go back to getting slime. They oblige.\nThey grab a random used syringe with just a dash of black serum still left inside it. They carefully stab you with it, injecting the mystery formula into your bloodstream. Almost immediately, normalcy returns to your inherently abnormal life… your body returns to whatever might be considered normal for your species. You hand off one of your hard-earned poudrins to the SlimeCorp employee for their troubles."
	return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
コード例 #14
0
ファイル: ewspooky.py プロジェクト: Mordnilap/endless-war
async def negaslime(cmd):
	total = ewutils.execute_sql_query("SELECT SUM(slimes) FROM users WHERE slimes < 0 AND id_server = '{}'".format(cmd.guild.id))
	total_negaslimes = total[0][0]
	
	if total_negaslimes:
		await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, "The dead have amassed {:,} negative slime.".format(total_negaslimes)))
	else:
		await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, "There is no negative slime in this world."))
コード例 #15
0
async def print_grid(cmd):
    grid_str = ""
    user_data = EwUser(member=cmd.message.author)
    poi = user_data.poi
    id_server = cmd.message.server.id
    time_now = int(time.time())
    if poi in mines_map:
        grid_map = mines_map.get(poi)
        if id_server not in grid_map:
            init_grid_ms(poi, id_server)
        grid_cont = grid_map.get(id_server)

        grid = grid_cont.grid

        grid_str += "   "
        for j in range(len(grid[0])):
            grid_str += "{} ".format(ewcfg.alphabet[j])
        grid_str += "\n"
        for i in range(len(grid)):
            row = grid[i]
            if i + 1 < 10:
                grid_str += " "

            grid_str += "{} ".format(i + 1)
            for j in range(len(row)):
                cell = row[j]
                cell_str = get_cell_symbol(cell)
                grid_str += cell_str + " "
            grid_str += "{}".format(i + 1)
            grid_str += "\n"

        grid_str += "   "
        for j in range(len(grid[0])):
            grid_str += "{} ".format(ewcfg.alphabet[j])

        grid_edit = "\n```\n{}\n```".format(grid_str)
        #grid_edit = grid_str
        if time_now > grid_cont.time_last_posted + 10 or grid_cont.times_edited > 8 or grid_cont.message == "":
            grid_cont.message = await ewutils.send_message(
                cmd.client, cmd.message.channel,
                ewutils.formatMessage(cmd.message.author, grid_edit))
            grid_cont.time_last_posted = time_now
            grid_cont.times_edited = 0
        else:
            await ewutils.edit_message(
                cmd.client, grid_cont.message,
                ewutils.formatMessage(cmd.message.author, grid_edit))
            grid_cont.times_edited += 1

        if grid_cont.wall_message == "":
            wall_channel = ewcfg.mines_wall_map.get(poi)
            resp_cont = ewutils.EwResponseContainer(id_server=id_server)
            resp_cont.add_channel_response(wall_channel, grid_edit)
            msg_handles = await resp_cont.post()
            grid_cont.wall_message = msg_handles[0]
        else:
            await ewutils.edit_message(cmd.client, grid_cont.wall_message,
                                       grid_edit)
コード例 #16
0
ファイル: ewfarm.py プロジェクト: teorec/endless-war
async def check_farm(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))

	response = ""
	levelup_response = ""
	mutations = user_data.get_mutations()

	# Checking availability of check farm action
	if user_data.life_state != ewcfg.life_state_juvenile:
		response = "Only Juveniles of pure heart and with nothing better to do can farm."
	elif cmd.message.channel.name not in [ewcfg.channel_jr_farms, ewcfg.channel_og_farms, ewcfg.channel_ab_farms]:
		response = "Do you remember planting anything here in this barren wasteland? No, you don’t. Idiot."
	else:
		poi = ewcfg.id_to_poi.get(user_data.poi)
		district_data = EwDistrict(district = poi.id_poi, id_server = user_data.id_server)

		if district_data.is_degraded():
			response = "{} has been degraded by shamblers. You can't {} here anymore.".format(poi.str_name, cmd.tokens[0])
			return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
		if user_data.poi == ewcfg.poi_id_jr_farms:
			farm_id = ewcfg.poi_id_jr_farms
		elif user_data.poi == ewcfg.poi_id_og_farms:
			farm_id = ewcfg.poi_id_og_farms
		else:  # if it's the farm in arsonbrook
			farm_id = ewcfg.poi_id_ab_farms


		farm = EwFarm(
			id_server = cmd.guild.id,
			id_user = cmd.message.author.id,
			farm = farm_id
		)

		if farm.time_lastsow == 0:
			response = "You missed a step, you haven’t planted anything here yet."
		elif farm.action_required == ewcfg.farm_action_none:
			if farm.phase == ewcfg.farm_phase_reap:
				response = "Your crop is ready for the harvest."
			elif farm.phase == ewcfg.farm_phase_sow:
				response = "You only just planted the seeds. Check back later."
			else:
				if farm.slimes_onreap < ewcfg.reap_gain:
					response = "Your crop looks frail and weak."
				elif farm.slimes_onreap < ewcfg.reap_gain + 3 * ewcfg.farm_slimes_peraction:
					response = "Your crop looks small and generally unremarkable."
				elif farm.slimes_onreap < ewcfg.reap_gain + 6 * ewcfg.farm_slimes_peraction:
					response = "Your crop seems to be growing well."
				else:
					response = "Your crop looks powerful and bursting with nutrients."

		else:
			farm_action = ewcfg.id_to_farm_action.get(farm.action_required)
			response = farm_action.str_check

	await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
コード例 #17
0
ファイル: ewspooky.py プロジェクト: Mordnilap/endless-war
async def possess_weapon(cmd):
	user_data = EwUser(member = cmd.message.author)
	response = ""
	if user_data.life_state != ewcfg.life_state_corpse:
		response = "You have no idea what you're doing."
	elif not user_data.get_inhabitee():
		response = "You're not **{}**ing anyone right now.".format(ewcfg.cmd_inhabit)
	elif user_data.slimes >= ewcfg.slimes_to_possess_weapon:
		response = "You'll have to become stronger before you can perform occult arts of this level."
	else:
		server = cmd.guild
		inhabitee_id = user_data.get_inhabitee()
		inhabitee_data = EwUser(id_user = inhabitee_id, id_server = user_data.id_server)
		inhabitee_member = server.get_member(inhabitee_id)
		inhabitee_name = inhabitee_member.display_name
		if inhabitee_data.weapon < 0:
			response = "{} is not wielding a weapon right now.".format(inhabitee_name)
		elif inhabitee_data.get_possession():
			response = "{} is already being possessed.".format(inhabitee_name)
		else:
			proposal_response = "You propose a trade to {}.\n" \
				"You will possess their weapon to empower it, and in return they'll sacrifice a fifth of their slime to your name upon their next kill.\n" \
				"Will they **{}** this exchange, or **{}** it?".format(inhabitee_name, ewcfg.cmd_accept, ewcfg.cmd_refuse)
			await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, proposal_response))
    
			accepted = False
			try:
				msg = await cmd.client.wait_for('message', timeout = 30, check=lambda message: message.author == inhabitee_member and 
														message.content.lower() in [ewcfg.cmd_accept, ewcfg.cmd_refuse])
				if msg != None:
					if msg.content.lower() == ewcfg.cmd_accept:
						accepted = True
					elif msg.content.lower() == ewcfg.cmd_refuse:
						accepted = False
			except:
				accepted = False

			if accepted:
				ewutils.execute_sql_query(
				"UPDATE inhabitations SET {empowered} = %s WHERE {id_fleshling} = %s AND {id_ghost} = %s".format(
					empowered = ewcfg.col_empowered,
					id_fleshling = ewcfg.col_id_fleshling,
					id_ghost = ewcfg.col_id_ghost,
				), (
					'weapon',
					inhabitee_id,
					user_data.id_user,
				))
				user_data.change_slimes(n = -ewcfg.slimes_to_possess_weapon, source = ewcfg.source_ghost_contract)
				user_data.persist()
				accepted_response = "You feel a metallic taste in your mouth as you sign {}'s spectral contract. You see them bind themselves to your weapon, which now bears their mark. It feels cold to the touch.".format(cmd.message.author.display_name)
				await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(inhabitee_member, accepted_response))
			else:
				response = "You should've known better, why would anyone ever trust you?"
	
	if response:
		return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
コード例 #18
0
async def beep(cmd):
    user_data = EwUser(member=cmd.message.author)
    response = ""
    if user_data.race == ewcfg.races["robot"]:
        roll = random.randrange(100)
        responses = []
        if roll > 19:
            responses = [
                "**BEEP**",
                "**BOOP**",
                "**BRRRRRRT**",
                "**CLICK CLICK**",
                "**BZZZZT**",
                "**WHIRRRRRRR**",
            ]
        elif roll > 0:
            responses = [
                "`ERROR: 'yiff' not in function library in ewrobot.py ln 366`",
                "`ERROR: 418 I'm a teapot`",
                "`ERROR: list index out of range`",
                "`ERROR: 'response' is undefined`",
                "https://youtu.be/7nQ2oiVqKHw", "https://youtu.be/Gb2jGy76v0Y"
            ]
        else:
            resp = await ewcmd.start(cmd=cmd)
            response = "```CRITICAL ERROR: 'life_state' NOT FOUND\nINITIATING LIFECYCLE TERMINATION SEQUENCE IN "
            await ewutils.edit_message(
                cmd.client, resp,
                ewutils.formatMessage(cmd.message.author,
                                      response + "10 SECONDS...```"))
            for i in range(10, 0, -1):
                await asyncio.sleep(1)
                await ewutils.edit_message(
                    cmd.client, resp,
                    ewutils.formatMessage(
                        cmd.message.author,
                        response + "{} SECONDS...```".format(i)))
            await asyncio.sleep(1)
            await ewutils.edit_message(
                cmd.client, resp,
                ewutils.formatMessage(cmd.message.author,
                                      response + "0 SECONDS...```"))
            await asyncio.sleep(1)
            await ewutils.edit_message(
                cmd.client, resp,
                ewutils.formatMessage(
                    cmd.message.author, response +
                    "0 SECONDS...\nERROR: 'reboot' not in function library in ewrobot.py ln 459```"
                ))
            return
        response = random.choice(responses)
    else:
        response = "You people are not allowed to do that."

    return await ewutils.send_message(
        cmd.client, cmd.message.channel,
        ewutils.formatMessage(cmd.message.author, response))
コード例 #19
0
async def dedorn(cmd):
	user_data = EwUser(member = cmd.message.author)

	# Check to see if you even have the item you want to repair
	item_id = ewutils.flattenTokenListToString(cmd.tokens[1:])

	try:
		item_id_int = int(item_id)
	except:
		item_id_int = None

	if item_id is not None and len(item_id) > 0:
		response = "You don't have one."

		cosmetic_items = ewitem.inventory(
			id_user = cmd.message.author.id,
			id_server = cmd.message.server.id,
			item_type_filter = ewcfg.it_cosmetic
		)

		item_sought = None
		already_adorned = False

		# Check all cosmetics found
		for item in cosmetic_items:
			i = EwItem(item.get('id_item'))

			# Search for desired cosmetic
			if item.get('id_item') == item_id_int or item_id in ewutils.flattenTokenListToString(item.get('name')):
				if i.item_props.get("adorned") == 'true':
					already_adorned = True
					item_sought = i
					break

		# If the cosmetic you want to adorn is found
		if item_sought != None:

			# Unadorn the cosmetic
			if already_adorned:
				item_sought.item_props['adorned'] = 'false'

				unadorn_response = str(item_sought.item_props['str_unadorn'])

				response = unadorn_response.format(item_sought.item_props['cosmetic_name'])


				item_sought.persist()
				user_data.persist()

			# That garment has not be adorned..
			else:
				response = "You haven't adorned that garment in the first place! How can you dedorn something you haven't adorned? You disgust me."

		await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
	else:
		await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, 'Adorn which cosmetic? Check your **!inventory**.'))
コード例 #20
0
async def clear_quadrant(cmd):
    response = ""
    author = cmd.message.author
    quadrant = None
    user_data = ew.EwUser(id_user=author.id, id_server=author.guild.id)
    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))

    for token in cmd.tokens[1:]:
        if token.lower() in ewcfg.quadrants_map:
            quadrant = ewcfg.quadrants_map[token.lower()]
        if quadrant is not None:
            break

    if quadrant is None:
        response = "Please select a quadrant for your romantic feelings."
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

    quadrant_data = EwQuadrant(id_server=author.guild.id,
                               id_user=author.id,
                               quadrant=quadrant.id_quadrant)

    if quadrant_data.id_target != -1:
        target_member_data = cmd.guild.get_member(quadrant_data.id_target)
        target_member_data_2 = None

        if quadrant_data.id_target2 != -1:
            target_member_data_2 = cmd.guild.get_member(
                quadrant_data.id_target)

        quadrant_data = EwQuadrant(id_server=author.guild.id,
                                   id_user=author.id,
                                   quadrant=quadrant.id_quadrant,
                                   id_target=-1,
                                   id_target2=-1)
        quadrant_data.persist()

        response = "You break up with {}. Maybe it's for the best...".format(
            target_member_data.display_name)
        if target_member_data_2 != None:
            response = "You break up with {} and {}. Maybe it's for the best...".format(
                target_member_data.display_name,
                target_member_data_2.display_name)

    else:
        response = "You haven't filled out that quadrant, bitch."

    return await ewutils.send_message(
        cmd.client, cmd.message.channel,
        ewutils.formatMessage(cmd.message.author, response))
コード例 #21
0
ファイル: ewitem.py プロジェクト: coolbeefriend/endless-war
async def item_look(cmd):
    item_id = ewutils.flattenTokenListToString(cmd.tokens[1:])

    try:
        item_id_int = int(item_id)
    except:
        item_id_int = None

    if item_id != None and len(item_id) > 0:
        response = "You don't have one."

        items = inventory(id_user=cmd.message.author.id,
                          id_server=(cmd.message.server.id if
                                     (cmd.message.server != None) else None))

        item_sought = None
        for item in items:
            if item.get(
                    'id_item'
            ) == item_id_int or item_id in ewutils.flattenTokenListToString(
                    item.get('name')):
                item_sought = item
                break

        if item_sought != None:
            item_def = item_sought.get('item_def')
            id_item = item_sought.get('id_item')
            name = item_sought.get('name')
            response = item_def.str_desc

            # Replace up to two levels of variable substitutions.
            if response.find('{') >= 0:
                item_inst = EwItem(id_item=id_item)
                response = response.format_map(item_inst.item_props)

                if response.find('{') >= 0:
                    response = response.format_map(item_inst.item_props)

            if item_sought.get('item_type') == ewcfg.it_food:
                if float(
                        item_inst.item_props.
                        get('time_expir') if not None else 0) < time.time():
                    response += " This food item is rotten so you decide to throw it away."
                    item_delete(id_item)

            response = name + "\n\n" + response

        await cmd.client.send_message(
            cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))
    else:
        await cmd.client.send_message(
            cmd.message.channel,
            ewutils.formatMessage(
                cmd.message.author,
                'Inspect which item? (check **!inventory**)'))
コード例 #22
0
ファイル: ewfaction.py プロジェクト: Mordnilap/endless-war
async def store(cmd):
	
	user_data = EwUser(member=cmd.message.author)
	response = ""

	poi = ewcfg.id_to_poi.get(user_data.poi)
	if poi.community_chest == None:
		response = "There is no community chest here."
		return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
	else:
		if len(poi.factions) > 0 and user_data.faction not in poi.factions:
			response = "Get real, asshole. You haven't even enlisted into this gang yet, so it's not like they'd trust you with a key to their valubles."
			return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))

	item_search = ewutils.flattenTokenListToString(cmd.tokens[1:])

	item_sought = ewitem.find_item(item_search = item_search, id_user = cmd.message.author.id, id_server = cmd.guild.id if cmd.guild is not None else None)
	
	if item_sought:
		item = EwItem(id_item = item_sought.get("id_item"))

		if not item.soulbound:
			if item.item_type == ewcfg.it_weapon:
				if user_data.weapon >= 0 and item.id_item == user_data.weapon:
					if user_data.weaponmarried:
						weapon = ewcfg.weapon_map.get(item.item_props.get("weapon_type"))
						response = "Your cuckoldry is appreciated, but your {} will always remain faithful to you.".format(item_sought.get('name'))
						return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
					else:
						user_data.weapon = -1
						user_data.persist()
				elif item.id_item == user_data.sidearm:
					user_data.sidearm = -1
					user_data.persist()

			if item.item_type == ewcfg.it_cosmetic:
				if "adorned" in item.item_props:
					item.item_props["adorned"] = "false"
				if "slimeoid" in item.item_props:
					item.item_props["slimeoid"] = "false"
			
			item.persist()
			ewitem.give_item(id_item = item.id_item, id_server = item.id_server, id_user = poi.community_chest)

			response = "You store your {} in the community chest.".format(item_sought.get("name"))

		else:
			response = "You can't {} soulbound items.".format(cmd.tokens[0])
	else:
		if item_search:
			response = "You don't have one"
		else:
			response = "{} which item? (check **!inventory**)".format(cmd.tokens[0])

	await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
コード例 #23
0
ファイル: ewfarm.py プロジェクト: teorec/endless-war
async def cultivate(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))

	response = ""
	levelup_response = ""
	mutations = user_data.get_mutations()

	# Checking availability of irrigate action
	if user_data.life_state != ewcfg.life_state_juvenile:
		response = "Only Juveniles of pure heart and with nothing better to do can tend to their crops."
	elif cmd.message.channel.name not in [ewcfg.channel_jr_farms, ewcfg.channel_og_farms, ewcfg.channel_ab_farms]:
		response = "Do you remember planting anything here in this barren wasteland? No, you don’t. Idiot."
	else:
		poi = ewcfg.id_to_poi.get(user_data.poi)
		district_data = EwDistrict(district = poi.id_poi, id_server = user_data.id_server)

		if district_data.is_degraded():
			response = "{} has been degraded by shamblers. You can't {} here anymore.".format(poi.str_name, cmd.tokens[0])
			return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
		if user_data.poi == ewcfg.poi_id_jr_farms:
			farm_id = ewcfg.poi_id_jr_farms
		elif user_data.poi == ewcfg.poi_id_og_farms:
			farm_id = ewcfg.poi_id_og_farms
		else:  # if it's the farm in arsonbrook
			farm_id = ewcfg.poi_id_ab_farms


		farm = EwFarm(
			id_server = cmd.guild.id,
			id_user = cmd.message.author.id,
			farm = farm_id
		)

		
		farm_action = ewcfg.cmd_to_farm_action.get(cmd.tokens[0].lower())

		if farm.time_lastsow == 0:
			response = "You missed a step, you haven’t planted anything here yet."
		elif farm.action_required != farm_action.id_action:
			response = farm_action.str_execute_fail
			farm.slimes_onreap -= ewcfg.farm_slimes_peraction
			farm.slimes_onreap = max(farm.slimes_onreap, 0)
			farm.persist()
		else:
			response = farm_action.str_execute
			# gvs - farm actions award more slime
			farm.slimes_onreap += ewcfg.farm_slimes_peraction * 2
			farm.action_required = ewcfg.farm_action_none
			farm.persist()

	await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
コード例 #24
0
ファイル: ewspooky.py プロジェクト: Mordnilap/endless-war
async def possess_fishing_rod(cmd):
	user_data = EwUser(member = cmd.message.author)
	response = ""
	if user_data.life_state != ewcfg.life_state_corpse:
		response = "You have no idea what you're doing."
	elif not user_data.get_inhabitee():
		response = "You're not **{}**ing anyone right now.".format(ewcfg.cmd_inhabit)
	elif user_data.slimes >= ewcfg.slimes_to_possess_fishing_rod:
		response = "You'll have to become stronger before you can perform occult arts of this level."
	else:
		server = cmd.guild
		inhabitee_id = user_data.get_inhabitee()
		inhabitee_data = EwUser(id_user = inhabitee_id, id_server = user_data.id_server)
		inhabitee_member = server.get_member(inhabitee_id)
		inhabitee_name = inhabitee_member.display_name
		if inhabitee_data.get_possession():
			response = "{} is already being possessed.".format(inhabitee_name)
		else:
			proposal_response = "You propose a trade to {}.\n" \
				"You will possess their fishing rod to enhance it, making it more attractive to fish. In exchange, you will corrupt away all of the fish's slime, and absorb it as antislime.\n" \
				"Both of you will need to reel the fish in together, and failing to do so will nullify this contract.\nWill they **{}** this exchange, or **{}** it?".format(inhabitee_name, ewcfg.cmd_accept, ewcfg.cmd_refuse)
			await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, proposal_response))
    
			accepted = False
			try:
				msg = await cmd.client.wait_for('message', timeout = 30, check=lambda message: message.author == inhabitee_member and 
														message.content.lower() in [ewcfg.cmd_accept, ewcfg.cmd_refuse])
				if msg != None:
					if msg.content.lower() == ewcfg.cmd_accept:
						accepted = True
					elif msg.content.lower() == ewcfg.cmd_refuse:
						accepted = False
			except:
				accepted = False

			if accepted:
				ewutils.execute_sql_query(
				"UPDATE inhabitations SET {empowered} = %s WHERE {id_fleshling} = %s AND {id_ghost} = %s".format(
					empowered = ewcfg.col_empowered,
					id_fleshling = ewcfg.col_id_fleshling,
					id_ghost = ewcfg.col_id_ghost,
				), (
					'rod',
					inhabitee_id,
					user_data.id_user,
				))
				user_data.change_slimes(n = -ewcfg.slimes_to_possess_fishing_rod, source = ewcfg.source_ghost_contract)
				user_data.persist()
				accepted_response = "You feel a metallic taste in your mouth as you sign {}'s spectral contract. Their ghastly arms superpose yours, enhancing your grip and causing shadowy tendrils to appear near your rod's hook.".format(cmd.message.author.display_name)
				await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(inhabitee_member, accepted_response))
			else:
				response = "You should've known better, why would anyone ever trust you?"
	
	if response:
		return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
コード例 #25
0
async def dye(cmd):
	first_id = ewutils.flattenTokenListToString(cmd.tokens[1:2])
	second_id = ewutils.flattenTokenListToString(cmd.tokens[2:])

	try:
		first_id_int = int(first_id)
		second_id_int = int(second_id)
	except:
		first_id_int = None
		second_id_int = None

	if first_id != None and len(first_id) > 0 and second_id != None and len(second_id) > 0:
		response = "You don't have one."

		items = ewitem.inventory(
			id_user = cmd.message.author.id,
			id_server = cmd.message.server.id,
		)

		cosmetic = None
		dye = None
		for item in items:
			if item.get('id_item') in [first_id_int, second_id_int] or first_id in ewutils.flattenTokenListToString(item.get('name')) or second_id in ewutils.flattenTokenListToString(item.get('name')):
				if item.get('item_type') == ewcfg.it_cosmetic and cosmetic is None:
					cosmetic = item

				if item.get('item_type') == ewcfg.it_item and item.get('name') in ewcfg.dye_map and dye is None:
					dye = item	

				if cosmetic != None and dye != None:
					break

		if cosmetic != None:
			if dye != None:
				user_data = EwUser(member = cmd.message.author)

				cosmetic_item = EwItem(id_item=cosmetic.get("id_item"))
				dye_item = EwItem(id_item=dye.get("id_item"))

				hue = ewcfg.hue_map.get(dye_item.item_props.get('id_item'))

				response = "You dye your {} in {} paint!".format(cosmetic_item.item_props.get('cosmetic_name'), hue.str_name)
				cosmetic_item.item_props['hue'] = hue.id_hue

				cosmetic_item.persist()
				ewitem.item_delete(id_item=dye.get('id_item'))
			else:
				response = 'Use which dye? Check your **!inventory**.'
		else:
			response = 'Dye which cosmetic? Check your **!inventory**.'
		
		await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
	else:
		await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, 'You need to specify which cosmetic you want to paint and which dye you want to use! Check your **!inventory**.'))
コード例 #26
0
async def request_petting(cmd):
    user_data = EwUser(member=cmd.message.author)
    response = ""
    if user_data.race == ewcfg.races["critter"]:
        if cmd.mentions_count == 0:
            response = "Request petting from who?"
        if cmd.mentions_count > 1:
            response = "You would die of overpetting."
        if cmd.mentions_count == 1:
            target_member = cmd.mentions[0]
            proposal_response = "You rub against {}'s leg and look at them expectantly. Will they **{}** and give you a rub, or do they **{}** your affection?".format(
                target_member.display_name, ewcfg.cmd_accept, ewcfg.cmd_refuse)
            await ewutils.send_message(
                cmd.client, cmd.message.channel,
                ewutils.formatMessage(cmd.message.author, proposal_response))

            accepted = False
            try:
                msg = await cmd.client.wait_for(
                    'message',
                    timeout=30,
                    check=lambda message:
                    message.author == target_member and message.content.lower(
                    ) in [ewcfg.cmd_accept, ewcfg.cmd_refuse])
                if msg != None:
                    if msg.content.lower() == ewcfg.cmd_accept:
                        accepted = True
                    elif msg.content.lower() == ewcfg.cmd_refuse:
                        accepted = False
            except:
                accepted = False

            if accepted:
                responses = [
                    "{user} gets on their back, and {target} gives them a thorough belly rub!",
                    "{target} cups {user}'s head between their hands, rubbing near their little ears with their thumbs.",
                    "{target} picks {user} up and carries them over the place for a little while, so they can see things from above.",
                    "{target} sits down next to {user}, who gets on their lap. They both lie there for a while, comforting one another.",
                    "{target} gets on the floor and starts petting the heck out of {user}!",
                ]
                accepted_response = random.choice(responses).format(
                    user=cmd.message.author.display_name,
                    target=target_member.display_name)
                await ewutils.send_message(cmd.client, cmd.message.channel,
                                           accepted_response)
            else:
                response = "The pain of rejection will only make you stronger, {}.".format(
                    cmd.message.author.display_name)
    else:
        response = "You people are not allowed to do that."
    if response:
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))
コード例 #27
0
async def add_quadrant(cmd):
	response = ""
	author = cmd.message.author
	quadrant = None
	user_data = ew.EwUser(id_user=author.id, id_server=author.guild.id)
	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))


	for token in cmd.tokens[1:]:
		if token.lower() in ewcfg.quadrants_map:
			quadrant = ewcfg.quadrants_map[token.lower()]
		if quadrant is not None:
			break
	
	if quadrant is None:
		response = "Please select a quadrant for your romantic feelings."
		return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))

	if cmd.mentions_count == 0:
		response = "Please select a target for your romantic feelings."
		return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))

	if user_data.has_soul == 0:
		response = "A soulless juvie can only desperately reach for companionship, they will never find it."
		return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))

	target = cmd.mentions[0].id
	target2 = None
	if quadrant.id_quadrant == ewcfg.quadrant_policitous and cmd.mentions_count > 1:
		target2 = cmd.mentions[1].id

	quadrant_data = EwQuadrant(id_server = author.guild.id, id_user = author.id, quadrant = quadrant.id_quadrant, id_target = target, id_target2 = target2)
	
	onesided = quadrant_data.check_if_onesided()

	if onesided:
		comment = random.choice(ewcfg.quadrants_comments_onesided)
		resp_add = quadrant.resp_add_onesided

	else:
		comment = random.choice(ewcfg.quadrants_comments_relationship)
		resp_add = quadrant.resp_add_relationship

	if target2 is None:
		resp_add = resp_add.format(cmd.mentions[0].display_name)
	else:
		resp_add = resp_add.format("{} and {}".format(cmd.mentions[0].display_name, cmd.mentions[1].display_name))
	response = "{} {}".format(resp_add, comment)

		
	return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
コード例 #28
0
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))
コード例 #29
0
ファイル: ewitem.py プロジェクト: lateralyst/endless-war
async def give(cmd):
    item_search = ewutils.flattenTokenListToString(cmd.tokens[1:])
    author = cmd.message.author
    server = cmd.message.server

    if cmd.mentions:  # if they're not empty
        recipient = cmd.mentions[0]
    else:
        response = "You have to specify the recipient of the item."
        return await cmd.client.send_message(
            cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

    item_sought = find_item(item_search=item_search,
                            id_user=author.id,
                            id_server=server.id)

    if item_sought:  # if an item was found

        # don't let people give others food when they shouldn't be able to carry more food items
        if item_sought.get('item_type') == ewcfg.it_food:
            food_items = inventory(id_user=recipient.id,
                                   id_server=server.id,
                                   item_type_filter=ewcfg.it_food)

            if len(food_items) >= math.ceil(
                    EwUser(member=recipient).slimelevel /
                    ewcfg.max_food_in_inv_mod):
                response = "They can't carry any more food items."
                return await cmd.client.send_message(
                    cmd.message.channel,
                    ewutils.formatMessage(cmd.message.author, response))

        if item_sought.get('soulbound'):
            response = "You can't just give away soulbound items."
        else:
            give_item(member=recipient, id_item=item_sought.get('id_item'))

            response = "You gave {recipient} a {item}".format(
                recipient=recipient.display_name, item=item_sought.get('name'))
        return await cmd.client.send_message(
            cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

    else:
        if item_search:  # if they didnt forget to specify an item and it just wasn't found
            response = "You don't have one."
        else:
            response = "Give which item? (check **!inventory**)"

        await cmd.client.send_message(
            cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))
コード例 #30
0
async def shamblego(cmd):

    global sb_userid_to_player
    shamble_player = sb_userid_to_player.get(cmd.message.author.id)

    if shamble_player == None:
        response = "You have to join a game using {} first.".format(
            ewcfg.cmd_shambleball)
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

    if not ewutils.channel_name_is_poi(cmd.message.channel.name):
        response = "You have to go into the city to play Shambleball."
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

    global sb_games
    game_data = sb_games.get(shamble_player.id_game)

    poi_data = ewcfg.chname_to_poi.get(cmd.message.channel.name)

    if poi_data.id_poi != game_data.poi:
        game_poi = ewcfg.id_to_poi.get(game_data.poi)
        response = "Your Shambleball game is happening in the #{} channel.".format(
            game_poi.channel)
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

    target_coords = get_coords(cmd.tokens[1:])

    if len(target_coords) != 2:
        response = "Specify where you want to {} to.".format(
            ewcfg.cmd_shamblego)
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

    target_vector = ewutils.EwVector2D(target_coords)
    current_vector = ewutils.EwVector2D(shamble_player.coords)

    target_direction = target_vector.subtract(current_vector)
    target_direction = target_direction.normalize()

    current_direction = ewutils.EwVector2D(shamble_player.velocity)

    result_direction = current_direction.add(target_direction)
    result_direction = result_direction.normalize()

    shamble_player.velocity = result_direction.vector