Exemple #1
0
def parse_file(args):
    """Reads a file specified by arguments, and returns an entry list"""

    entries = []
    started = False
    encounter_sets = []
    with args.file as file:
        # If searching for encounters, divert and find start/end first.
        if args.search_fights:
            encounter_sets = e_tools.find_fights_in_file(file)
            # If all we want to do is list encounters, stop here and give to the user.
            if args.search_fights < 0:
                return [f'{i + 1}. {" ".join(e_info)}' for i, e_info in enumerate(encounter_sets)]
            elif args.search_fights > len(encounter_sets):
                raise Exception('Selected fight index not in selected ACT log.')

        start_time, end_time = e_tools.choose_fight_times(args, encounter_sets)
        # Scan the file until the start timestamp
        for line in file:

            if not started and start_time != line[14:26]:
                continue

            if end_time == line[14:26]:
                break

            # We're at the start of the encounter now.
            if not started:
                started = True
                last_ability_time = e_tools.parse_event_time(line)

            # We're looking for enemy casts
            # These lines will start with 21 or 22, and have an NPC ID (400#####)
            # If this isn't one, skip the line
            if not (line[0:2] == '21' or line[0:2] == '22') or not line[37:40] == '400':
                continue

            # At this point, we have a combat line for the timeline.
            line_fields = line.split('|')
            entry = {
                'time': e_tools.parse_event_time(line),
                'combatant': line_fields[3],
                'ability_id': line_fields[4],
                'ability_name': line_fields[5],
            }

            # Unknown abilities should be hidden sync lines by default.
            if line_fields[5].startswith('Unknown_'):
                entry['ability_name'] = '--sync--'

            entries.append(entry)

    if not started:
        raise Exception('Fight start not found')

    return entries, last_ability_time
Exemple #2
0
def run_file(args, timelist):
    """Runs a timeline against a specified file"""
    state = {
        "file": True,
        "last_entry": False,
        "last_sync_position": 0,
        "last_jump": 0,
        "branch": 1,
        "timeline_stopped": True,
    }
    started = False
    encounter_sets = []

    with args.file as file:
        # If searching for encounters, divert and find start/end first.
        if args.search_fights:
            encounter_sets = e_tools.find_fights_in_file(file)
            # If all we want to do is list encounters, stop here and give to the user.
            if args.search_fights == -1:
                return [
                    f'{i + 1}. {" ".join(e_info)}'
                    for i, e_info in enumerate(encounter_sets)
                ]
            elif args.search_fights > len(
                    encounter_sets) or args.search_fights < -1:
                raise Exception(
                    "Selected fight index not in selected ACT log.")

        start_time, end_time = e_tools.choose_fight_times(args, encounter_sets)
        # Scan the file until the start timestamp
        for line in file:

            # Scan the file until the start timestamp
            if not started and line[14:26] != start_time:
                continue

            if line[14:26] == end_time:
                break

            # We're at the start of the encounter now.
            if not started:
                started = True
                state["last_sync_timestamp"] = e_tools.parse_event_time(line)

            state = check_event(line, timelist, state)
    if not started:
        raise Exception("Fight start not found")
