Browse Source

- Added better support for tracking caught pokemon and calculating the catch numbers

master
Quildra 1 year ago
parent
commit
7cdd305ef5
  1. 47
      origin-dex-api/src/server.ts
  2. 11
      origin-dex/src/app/app.component.ts
  3. 4
      origin-dex/src/app/app.routes.ts
  4. 40
      origin-dex/src/app/core/services/pokemon.service.ts
  5. 167
      origin-dex/src/app/features/plan/plan-game/plan-game.component.ts
  6. 14
      origin-dex/src/app/features/plan/plan-pokemon/plan-pokemon.component.ts
  7. 90
      origin-dex/src/app/features/plan/plan.component.ts
  8. 8
      origin-dex/src/app/features/pokemon/pokemon-carousel/pokemon-carousel.component.ts
  9. 1
      origin-dex/src/app/features/pokemon/pokemon-cell/pokemon-cell.component.ts
  10. BIN
      origin-dex/src/assets/images/games/alphasapphire.png
  11. BIN
      origin-dex/src/assets/images/games/black-2.png
  12. BIN
      origin-dex/src/assets/images/games/black.png
  13. BIN
      origin-dex/src/assets/images/games/blue.png
  14. BIN
      origin-dex/src/assets/images/games/brilliantdiamond.png
  15. BIN
      origin-dex/src/assets/images/games/crystal.png
  16. BIN
      origin-dex/src/assets/images/games/diamond.png
  17. BIN
      origin-dex/src/assets/images/games/emerald.png
  18. BIN
      origin-dex/src/assets/images/games/epxansionpass2.png
  19. BIN
      origin-dex/src/assets/images/games/expansion-pass.png
  20. BIN
      origin-dex/src/assets/images/games/firered.png
  21. BIN
      origin-dex/src/assets/images/games/gold.png
  22. BIN
      origin-dex/src/assets/images/games/heartgold.png
  23. BIN
      origin-dex/src/assets/images/games/leafgreen.png
  24. BIN
      origin-dex/src/assets/images/games/legends-arceus.png
  25. BIN
      origin-dex/src/assets/images/games/letsgoeevee.png
  26. BIN
      origin-dex/src/assets/images/games/letsgopikachu.png
  27. BIN
      origin-dex/src/assets/images/games/moon.png
  28. BIN
      origin-dex/src/assets/images/games/omegaruby.png
  29. BIN
      origin-dex/src/assets/images/games/pearl.png
  30. BIN
      origin-dex/src/assets/images/games/platinum.png
  31. BIN
      origin-dex/src/assets/images/games/pokemon_the_indigo_disk_dlc_dock_icon_by_lexiloo826_dgkjxy3-pre.png
  32. BIN
      origin-dex/src/assets/images/games/red.png
  33. BIN
      origin-dex/src/assets/images/games/ruby.png
  34. BIN
      origin-dex/src/assets/images/games/sapphire.png
  35. BIN
      origin-dex/src/assets/images/games/scarlet.png
  36. BIN
      origin-dex/src/assets/images/games/shield.png
  37. BIN
      origin-dex/src/assets/images/games/shiiningpearl.png
  38. BIN
      origin-dex/src/assets/images/games/silver.png
  39. BIN
      origin-dex/src/assets/images/games/soulsilver.png
  40. BIN
      origin-dex/src/assets/images/games/sun.png
  41. BIN
      origin-dex/src/assets/images/games/sword.png
  42. BIN
      origin-dex/src/assets/images/games/the-hidden treasure of area zero.png
  43. BIN
      origin-dex/src/assets/images/games/ultra-moon.png
  44. BIN
      origin-dex/src/assets/images/games/ultra-sun.png
  45. BIN
      origin-dex/src/assets/images/games/violet.png
  46. BIN
      origin-dex/src/assets/images/games/white-2.png
  47. BIN
      origin-dex/src/assets/images/games/white.png
  48. BIN
      origin-dex/src/assets/images/games/x.png
  49. BIN
      origin-dex/src/assets/images/games/y.png
  50. BIN
      origin-dex/src/assets/images/games/yellow.png

47
origin-dex-api/src/server.ts

