Skip to content

Commit 9828386

Browse files
committed
Names of squadmates are now detected and displayed.
1 parent afd68bc commit 9828386

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

pt.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
from collections import defaultdict
1414
from math import nan, isnan
1515
from time import sleep
16-
from typing import Iterator, Callable, Literal
16+
from typing import Iterator, Callable, Literal, Iterable
1717

1818
from sty import fg, rs
1919
import colorama
2020

2121

22-
VERSION = "v2.1.2"
22+
VERSION = "v2.2"
2323
follow_mode = False # False -> analyze mode
2424

2525
dt_dict = {
@@ -51,6 +51,7 @@ class LogEnd(Exception):
5151

5252
class Constants:
5353
NICKNAME = 'Net [Info]: name: '
54+
SQUAD_MEMBER = 'loadout loader finished.'
5455
HEIST_START = 'jobId=/Lotus/Types/Gameplay/Venus/Jobs/Heists/HeistProfitTakerBountyFour'
5556
HOST_MIGRATION = '"jobId" : "/Lotus/Types/Gameplay/Venus/Jobs/Heists/HeistProfitTakerBountyFour'
5657
HEIST_ABORT = 'SetReturnToLobbyLevelArgs: '
@@ -72,6 +73,17 @@ def color(text: str, col: str) -> str:
7273
return col + text + rs.fg
7374

7475

76+
def oxfordcomma(collection: Iterable[str]):
77+
collection = list(collection)
78+
if len(collection) == 0:
79+
return ''
80+
if len(collection) == 1:
81+
return collection[0]
82+
if len(collection) == 2:
83+
return collection[0] + ' and ' + collection[1]
84+
return ', '.join(collection[:-1]) + ', and ' + collection[-1]
85+
86+
7587
def time_str(seconds: float, format_: Literal['brackets', 'units']) -> str:
7688
if format_ == 'brackets':
7789
return f'[{int(seconds / 60)}:{int(seconds % 60):02d}]'
@@ -88,6 +100,7 @@ class RelRun:
88100
def __init__(self,
89101
run_nr: int,
90102
nickname: str,
103+
squad_members: set[str],
91104
pt_found: float,
92105
phase_durations: dict[int, float],
93106
shields: dict[float, list[tuple[str, float]]],
@@ -96,6 +109,7 @@ def __init__(self,
96109
pylon_dur: dict[int, float]):
97110
self.run_nr = run_nr
98111
self.nickname = nickname
112+
self.squad_members = squad_members
99113
self.pt_found = pt_found
100114
self.phase_durations = phase_durations
101115
self.shields = shields
@@ -126,7 +140,8 @@ def pretty_print(self):
126140
print(f'{fg.white}{"-" * 72}\n\n') # footer
127141

128142
def pretty_print_run_summary(self):
129-
run_info = f'{fg.cyan}Profit-Taker Run #{self.run_nr} by {fg.li_cyan}{self.nickname}{fg.cyan} cleared in ' \
143+
players = oxfordcomma([self.nickname] + list(self.squad_members - {self.nickname}))
144+
run_info = f'{fg.cyan}Profit-Taker Run #{self.run_nr} by {fg.li_cyan}{players}{fg.cyan} cleared in ' \
130145
f'{fg.li_cyan}{time_str(self.length(), "units")}'
131146
if self.best_run:
132147
run_info += f'{fg.white} - {fg.li_magenta}Best run!'
@@ -186,6 +201,7 @@ class AbsRun:
186201
def __init__(self, run_nr: int):
187202
self.run_nr = run_nr
188203
self.nickname = ''
204+
self.squad_members: set[str] = set()
189205
self.heist_start = 0.0
190206
self.pt_found = 0.0
191207
self.shields: dict[float, list[tuple[str, float]]] = defaultdict(list) # phase -> list((type, absolute time))
@@ -239,7 +255,8 @@ def to_rel(self) -> RelRun:
239255
# Set phase 3.5 shields
240256
shields[3.5] = [(shield, nan) for shield, _ in self.shields[3.5]]
241257

242-
return RelRun(self.run_nr, self.nickname, pt_found, phase_durations, shields, legs, body_dur, pylon_dur)
258+
return RelRun(self.run_nr, self.nickname, self.squad_members, pt_found,
259+
phase_durations, shields, legs, body_dur, pylon_dur)
243260

244261

245262
def time_from_line(line: str) -> float:
@@ -274,7 +291,8 @@ def register_phase(log: Iterator[str], run: AbsRun, phase: int):
274291
lambda line: Constants.NICKNAME in line,
275292
lambda line: Constants.ELEVATOR_EXIT in line,
276293
lambda line: Constants.HEIST_START in line, # Functions as abort as well
277-
lambda line: Constants.HOST_MIGRATION in line])
294+
lambda line: Constants.HOST_MIGRATION in line,
295+
lambda line: Constants.SQUAD_MEMBER in line])
278296
if match == 0: # Shield switch
279297
# Shield_phase '3.5' is for when shields swap during the pylon phase in phase 3.
280298
shield_phase = 3.5 if phase == 3 and 3 in run.pylon_start else phase
@@ -314,6 +332,8 @@ def register_phase(log: Iterator[str], run: AbsRun, phase: int):
314332
raise RunAbort(require_heist_start=False)
315333
elif match == 10: # Host migration
316334
raise RunAbort(require_heist_start=True)
335+
elif match == 11: # Squad member
336+
run.squad_members.add(line.split()[-4])
317337

318338

319339
def read_run(log: Iterator[str], run_nr: int, require_heist_start=False) -> AbsRun:

0 commit comments

Comments
 (0)