Demo entry 6716208

get single action from replay

   

Submitted by anonymous on Feb 17, 2018 at 04:07
Language: Python 3. Code size: 1.2 kB.

    def get_single_action(self, lower_bound, ln_actions):
        position = 0
        frame_str = ""
        input_str = ""

        while True:
            if ln_actions[lower_bound + position].isdigit():
                frame_str = frame_str + ln_actions[lower_bound + position]
                position += 1
            else:
                break

        # If the input does not have a frame, give it the same frame number as
        # the previous action
        if frame_str == "":
            frame_str = self.actions[-1].frame_index

        while True:
            if ln_actions[lower_bound + position] != 'y':
                input_str = input_str + ln_actions[lower_bound + position]
                break
            else:
                input_str = input_str + \
                    ln_actions[lower_bound + position: lower_bound + position + 4]
                position += 3
                break

        # This line is here to remove any invaid actions
        # We do this because sometimes there are spaces at the end of a line
        if(len(input_str.rstrip()) > 0):
            self.actions.append(Action(frame_str, input_str))

        position += 1
        return position

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).