Add files via upload
This commit is contained in:
27
ui/src/util/ApiConfig.ts
Normal file
27
ui/src/util/ApiConfig.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { EnvConfig } from "./EnvConfig";
|
||||
import { IRetrieveDTO } from '../models/FiltersModels';
|
||||
|
||||
export class ApiConfig{
|
||||
|
||||
private static baseRoute : string = EnvConfig.API_URL;
|
||||
|
||||
/* User */
|
||||
public static loginRoute = () => this.baseRoute + `/users/login`;
|
||||
public static registerRoute = () => this.baseRoute + `/users/register`;
|
||||
public static updateUserRoute = () => this.baseRoute + `/users/update`;
|
||||
public static findUserRoute = (userId : string) => this.baseRoute + `users/${userId}`;
|
||||
|
||||
/* Chat */
|
||||
public static saveMessageRoute = () => this.baseRoute + `/chats/save`;
|
||||
public static retrieveMessagesRoute = () => this.baseRoute + `/chats/retrieve`;
|
||||
|
||||
/* History */
|
||||
public static retrieveMatchHistory = (userId : string) => this.baseRoute + `/matchings/${userId}`;
|
||||
|
||||
/* Commend */
|
||||
public static saveCommendRoute = () => this.baseRoute + `/commendations`;
|
||||
|
||||
/* Filters */
|
||||
public static upsertFiltersRoute = () => this.baseRoute + `/filters`;
|
||||
public static retrieveFiltersRoute = (retrieveDTO : IRetrieveDTO) => this.baseRoute + `/filters/${retrieveDTO.userId}`;
|
||||
}
|
||||
15
ui/src/util/EnvConfig.ts
Normal file
15
ui/src/util/EnvConfig.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
export class EnvConfig{
|
||||
|
||||
/* Enviroment variables for api config */
|
||||
private static API_HOST : string = process.env.REACT_APP_API_HOST ?? "";
|
||||
private static API_PORT : string = process.env.REACT_APP_API_PORT ?? "";
|
||||
public static API_URL : string = `http://${EnvConfig.API_HOST}:${EnvConfig.API_PORT}`;
|
||||
|
||||
/* Enviroment variables for socket.io config */
|
||||
private static SOCKET_HOST : string = process.env.REACT_APP_SOCKET_HOST ?? "";
|
||||
private static SOCKET_PORT : string = process.env.REACT_APP_SOCKET_PORT ?? "";
|
||||
public static SOCKET_URL : string = `http://${EnvConfig.SOCKET_HOST}:${EnvConfig.SOCKET_PORT}`;
|
||||
|
||||
/* Others */
|
||||
public static DEBUG : boolean = ( (process.env.REACT_APP_DEBUG??'true') === 'true');
|
||||
}
|
||||
173
ui/src/util/Micellaneous.ts
Normal file
173
ui/src/util/Micellaneous.ts
Normal file
@@ -0,0 +1,173 @@
|
||||
import {
|
||||
GameMode,
|
||||
Gender,
|
||||
RankLevel,
|
||||
RankType,
|
||||
ServerPreference,
|
||||
} from "../models/FiltersModels";
|
||||
|
||||
export class Micellaneous {
|
||||
private static agentIcons: Array<string> = [
|
||||
"/images/icons/Astra_icon.webp",
|
||||
"/images/icons/Breach_icon.webp",
|
||||
"/images/icons/Brimstone_icon.webp",
|
||||
"/images/icons/Chamber_icon.webp",
|
||||
"/images/icons/Cypher_icon.webp",
|
||||
"/images/icons/Fade_icon.webp",
|
||||
"/images/icons/Harbor_icon.webp",
|
||||
"/images/icons/Jett_icon.webp",
|
||||
"/images/icons/KAYO_icon.webp",
|
||||
"/images/icons/Killjoy_icon.webp",
|
||||
"/images/icons/Neon_icon.webp",
|
||||
"/images/icons/Omen_icon.webp",
|
||||
"/images/icons/Phoenix_icon.webp",
|
||||
"/images/icons/Raze_icon.webp",
|
||||
"/images/icons/Reyna_icon.webp",
|
||||
"/images/icons/Sage_icon.webp",
|
||||
"/images/icons/Skye_icon.webp",
|
||||
"/images/icons/Sova_icon.webp",
|
||||
"/images/icons/Viper_icon.webp",
|
||||
"/images/icons/Yoru_icon.webp",
|
||||
];
|
||||
|
||||
private static backgroundAgents: Array<string> = [
|
||||
"/images/background/Astra.png",
|
||||
"/images/background/Breach.png",
|
||||
"/images/background/Brimstone.png",
|
||||
"/images/background/Chamber.png",
|
||||
"/images/background/Cypher.png",
|
||||
"/images/background/Fade.png",
|
||||
"/images/background/Harbor.png",
|
||||
"/images/background/Jett.png",
|
||||
"/images/background/KAYO.png",
|
||||
"/images/background/Killjoy.png",
|
||||
"/images/background/Neon.png",
|
||||
"/images/background/Omen.png",
|
||||
"/images/background/Phoenix.png",
|
||||
"/images/background/Raze.png",
|
||||
"/images/background/Reyna.png",
|
||||
"/images/background/Sage.png",
|
||||
"/images/background/Skye.png",
|
||||
"/images/background/Sova.png",
|
||||
"/images/background/Viper.png",
|
||||
"/images/background/Yoru.png",
|
||||
];
|
||||
|
||||
// Converts a string to Title Case
|
||||
public static toTitleCase(str: string) {
|
||||
return str?.replace(/\w\S*/g, function (txt) {
|
||||
return txt?.charAt(0).toUpperCase() + txt?.substr(1).toLowerCase();
|
||||
});
|
||||
}
|
||||
|
||||
// Map rank to string
|
||||
public static rankToString(rank: number[]) {
|
||||
let rankType = "";
|
||||
let rankLevel = "";
|
||||
|
||||
switch (rank[0]) {
|
||||
case RankType.iron:
|
||||
rankType = "Iron";
|
||||
break;
|
||||
case RankType.bronze:
|
||||
rankType = "Bronze";
|
||||
break;
|
||||
case RankType.silver:
|
||||
rankType = "Silver";
|
||||
break;
|
||||
case RankType.gold:
|
||||
rankType = "Gold";
|
||||
break;
|
||||
case RankType.platinum:
|
||||
rankType = "Platinum";
|
||||
break;
|
||||
case RankType.diamond:
|
||||
rankType = "Diamond";
|
||||
break;
|
||||
case RankType.ascendant:
|
||||
rankType = "Ascendant";
|
||||
break;
|
||||
case RankType.immortal:
|
||||
rankType = "Immortal";
|
||||
break;
|
||||
case RankType.radiant:
|
||||
rankType = "Radiant";
|
||||
break;
|
||||
}
|
||||
|
||||
switch (rank[1]) {
|
||||
case RankLevel.one:
|
||||
rankLevel = " 1";
|
||||
break;
|
||||
case RankLevel.two:
|
||||
rankLevel = " 2";
|
||||
break;
|
||||
case RankLevel.three:
|
||||
rankLevel = " 3";
|
||||
break;
|
||||
}
|
||||
|
||||
return rankType + rankLevel;
|
||||
}
|
||||
|
||||
// Map server preference to string
|
||||
public static serverPreferenceToString(
|
||||
serverPref: ServerPreference,
|
||||
longVersion: boolean = false
|
||||
) {
|
||||
switch (serverPref) {
|
||||
case ServerPreference.na:
|
||||
return longVersion ? "N. America" : "NA";
|
||||
case ServerPreference.eu:
|
||||
return longVersion ? "Europe" : "EU";
|
||||
case ServerPreference.ap:
|
||||
return longVersion ? "Asia Pacific" : "AP";
|
||||
case ServerPreference.kr:
|
||||
return longVersion ? "Korea" : "KR";
|
||||
}
|
||||
}
|
||||
|
||||
// Map gender to string
|
||||
public static genderToString(gender: Gender, longVersion: boolean = false) {
|
||||
switch (gender) {
|
||||
case Gender.woman:
|
||||
return longVersion ? "Woman" : "W";
|
||||
case Gender.man:
|
||||
return longVersion ? "Man" : "M";
|
||||
case Gender.nonBinary:
|
||||
return longVersion ? "Non-Binary" : "NB";
|
||||
}
|
||||
}
|
||||
|
||||
// Get a specific icon
|
||||
public static getAgentIcon(idx: number, randomly: boolean = false) {
|
||||
if (!randomly) {
|
||||
if (idx < 0 || idx >= Micellaneous.agentIcons.length) idx = 0;
|
||||
return Micellaneous.agentIcons[idx];
|
||||
} else {
|
||||
idx = Math.floor(Math.random() * (Micellaneous.agentIcons.length - 1));
|
||||
return Micellaneous.agentIcons[idx];
|
||||
}
|
||||
}
|
||||
|
||||
public static getBackgroundAgents(iconSrc: string) {
|
||||
const bgAgent1: number = Micellaneous.agentIcons.indexOf(iconSrc);
|
||||
if (bgAgent1 !== -1) {
|
||||
let bgAgent2: number = bgAgent1;
|
||||
while (bgAgent1 === bgAgent2) {
|
||||
bgAgent2 = Math.floor(Math.random() * 20);
|
||||
}
|
||||
const bgAgents = [
|
||||
Micellaneous.backgroundAgents[bgAgent1],
|
||||
Micellaneous.backgroundAgents[bgAgent2],
|
||||
];
|
||||
return bgAgents;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static playerTypeToString(playerType: GameMode) {
|
||||
if (playerType === GameMode.casual) return "Casual";
|
||||
else return "Competitive";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user