Skip to content

Commit

Permalink
seperate into teams for marne
Browse files Browse the repository at this point in the history
  • Loading branch information
zefanjajobse committed Nov 19, 2023
1 parent 81aac23 commit 8d2a0ea
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 58 deletions.
14 changes: 7 additions & 7 deletions src/api/ReturnTypes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ export type ServerLeaderboardList = {
};

export type ServerPlayersReturn = {
apiUrl: string;
apiUrl?: string;
teams: serverTeamList[];
loading: serverPlayer[];
que: serverPlayer[];
Expand Down Expand Up @@ -371,14 +371,14 @@ export type serverTeamList = {
};

export type serverPlayer = {
player_id: number;
user_id: number;
player_id?: number;
user_id?: number;
name: string;
position: number;
position?: number;
latency?: number;
platoon: string;
join_time: number;
localization: string;
platoon?: string;
join_time?: number;
localization?: string;

platform?: string;
rank?: number;
Expand Down
2 changes: 1 addition & 1 deletion src/api/marneApi.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ export class ApiProvider extends JsonClient {
settings: result?.settings,
description: result?.description,
rotation:
result?.rotation == ""
result?.rotation === ""
? []
: result?.rotation?.map((current: RotationReturn, index: number) => {
if (current !== null) {
Expand Down
8 changes: 7 additions & 1 deletion src/components/routes/Servers/Detailed/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
Bf3ServerPlayerlist,
BfListServerPlayerList,
ServerPlayerlist,
MarnePlayerList,
} from "./Players";
import { ServerLeaderboard } from "./Leaderboard";
import { ServerPlatoon } from "./Platoon";
Expand Down Expand Up @@ -426,7 +427,12 @@ export function Results(props: Views): React.ReactElement {
/>
) : (
props.game === "bf1marne" && (
<Bf3ServerPlayerlist players={stats?.players} game="bf1" />
<MarnePlayerList
players={stats?.players}
game={props?.game}
gameId={stats?.gameId}
/>
// <Bf3ServerPlayerlist players={stats?.players} game="bf1" />
)
)}
</>
Expand Down
114 changes: 65 additions & 49 deletions src/components/routes/Servers/Detailed/Players.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function Players(props: {
teams.forEach((teamInfo: serverTeamList) => {
playerIds = playerIds.concat(
teamInfo.players.map((player) => {
return player.player_id.toString();
return player?.player_id?.toString();
}),
);
});
Expand Down Expand Up @@ -200,7 +200,7 @@ function Players(props: {
<div key={index}>
<Align>
<h3 style={{ margin: ".5rem", marginTop: 0 }}>
{teamInfo.faction in factions
{teamInfo?.faction in factions
? t(`servers.factions.${teamInfo.faction}`)
: t(`servers.factions.${teamInfo.teamid}`)}
</h3>
Expand All @@ -211,14 +211,13 @@ function Players(props: {
{teamInfo.players.map(
(key: serverPlayer, index: number) => {
const seederPlayer = seederPlayers.get(key.player_id);
const dateAdded = new Date(key.join_time / 1000);
return (
<Column key={index}>
<Row>
<AlignW>
{props.game !== "bf2042" && (
{key?.rank && (
<img
src={`https://cdn.gametools.network/bf1/${key.rank}.png`}
src={`https://cdn.gametools.network/bf1/${key?.rank}.png`}
height="25px"
loading="lazy"
/>
Expand Down Expand Up @@ -253,7 +252,7 @@ function Players(props: {
</a>
</AlignW>
<CheckBan
playerId={key.player_id.toString()}
playerId={key?.player_id?.toString()}
bfBanList={bfBanInfo}
bfbanLoading={bfbanLoading}
bfbanError={bfbanError}
Expand All @@ -262,16 +261,7 @@ function Players(props: {
bfeacError={bfeacError}
/>
</Row>
{props.game !== "bf2042" ? (
<Row>
<h4 style={{ marginTop: "0.5rem" }}>
{key.latency}
</h4>
<Description style={{ lineHeight: 0 }}>
{t("servers.playerlist.row.ping")}
</Description>
</Row>
) : (
{props.game === "bf2042" ? (
<Row>
<h4 style={{ marginTop: "0.5rem" }}>
{key.platform.toUpperCase()}
Expand All @@ -280,6 +270,17 @@ function Players(props: {
{t("servers.playerlist.row.platform")}
</Description>
</Row>
) : (
props.game !== "bf1marne" && (
<Row>
<h4 style={{ marginTop: "0.5rem" }}>
{key.latency}
</h4>
<Description style={{ lineHeight: 0 }}>
{t("servers.playerlist.row.ping")}
</Description>
</Row>
)
)}
{haveSeederPlayers && (
<>
Expand All @@ -303,14 +304,18 @@ function Players(props: {
</>
)}
<Row>
<h4 style={{ marginTop: "0.5rem" }}>
{t("change", {
change: dateAdded,
})}
</h4>
<Description style={{ lineHeight: 0 }}>
{t("servers.playerlist.row.timePlayed")}
</Description>
{key.join_time && (
<>
<h4 style={{ marginTop: "0.5rem" }}>
{t("change", {
change: new Date(key?.join_time / 1000),
})}
</h4>
<Description style={{ lineHeight: 0 }}>
{t("servers.playerlist.row.timePlayed")}
</Description>
</>
)}
</Row>
<PhoneRow>
<ButtonLink
Expand Down Expand Up @@ -397,6 +402,42 @@ export function ServerPlayerlist(props: {
);
}

export function MarnePlayerList(props: {
players: ScoreServerPlayer[];
game: string;
gameId: string;
}): React.ReactElement {
const stats = {
teams: [
{
teamid: "teamOne",
players: [],
image: "",
name: "1",
},
{
teamid: "teamTwo",
players: [],
image: "",
name: "",
},
],
update_timestamp: Date.now() / 1000,
};
props?.players?.forEach((element) => {
stats.teams[element.team - 1].players.push(element);
});

return (
<Players
stats={stats}
game={props.game}
gameid={props.gameId}
platform="pc"
/>
);
}

export function Bf3ServerPlayerlist(props: {
players: ScoreServerPlayer[];
game: string;
Expand Down Expand Up @@ -617,31 +658,6 @@ export function BfListServerPlayerList(props: {
{t("servers.playerlist.row.killDeath")}
</Description>
</Row>
{/* <PhoneRow>
<ButtonLink
style={
haveSeederPlayers
? {
marginTop: ".5rem",
width: "4rem",
}
: {
marginTop: ".5rem",
}
}
href={`https://gametools.network/stats/${
playerToStatsPlatform[key.platform] ||
key.platform ||
props.platform
}/playerid/${key.player_id}?game=${
props.game
}&name=${encodeURIComponent(key.name)}`}
target="_blank"
rel="noreferrer"
>
{t("stats.view")}
</ButtonLink>
</PhoneRow> */}
</Column>
);
})}
Expand Down

0 comments on commit 8d2a0ea

Please sign in to comment.