Exemplo n.º 1
0
def list_room_contents(ch, room):
    # find our list of visible objects and characters
    vis_objs = utils.find_all_objs(ch, room.objs, "", None, True)
    vis_chars = utils.find_all_chars(ch, room.chars, "", None, True)

    # lists of used furnture, and characters using furniture
    furniture = []

    # find our list of used furniture
    for obj in vis_objs:
        if len(obj.chars) > 0:
            furniture.append(obj)

    # now remove our used furniture and people using it from the visible lists
    for furn in furniture:
        vis_objs.remove(furn)
        for pers in furn.chars:
            vis_chars.remove(pers)

    # show our list of visible characters
    if ch in vis_chars:
        vis_chars.remove(ch)
    if len(vis_chars) > 0:
        utils.show_list(ch, vis_chars, lambda (x): x.rdesc, lambda (x): x.mdesc)

    # show our list of used furniture
    for furn in furniture:
        list_one_furniture(ch, furn)

    # show our list of visible objects
    if len(vis_objs) > 0:
        utils.show_list(ch, vis_objs, lambda (x): x.rdesc, lambda (x): x.mdesc)
Exemplo n.º 2
0
def cmd_inventory(ch, cmd, arg):
    '''Lists all of the items currently carried in your inventory.'''
    if len(ch.inv) == 0:
        ch.send("You are not carrying anything.")
    else:
        ch.send("You are carrying:")
        visible = utils.find_all_objs(ch, ch.inv, "", None, True)
        utils.show_list(ch, visible, lambda(x): x.name, lambda(x): x.mname)
Exemplo n.º 3
0
    def show_hand(self, hand, instruction, beginner=False):
        description = f"**Tribalcard | Deine Hand:**\n\n"
        for index, player in enumerate(hand):

            if beginner and index == 0:
                card = f"Oberste Karte:\n"
                values = []
                for key, value in prop.items():
                    pval = getattr(player, key)

                    if key in self.format:
                        pval = utils.seperator(pval)

                    pstat = f"**{value}:** `{pval}`"
                    values.append(pstat)

                result = utils.show_list(values, sep=" | ", line_break=3)
                card += f"{result}\n\n"

                base = "Du bist am Zug, wähle eine Eigenschaft mit {}play <property>"
                instruction = base.format(instruction)

            else:
                card = f"**{index + 1}**: {player.name}\n"

            description += card

        embed = discord.Embed(description=description)
        embed.set_footer(text=instruction)
        return embed
Exemplo n.º 4
0
 async def worlds_(self, ctx):
     worlds = sorted(self.bot.worlds)
     result = utils.show_list(worlds, line_break=3)
     description = f"**Aktuelle Welten:**\n{result}"
     embed = discord.Embed(description=description)
     await ctx.send(embed=embed)
Exemplo n.º 5
0
    async def tribalcard_(self, ctx, response=None):
        data = self.get_game_data(ctx)

        if ctx.author.id in self.cache and response is None:
            msg = f"Du bist bereits Spieler einer aktiven Tribalcard-Runde"
            return await ctx.send(msg)

        if response and response.lower() == "join":
            if not data:
                base = "Aktuell ist keine Spielanfrage offen, starte mit `{}`"
                msg = f"{base.format(ctx.prefix)}tribalcard"

            elif len(data['players']) == 4:
                msg = "Es sind bereits 4 Spieler registriert"

            elif data.get('active'):
                names = [f"`{m.display_name}`" for m in data['players']]
                base = "Aktuell läuft bereits eine Runde auf dem Server, Teilnehmer:\n`{}`"
                msg = base.format(utils.show_list(names, line_break=4))

            else:
                data['players'][ctx.author] = {}
                amount = 4 - len(data['players'])

                if not amount:
                    free_spots = "`keine Plätze` mehr"
                else:
                    free_spots = f"noch `{amount} Plätze`"

                base = "**{}** nimmt am Spiel teil\n(Noch {} frei)"
                msg = base.format(ctx.author.display_name, free_spots)
                self.cache.append(ctx.author.id)

            await ctx.send(msg)

        elif response is None:
            self.cache.append(ctx.author.id)

            data = {'players': {ctx.author: {}}, 'id': ctx.message.id,
                    'played': {}, 'beginner': ctx.author, 'ctx': ctx}
            self.tribalcard[ctx.guild.id] = data

            base = "**{}** möchte eine Runde **Tribalcard** spielen,\ntritt der Runde mit " \
                   "`{}tc join` bei:\n(2-4 Spieler, Spiel beginnt in 60s)"
            msg = base.format(ctx.author.display_name, ctx.prefix)
            begin = await ctx.send(msg)

            await asyncio.sleep(20)
            data['active'] = True

            player_amount = len(data['players'])
            if player_amount == 1:
                content = "Es wollte leider niemand mitspielen :/\n**Spiel beendet**"
                await begin.edit(content=content)
                self.tribalcard.pop(ctx.guild.id)
                return

            # 7 base cards + diff per player
            amount = player_amount * (12 - player_amount)
            cards = await self.bot.fetch_random(ctx.server, amount=amount, top=100)
            for player, userdata in data['players'].items():
                hand = userdata['cards'] = []
                userdata['points'] = 0
                while len(hand) < amount / player_amount:
                    card = cards.pop(0)
                    hand.append(card)

            hand = data['players'][ctx.author]['cards']
            embed = self.show_hand(hand, ctx.prefix, True)
            resp = await utils.silencer(ctx.author.send(embed=embed))

            if resp is False:
                base = "**{}** konnte keine private Nachricht geschickt werden,\n" \
                       "**Spiel beendet**"
                msg = base.format(ctx.author.display_name)
                await begin.edit(content=msg)
                self.tribalcard.pop(ctx.guild.id)

            else:
                data['players'][ctx.author]['msg'] = resp
                await asyncio.sleep(3600)
                current = self.tribalcard.get(ctx.guild.id)
                if current and current['id'] == data['id']:
                    self.tribalcard.pop(ctx.guild.id)