Exemple #1
0
def make_district_control_board(id_server, title):
    entries = []

    districts = []
    for poi in ewcfg.poi_list:
        if poi.is_district:
            districts.append(poi.id_poi)

    rowdy_districts = 0
    killer_districts = 0

    for district in districts:
        district_data = EwDistrict(district=district, id_server=id_server)
        if district_data.all_streets_taken() == ewcfg.faction_rowdys:
            rowdy_districts += 1
        elif district_data.all_streets_taken() == ewcfg.faction_killers:
            killer_districts += 1

    rowdy_entry = [ewcfg.faction_rowdys.capitalize(), rowdy_districts]
    killer_entry = [ewcfg.faction_killers.capitalize(), killer_districts]

    return format_board(
        entries=[rowdy_entry, killer_entry]
        if rowdy_districts > killer_districts else [killer_entry, rowdy_entry],
        title=title,
        entry_type=ewcfg.entry_type_districts)
Exemple #2
0
async def menu(cmd):
    user_data = EwUser(member=cmd.message.author, data_level=2)
    if user_data.life_state == ewcfg.life_state_shambler and user_data.poi != ewcfg.poi_id_nuclear_beach_edge:
        response = "You lack the higher brain functions required to {}.".format(
            cmd.tokens[0])
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

    market_data = EwMarket(id_server=cmd.guild.id)
    #poi = ewmap.fetch_poi_if_coordless(cmd.message.channel.name)
    poi = ewcfg.id_to_poi.get(user_data.poi)

    if poi is None or len(poi.vendors) == 0 or ewutils.channel_name_is_poi(
            cmd.message.channel.name) == False:
        # Only allowed in the food court.
        response = "There’s nothing to buy here. If you want to purchase some items, go to a sub-zone with a vendor in it, like the food court, the speakeasy, or the bazaar."
    else:
        poi = ewcfg.id_to_poi.get(user_data.poi)

        mother_district_data = None
        for mother_poi in poi.mother_districts:

            mother_poi_data = ewcfg.id_to_poi.get(mother_poi)

            if mother_poi_data.is_district:
                # One of the mother pois was a district, get its controlling faction
                mother_district_data = EwDistrict(
                    district=mother_poi, id_server=user_data.id_server)
                break
            else:
                # One of the mother pois was a street, get the father district of that street and its controlling faction
                father_poi = mother_poi_data.father_district
                mother_district_data = EwDistrict(
                    district=father_poi, id_server=user_data.id_server)
                break

        district_data = EwDistrict(district=poi.id_poi,
                                   id_server=user_data.id_server)
        #mother_district_data = EwDistrict(district = destination_poi.id_poi, id_server = user_data.id_server)

        shambler_multiplier = 1  #for speakeasy during shambler times

        if district_data.is_degraded(
        ) and poi.id_poi != ewcfg.poi_id_nuclear_beach_edge:
            if poi.id_poi == ewcfg.poi_id_speakeasy:
                shambler_multiplier = 4
            else:
                response = "{} has been degraded by shamblers. You can't {} here anymore.".format(
                    poi.str_name, cmd.tokens[0])
                return await ewutils.send_message(
                    cmd.client, cmd.message.channel,
                    ewutils.formatMessage(cmd.message.author, response))

        controlling_faction = ewutils.get_subzone_controlling_faction(
            user_data.poi, user_data.id_server)

        response = "{} Menu:\n\n".format(poi.str_name)

        vendors_list = poi.vendors

        for vendor in vendors_list:
            if vendor == ewcfg.vendor_secretbodega:
                if user_data.freshness < ewcfg.freshnesslevel_4:
                    continue
                else:
                    response += '\nThe hipster behind the counter nearly falls out of his chair after laying eyes on the sheer, unadulterated freshness before him.\n"S-Sir! Your outfit... i-it is positively ***on fleek!!*** As I see you are a fashion enthusiast like myself, let me show you the good stuff…"\n'

            items = []
            # If the vendor is the bazaar get the current rotation of items from the market_data
            vendor_inv = ewcfg.vendor_inv[
                vendor] if vendor != ewcfg.vendor_bazaar else market_data.bazaar_wares.values(
                )
            for item_name in vendor_inv:
                item_item = ewcfg.item_map.get(item_name)
                food_item = ewcfg.food_map.get(item_name)
                cosmetic_item = ewcfg.cosmetic_map.get(item_name)
                furniture_item = ewcfg.furniture_map.get(item_name)
                weapon_item = ewcfg.weapon_map.get(item_name)

                # increase profits for the stock market
                stock_data = None
                if vendor in ewcfg.vendor_stock_map:
                    stock = ewcfg.vendor_stock_map.get(vendor)
                    stock_data = EwStock(id_server=user_data.id_server,
                                         stock=stock)

                value = 0

                if item_item:
                    value = item_item.price

                if food_item:
                    value = food_item.price

                if cosmetic_item:
                    value = cosmetic_item.price

                if furniture_item:
                    value = furniture_item.price

                if weapon_item:
                    value = weapon_item.price

                if stock_data != None:
                    value *= (stock_data.exchange_rate /
                              ewcfg.default_stock_exchange_rate)**0.2

                #multiply by 4 is speakeasy is shambled
                value *= shambler_multiplier

                if mother_district_data != None:
                    if mother_district_data.all_streets_taken(
                    ) != "" and poi.id_poi != ewcfg.poi_id_nuclear_beach_edge:
                        # prices are halved for the controlling gang
                        if mother_district_data.all_streets_taken(
                        ) == user_data.faction:
                            value /= 2

                        # and 4 times as much for enemy gangsters
                        elif user_data.faction != "":
                            value *= 4

                if vendor == ewcfg.vendor_breakroom and user_data.faction == ewcfg.faction_slimecorp:
                    value = 0

                value = int(value)

                if value != 0:
                    items.append('{name} ({price})'.format(name=item_name,
                                                           price=value))
                else:
                    items.append(item_name)

            response += "**{}**: *{}*\n".format(
                vendor, ewutils.formatNiceList(names=items))

            if vendor == ewcfg.vendor_bodega:
                if user_data.freshness < ewcfg.freshnesslevel_1:
                    response += "\nThe hipster behind the counter is utterly repulsed by the fashion disaster in front of him. Looks like you just aren’t fresh enough for him."
            if user_data.has_soul == 0:
                if vendor == ewcfg.vendor_dojo:
                    response += "\n\nThe Dojo master looks at your soulless form with pity."
                elif vendor == ewcfg.vendor_bar:
                    response += "\n\nThe bartender, sensing your misery, asks if you're okay."
                elif vendor == ewcfg.vendor_diner:
                    response += "\n\nThe cook gives you a concerned look as he throws down another helping of flapjacks."
                elif vendor == ewcfg.vendor_seafood:
                    response += "\n\nThe waiter sneers at how soulless and unkempt you look. You try to ignore him."
                elif vendor == ewcfg.vendor_bazaar:
                    response += "\n\nAll the shops seem so lively. You wish you had a soul so you could be like them."
                elif vendor == ewcfg.vendor_beachresort or vendor == ewcfg.vendor_countryclub:
                    response += "\n\nEverything looks so fancy here, but it doesn't really appeal to you since you don't have a soul."
                elif vendor == ewcfg.vendor_bodega:
                    if user_data.freshness < ewcfg.freshnesslevel_1:
                        response += ".. and you probably never will be."
                elif vendor == ewcfg.vendor_glocksburycomics:
                    response += "\n\nThe cashier here tries to start up a conversation about life being worth living. You're having none of it."
                elif vendor == ewcfg.vendor_basedhardware:
                    response += "\n\nSo many industrial metals here... You contemplate which you could use to kill yourself..."
                elif vendor == ewcfg.vendor_basedhardware:
                    response += "\n\nNot even waffles could hope to make your emptiness go away."
                elif vendor == ewcfg.vendor_greencakecafe:
                    response += "\n\nThe barista behind the counter pauses to look at your soulless misery for a second, but decides you're not worth it and gets back to work."
                elif vendor == ewcfg.vendor_slimypersuits:
                    response += "\n\nYour mere presence in here ruins the cheery atmosphere."

    # Send the response to the player.
    await ewutils.send_message(
        cmd.client, cmd.message.channel,
        ewutils.formatMessage(cmd.message.author, response))