Exemple #3
0
def parse_file(args):
    """Reads a file specified by arguments, and returns an entry list"""

    entries = []
    started = False
    encounter_sets = []
    with args.file as file:
        # If searching for encounters, divert and find start/end first.
        if args.search_fights:
            encounter_sets = e_tools.find_fights_in_file(file)
            # If all we want to do is list encounters, stop here and give to the user.
            if args.search_fights < 0:
                return [
                    f'{i + 1}. {" ".join(e_info)}'
                    for i, e_info in enumerate(encounter_sets)
                ]
            elif args.search_fights > len(encounter_sets):
                raise Exception(
                    "Selected fight index not in selected ACT log.")

        start_time, end_time = e_tools.choose_fight_times(args, encounter_sets)
        # Scan the file until the start timestamp
        for line in file:

            if not started and start_time != line[14:26]:
                continue

            if end_time == line[14:26]:
                break

            # We're at the start of the encounter now.
            if not started:
                started = True
                last_ability_time = e_tools.parse_event_time(line)

            # We're looking for enemy casts or enemies becoming targetable/untargetable.
            # These lines will start with 21, 22, or 34, and have an NPC ID (400#####)
            # If this isn't one, skip the line

            if not (line[0:2] in ["21", "22", "34"
                                  ]) or not line[37:40] == "400":
                continue
            line_fields = line.split("|")
            # We aren't including targetable lines unless the user explicitly says to.
            if line[0:2] == "34" and not line_fields[
                    3] in args.include_targetable:
                continue

            # At this point, we have a combat line for the timeline.
            entry = make_entry({
                "line_type": line_fields[0],
                "time": e_tools.parse_event_time(line),
                "combatant": line_fields[3],
            })
            if line[0:2] in ["21", "22"]:
                entry["ability_id"] = line_fields[4]
                entry["ability_name"] = line_fields[5]

            # Unknown abilities should be hidden sync lines by default.
            if line_fields[5].startswith("Unknown_"):
                entry["ability_name"] = "--sync--"
            else:
                entry["targetable"] = ("--targetable--" if line_fields[6]
                                       == "01" else "--untargetable--")
            entries.append(entry)

    if not started:
        raise Exception("Fight start not found")

    return entries, last_ability_time
def parse_file(args):
    """Reads a file specified by arguments, and returns an entry list"""

    entries = []
    started = False
    encounter_sets = []
    with args.file as file:
        # If searching for encounters, divert and find start/end first.
        if args.search_fights:
            encounter_sets = e_tools.find_fights_in_file(file)
            # If all we want to do is list encounters, stop here and give to the user.
            if args.search_fights < 0:
                return e_tools.list_fights_in_file(args, encounter_sets)
        start_time, end_time = e_tools.choose_fight_times(args, encounter_sets)
        # Scan the file until the start timestamp
        for line in file:

            if not started and start_time != line[14:26]:
                continue

            if end_time == line[14:26]:
                break

            # We're at the start of the encounter now.
            if not started:
                started = True
                last_ability_time = e_tools.parse_event_time(line)

            # We cull non-useful lines before potentially more expensive operations.
            if not line[0:2] in ["00", "21", "22", "34"]:
                continue

            line_fields = line.split("|")

            # If it's a zone seal, we want to make a special entry.
            if e_tools.is_zone_seal(line_fields):
                entry = make_entry(
                    {
                        "line_type": "zone_seal",
                        "time": e_tools.parse_event_time(line),
                        "zone_message": line_fields[4].split(" will be sealed off")[0],
                    }
                )
                entries.append(entry)
                continue

            # We're looking for enemy casts or enemies becoming targetable/untargetable.
            # These lines will start with 21, 22, or 34, and have an NPC ID (400#####)
            # If none of these apply, skip the line

            if not line[0:2] in ["21", "22", "34"] or not line[37:40] == "400":
                continue

            # We aren't including targetable lines unless the user explicitly says to.
            if line[0:2] == "34" and not line_fields[3] in args.include_targetable:
                continue
            # At this point, we have a combat line for the timeline.
            entry = make_entry(
                {
                    "line_type": line_fields[0],
                    "time": e_tools.parse_event_time(line),
                    "combatant": line_fields[3],
                }
            )
            if line[0:2] in ["21", "22"]:
                entry["ability_id"] = line_fields[4]
                entry["ability_name"] = line_fields[5]

            # Unknown abilities should be hidden sync lines by default.
            if line_fields[5].startswith(("Unknown_", "unknown_")):
                entry["ability_name"] = "--sync--"
            else:
                entry["targetable"] = (
                    "--targetable--" if line_fields[6] == "01" else "--untargetable--"
                )
            entries.append(entry)

    if not started:
        raise Exception("Fight start not found")

    return entries, last_ability_time