Adding initial support to looking at you team data on profile.
This commit is contained in:
parent
9279e6388a
commit
589782365b
@ -6,6 +6,7 @@ export default class SelfPlayerUI extends AbstractTopBarInterface {
|
|||||||
private selfPlayer: ConquerUser | null = null
|
private selfPlayer: ConquerUser | null = null
|
||||||
private userWelcome: HTMLElement | null = null
|
private userWelcome: HTMLElement | null = null
|
||||||
private isExplorerModeEnabled: boolean;
|
private isExplorerModeEnabled: boolean;
|
||||||
|
private userTeamData: HTMLElement | null = null;
|
||||||
|
|
||||||
constructor(isExplorerModeEnabled: boolean) {
|
constructor(isExplorerModeEnabled: boolean) {
|
||||||
super();
|
super();
|
||||||
@ -23,7 +24,6 @@ export default class SelfPlayerUI extends AbstractTopBarInterface {
|
|||||||
|
|
||||||
public async run(): Promise<void> {
|
public async run(): Promise<void> {
|
||||||
const selfPlayerNode = this.getMainNode()
|
const selfPlayerNode = this.getMainNode()
|
||||||
selfPlayerNode.classList.remove('conquer-display-none')
|
|
||||||
const user = await ConquerUser.getSelfUser()
|
const user = await ConquerUser.getSelfUser()
|
||||||
if (user === null) {
|
if (user === null) {
|
||||||
this.runCallbacks('close')
|
this.runCallbacks('close')
|
||||||
@ -33,6 +33,8 @@ export default class SelfPlayerUI extends AbstractTopBarInterface {
|
|||||||
this.populateWelcome()
|
this.populateWelcome()
|
||||||
this.populateCreateNodeOption()
|
this.populateCreateNodeOption()
|
||||||
this.populateToggleExplorerModeOption();
|
this.populateToggleExplorerModeOption();
|
||||||
|
await this.populateUserTeamData();
|
||||||
|
selfPlayerNode.classList.remove('conquer-display-none')
|
||||||
}
|
}
|
||||||
|
|
||||||
private populateToggleExplorerModeOption(): void {
|
private populateToggleExplorerModeOption(): void {
|
||||||
@ -78,6 +80,43 @@ export default class SelfPlayerUI extends AbstractTopBarInterface {
|
|||||||
this.getMainNode().appendChild(createNodeButtonInterface)
|
this.getMainNode().appendChild(createNodeButtonInterface)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async getUserTeamData(): Promise<HTMLElement> {
|
||||||
|
if (this.userTeamData !== null) {
|
||||||
|
return this.userTeamData;
|
||||||
|
}
|
||||||
|
const element = document.createElement('p');
|
||||||
|
this.userTeamData = element;
|
||||||
|
if (this.selfPlayer === null) {
|
||||||
|
throw new Error('User still not set')
|
||||||
|
}
|
||||||
|
const team = await this.selfPlayer.getTeam();
|
||||||
|
if (team === null) {
|
||||||
|
element.innerText = 'No tienes equipo aun,'
|
||||||
|
+ ' ve al nodo más cercano para unirte a un equipo.';
|
||||||
|
return this.userTeamData;
|
||||||
|
}
|
||||||
|
const spanCircle = document.createElement('span');
|
||||||
|
spanCircle.classList.add('conquer-team-circle');
|
||||||
|
spanCircle.style.backgroundColor = team.getColor();
|
||||||
|
element.append(spanCircle);
|
||||||
|
const spanText = document.createElement('span');
|
||||||
|
spanText.innerText = 'Perteneces al equipo: ';
|
||||||
|
element.append(spanText);
|
||||||
|
const spanTeamName = document.createElement('span');
|
||||||
|
spanTeamName.style.color = team.getColor();
|
||||||
|
spanTeamName.style.backgroundColor = 'white';
|
||||||
|
spanTeamName.innerText = team.getName();
|
||||||
|
element.append(spanTeamName);
|
||||||
|
return this.userTeamData;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async populateUserTeamData(): Promise<void> {
|
||||||
|
const userTeamData = await this.getUserTeamData();
|
||||||
|
const userTeamDataInterface = this.generateInterfaceElementCentered();
|
||||||
|
userTeamDataInterface.append(userTeamData);
|
||||||
|
this.getMainNode().append(userTeamDataInterface);
|
||||||
|
}
|
||||||
|
|
||||||
private populateWelcome(): void {
|
private populateWelcome(): void {
|
||||||
const userWelcome = this.getUserWelcome()
|
const userWelcome = this.getUserWelcome()
|
||||||
const userWelcomeInterface = this.generateInterfaceElementCentered();
|
const userWelcomeInterface = this.generateInterfaceElementCentered();
|
||||||
|
@ -16,6 +16,18 @@ export default class ConquerTeam {
|
|||||||
@JsonProperty()
|
@JsonProperty()
|
||||||
private color: string;
|
private color: string;
|
||||||
|
|
||||||
|
public getName(): string {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public getDescription(): string {
|
||||||
|
return this.description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public getColor(): string {
|
||||||
|
return this.color;
|
||||||
|
}
|
||||||
|
|
||||||
constructor(uuid: string, name: string, description: string, points: number, color: string) {
|
constructor(uuid: string, name: string, description: string, points: number, color: string) {
|
||||||
this.kind = 'ConquerTeam';
|
this.kind = 'ConquerTeam';
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
|
@ -25,8 +25,8 @@ export default class ConquerUser {
|
|||||||
private username: string;
|
private username: string;
|
||||||
@JsonProperty()
|
@JsonProperty()
|
||||||
private uuid: string;
|
private uuid: string;
|
||||||
@JsonProperty({name: 'team'})
|
@JsonProperty()
|
||||||
private team_uuid: string | null;
|
private team: string | null;
|
||||||
|
|
||||||
constructor(kind: string, uuid: string, username: string, is_admin = false, registration_date: string | null = null, last_activity: string | null = null) {
|
constructor(kind: string, uuid: string, username: string, is_admin = false, registration_date: string | null = null, last_activity: string | null = null) {
|
||||||
this.kind = kind;
|
this.kind = kind;
|
||||||
@ -38,10 +38,10 @@ export default class ConquerUser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async getTeam(): Promise<ConquerTeam | null> {
|
public async getTeam(): Promise<ConquerTeam | null> {
|
||||||
if (this.team_uuid === null) {
|
if (this.team === null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return ConquerTeam.getTeam(this.team_uuid);
|
return ConquerTeam.getTeam(this.team);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async getSelfUser(): Promise<ConquerUser | null> {
|
public static async getSelfUser(): Promise<ConquerUser | null> {
|
||||||
|
@ -37,6 +37,9 @@ __PACKAGE__->add_columns(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
__PACKAGE__->set_primary_key('uuid');
|
||||||
|
__PACKAGE__->has_many( players => 'BurguillosInfo::Schema::Result::ConquerUser', 'team');
|
||||||
|
|
||||||
sub serialize ($self) {
|
sub serialize ($self) {
|
||||||
$self = $self->get_from_storage();
|
$self = $self->get_from_storage();
|
||||||
return {
|
return {
|
||||||
@ -48,6 +51,4 @@ sub serialize ($self) {
|
|||||||
color => $self->color,
|
color => $self->color,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
__PACKAGE__->has_many( players => 'BurguillosInfo::Schema::Result::ConquerUser', 'team');
|
|
||||||
__PACKAGE__->set_primary_key('uuid');
|
|
||||||
1;
|
1;
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user