Browse Source

- Start to get the left to catch count sorted

pull/1/head
Dan 1 year ago
parent
commit
e1bae92618
  1. 51
      src/app/features/plan/plan-pokemon/plan-pokemonV2.component.ts

51
src/app/features/plan/plan-pokemon/plan-pokemonV2.component.ts

@ -62,11 +62,11 @@ interface PokemonStatusEvent {
<div class="catch-info"> <div class="catch-info">
<img <img
src="/assets/images/pokeball_color.png" src="/assets/images/pokeball_color.png"
[class.grayscale]="pokemon_family.catch_count === 0" [class.grayscale]="this.catch_count === 0"
class="pokeball-icon" class="pokeball-icon"
[matTooltip]="'Need: ' + pokemon_family.catch_count" [matTooltip]="'Need: ' + this.catch_count"
> >
<span class="catch-count">{{ pokemon_family.catch_count }}</span> <span class="catch-count">{{ this.catch_count }}</span>
</div> </div>
</div> </div>
</div> </div>
@ -169,6 +169,7 @@ export class PlanPokemonV2Component {
@Output() familySelected = new EventEmitter<PokemonFamilyEntry>(); @Output() familySelected = new EventEmitter<PokemonFamilyEntry>();
representative_pokemon: Pokemon | null = null; representative_pokemon: Pokemon | null = null;
catch_count = 0;
constructor( constructor(
public pokemonService: PokemonService, public pokemonService: PokemonService,
@ -178,6 +179,7 @@ export class PlanPokemonV2Component {
ngOnInit() { ngOnInit() {
this.representative_pokemon = null; this.representative_pokemon = null;
this.handlePokemonFamilyChange(this.pokemon_family); this.handlePokemonFamilyChange(this.pokemon_family);
this.catch_count = this.pokemon_family.catch_count;
} }
ngOnChanges(changes: SimpleChanges) { ngOnChanges(changes: SimpleChanges) {
@ -209,6 +211,9 @@ export class PlanPokemonV2Component {
this.cdr.markForCheck(); this.cdr.markForCheck();
} }
}); });
this.updateCatchCount();
this.cdr.markForCheck();
} }
get hasTargets(): boolean { get hasTargets(): boolean {
@ -219,26 +224,6 @@ export class PlanPokemonV2Component {
return this.pokemonService.isTargetCompleted(pfic); 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 { calculateTotalCaught(): number {
let count = 0; let count = 0;
@ -265,24 +250,8 @@ export class PlanPokemonV2Component {
updateCatchCount() { updateCatchCount() {
const newCount = this.calculateTotalCaught(); const newCount = this.calculateTotalCaught();
if (newCount !== this.pokemon_family.catch_count) { this.catch_count = this.pokemon_family.catch_count - newCount;
this.pokemon_family.catch_count = newCount; console.log(this.catch_count)
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
});
}
}
} }
getRepresentativePokemon() { getRepresentativePokemon() {

Loading…
Cancel
Save