wip
This commit is contained in:
47
packages/testing-support/src/images/images.ts
Normal file
47
packages/testing-support/src/images/images.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
const DRIVER_AVATARS = [
|
||||
'/images/avatars/avatar-1.svg',
|
||||
'/images/avatars/avatar-2.svg',
|
||||
'/images/avatars/avatar-3.svg',
|
||||
'/images/avatars/avatar-4.svg',
|
||||
'/images/avatars/avatar-5.svg',
|
||||
'/images/avatars/avatar-6.svg',
|
||||
] as const;
|
||||
|
||||
const TEAM_LOGOS = [
|
||||
'/images/logos/team-1.svg',
|
||||
'/images/logos/team-2.svg',
|
||||
'/images/logos/team-3.svg',
|
||||
'/images/logos/team-4.svg',
|
||||
] as const;
|
||||
|
||||
const LEAGUE_BANNERS = [
|
||||
'/images/header.jpeg',
|
||||
'/images/ff1600.jpeg',
|
||||
'/images/lmp3.jpeg',
|
||||
'/images/porsche.jpeg',
|
||||
] as const;
|
||||
|
||||
function hashString(input: string): number {
|
||||
let hash = 0;
|
||||
for (let i = 0; i < input.length; i += 1) {
|
||||
hash = (hash * 31 + input.charCodeAt(i)) | 0;
|
||||
}
|
||||
return Math.abs(hash);
|
||||
}
|
||||
|
||||
export function getDriverAvatar(driverId: string): string {
|
||||
const index = hashString(driverId) % DRIVER_AVATARS.length;
|
||||
return DRIVER_AVATARS[index];
|
||||
}
|
||||
|
||||
export function getTeamLogo(teamId: string): string {
|
||||
const index = hashString(teamId) % TEAM_LOGOS.length;
|
||||
return TEAM_LOGOS[index];
|
||||
}
|
||||
|
||||
export function getLeagueBanner(leagueId: string): string {
|
||||
const index = hashString(leagueId) % LEAGUE_BANNERS.length;
|
||||
return LEAGUE_BANNERS[index];
|
||||
}
|
||||
|
||||
export { DRIVER_AVATARS, TEAM_LOGOS, LEAGUE_BANNERS };
|
||||
Reference in New Issue
Block a user