Beispiel #1
0
    def colorize_vital(self, value):
        """ Give us green, yellow, and red colored numbers for vitals depending on our
        percentage. """

        if value >= 66:
            return ansi.green(str(value))
        elif value >= 33:
            return ansi.bold_yellow(str(value))
        else:
            return ansi.bold_red(str(value))
Beispiel #2
0
    def colorize_vital(self, value):
        """ Give us green, yellow, and red colored numbers for vitals depending on our
        percentage. """

        if value >= 66:
            return ansi.green(str(value))
        elif value >= 33:
            return ansi.bold_yellow(str(value))
        else:
            return ansi.bold_red(str(value))
Beispiel #3
0
    def segmentReceived(self):
        data = self.data_buffer
        self.data_buffer = ''

        # don't lead with a newline
        if data[0] == NL:
            data = data[1:]

        # Fix color-only leading line
        color_newline = self.color_newline.match(data)
        if color_newline:
            color = data[0:color_newline.end() - 1]
            data = color + data[color_newline.end():]

        data = data.split('\n')

        pre_prompt.send(raw_data=data)

        # lines received
        lines = data[:-1]

        # last line is always the prompt
        prompt_data = data[-1]

        # Send the prompt to the prompt receiver
        try:
            prompt_output = prompt.receiver(prompt_data)
        except Exception as err:
            _log.err()
            prompt_output = "%s - %s" % (ansi.bold_red('ERROR:'), ansi.red(str(err)))

        # send lines to inbound receiver
        lines = inbound.receiver(lines)

        post_prompt.send()

        signal.pre_outbound.send(
            raw_lines=sage.buffer,
            lines=lines,
            ansi_prompt=prompt_output,
            prompt=ansi.filter_ansi(prompt_output)
        )

        self.receivers.input(lines, prompt_output)
Beispiel #4
0
    def segmentReceived(self):
        data = self.data_buffer
        self.data_buffer = ''

        # don't lead with a newline
        if data[0] == NL:
            data = data[1:]

        # Fix color-only leading line
        color_newline = self.color_newline.match(data)
        if color_newline:
            color = data[0:color_newline.end() - 1]
            data = color + data[color_newline.end():]

        data = data.split('\n')

        pre_prompt.send(raw_data=data)

        # lines received
        lines = data[:-1]

        # last line is always the prompt
        prompt_data = data[-1]

        # Send the prompt to the prompt receiver
        try:
            prompt_output = prompt.receiver(prompt_data)
        except Exception as err:
            _log.err()
            prompt_output = "%s - %s" % (ansi.bold_red('ERROR:'),
                                         ansi.red(str(err)))

        # send lines to inbound receiver
        lines = inbound.receiver(lines)

        post_prompt.send()

        signal.pre_outbound.send(raw_lines=sage.buffer,
                                 lines=lines,
                                 ansi_prompt=prompt_output,
                                 prompt=ansi.filter_ansi(prompt_output))

        self.receivers.input(lines, prompt_output)
Beispiel #5
0
    def end(self, signal):
        if self.text != "":
            if self.got_dstab:
                self.got_dstab = False
                if(len(self.venoms) != 2):
                    self.text = ""
                    self.text = player.afflictions
                else:
                    self.text = ansi.bold_red(self.text +" %s %s"%(self.venoms[0], self.venoms[1]))
            sage.echo(self.text)
            self.text = ""

        if self.echo_aff:
            sage.echo(ansi.bold_yellow(self.aff_str))
            self.echo_aff = False
        if len(self.cures) > 0:
            for cure in self.cures:
                sage.echo(cure[1])
            self.cures=[]
        self.venoms=[]
Beispiel #6
0
    def end(self, signal):
        if self.text != "":
            if self.got_dstab:
                self.got_dstab = False
                if (len(self.venoms) != 2):
                    self.text = ""
                    self.text = player.afflictions
                else:
                    self.text = ansi.bold_red(self.text + " %s %s" %
                                              (self.venoms[0], self.venoms[1]))
            sage.echo(self.text)
            self.text = ""

        if self.echo_aff:
            sage.echo(ansi.bold_yellow(self.aff_str))
            self.echo_aff = False
        if len(self.cures) > 0:
            for cure in self.cures:
                sage.echo(cure[1])
            self.cures = []
        self.venoms = []
Beispiel #7
0
 def hit_rebounding(self):
     self.text = ansi.bold_red("REBOUNDED: " + self.text)
Beispiel #8
0
def echo_aff(signal,affliction):
    sage.echo(ansi.bold_red("ADDED AFFLICTION: %s"%affliction))
Beispiel #9
0
 def hit_rebounding(self):
     self.text = ansi.bold_red("REBOUNDED: " + self.text)
Beispiel #10
0
def echo_aff(signal, affliction):
    sage.echo(ansi.bold_red("ADDED AFFLICTION: %s" % affliction))