implement most registration functions

This commit is contained in:
mightypanders 2021-11-11 01:01:22 +01:00
parent 7636308da6
commit 41258cd19f
1 changed files with 31 additions and 9 deletions

View File

@ -1,14 +1,36 @@
export default class RegistrationHandler { export interface userNameBinding {
Steam: string,
private register(): void { Discord: string
console.log('Registering')
} }
private removeUser(): void { } export type Maybe<T> = T | undefined
private getNameRegisteredForDiscordUser(): string { return "" } export default class RegistrationHandler {
private getNameRegisteredForSteamUser(): string { return "" } private userRegister: userNameBinding[] = []
private listRegisteredMembers(): void { } public constructor() {
private getMemberForPlayer(): any { return "" } console.log('Setup RegistrationHandler')
private isRegistered(): boolean { return false } }
public register(discordname: string, steamname: string): boolean {
const binding: userNameBinding = {
Steam: steamname,
Discord: discordname
}
console.log(`Trying to register ${JSON.stringify(binding)}`)
let alreadyPresentBinding = this.userRegister.find(x => x.Discord == binding.Discord)
if (alreadyPresentBinding) {
console.log(`Binding already present: ${alreadyPresentBinding}, overwriting.`)
alreadyPresentBinding = binding
}
else {
this.userRegister.push(binding)
console.log(`Binding successfully added.`)
}
return true
}
public removeUser(discordName: string): void { this.userRegister = this.userRegister.filter(x => x.Discord !== discordName) }
public getNameRegisteredForDiscordUser(discordUser: string): Maybe<userNameBinding> { return this.userRegister.find(x => x.Discord == discordUser) }
public getNameRegisteredForSteamUser(steamUser: string): Maybe<userNameBinding> { return this.userRegister.find(x => x.Steam == steamUser) }
public listRegisteredMembers(): string { return JSON.stringify(this.userRegister) }
private printHelpText(): void { } private printHelpText(): void { }
private buildHelpText(): string { return "" } private buildHelpText(): string { return "" }
} }