Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different color on board when already played with someone #126 #163

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 40 additions & 19 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,11 @@ def program_exit(status: int): # so we don't need to import the entire sys modu
for p in Players:
if p["Subject"] == Requests.puuid:
allyTeam = p["TeamID"]
break
for player in Players:
status.update(f"Loading players... [{playersLoaded}/{len(Players)}]")
playersLoaded += 1
last_seen = 0

if player["Subject"] in stats_data.keys():
if player["Subject"] != Requests.puuid and player["Subject"] not in partyMembersList:
Expand All @@ -286,28 +288,41 @@ def program_exit(status: int): # so we don't need to import the entire sys modu
m_set = ()
for m in stats_data[player["Subject"]]:
if m["match_id"] != coregame.match_id and m["match_id"] not in m_set:
if m["epoch"] > last_seen:
# get the last match they played with or against you
last_seen = m["epoch"]
# saves if they were on your team or not, defaults to true for old data
zayKenyon marked this conversation as resolved.
Show resolved Hide resolved
teammate = m.get("team", True)
times += 1
m_set += (m["match_id"],)

if teammate:
team = "with"
else:
team = "against"

if player["PlayerIdentity"]["Incognito"] == False:
already_played_with.append(
{
"times": times,
"name": curr_player_stat["name"],
"agent": curr_player_stat["agent"],
"time_diff": time.time() - curr_player_stat["epoch"]
})
{
"times": times,
"name": curr_player_stat["name"],
"agent": curr_player_stat["agent"],
"time_diff": time.time() - curr_player_stat["epoch"],
"team": team
})
else:
if player["TeamID"] == allyTeam:
team_string = "your"
else:
team_string = "enemy"
already_played_with.append(
{
"times": times,
"name": agent_dict[player["CharacterID"].lower()] + " on " + team_string + " team",
"agent": curr_player_stat["agent"],
"time_diff": time.time() - curr_player_stat["epoch"]
})
{
"times": times,
"name": agent_dict[player["CharacterID"].lower()] + " on " + team_string + " team",
"agent": curr_player_stat["agent"],
"time_diff": time.time() - curr_player_stat["epoch"],
"team": team
})

party_icon = ''

Expand Down Expand Up @@ -346,12 +361,17 @@ def program_exit(status: int): # so we don't need to import the entire sys modu

if player["PlayerIdentity"]["Incognito"]:
Namecolor = colors.get_color_from_team(player["TeamID"],
names[player["Subject"]],
player["Subject"], Requests.puuid, agent=player["CharacterID"], party_members=partyMembersList)
names[player["Subject"]],
player["Subject"], Requests.puuid,
agent=player["CharacterID"],
party_members=partyMembersList,
already_seen=bool(last_seen))
else:
Namecolor = colors.get_color_from_team(player["TeamID"],
names[player["Subject"]],
player["Subject"], Requests.puuid, party_members=partyMembersList)
names[player["Subject"]],
player["Subject"], Requests.puuid,
party_members=partyMembersList,
already_seen=bool(last_seen))
if lastTeam != player["TeamID"]:
if lastTeamBoolean:
table.add_empty_row()
Expand Down Expand Up @@ -435,6 +455,7 @@ def program_exit(status: int): # so we don't need to import the entire sys modu
"rr": rr,
"match_id": coregame.match_id,
"epoch": time.time(),
"team": player["TeamID"] == allyTeam
}
}
)
Expand Down Expand Up @@ -695,7 +716,7 @@ def program_exit(status: int): # so we don't need to import the entire sys modu
if game_state == "INGAME":
if isRange:
table.set_runtime_col_flag('Party', False)
table.set_runtime_col_flag('Agent',False)
table.set_runtime_col_flag('Agent', False)

# We don't to show the RR column if the "aggregate_rank_rr" feature flag is True.
table.set_runtime_col_flag('RR', cfg.table.get("rr") and not cfg.get_feature_flag("aggregate_rank_rr"))
Expand All @@ -716,8 +737,8 @@ def program_exit(status: int): # so we don't need to import the entire sys modu
if len(already_played_with) > 0:
print("\n")
for played in already_played_with:
print(f"Already played with {played['name']} (last {played['agent']}) {stats.convert_time(played['time_diff'])} ago. (Total played {played['times']} times)")
chatlog(f"Already played with {played['name']} (last {played['agent']}) {stats.convert_time(played['time_diff'])} ago. (Total played {played['times']} times)")
print(f"Already played {played['team']} {played['name']} (last {played['agent']}) {stats.convert_time(played['time_diff'])} ago. (Total played {played['times']} times)")
chatlog(f"Already played {played['team']} {played['name']} (last {played['agent']}) {stats.convert_time(played['time_diff'])} ago. (Total played {played['times']} times)")
already_played_with = []
if cfg.cooldown == 0:
input("Press enter to fetch again...")
Expand Down
4 changes: 3 additions & 1 deletion src/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def __init__(self, hide_names, agent_dict, AGENTCOLORLIST):
self.tier_dict = tierDict
self.AGENTCOLORLIST = AGENTCOLORLIST

def get_color_from_team(self, team, name, playerPuuid, selfPuuid, agent=None, party_members=None):
def get_color_from_team(self, team, name, playerPuuid, selfPuuid, agent=None, party_members=None, already_seen=None):
orig_name = name
if agent is not None:
if self.hide_names:
Expand All @@ -29,6 +29,8 @@ def get_color_from_team(self, team, name, playerPuuid, selfPuuid, agent=None, pa
Teamcolor = color(orig_name, fore=(76, 151, 237))
else:
Teamcolor = ''
if already_seen:
Teamcolor = color(orig_name, fore=(10, 211, 8))
if playerPuuid == selfPuuid:
Teamcolor = color(orig_name, fore=(221, 224, 41))
return Teamcolor
Expand Down