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 all commits
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
57 changes: 37 additions & 20 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
times = 0

if player["Subject"] in stats_data.keys():
if player["Subject"] != Requests.puuid and player["Subject"] not in partyMembersList:
Expand All @@ -282,32 +284,41 @@ def program_exit(status: int): # so we don't need to import the entire sys modu
curr_player_stat = stats_data[player["Subject"]][-i]
if curr_player_stat["match_id"] != coregame.match_id:
#checking for party memebers and self players
times = 0
m_set = ()
for m in stats_data[player["Subject"]]:
if m["match_id"] != coregame.match_id and m["match_id"] not in m_set:
# saves if they were on your team or not, defaults to true for old data
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 +357,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=True if times > 0 else False)
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=True if times > 0 else False)
if lastTeam != player["TeamID"]:
if lastTeamBoolean:
table.add_empty_row()
Expand Down Expand Up @@ -435,6 +451,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 +712,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 +733,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
16 changes: 7 additions & 9 deletions src/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,24 @@ 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:
if agent != "":
name = self.agent_dict[agent.lower()]
else:
name = "Player"
if playerPuuid in party_members:
name = orig_name
if team == 'Red':
if playerPuuid not in party_members:
Teamcolor = color(name, fore=(238, 77, 77))
else:
Teamcolor = color(orig_name, fore=(238, 77, 77))
Teamcolor = color(name, fore=(238, 77, 77))
elif team == 'Blue':
if playerPuuid not in party_members:
Teamcolor = color(name, fore=(76, 151, 237))
else:
Teamcolor = color(orig_name, fore=(76, 151, 237))
Teamcolor = color(name, fore=(76, 151, 237))
else:
Teamcolor = ''
if already_seen:
Teamcolor = color(name, fore=(10, 211, 8))
if playerPuuid == selfPuuid:
Teamcolor = color(orig_name, fore=(221, 224, 41))
return Teamcolor
Expand Down