@ -254,7 +254,7 @@ app.get('/api/pokemon/:pfic/details', async (req, res) => {
} }
}); });
app.get('/api/plan', async (req: Request, res: Response) => { app.get('/api/plan', authenticateToken, async (req: AuthRequest, res: Response) => {
try { try {
// Read the efficiency plan file // Read the efficiency plan file
const planData = await fs.readFile( const planData = await fs.readFile(
@ -269,6 +269,14 @@ app.get('/api/plan', async (req: Request, res: Response) => {
driver: sqlite3.Database driver: sqlite3.Database
}); });
// Get user's caught Pokemon
const userDb = await userDbPromise;
const caughtPokemon = await userDb.all(
'SELECT pfic FROM caught_pokemon WHERE user_id = ?',
[req.user.id]
);
const caughtPfics = new Set(caughtPokemon.map(p => p.pfic));
// Helper function to get evolution methods // Helper function to get evolution methods
async function getEvolutionMethods(fromPfic: string, toPfic: string) { async function getEvolutionMethods(fromPfic: string, toPfic: string) {
// Try direct evolution first // Try direct evolution first
@ -309,15 +317,49 @@ app.get('/api/plan', async (req: Request, res: Response) => {
return ['Evolution']; return ['Evolution'];
} }
// Enhance the plan with evolution methods const debug_pfic = "0010-01-000-0";
// Enhance the plan with evolution methods and account for caught Pokemon
for (const game of efficiencyPlan) { for (const game of efficiencyPlan) {
for (const pokemon of game.pokemon) { for (const pokemon of game.pokemon) {
// Set initial catch count
pokemon.catch_count = 1;
if (pokemon.pfic === debug_pfic) {
console.log(`pokemon: ${pokemon.name} - ${pokemon.catch_count}`);
}
// Add evolution targets to catch count
if (pokemon.evolve_to) { if (pokemon.evolve_to) {
pokemon.catch_count += pokemon.evolve_to.length;
if (pokemon.pfic === debug_pfic) {
console.log(`pokemon: ${pokemon.name} - ${pokemon.catch_count}`);
}
// Add evolution methods
for (const evolution of pokemon.evolve_to) { for (const evolution of pokemon.evolve_to) {
const methods = await getEvolutionMethods(pokemon.pfic, evolution.pfic); const methods = await getEvolutionMethods(pokemon.pfic, evolution.pfic);
evolution.method = methods.join(' → '); evolution.method = methods.join(' → ');
} }
} }
// Reduce catch count for already caught Pokemon
if (caughtPfics.has(pokemon.pfic)) {
pokemon.catch_count = Math.max(0, pokemon.catch_count - 1);
if (pokemon.pfic === debug_pfic) {
console.log(`B pokemon: ${pokemon.name} - ${pokemon.catch_count}`);
}
}
// Check evolution targets
if (pokemon.evolve_to) {
for (const evolution of pokemon.evolve_to) {
if (caughtPfics.has(evolution.pfic)) {
pokemon.catch_count = Math.max(0, pokemon.catch_count - 1);
if (pokemon.pfic === debug_pfic) {
console.log(`C pokemon: ${pokemon.name} - ${pokemon.catch_count} (${evolution.pfic})`);
}
}
}
}
} }
} }
@ -368,6 +410,7 @@ app.post('/api/pokemon/caught/:pfic', authenticateToken, (req: AuthRequest, res:
); );
res.json({ status: 'caught' }); res.json({ status: 'caught' });
} }
console.log(`Caught ${pfic}`);
} catch (err) { } catch (err) {
console.error('Error updating caught status:', err); console.error('Error updating caught status:', err);
res.status(500).json({ error: 'Internal server error' }); res.status(500).json({ error: 'Internal server error' });

11
origin-dex/src/app/app.component.ts

@ -7,6 +7,7 @@ import { MatTabsModule } from '@angular/material/tabs';
import { AuthService } from './core/services/auth.service'; import { AuthService } from './core/services/auth.service';
import { MatSidenavModule } from '@angular/material/sidenav'; import { MatSidenavModule } from '@angular/material/sidenav';
import { MatListModule } from '@angular/material/list'; import { MatListModule } from '@angular/material/list';
import { PokemonService } from './core/services/pokemon.service';
@Component({ @Component({
selector: 'app-root', selector: 'app-root',
@ -39,9 +40,6 @@ import { MatListModule } from '@angular/material/list';
<mat-sidenav-container class="content-container"> <mat-sidenav-container class="content-container">
<mat-sidenav mode="side" opened> <mat-sidenav mode="side" opened>
<mat-nav-list> <mat-nav-list>
<a mat-list-item routerLink="/storage" routerLinkActive="active">
Storage
</a>
<a mat-list-item routerLink="/storage-carousel" routerLinkActive="active"> <a mat-list-item routerLink="/storage-carousel" routerLinkActive="active">
Storage Carousel Storage Carousel
</a> </a>
@ -96,5 +94,10 @@ import { MatListModule } from '@angular/material/list';
`] `]
}) })
export class AppComponent { export class AppComponent {
constructor(public auth: AuthService) {} constructor(
public auth: AuthService,
public pokemonService: PokemonService
) {
this.pokemonService.initializeCaughtPokemon();
}
} }

4
origin-dex/src/app/app.routes.ts

@ -4,8 +4,8 @@ import { AuthGuard } from './core/guards/auth.guard';
export const routes: Routes = [ export const routes: Routes = [
{ {
path: 'storage', path: 'storage',
loadComponent: () => import('./features/pokemon/pokemon-grid/pokemon-grid.component') loadComponent: () => import('./features/pokemon/pokemon-carousel/pokemon-carousel.component')
.then(m => m.PokemonGridComponent) .then(m => m.PokemonCarouselComponent)
}, },
{ {
path: 'storage-carousel', // Add new route path: 'storage-carousel', // Add new route

40
origin-dex/src/app/core/services/pokemon.service.ts

@ -1,6 +1,6 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { map, Observable, shareReplay } from 'rxjs'; import { map, Observable, shareReplay, tap } from 'rxjs';
import { Pokemon, PokemonEncounter } from '../models/pokemon.model'; import { Pokemon, PokemonEncounter } from '../models/pokemon.model';
import { environment } from '../../../environments/environment.development'; import { environment } from '../../../environments/environment.development';
import { comparePfics } from '../utils/pfic-utils'; import { comparePfics } from '../utils/pfic-utils';
@ -11,6 +11,7 @@ import { comparePfics } from '../utils/pfic-utils';
export class PokemonService { export class PokemonService {
private apiUrl = environment.apiUrl; private apiUrl = environment.apiUrl;
private pokemonCache: Observable<(Pokemon | null)[][]> | null = null; private pokemonCache: Observable<(Pokemon | null)[][]> | null = null;
private pokemonGroups: (Pokemon | null)[][] = [];
constructor(private http: HttpClient) { } constructor(private http: HttpClient) { }
@ -34,9 +35,12 @@ export class PokemonService {
MarkName: pokemon.mark_name, MarkName: pokemon.mark_name,
Image: this.getPokemonImageUrl(pokemon.PFIC), Image: this.getPokemonImageUrl(pokemon.PFIC),
IsDefault: pokemon.is_default || false, IsDefault: pokemon.is_default || false,
IsCaught: false IsCaught: this.caughtPokemon.has(pokemon.PFIC)
} as Pokemon : null) } as Pokemon : null)
)), )),
tap(groups => {
this.pokemonGroups = groups; // Store the groups for later updates
}),
shareReplay(1) shareReplay(1)
); );
@ -49,13 +53,29 @@ export class PokemonService {
toggleCatch(pfic: string): Observable<{status: string, pfic: string}> { toggleCatch(pfic: string): Observable<{status: string, pfic: string}> {
return this.http.post<{status: string, pfic: string}>( return this.http.post<{status: string, pfic: string}>(
`${this.apiUrl}/toggle_catch/${pfic}`, `${this.apiUrl}/pokemon/caught/${pfic}`,
{} {}
).pipe(
tap(response => {
// Update both the Set and the cached Pokemon objects
this.updateCaughtStatus(pfic, response.status === 'caught');
this.updatePokemonCaughtStatus(pfic, response.status === 'caught');
})
); );
} }
private updatePokemonCaughtStatus(pfic: string, isCaught: boolean) {
this.pokemonGroups.forEach(group => {
group.forEach(pokemon => {
if (pokemon && pokemon.PFIC === pfic) {
pokemon.IsCaught = isCaught;
}
});
});
}
getCaughtPokemon(): Observable<string[]> { getCaughtPokemon(): Observable<string[]> {
return this.http.get<string[]>(`${this.apiUrl}/get_caught_pokemon`); return this.http.get<string[]>(`${this.apiUrl}/pokemon/caught`);
} }
private caughtPokemon = new Set<string>(); private caughtPokemon = new Set<string>();
@ -79,4 +99,16 @@ export class PokemonService {
getMarkImageUrl(markName: string): string { getMarkImageUrl(markName: string): string {
return `/assets/images/marks/${markName}.png`; return `/assets/images/marks/${markName}.png`;
} }
initializeCaughtPokemon() {
this.getCaughtPokemon().subscribe(
pfics => {
pfics.forEach(pfic => this.updateCaughtStatus(pfic, true));
// If pokemon are already loaded, update their status
if (this.pokemonGroups.length > 0) {
pfics.forEach(pfic => this.updatePokemonCaughtStatus(pfic, true));
}
}
);
}
} }

167
origin-dex/src/app/features/plan/plan-game/plan-game.component.ts

@ -1,150 +1,87 @@
import { Component, Input, Output, EventEmitter } from '@angular/core'; import { Component, Input, Output, EventEmitter } from '@angular/core';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { MatExpansionModule } from '@angular/material/expansion'; import { MatCardModule } from '@angular/material/card';
import { MatFormFieldModule } from '@angular/material/form-field'; import { GamePlan } from '../../../core/models/plan.model';
import { MatInputModule } from '@angular/material/input';
import { FormsModule } from '@angular/forms';
import { PlanPokemonComponent } from '../plan-pokemon/plan-pokemon.component';
import { GamePlan, PlanPokemon } from '../../../core/models/plan.model';
interface StatusUpdateEvent {
pfic?: string;
caught?: boolean;
gameId?: number;
total?: number;
}
@Component({ @Component({
selector: 'app-plan-game', selector: 'app-plan-game',
standalone: true, standalone: true,
imports: [ imports: [
CommonModule, CommonModule,
MatExpansionModule, MatCardModule
MatFormFieldModule,
MatInputModule,
FormsModule,
PlanPokemonComponent
], ],
template: ` template: `
<mat-expansion-panel> <mat-card
<mat-expansion-panel-header> class="game-card"
<mat-panel-title> [class.selected]="isSelected"
{{ game.game_name }} (click)="onSelect()">
</mat-panel-title> <img
<mat-panel-description> [src]="getGameBoxArt()"
Catch: {{ getTotalCatchCount() }} [alt]="game.game_name"
</mat-panel-description> class="game-image"
</mat-expansion-panel-header> >
<mat-card-content>
<div class="search-container"> <h3>{{ game.game_name }}</h3>
<mat-form-field appearance="outline" class="search-field"> <p class="catch-count">
<mat-label>Search Pokémon</mat-label> Pokémon to catch: {{ getTotalCatchCount() }}
<input matInput [(ngModel)]="searchTerm" (input)="filterPokemon()"> </p>
</mat-form-field> </mat-card-content>
</div> </mat-card>
<div class="game-sections">
<div class="active-section">
<app-plan-pokemon
*ngFor="let pokemon of filteredPokemon"
[pokemon]="pokemon"
(statusUpdate)="onPokemonStatusUpdate($event)"
></app-plan-pokemon>
</div>
<div class="completed-section" *ngIf="completedPokemon.length > 0">
<h3 class="section-title">Completed</h3>
<app-plan-pokemon
*ngFor="let pokemon of completedPokemon"
[pokemon]="pokemon"
(statusUpdate)="onPokemonStatusUpdate($event)"
></app-plan-pokemon>
</div>
</div>
</mat-expansion-panel>
`, `,
styles: [` styles: [`
.search-container { .game-card {
margin-bottom: 16px; width: 200px;
cursor: pointer;
transition: transform 0.2s, box-shadow 0.2s;
} }
.search-field { .game-card:hover {
width: 100%; transform: translateY(-4px);
box-shadow: 0 4px 8px rgba(0,0,0,0.2);
} }
.game-sections { .game-card.selected {
display: flex; border: 2px solid #4CAF50;
flex-direction: column; transform: translateY(-4px);
gap: 24px;
} }
.completed-section { .game-image {
border-top: 2px solid #eee; width: 100%;
padding-top: 16px; height: 160px;
object-fit: cover;
}
mat-card-content {
padding: 16px;
} }
.section-title { h3 {
color: #4CAF50; margin: 0;
margin: 0 0 16px 0;
font-size: 1.2em; font-size: 1.2em;
color: #333;
}
.catch-count {
margin: 8px 0 0;
color: #666;
} }
`] `]
}) })
export class PlanGameComponent { export class PlanGameComponent {
@Input() game!: GamePlan; @Input() game!: GamePlan;
@Output() statusUpdate = new EventEmitter<StatusUpdateEvent>(); @Input() isSelected = false;
@Output() gameSelect = new EventEmitter<GamePlan>();
searchTerm = '';
filteredPokemon: typeof this.game.pokemon = [];
completedPokemon: typeof this.game.pokemon = [];
ngOnInit() {
this.filterPokemon();
}
filterPokemon() {
const term = this.searchTerm.toLowerCase();
const filtered = this.game.pokemon.filter(pokemon => {
const nameMatch = pokemon.name.toLowerCase().includes(term);
const formMatch = pokemon.form_name?.toLowerCase().includes(term);
return nameMatch || formMatch;
});
this.completedPokemon = filtered.filter(p => p.catch_count === 0);
this.filteredPokemon = filtered.filter(p => p.catch_count > 0);
}
getTotalCatchCount(): number { getTotalCatchCount(): number {
return this.game.pokemon.reduce((sum, pokemon) => sum + pokemon.catch_count, 0); return this.game.pokemon.reduce((sum, pokemon) => sum + pokemon.catch_count, 0);
} }
onPokemonStatusUpdate(event: {pfic: string, caught: boolean}) { getGameBoxArt(): string {
this.statusUpdate.emit(event); // You'll need to implement this to return the correct box art URL
this.filterPokemon(); // Refresh the lists return `/assets/images/games/${this.game.game_name.toLowerCase().replace(' ', '-')}.png`;
} }
updateGameTotal(change: number) { onSelect() {
const currentTotal = this.getTotalCatchCount(); this.gameSelect.emit(this.game);
// Emit the new total to update the header
this.statusUpdate.emit({
gameId: this.game.game_id,
total: currentTotal + change
});
}
moveToCompletedSection(pokemon: PlanPokemon) {
const index = this.filteredPokemon.findIndex(p => p.pfic === pokemon.pfic);
if (index > -1) {
const [movedPokemon] = this.filteredPokemon.splice(index, 1);
this.completedPokemon.push(movedPokemon);
}
}
moveToActiveSection(pokemon: PlanPokemon) {
const index = this.completedPokemon.findIndex(p => p.pfic === pokemon.pfic);
if (index > -1) {
const [movedPokemon] = this.completedPokemon.splice(index, 1);
this.filteredPokemon.push(movedPokemon);
}
} }
} }

14
origin-dex/src/app/features/plan/plan-pokemon/plan-pokemon.component.ts

@ -29,7 +29,6 @@ interface PokemonStatusEvent {
template: ` template: `
<mat-expansion-panel <mat-expansion-panel
class="pokemon-panel" class="pokemon-panel"
[expanded]="hasTargets"
[disabled]="!hasTargets" [disabled]="!hasTargets"
> >
<mat-expansion-panel-header> <mat-expansion-panel-header>
@ -55,7 +54,6 @@ interface PokemonStatusEvent {
src="/assets/images/pokeball_color.png" src="/assets/images/pokeball_color.png"
[class.grayscale]="pokemon.catch_count === 0" [class.grayscale]="pokemon.catch_count === 0"
class="pokeball-icon" class="pokeball-icon"
(click)="toggleCatch($event)"
[matTooltip]="'Need: ' + pokemon.catch_count" [matTooltip]="'Need: ' + pokemon.catch_count"
> >
<span class="catch-count">{{ pokemon.catch_count }}</span> <span class="catch-count">{{ pokemon.catch_count }}</span>
@ -169,6 +167,7 @@ interface PokemonStatusEvent {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 8px; gap: 8px;
min-width: 80px;
} }
.pokeball-icon { .pokeball-icon {
@ -263,16 +262,7 @@ export class PlanPokemonComponent {
} }
isTargetCompleted(pfic: string): boolean { isTargetCompleted(pfic: string): boolean {
// This should be connected to your caught Pokemon service/state return this.pokemonService.isTargetCompleted(pfic);
return false; // Placeholder
}
toggleCatch(event: MouseEvent) {
event.stopPropagation();
this.statusUpdate.emit({
pfic: this.pokemon.pfic,
caught: this.pokemon.catch_count > 0
});
} }
calculateTotalNeeded(): number { calculateTotalNeeded(): number {

90
origin-dex/src/app/features/plan/plan.component.ts

@ -1,50 +1,100 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { MatExpansionModule } from '@angular/material/expansion'; import { MatCardModule } from '@angular/material/card';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
import { FormsModule } from '@angular/forms'; import { FormsModule } from '@angular/forms';
import { PlanGameComponent } from './plan-game/plan-game.component'; import { PlanGameComponent } from './plan-game/plan-game.component';
import { PlanService } from '../../core/services/plan.service'; import { PlanService } from '../../core/services/plan.service';
import { GamePlan } from '../../core/models/plan.model'; import { GamePlan } from '../../core/models/plan.model';
import { PlanPokemonComponent } from "./plan-pokemon/plan-pokemon.component";
@Component({ @Component({
selector: 'app-plan', selector: 'app-plan',
standalone: true, standalone: true,
imports: [ imports: [
CommonModule, CommonModule,
MatExpansionModule, MatCardModule,
MatFormFieldModule,
MatInputModule,
FormsModule, FormsModule,
PlanGameComponent PlanGameComponent,
PlanPokemonComponent
], ],
template: ` template: `
<div class="plan-container"> <div class="plan-container">
<div class="games-accordion"> <div class="games-section">
<div class="games-scroll">
<div class="games-list">
<app-plan-game <app-plan-game
*ngFor="let game of gamePlans" *ngFor="let game of gamePlans"
[game]="game" [game]="game"
[isSelected]="selectedGame?.game_name === game.game_name"
(gameSelect)="selectGame($event)"
></app-plan-game> ></app-plan-game>
</div> </div>
</div> </div>
</div>
<div class="pokemon-section" *ngIf="selectedGame">
<h2>{{ selectedGame.game_name }} - Pokémon to Catch</h2>
<div class="pokemon-list">
<app-plan-pokemon
*ngFor="let pokemon of selectedGame.pokemon"
[pokemon]="pokemon"
(statusUpdate)="onPokemonStatusUpdate($event)"
></app-plan-pokemon>
</div>
</div>
</div>
`, `,
styles: [` styles: [`
.plan-container { .plan-container {
padding: 20px; display: flex;
max-width: 1200px; flex-direction: column;
margin: 0 auto; height: calc(100vh - 64px); /* Adjust based on your header height */
overflow: hidden;
} }
.games-accordion { .games-section {
padding: 20px 20px 0 20px;
}
.games-scroll {
width: 100%;
overflow-x: auto;
padding: 8px 0;
}
.games-list {
display: flex; display: flex;
flex-direction: column;
gap: 16px; gap: 16px;
padding: 0 8px;
min-width: min-content;
}
.pokemon-section {
padding: 0 20px;
flex: 1;
min-height: 0; /* Important for Firefox */
display: flex;
flex-direction: column;
}
.pokemon-section h2 {
margin: 16px 0;
color: #333;
}
.pokemon-list {
flex: 1;
overflow-y: auto;
padding: 16px;
background: #f5f5f5;
border-radius: 8px;
margin-bottom: 20px;
} }
`] `]
}) })
export class PlanComponent implements OnInit { export class PlanComponent implements OnInit {
gamePlans: GamePlan[] = []; gamePlans: GamePlan[] = [];
selectedGame: GamePlan | null = null;
constructor(private planService: PlanService) {} constructor(private planService: PlanService) {}
@ -54,12 +104,20 @@ export class PlanComponent implements OnInit {
private loadPlan() { private loadPlan() {
this.planService.getPlan().subscribe( this.planService.getPlan().subscribe(
plan => this.gamePlans = plan plan => {
this.gamePlans = plan;
if (!this.selectedGame && plan.length > 0) {
this.selectedGame = plan[0];
}
}
); );
} }
selectGame(game: GamePlan) {
this.selectedGame = game;
}
onPokemonStatusUpdate(event: { pfic: string, caught: boolean }) { onPokemonStatusUpdate(event: { pfic: string, caught: boolean }) {
// Handle status updates that might affect other games' plans this.loadPlan();
this.loadPlan(); // Reload the full plan to ensure consistency
} }
} }

8
origin-dex/src/app/features/pokemon/pokemon-carousel/pokemon-carousel.component.ts

@ -223,12 +223,8 @@ export class PokemonCarouselComponent implements OnInit {
onPokemonCaught(pfic: string) { onPokemonCaught(pfic: string) {
this.pokemonService.toggleCatch(pfic).subscribe( this.pokemonService.toggleCatch(pfic).subscribe(
response => { () => {
if (response.status === 'caught') { // The service handles the update now
this.caughtPokemon.add(pfic);
} else {
this.caughtPokemon.delete(pfic);
}
this.cdr.markForCheck(); this.cdr.markForCheck();
} }
); );

1
origin-dex/src/app/features/pokemon/pokemon-cell/pokemon-cell.component.ts

@ -167,7 +167,6 @@ export class PokemonCellComponent {
event.stopPropagation(); event.stopPropagation();
if (this.pokemon) { if (this.pokemon) {
this.caught.emit(this.pokemon.PFIC); this.caught.emit(this.pokemon.PFIC);
this.pokemon.IsCaught = !this.pokemon.IsCaught;
} }
} }
} }

BIN
origin-dex/src/assets/images/games/alphasapphire.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

BIN
origin-dex/src/assets/images/games/black-2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 655 KiB

BIN
origin-dex/src/assets/images/games/black.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 578 KiB

BIN
origin-dex/src/assets/images/games/blue.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 885 KiB

BIN
origin-dex/src/assets/images/games/brilliantdiamond.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 918 KiB

BIN
origin-dex/src/assets/images/games/crystal.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 868 KiB

BIN
origin-dex/src/assets/images/games/diamond.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 511 KiB

BIN
origin-dex/src/assets/images/games/emerald.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 925 KiB

BIN
origin-dex/src/assets/images/games/epxansionpass2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 973 KiB

BIN
origin-dex/src/assets/images/games/expansion-pass.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1012 KiB

BIN
origin-dex/src/assets/images/games/firered.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 702 KiB

BIN
origin-dex/src/assets/images/games/gold.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 850 KiB

BIN
origin-dex/src/assets/images/games/heartgold.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 797 KiB

BIN
origin-dex/src/assets/images/games/leafgreen.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 660 KiB

BIN
origin-dex/src/assets/images/games/legends-arceus.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 865 KiB

BIN
origin-dex/src/assets/images/games/letsgoeevee.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 919 KiB

BIN
origin-dex/src/assets/images/games/letsgopikachu.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 860 KiB

BIN
origin-dex/src/assets/images/games/moon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 943 KiB

BIN
origin-dex/src/assets/images/games/omegaruby.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

BIN
origin-dex/src/assets/images/games/pearl.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 589 KiB

BIN
origin-dex/src/assets/images/games/platinum.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 546 KiB

BIN
origin-dex/src/assets/images/games/pokemon_the_indigo_disk_dlc_dock_icon_by_lexiloo826_dgkjxy3-pre.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

BIN
origin-dex/src/assets/images/games/red.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 889 KiB

BIN
origin-dex/src/assets/images/games/ruby.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 593 KiB

BIN
origin-dex/src/assets/images/games/sapphire.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 526 KiB

BIN
origin-dex/src/assets/images/games/scarlet.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 900 KiB

BIN
origin-dex/src/assets/images/games/shield.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 757 KiB

BIN
origin-dex/src/assets/images/games/shiiningpearl.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 874 KiB

BIN
origin-dex/src/assets/images/games/silver.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 578 KiB

BIN
origin-dex/src/assets/images/games/soulsilver.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 689 KiB

BIN
origin-dex/src/assets/images/games/sun.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 753 KiB

BIN
origin-dex/src/assets/images/games/sword.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 796 KiB

BIN
origin-dex/src/assets/images/games/the-hidden treasure of area zero.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

BIN
origin-dex/src/assets/images/games/ultra-moon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 940 KiB

BIN
origin-dex/src/assets/images/games/ultra-sun.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 995 KiB

BIN
origin-dex/src/assets/images/games/violet.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 992 KiB

BIN
origin-dex/src/assets/images/games/white-2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 639 KiB

BIN
origin-dex/src/assets/images/games/white.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 647 KiB

BIN
origin-dex/src/assets/images/games/x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 950 KiB

BIN
origin-dex/src/assets/images/games/y.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 943 KiB

BIN
origin-dex/src/assets/images/games/yellow.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 811 KiB

Loading…
Cancel
Save