From e1bae926185073d4b41278cdd0289600e19e23cf Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 20 Nov 2024 15:53:26 +0000 Subject: [PATCH] - Start to get the left to catch count sorted --- .../plan-pokemon/plan-pokemonV2.component.ts | 51 ++++--------------- 1 file changed, 10 insertions(+), 41 deletions(-) diff --git a/src/app/features/plan/plan-pokemon/plan-pokemonV2.component.ts b/src/app/features/plan/plan-pokemon/plan-pokemonV2.component.ts index 41da661..242f59c 100644 --- a/src/app/features/plan/plan-pokemon/plan-pokemonV2.component.ts +++ b/src/app/features/plan/plan-pokemon/plan-pokemonV2.component.ts @@ -62,11 +62,11 @@ interface PokemonStatusEvent {
- {{ pokemon_family.catch_count }} + {{ this.catch_count }}
@@ -169,6 +169,7 @@ export class PlanPokemonV2Component { @Output() familySelected = new EventEmitter(); representative_pokemon: Pokemon | null = null; + catch_count = 0; constructor( public pokemonService: PokemonService, @@ -178,6 +179,7 @@ export class PlanPokemonV2Component { ngOnInit() { this.representative_pokemon = null; this.handlePokemonFamilyChange(this.pokemon_family); + this.catch_count = this.pokemon_family.catch_count; } ngOnChanges(changes: SimpleChanges) { @@ -209,6 +211,9 @@ export class PlanPokemonV2Component { this.cdr.markForCheck(); } }); + + this.updateCatchCount(); + this.cdr.markForCheck(); } get hasTargets(): boolean { @@ -219,26 +224,6 @@ export class PlanPokemonV2Component { return this.pokemonService.isTargetCompleted(pfic); } - calculateTotalNeeded(): number { - let total = 1; // Initial catch - let breedCount = 0; - let evolveCount = 0; - - // Calculate breeding needs - if (this.pokemon_family.breed_for.length > 0) { - breedCount = 1; // We only need one for breeding, regardless of how many we breed - } - - // Calculate evolution needs - this.pokemon_family.evolve_to.forEach(target => { - if (!this.isTargetCompleted(target)) { - evolveCount += 1; - } - }); - - return total + breedCount + evolveCount; - } - calculateTotalCaught(): number { let count = 0; @@ -265,24 +250,8 @@ export class PlanPokemonV2Component { updateCatchCount() { const newCount = this.calculateTotalCaught(); - if (newCount !== this.pokemon_family.catch_count) { - this.pokemon_family.catch_count = newCount; - if (newCount === 0) { - // Emit event to move to completed section - this.statusUpdate.emit({ - pfic: this.pokemon_family.representative, - caught: true, - completed: true - }); - } else if (newCount > 0 && this.pokemon_family.catch_count === 0) { - // Emit event to move back to active section - this.statusUpdate.emit({ - pfic: this.pokemon_family.representative, - caught: false, - completed: false - }); - } - } + this.catch_count = this.pokemon_family.catch_count - newCount; + console.log(this.catch_count) } getRepresentativePokemon() {