Пример #1
0
    def weekly_practice_update(self):

        results = []
        for practitioner in self.get_active_practitioners().all():
            result = self.advance_weekly_practice(practitioner)
            if result:
                results.append(result)

        from typeclasses.bulletin_board.bboard import BBoard
        board = BBoard.objects.get(db_key__iexact="staff")
        table = EvTable(border="cells", width=78)
        table.add_column("|wName|n", width=20, valign='t')
        table.add_column("|wPractices|n", valign='t')
        for result in results:
            subtable = EvTable(border=None)
            for node in result['practices']:
                subtable.add_row(node['node'], "%.2f gain" % node['gain'],
                                 "%.2f total" % node['resonance'],
                                 node['teacher'])
            table.add_row(result['name'], str(subtable))

        SkillNodeResonance.objects.filter(
            teaching_multiplier__isnull=False).update(teaching_multiplier=None,
                                                      taught_by=None,
                                                      taught_on=None)

        board.bb_post(poster_obj=self,
                      msg=str(table),
                      subject="Magic Practice Results",
                      poster_name="Magic System")
        inform_staff("List of magic practice results posted.")
Пример #2
0
    def get_text(self):
        """Display the app."""
        try:
            number = self.app.phone_number
            pretty_number = self.app.pretty_phone_number
        except ValueError:
            self.msg("Your phone number couldn't be found.")
            self.back()
            return

        # Load the threads (conversations) to which "number" participated
        threads = Text.objects.get_threads_for(number)
        string = "Texts for {}".format(pretty_number)
        string += "\n"
        self.db["threads"] = {}
        stored_threads = self.db["threads"]
        if threads:
            len_i = 3 if len(threads) < 100 else 4
            string += "  Create a {new} message.\n".format(
                new=self.format_cmd("new"))
            i = 1
            table = EvTable(pad_left=0, border="none")
            table.add_column("S", width=2)
            table.add_column("I", width=len_i, align="r", valign="t")
            table.add_column("Sender", width=21)
            table.add_column("Content", width=36)
            table.add_column("Ago", width=15)
            for thread_id, text in threads.items():
                thread = text.db_thread
                stored_threads[i] = thread
                sender = text.recipients
                sender = [self.app.format(num) for num in sender]
                sender = ", ".join(sender)
                if thread.name:
                    sender = thread.name
                sender = crop(sender, 20, "")

                content = text.content.replace("\n", "  ")
                if text.sender.db_phone_number == number:
                    content = "[You] " + content
                content = crop(content, 35)
                status = " " if thread.has_read(number) else "|rU|n"
                table.add_row(status, self.format_cmd(str(i)), sender, content,
                              text.sent_ago.capitalize())
                i += 1
            lines = str(table).splitlines()
            del lines[0]
            lines = [line.rstrip() for line in lines]
            string += "\n" + "\n".join(lines)
            string += "\n\n(Type a number to open this text.)"
        else:
            string += "\n  You have no texts yet.  Want to create a {new} one?".format(
                new=self.format_cmd("new"))

        string += "\n\n(Enter {settings} to edit the app settings).".format(
            settings=self.format_cmd("settings"))
        count = Text.objects.get_texts_for(number).count()
        s = "" if count == 1 else "s"
        string += "\n\nText app: {} saved message{s}.".format(count, s=s)
        return string
Пример #3
0
    def pretty_print(self, looker, filter_stats=None, print_stats = True):
        # Get the currently equipped armor/weapons.
        data = []
        s_width = 0;

        table = EvTable("|wLimb|n",
                        "|wSlot|n",
                        "|wItem|n",
                        "|wLevel|n",
                        "|wRarity|n",
                        "|wDurability|n",
                        border = "cells")

# ISSUE 1480 - still under pull request
        if print_stats:
            table.add_column(header="|wStats|n")

        for slot, obj in self:
            wearName = slot

            if obj and not obj.access(looker, "view"):
                continue

            if not obj:
                objString = ""
                objLevel = ""
                objRarity = ""
                objDurability = ""
            else:
                # construct the string for the object.
                objString = "{name}".format(name=obj.name)
                objLevel = obj.get_level()
                objRarity = obj.get_rarity()
                objDurability = "{} %".format(obj.get_durability_percentage())

            if (self.limbs):
                # For limbs, use the named limb instead.
                for limbName, slots in self.limbs.iteritems():
                    if slot in slots: # Check if limb attached to slot
                        wearName = limbName # Set wearname to limb name.

            s_width = max(len(wearName), s_width)

            rowData = [wearName, slot, objString, objLevel, objRarity, objDurability]
            if print_stats and obj is not None:
                rowData.append(obj.pp_stats(looker=self.obj, excludeStats=["level", "rarity", "durability"]))

            table.add_row(*rowData)

#            data.append(
#                "  |b{slot:>{swidth}.{swidth}}|n: {item:<20.20}".format(
#                    slot=wearName.capitalize(),
#                    swidth=s_width,
#                    item=objName,
#                )
#            )

        return str(table)