Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions teams-page.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<div class="grid-container">
<!--<app-navbar class="navbar"></app-navbar>-->



<div class="content">

<div class="teams">
<!-- <h4 class="flex-center" style="padding-top: 0.2rem;">Teams Score = 10</h4> -->
<h4 class="flex-center" style="padding-top: 0.2rem;">Score = {{ score }} <button style="margin-left: 2rem;margin-right: 2rem;"
class="profile-button" (click)="onDone()">Done ✔</button>xP = {{xp}}/100</h4>
<p *ngIf="teamsArr.length == 0" style="padding-top: 0.5rem;"> Please add pokemons to teams</p>

<div class="poke-teams" *ngFor="let id of teamsArr">
<div class="poke-teams-id">#{{id}}</div>
<div class="poke-teams-name">{{pokemons[id].name}}</div>
<div class="poke-teams-img">
<img src="/assets/images/pokemon-images/{{id}}.gif" alt="poke-teams-img">
</div>

<div class="poke-teams-button">
<button class="remove-button" (click)="onClick(id)">X</button>
</div>
</div>


</div>

</div>





<app-footer class="footer flex-center"></app-footer>
</div>
52 changes: 52 additions & 0 deletions teams-page.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { Component, OnInit } from '@angular/core';
import { TeamsService } from '../teams.service';
import { XpService } from '../xp.service';
import { ScoreService } from 'src/app/score.service';
import { GlobalvarService } from 'src/app/globalvar.service';
import { Router } from '@angular/router';

@Component({
selector: 'app-teams-page',
templateUrl: './teams-page.component.html',
styleUrls: ['./teams-page.component.css']
})
export class TeamsPageComponent implements OnInit {
pokemons = this.teamServ.pokeArray;

teamsArr = this.teamServ.getTeam();
score = this.teamServ.getScore(); //Added the score in team service.
xp = this.xpServ.xp;
onClick(pokemonId: number) {
this.teamServ.removeFromTeam(pokemonId);
this.teamServ.removeScore(this.pokemons[pokemonId].base_experience);
}

constructor(private teamServ: TeamsService,
private update: ScoreService,
private global: GlobalvarService,
private router: Router,
private xpServ: XpService) { }

ngOnInit(): void {
console.log(this.teamServ.pokeArray);
console.log(this.teamServ.getTeam());
}

result: string;
email = this.global.receivedEmail;
onDone() {

console.log(this.email, this.score);
this.update.updateScore(this.email, this.score).subscribe(
(response: any) => {
this.result = response;
}
);
this.teamServ.score = 0;
this.xpServ.xp = 100;
this.teamServ.team = [];
this.router.navigate(['home']);

}

}