It works, don't know why
This commit is contained in:
30
src/app/farmer-container/farmer-container.component.ts
Normal file
30
src/app/farmer-container/farmer-container.component.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
|
||||
import {PlantDto} from "../plant.dto";
|
||||
import {PlayerService} from "../player.service";
|
||||
import Plant from "../Plant";
|
||||
|
||||
@Component({
|
||||
selector: 'app-farmer-container',
|
||||
templateUrl: './farmer-container.component.html',
|
||||
styleUrls: ['./farmer-container.component.scss'],
|
||||
})
|
||||
export class FarmerContainerComponent implements OnInit {
|
||||
|
||||
@Input('plant') plant!: Plant;
|
||||
constructor(private playerService: PlayerService) { }
|
||||
|
||||
getPrice() {
|
||||
if (!this.plant) return 0;
|
||||
return this.plant.getPlantData().farmer.price;
|
||||
}
|
||||
buy() {
|
||||
this.playerService.buyFarmer(this.plant.id);
|
||||
}
|
||||
|
||||
canAfford(): boolean {
|
||||
return this.playerService.canAffordFarmer(this.plant.id);
|
||||
}
|
||||
|
||||
ngOnInit() {}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user