export type TileType = 'grass' | 'forest' | 'stone' | 'water';

export class Tile implements ITile {
    readonly x: number;
    readonly y: number;
    type: TileType;

    public woodAmount = 0;

    constructor({x, y, type}: ITile) {
        this.x = x;
        this.y = y;
        this.type = type;

        if (type === 'forest') {
      this.woodAmount = Phaser.Math.Between(3, 6); // z. B. 3–6 Holz pro Baum
    }
    }

    harvestWood(amount: number): number {
    if (this.type !== 'forest') return 0;
    const taken = Math.min(amount, this.woodAmount);
    this.woodAmount -= taken;
    if (this.woodAmount <= 0) {
      this.type = 'grass';
    }
    return taken;
  }
    
}

export interface ITile {
    x: number;
    y: number;
    type: TileType;
}